summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/call-stub.c
diff options
context:
space:
mode:
authorSusant Palai <spalai@redhat.com>2017-08-22 13:44:52 +0530
committerAmar Tumballi <amarts@redhat.com>2017-12-05 21:23:57 +0000
commitefad78260379f0ca836e8a2327b97dd620acd098 (patch)
treea80201543e9e1851fa05580b0f9b7f1e75b2e9b1 /libglusterfs/src/call-stub.c
parentee20190a3a6e36b97c4914e0fa486017e72b0375 (diff)
rio/everywhere: add icreate/namelink fop
icreate creates inode, while namelink links the basename to it's parent gfid. For now mkdir is the primary user of these fops. Better distribution is acheived by creating the inode on ,(say) mds1 and linking the basename to it's parent gfid on mds2. The inode serves readdirp, stat etc. More details about the fops are present at: https://review.gluster.org/#/c/13395/3/design/DHT2/DHT2_Icreate_Namelink_Notes.md This backport of three patches from experimental branch. 1- https://review.gluster.org/#/c/18085/ 2- https://review.gluster.org/#/c/18086/ 3- https://review.gluster.org/#/c/18094/ Updates gluster/glusterfs#243 Change-Id: I1bd3d5a441a3cfab1acfeb52f15c6c867d362592 Signed-off-by: Susant Palai <spalai@redhat.com>
Diffstat (limited to 'libglusterfs/src/call-stub.c')
-rw-r--r--libglusterfs/src/call-stub.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 74a64294528..d5c4f1365e8 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -2009,6 +2009,126 @@ out:
return stub;
}
+call_stub_t *
+fop_icreate_stub (call_frame_t *frame, fop_icreate_t fn,
+ loc_t *loc, mode_t mode, dict_t *xdata)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fn, out);
+
+ stub = stub_new (frame, 1, GF_FOP_ICREATE);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn.icreate = fn;
+
+ stub->args.mode = mode;
+ if (loc)
+ loc_copy (&stub->args.loc, loc);
+ if (xdata)
+ stub->args.xdata = dict_ref (xdata);
+
+ out:
+ return stub;
+}
+
+static void
+args_icreate_store_cbk (default_args_cbk_t *args,
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf, dict_t *xdata)
+{
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+ if (inode)
+ args->inode = inode_ref (inode);
+ if (buf)
+ args->stat = *buf;
+ if (xdata)
+ args->xdata = dict_ref (xdata);
+}
+
+call_stub_t *
+fop_icreate_cbk_stub (call_frame_t *frame,
+ fop_icreate_cbk_t fn,
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf, dict_t *xdata)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+
+ stub = stub_new (frame, 0, GF_FOP_ICREATE);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn_cbk.icreate = fn;
+ args_icreate_store_cbk (&stub->args_cbk,
+ op_ret, op_errno, inode, buf, xdata);
+
+ out:
+ return stub;
+}
+
+call_stub_t *
+fop_namelink_stub (call_frame_t *frame,
+ fop_namelink_t fn, loc_t *loc, dict_t *xdata)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fn, out);
+
+ stub = stub_new (frame, 1, GF_FOP_NAMELINK);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn.namelink = fn;
+
+ if (loc)
+ loc_copy (&stub->args.loc, loc);
+ if (xdata)
+ stub->args.xdata = dict_ref (xdata);
+
+ out:
+ return stub;
+}
+
+static void
+args_namelink_store_cbk (default_args_cbk_t *args,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+{
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ if (prebuf)
+ args->prestat = *prebuf;
+ if (postbuf)
+ args->poststat = *postbuf;
+ if (xdata)
+ args->xdata = dict_ref (xdata);
+}
+
+call_stub_t *
+fop_namelink_cbk_stub (call_frame_t *frame,
+ fop_namelink_cbk_t fn,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+
+ stub = stub_new (frame, 0, GF_FOP_NAMELINK);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn_cbk.namelink = fn;
+ args_namelink_store_cbk (&stub->args_cbk,
+ op_ret, op_errno, prebuf, postbuf, xdata);
+
+ out:
+ return stub;
+}
+
void
call_resume_wind (call_stub_t *stub)
{