diff options
author | Anuradha Talur <atalur@redhat.com> | 2016-02-05 10:45:37 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-04-09 11:44:24 -0700 |
commit | 5ff451beecaf564b4f854b10e63a307e40660c8c (patch) | |
tree | 066fa26ce9e424d469f2483295c1fe6e05da562e /libglusterfs/src/call-stub.c | |
parent | be99ddd842025e0cd1a84076ee199cd4554a4575 (diff) |
libglusterfs: Refactor packing of arguments
Added these changes so that they can be re-used to pack
arguments required for each fop while populating the
compound fop structure used by each xlator.
Change-Id: Id9923e10003adafbc16a8bf3fbefa30677847313
BUG: 1303829
Signed-off-by: Anuradha Talur <atalur@redhat.com>
Reviewed-on: http://review.gluster.org/13360
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Ashish Pandey <aspandey@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'libglusterfs/src/call-stub.c')
-rw-r--r-- | libglusterfs/src/call-stub.c | 350 |
1 files changed, 52 insertions, 298 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index e48e6c3651c..3f64cbc7d3b 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -52,11 +52,7 @@ fop_lookup_stub (call_frame_t *frame, fop_lookup_t fn, loc_t *loc, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.lookup = fn; - - loc_copy (&stub->args.loc, loc); - if (xdata) - stub->args.xdata = dict_ref (xdata); - + args_lookup_store (&stub->args, loc, xdata); out: return stub; } @@ -96,9 +92,7 @@ fop_stat_stub (call_frame_t *frame, fop_stat_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.stat = fn; - loc_copy (&stub->args.loc, loc); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_stat_store (&stub->args, loc, xdata); out: return stub; } @@ -136,11 +130,7 @@ fop_fstat_stub (call_frame_t *frame, fop_fstat_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fstat = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fstat_store (&stub->args, fd, xdata); out: return stub; } @@ -179,10 +169,7 @@ fop_truncate_stub (call_frame_t *frame, fop_truncate_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.truncate = fn; - loc_copy (&stub->args.loc, loc); - stub->args.offset = off; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_truncate_store (&stub->args, loc, off, xdata); out: return stub; } @@ -220,12 +207,8 @@ fop_ftruncate_stub (call_frame_t *frame, fop_ftruncate_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.ftruncate = fn; - if (fd) - stub->args.fd = fd_ref (fd); + args_ftruncate_store (&stub->args, fd, off, xdata); - stub->args.offset = off; - if (xdata) - stub->args.xdata = dict_ref (xdata); out: return stub; } @@ -265,10 +248,7 @@ fop_access_stub (call_frame_t *frame, fop_access_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.access = fn; - loc_copy (&stub->args.loc, loc); - stub->args.mask = mask; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_access_store (&stub->args, loc, mask, xdata); out: return stub; } @@ -305,10 +285,7 @@ fop_readlink_stub (call_frame_t *frame, fop_readlink_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.readlink = fn; - loc_copy (&stub->args.loc, loc); - stub->args.size = size; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_readlink_store (&stub->args, loc, size, xdata); out: return stub; } @@ -347,12 +324,7 @@ fop_mknod_stub (call_frame_t *frame, fop_mknod_t fn, loc_t *loc, mode_t mode, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.mknod = fn; - loc_copy (&stub->args.loc, loc); - stub->args.mode = mode; - stub->args.rdev = rdev; - stub->args.umask = umask; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_mknod_store (&stub->args, loc, mode, rdev, umask, xdata); out: return stub; } @@ -392,12 +364,7 @@ fop_mkdir_stub (call_frame_t *frame, fop_mkdir_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.mkdir = fn; - loc_copy (&stub->args.loc, loc); - stub->args.mode = mode; - stub->args.umask = umask; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_mkdir_store (&stub->args, loc, mode, umask, xdata); out: return stub; } @@ -437,10 +404,8 @@ fop_unlink_stub (call_frame_t *frame, fop_unlink_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.unlink = fn; - loc_copy (&stub->args.loc, loc); - stub->args.xflag = xflag; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_unlink_store (&stub->args, loc, xflag, xdata); + out: return stub; } @@ -481,10 +446,8 @@ fop_rmdir_stub (call_frame_t *frame, fop_rmdir_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.rmdir = fn; - loc_copy (&stub->args.loc, loc); - stub->args.flags = flags; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_rmdir_store (&stub->args, loc, flags, xdata); + out: return stub; } @@ -525,11 +488,7 @@ fop_symlink_stub (call_frame_t *frame, fop_symlink_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.symlink = fn; - stub->args.linkname = gf_strdup (linkname); - stub->args.umask = umask; - loc_copy (&stub->args.loc, loc); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_symlink_store (&stub->args, linkname, loc, umask, xdata); out: return stub; } @@ -571,10 +530,7 @@ fop_rename_stub (call_frame_t *frame, fop_rename_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.rename = fn; - loc_copy (&stub->args.loc, oldloc); - loc_copy (&stub->args.loc2, newloc); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_rename_store (&stub->args, oldloc, newloc, xdata); out: return stub; } @@ -617,11 +573,7 @@ fop_link_stub (call_frame_t *frame, fop_link_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.link = fn; - loc_copy (&stub->args.loc, oldloc); - loc_copy (&stub->args.loc2, newloc); - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_link_store (&stub->args, oldloc, newloc, xdata); out: return stub; } @@ -663,14 +615,8 @@ fop_create_stub (call_frame_t *frame, fop_create_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.create = fn; - loc_copy (&stub->args.loc, loc); - stub->args.flags = flags; - stub->args.mode = mode; - stub->args.umask = umask; - if (fd) - stub->args.fd = fd_ref (fd); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_create_store (&stub->args, loc, flags, mode, + umask, fd, xdata); out: return stub; } @@ -711,12 +657,7 @@ fop_open_stub (call_frame_t *frame, fop_open_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.open = fn; - loc_copy (&stub->args.loc, loc); - stub->args.flags = flags; - if (fd) - stub->args.fd = fd_ref (fd); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_open_store (&stub->args, loc, flags, fd, xdata); out: return stub; } @@ -754,14 +695,7 @@ fop_readv_stub (call_frame_t *frame, fop_readv_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.readv = fn; - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.size = size; - stub->args.offset = off; - stub->args.flags = flags; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_readv_store (&stub->args, fd, size, off, flags, xdata); out: return stub; } @@ -802,15 +736,8 @@ fop_writev_stub (call_frame_t *frame, fop_writev_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.writev = fn; - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.vector = iov_dup (vector, count); - stub->args.count = count; - stub->args.offset = off; - stub->args.flags = flags; - stub->args.iobref = iobref_ref (iobref); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_writev_store (&stub->args, fd, vector, count, off, flags, + iobref, xdata); out: return stub; } @@ -848,10 +775,7 @@ fop_flush_stub (call_frame_t *frame, fop_flush_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.flush = fn; - if (fd) - stub->args.fd = fd_ref (fd); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_flush_store (&stub->args, fd, xdata); out: return stub; } @@ -887,11 +811,7 @@ fop_fsync_stub (call_frame_t *frame, fop_fsync_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fsync = fn; - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.datasync = datasync; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fsync_store (&stub->args, fd, datasync, xdata); out: return stub; } @@ -930,11 +850,7 @@ fop_opendir_stub (call_frame_t *frame, fop_opendir_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.opendir = fn; - loc_copy (&stub->args.loc, loc); - if (fd) - stub->args.fd = fd_ref (fd); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_opendir_store (&stub->args, loc, fd, xdata); out: return stub; } @@ -971,11 +887,7 @@ fop_fsyncdir_stub (call_frame_t *frame, fop_fsyncdir_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fsyncdir = fn; - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.datasync = datasync; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fsyncdir_store (&stub->args, fd, datasync, xdata); out: return stub; } @@ -1012,9 +924,7 @@ fop_statfs_stub (call_frame_t *frame, fop_statfs_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.statfs = fn; - loc_copy (&stub->args.loc, loc); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_statfs_store (&stub->args, loc, xdata); out: return stub; } @@ -1053,13 +963,7 @@ fop_setxattr_stub (call_frame_t *frame, fop_setxattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.setxattr = fn; - loc_copy (&stub->args.loc, loc); - /* TODO */ - if (dict) - stub->args.xattr = dict_ref (dict); - stub->args.flags = flags; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_setxattr_store (&stub->args, loc, dict, flags, xdata); out: return stub; } @@ -1098,12 +1002,7 @@ fop_getxattr_stub (call_frame_t *frame, fop_getxattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.getxattr = fn; - loc_copy (&stub->args.loc, loc); - - if (name) - stub->args.name = gf_strdup (name); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_getxattr_store (&stub->args, loc, name, xdata); out: return stub; } @@ -1142,13 +1041,7 @@ fop_fsetxattr_stub (call_frame_t *frame, fop_fsetxattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fsetxattr = fn; - stub->args.fd = fd_ref (fd); - - if (dict) - stub->args.xattr = dict_ref (dict); - stub->args.flags = flags; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fsetxattr_store (&stub->args, fd, dict, flags, xdata); out: return stub; } @@ -1185,12 +1078,7 @@ fop_fgetxattr_stub (call_frame_t *frame, fop_fgetxattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fgetxattr = fn; - stub->args.fd = fd_ref (fd); - - if (name) - stub->args.name = gf_strdup (name); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fgetxattr_store (&stub->args, fd, name, xdata); out: return stub; } @@ -1230,10 +1118,7 @@ fop_removexattr_stub (call_frame_t *frame, fop_removexattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.removexattr = fn; - loc_copy (&stub->args.loc, loc); - stub->args.name = gf_strdup (name); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_removexattr_store (&stub->args, loc, name, xdata); out: return stub; } @@ -1271,10 +1156,7 @@ fop_fremovexattr_stub (call_frame_t *frame, fop_fremovexattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fremovexattr = fn; - stub->args.fd = fd_ref (fd); - stub->args.name = gf_strdup (name); - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fremovexattr_store (&stub->args, fd, name, xdata); out: return stub; } @@ -1312,12 +1194,7 @@ fop_lk_stub (call_frame_t *frame, fop_lk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.lk = fn; - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.cmd = cmd; - stub->args.lock = *lock; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_lk_store (&stub->args, fd, cmd, lock, xdata); out: return stub; } @@ -1356,15 +1233,8 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.inodelk = fn; - - if (volume) - stub->args.volume = gf_strdup (volume); - - loc_copy (&stub->args.loc, loc); - stub->args.cmd = cmd; - stub->args.lock = *lock; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_inodelk_store (&stub->args, volume, loc, cmd, + lock, xdata); out: return stub; } @@ -1402,18 +1272,9 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.finodelk = fn; + args_finodelk_store (&stub->args, volume, fd, cmd, + lock, xdata); - if (fd) - stub->args.fd = fd_ref (fd); - - if (volume) - stub->args.volume = gf_strdup (volume); - - stub->args.cmd = cmd; - stub->args.lock = *lock; - - if (xdata) - stub->args.xdata = dict_ref (xdata); out: return stub; } @@ -1450,20 +1311,8 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.entrylk = fn; + args_entrylk_store (&stub->args, volume, loc, name, cmd, type, xdata); - if (volume) - stub->args.volume = gf_strdup (volume); - - loc_copy (&stub->args.loc, loc); - - stub->args.entrylkcmd = cmd; - stub->args.entrylktype = type; - - if (name) - stub->args.name = gf_strdup (name); - - if (xdata) - stub->args.xdata = dict_ref (xdata); out: return stub; } @@ -1500,19 +1349,7 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fentrylk = fn; - - if (volume) - stub->args.volume = gf_strdup (volume); - - if (fd) - stub->args.fd = fd_ref (fd); - stub->args.entrylkcmd = cmd; - stub->args.entrylktype = type; - if (name) - stub->args.name = gf_strdup (name); - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fentrylk_store (&stub->args, volume, fd, name, cmd, type, xdata); out: return stub; } @@ -1587,12 +1424,7 @@ fop_readdir_stub (call_frame_t *frame, fop_readdir_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.readdir = fn; - stub->args.fd = fd_ref (fd); - stub->args.size = size; - stub->args.offset = off; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_readdir_store (&stub->args, fd, size, off, xdata); out: return stub; } @@ -1608,11 +1440,7 @@ fop_readdirp_stub (call_frame_t *frame, fop_readdirp_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.readdirp = fn; - stub->args.fd = fd_ref (fd); - stub->args.size = size; - stub->args.offset = off; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_readdirp_store (&stub->args, fd, size, off, xdata); out: return stub; } @@ -1631,11 +1459,7 @@ fop_rchecksum_stub (call_frame_t *frame, fop_rchecksum_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.rchecksum = fn; - stub->args.fd = fd_ref (fd); - stub->args.offset = offset; - stub->args.size = len; - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_rchecksum_store (&stub->args, fd, offset, len, xdata); out: return stub; } @@ -1714,14 +1538,7 @@ fop_xattrop_stub (call_frame_t *frame, fop_xattrop_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.xattrop = fn; - - loc_copy (&stub->args.loc, loc); - - stub->args.optype = optype; - stub->args.xattr = dict_ref (xattr); - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_xattrop_store (&stub->args, loc, optype, xattr, xdata); out: return stub; } @@ -1741,14 +1558,7 @@ fop_fxattrop_stub (call_frame_t *frame, fop_fxattrop_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fxattrop = fn; - - stub->args.fd = fd_ref (fd); - - stub->args.optype = optype; - stub->args.xattr = dict_ref (xattr); - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fxattrop_store (&stub->args, fd, optype, xattr, xdata); out: return stub; } @@ -1810,16 +1620,7 @@ fop_setattr_stub (call_frame_t *frame, fop_setattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.setattr = fn; - - loc_copy (&stub->args.loc, loc); - - if (stbuf) - stub->args.stat = *stbuf; - - stub->args.valid = valid; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_setattr_store (&stub->args, loc, stbuf, valid, xdata); out: return stub; } @@ -1839,17 +1640,7 @@ fop_fsetattr_stub (call_frame_t *frame, fop_fsetattr_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fsetattr = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - - if (stbuf) - stub->args.stat = *stbuf; - - stub->args.valid = valid; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fsetattr_store (&stub->args, fd, stbuf, valid, xdata); out: return stub; } @@ -1888,16 +1679,7 @@ fop_fallocate_stub(call_frame_t *frame, fop_fallocate_t fn, fd_t *fd, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.fallocate = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - - stub->args.flags = mode; - stub->args.offset = offset; - stub->args.size = len; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_fallocate_store (&stub->args, fd, mode, offset, len, xdata); out: return stub; @@ -1937,15 +1719,7 @@ fop_discard_stub(call_frame_t *frame, fop_discard_t fn, fd_t *fd, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.discard = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - - stub->args.offset = offset; - stub->args.size = len; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_discard_store (&stub->args, fd, offset, len, xdata); out: return stub; @@ -1985,15 +1759,7 @@ fop_zerofill_stub(call_frame_t *frame, fop_zerofill_t fn, fd_t *fd, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.zerofill = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - - stub->args.offset = offset; - stub->args.size = len; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_zerofill_store (&stub->args, fd, offset, len, xdata); out: return stub; @@ -2031,11 +1797,7 @@ fop_ipc_stub (call_frame_t *frame, fop_ipc_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.ipc = fn; - - stub->args.cmd = op; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_ipc_store (&stub->args, op, xdata); out: return stub; @@ -2075,15 +1837,7 @@ fop_seek_stub (call_frame_t *frame, fop_seek_t fn, fd_t *fd, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn.seek = fn; - - if (fd) - stub->args.fd = fd_ref (fd); - - stub->args.offset = offset; - stub->args.what = what; - - if (xdata) - stub->args.xdata = dict_ref (xdata); + args_seek_store (&stub->args, fd, offset, what, xdata); out: return stub; |