summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-02-10 16:43:50 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-02-16 07:47:58 -0800
commite04039092d28dde70a9a394010cd04cf0a12726a (patch)
tree6d0b870609c036291fa87f2358b13be8b1bf9f77 /xlators/features
parent8618abaaf07a96c0384db9bd1e7dbbe663f4f24c (diff)
downloadglusterfs-e04039092d28dde70a9a394010cd04cf0a12726a.tar.gz
glusterfs-e04039092d28dde70a9a394010cd04cf0a12726a.tar.xz
glusterfs-e04039092d28dde70a9a394010cd04cf0a12726a.zip
feature/gfid-access: Send a named lookup before trying to create a file.
Normally a named-lookup is done by the kernel on an entry before it issues a dentry creation fop like create/mknod etc. This will enable cluster translators like dht to maintain internal consistency like deleting a linkto file if no corresponding datafile is present etc. While handling file creation on auxiliary gfid mounts, we issue dentry creation fop without issuing a lookup. If there are stale-linkto files, creation would fail with EEXIST, however access would fail since there is no datafile. A named lookup would cleanup the linkto file allowing create to succeed. Change-Id: I2932107296adac710dd179df7d0946b8697a497a BUG: 1191413 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/9634 Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c59
-rw-r--r--xlators/features/gfid-access/src/gfid-access.h6
2 files changed, 55 insertions, 10 deletions
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index 982de6358e..119f795a2d 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -419,6 +419,8 @@ ga_newentry_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
STACK_UNWIND_STRICT (setxattr, local->orig_frame, op_ret,
op_errno, xdata);
+ if (local->xdata)
+ dict_unref (local->xdata);
loc_wipe (&local->loc);
mem_put (local);
@@ -460,6 +462,40 @@ done:
STACK_UNWIND_STRICT (setxattr, local->orig_frame, op_ret,
op_errno, xdata);
+ if (local->xdata)
+ dict_unref (local->xdata);
+ loc_wipe (&local->loc);
+ mem_put (local);
+
+ return 0;
+}
+
+static int
+ga_newentry_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stat, dict_t *xdata,
+ struct iatt *postparent)
+
+{
+ ga_local_t *local = NULL;
+
+ local = frame->local;
+
+ if ((op_ret < 0) && ((op_errno != ENOENT) && (op_errno != ESTALE)))
+ goto err;
+
+ STACK_WIND (frame, ga_newentry_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod, &local->loc, local->mode,
+ local->rdev, local->umask, local->xdata);
+ return 0;
+
+err:
+ frame->local = NULL;
+ STACK_DESTROY (frame->root);
+ STACK_UNWIND_STRICT (setxattr, local->orig_frame, op_ret, op_errno,
+ xdata);
+ if (local->xdata)
+ dict_unref (local->xdata);
loc_wipe (&local->loc);
mem_put (local);
@@ -474,7 +510,6 @@ ga_new_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data,
ga_newfile_args_t *args = NULL;
loc_t tmp_loc = {0,};
call_frame_t *new_frame = NULL;
- mode_t mode = 0;
ga_local_t *local = NULL;
uuid_t gfid = {0,};
@@ -528,14 +563,20 @@ ga_new_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data,
&tmp_loc, 0, xdata);
} else {
/* use 07777 (4 7s) for considering the Sticky bits etc) */
- mode = (S_IFMT & args->st_mode) |
- (07777 & args->args.mknod.mode);;
-
- STACK_WIND (new_frame, ga_newentry_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod,
- &tmp_loc, mode,
- args->args.mknod.rdev, args->args.mknod.umask,
- xdata);
+ ((ga_local_t *)new_frame->local)->mode =
+ (S_IFMT & args->st_mode) | (07777 & args->args.mknod.mode);
+
+ ((ga_local_t *)new_frame->local)->umask =
+ args->args.mknod.umask;
+ ((ga_local_t *)new_frame->local)->rdev = args->args.mknod.rdev;
+ ((ga_local_t *)new_frame->local)->xdata = dict_ref (xdata);
+
+ /* send a named lookup, so that dht can cleanup up stale linkto
+ * files etc.
+ */
+ STACK_WIND (new_frame, ga_newentry_lookup_cbk,
+ FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup,
+ &tmp_loc, NULL);
}
ret = 0;
diff --git a/xlators/features/gfid-access/src/gfid-access.h b/xlators/features/gfid-access/src/gfid-access.h
index 5c7a95af4c..2449c5f683 100644
--- a/xlators/features/gfid-access/src/gfid-access.h
+++ b/xlators/features/gfid-access/src/gfid-access.h
@@ -101,7 +101,11 @@ struct __ga_local {
call_frame_t *orig_frame;
unsigned int uid;
unsigned int gid;
- loc_t loc;
+ loc_t loc;
+ mode_t mode;
+ dev_t rdev;
+ mode_t umask;
+ dict_t *xdata;
};
typedef struct __ga_local ga_local_t;