summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorBasavanagowda Kanur <gowda@gluster.com>2009-04-16 14:38:02 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-04-16 17:09:20 +0530
commite77eb62f253bc2288b1b4ff582f99ebf16a28c47 (patch)
treee5e1b4c9a1277822850808595bd0509398730116 /xlators/cluster
parentd1703344735d9c4df89b84310deaf1b9703f8c49 (diff)
cluster/distribute bug fix - try to create linkfile in dht_lookup_everywhere_cbk(), only if hashed subvolume can be determined, else error out with ENOENT.
-- with local fixes (avati) Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-common.c60
-rw-r--r--xlators/cluster/dht/src/dht-common.h2
-rw-r--r--xlators/cluster/dht/src/dht-layout.c22
3 files changed, 68 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index fea2ed4b6..9254078df 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -309,23 +309,22 @@ dht_lookup_linkfile_create_cbk (call_frame_t *frame, void *cookie,
inode_t *inode, struct stat *stbuf)
{
dht_local_t *local = NULL;
- dht_layout_t *layout = NULL;
xlator_t *cached_subvol = NULL;
+ int ret = -1;
local = frame->local;
cached_subvol = local->cached_subvol;
- layout = dht_layout_for_subvol (this, local->cached_subvol);
- if (!layout) {
- gf_log (this->name, GF_LOG_ERROR,
- "no pre-set layout for subvolume %s",
- cached_subvol ? cached_subvol->name : "<nil>");
- local->op_ret = -1;
- local->op_errno = EINVAL;
- goto unwind;
- }
+ ret = dht_layout_inode_set (this, local->cached_subvol, inode);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to set layout for subvolume %s",
+ cached_subvol ? cached_subvol->name : "<nil>");
+ local->op_ret = -1;
+ local->op_errno = EINVAL;
+ goto unwind;
+ }
- inode_ctx_put (local->inode, this, (uint64_t)(long)layout);
local->op_ret = 0;
if (local->stbuf.st_nlink == 1)
local->stbuf.st_mode |= S_ISVTX;
@@ -353,6 +352,7 @@ dht_lookup_everywhere_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
xlator_t *link_subvol = NULL;
xlator_t *hashed_subvol = NULL;
xlator_t *cached_subvol = NULL;
+ int ret = -1;
conf = this->private;
@@ -443,12 +443,40 @@ unlock:
return 0;
}
- gf_log (this->name, GF_LOG_WARNING,
- "linking file %s existing on %s to %s (hash)",
- loc->path, cached_subvol->name, hashed_subvol->name);
+ if (!hashed_subvol) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "cannot create linkfile file for %s on %s: "
+ "hashed subvolume cannot be found.",
+ loc->path, cached_subvol->name);
+
+ local->op_ret = 0;
+ local->op_errno = 0;
+
+ ret = dht_layout_inode_set (frame->this, cached_subvol,
+ local->inode);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to set layout for subvol %s",
+ cached_subvol ? cached_subvol->name :
+ "<nil>");
+ local->op_ret = -1;
+ local->op_errno = EINVAL;
+ }
- dht_linkfile_create (frame, dht_lookup_linkfile_create_cbk,
- cached_subvol, hashed_subvol, loc);
+ DHT_STACK_UNWIND (frame, local->op_ret,
+ local->op_errno, local->inode,
+ &local->stbuf, local->xattr);
+ return 0;
+ }
+
+ gf_log (this->name, GF_LOG_WARNING,
+ "linking file %s existing on %s to %s (hash)",
+ loc->path, cached_subvol->name,
+ hashed_subvol->name);
+
+ dht_linkfile_create (frame,
+ dht_lookup_linkfile_create_cbk,
+ cached_subvol, hashed_subvol, loc);
}
return 0;
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 303cf9cb1..6d7847962 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -236,4 +236,6 @@ int dht_is_subvol_filled (xlator_t *this, xlator_t *subvol);
xlator_t *dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol);
int dht_get_du_info_for_subvol (xlator_t *this, int subvol_idx);
+int dht_layout_inode_set (xlator_t *this, xlator_t *subvol, inode_t *inode);
+
#endif /* _DHT_H */
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index d9824908a..a49382f19 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -591,3 +591,25 @@ out:
return ret;
}
+
+int
+dht_layout_inode_set (xlator_t *this, xlator_t *subvol, inode_t *inode)
+{
+ dht_layout_t *layout = NULL;
+ int ret = -1;
+
+ layout = dht_layout_for_subvol (this, subvol);
+ if (!layout) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "no pre-set layout for subvolume %s",
+ subvol ? subvol->name : "<nil>");
+ ret = -1;
+ goto out;
+ }
+
+ inode_ctx_put (inode, this, (uint64_t)(long)layout);
+
+ ret = 0;
+out:
+ return ret;
+}