diff options
author | Amar Tumballi <amar@gluster.com> | 2009-04-13 23:40:22 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-14 14:51:53 +0530 |
commit | 33e81bc94986929caab14a05231b25787a25a41b (patch) | |
tree | 6337d00296825fd6fc461c813c2f96ff67366fba /xlators/cluster/dht/src | |
parent | d8bc2834d056a23f55bd86a5fd704bd81e35836d (diff) |
bug fixes in dht-disk-usage feature.
fixes bugs seen with dht's disk usage.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster/dht/src')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 90 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-diskusage.c | 3 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 3 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-selfheal.c | 11 |
4 files changed, 72 insertions, 35 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index b2d2a0d9f46..fea2ed4b674 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2408,22 +2408,32 @@ dht_mknod (call_frame_t *frame, xlator_t *this, subvol, subvol->fops->mknod, loc, mode, rdev); } else { - /* Choose the minimum filled volume, and create the - files there */ - local = dht_local_init (frame); - if (!local) { - op_errno = ENOMEM; - gf_log (this->name, GF_LOG_ERROR, - "memory allocation failed :("); - goto err; - } avail_subvol = dht_free_disk_available_subvol (this, subvol); - local->cached_subvol = avail_subvol; - local->mode = mode; - local->rdev = rdev; - - dht_linkfile_create (frame, dht_mknod_linkfile_create_cbk, - avail_subvol, subvol, loc); + if (avail_subvol != subvol) { + /* Choose the minimum filled volume, and create the + files there */ + local = dht_local_init (frame); + if (!local) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, + "memory allocation failed :("); + goto err; + } + local->cached_subvol = avail_subvol; + local->mode = mode; + local->rdev = rdev; + + dht_linkfile_create (frame, + dht_mknod_linkfile_create_cbk, + avail_subvol, subvol, loc); + } else { + gf_log (this->name, GF_LOG_DEBUG, + "creating %s on %s", loc->path, subvol->name); + + STACK_WIND (frame, dht_newfile_cbk, + subvol, subvol->fops->mknod, + loc, mode, rdev); + } } return 0; @@ -2783,26 +2793,36 @@ dht_create (call_frame_t *frame, xlator_t *this, /* Choose the minimum filled volume, and create the files there */ /* TODO */ - ret = loc_dup (loc, &local->loc); - if (ret == -1) { - op_errno = ENOMEM; - gf_log (this->name, GF_LOG_ERROR, - "memory allocation failed :("); - goto err; - } - local->fd = fd_ref (fd); - local->flags = flags; - local->mode = mode; avail_subvol = dht_free_disk_available_subvol (this, subvol); + if (avail_subvol != subvol) { + ret = loc_dup (loc, &local->loc); + if (ret == -1) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, + "memory allocation failed :("); + goto err; + } - local->cached_subvol = avail_subvol; - local->hashed_subvol = subvol; - gf_log (this->name, GF_LOG_DEBUG, - "creating %s on %s (link at %s)", loc->path, - avail_subvol->name, subvol->name); - dht_linkfile_create (frame, dht_create_linkfile_create_cbk, - avail_subvol, subvol, loc); - + local->fd = fd_ref (fd); + local->flags = flags; + local->mode = mode; + + local->cached_subvol = avail_subvol; + local->hashed_subvol = subvol; + gf_log (this->name, GF_LOG_DEBUG, + "creating %s on %s (link at %s)", loc->path, + avail_subvol->name, subvol->name); + dht_linkfile_create (frame, + dht_create_linkfile_create_cbk, + avail_subvol, subvol, loc); + } else { + gf_log (this->name, GF_LOG_DEBUG, + "creating %s on %s", loc->path, subvol->name); + STACK_WIND (frame, dht_create_cbk, + subvol, subvol->fops->create, + loc, flags, mode, fd); + + } } return 0; @@ -2862,7 +2882,7 @@ dht_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { if (subvol_filled && (op_ret != -1)) { ret = dht_layout_merge (this, layout, prev->this, - -1, ENOTCONN, NULL); + -1, ENOSPC, NULL); } else { ret = dht_layout_merge (this, layout, prev->this, op_ret, op_errno, NULL); @@ -2908,7 +2928,7 @@ dht_mkdir_hashed_cbk (call_frame_t *frame, void *cookie, if (dht_is_subvol_filled (this, hashed_subvol)) ret = dht_layout_merge (this, layout, prev->this, - -1, ENOTCONN, NULL); + -1, ENOSPC, NULL); else ret = dht_layout_merge (this, layout, prev->this, op_ret, op_errno, NULL); diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c index 795574661e7..5e3dc23e820 100644 --- a/xlators/cluster/dht/src/dht-diskusage.c +++ b/xlators/cluster/dht/src/dht-diskusage.c @@ -223,6 +223,9 @@ dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol) } UNLOCK (&conf->subvolume_lock); + if (max_avail < conf->min_free_disk) + avail_subvol = subvol; + if (avail_subvol == subvol) { gf_log (this->name, GF_LOG_CRITICAL, "no node has enough free space to schedule create"); diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 45a7df60138..d9824908a63 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -403,6 +403,9 @@ dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout, case ENOTCONN: down++; break; + case ENOSPC: + down++; + break; default: misc++; } diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 8b6bdabd681..b51906ac5aa 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -293,6 +293,17 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc, } } + /* no subvolume has enough space, but can't stop directory creation */ + if (!cnt) { + for (i = 0; i < layout->cnt; i++) { + err = layout->list[i].err; + if (err == ENOSPC) { + layout->list[i].err = -1; + cnt++; + } + } + } + chunk = ((unsigned long) 0xffffffff) / cnt; start = 0; |