diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2015-04-14 13:45:33 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-05 03:14:25 -0700 |
commit | 7dd7d6ce904661173bdbb156e23d096f9b02464e (patch) | |
tree | 09089ba9ea73735d4e7cf3dda7137c0913b2fed9 | |
parent | d7c30458c87f1341295f764e1a2a539dc4248ecc (diff) |
libglusterfs: Implement cluster-syncop
Backport of http://review.gluster.org/10240
This patch implements syncop equivalent for cluster of xlators. The xlators on
which the fop needs to be performed is taken in input arguments to the
functions and the responses are gathered and provided as the output.
This idea is taken from afr-v2 self-heal implementation by Avati.
BUG: 1216303
Change-Id: I189400ea5bb3205aae928a72afbb6c960968b65a
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/10439
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | libglusterfs/src/Makefile.am | 6 | ||||
-rw-r--r-- | libglusterfs/src/call-stub.c | 474 | ||||
-rw-r--r-- | libglusterfs/src/call-stub.h | 26 | ||||
-rw-r--r-- | libglusterfs/src/cluster-syncop.c | 1184 | ||||
-rw-r--r-- | libglusterfs/src/cluster-syncop.h | 126 | ||||
-rw-r--r-- | libglusterfs/src/defaults.c | 809 | ||||
-rw-r--r-- | libglusterfs/src/defaults.h | 277 |
7 files changed, 2480 insertions, 422 deletions
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index 09341d164dd..cdec56a2b51 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -22,7 +22,8 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \ $(CONTRIBDIR)/rbtree/rb.c rbthash.c store.c latency.c \ graph.c syncop.c graph-print.c trie.c run.c options.c fd-lk.c \ circ-buff.c event-history.c gidcache.c ctx.c client_t.c event-poll.c \ - event-epoll.c syncop-utils.c $(CONTRIBDIR)/libgen/basename_r.c \ + event-epoll.c syncop-utils.c cluster-syncop.c \ + $(CONTRIBDIR)/libgen/basename_r.c \ $(CONTRIBDIR)/libgen/dirname_r.c $(CONTRIBDIR)/stdlib/gf_mkostemp.c \ strfd.c parse-utils.c $(CONTRIBDIR)/mount/mntent.c \ $(CONTRIBDIR)/libexecinfo/execinfo.c quota-common-utils.c rot-buffs.c \ @@ -38,7 +39,8 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec. fd.h revision.h compat-errno.h event.h mem-pool.h byte-order.h \ gf-dirent.h locking.h syscall.h iobuf.h globals.h statedump.h \ checksum.h daemon.h $(CONTRIBDIR)/rbtree/rb.h store.h\ - rbthash.h iatt.h latency.h mem-types.h syncop.h graph-utils.h trie.h \ + rbthash.h iatt.h latency.h mem-types.h syncop.h cluster-syncop.h \ + graph-utils.h trie.h \ run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \ gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \ template-component-messages.h strfd.h syncop-utils.h parse-utils.h \ diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index ee2e7c93337..128dcf9e15f 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -81,16 +81,8 @@ fop_lookup_cbk_stub (call_frame_t *frame, fop_lookup_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.lookup = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_lookup_cbk_store (&stub->args_cbk, op_ret, op_errno, inode, + buf, xdata, postparent); out: return stub; } @@ -130,12 +122,8 @@ fop_stat_cbk_stub (call_frame_t *frame, fop_stat_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.stat = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (op_ret == 0) - stub->args_cbk.stat = *buf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_stat_cbk_store (&stub->args_cbk, op_ret, op_errno, buf, + xdata); out: return stub; } @@ -176,12 +164,8 @@ fop_fstat_cbk_stub (call_frame_t *frame, fop_fstat_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fstat = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (buf) - stub->args_cbk.stat = *buf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fstat_cbk_store (&stub->args_cbk, op_ret, op_errno, buf, + xdata); out: return stub; } @@ -222,14 +206,8 @@ fop_truncate_cbk_stub (call_frame_t *frame, fop_truncate_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.truncate = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (prebuf) - stub->args_cbk.prestat = *prebuf; - if (postbuf) - stub->args_cbk.poststat = *postbuf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_truncate_cbk_store (&stub->args_cbk, op_ret, op_errno, + prebuf, postbuf, xdata); out: return stub; } @@ -271,14 +249,8 @@ fop_ftruncate_cbk_stub (call_frame_t *frame, fop_ftruncate_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.ftruncate = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (prebuf) - stub->args_cbk.prestat = *prebuf; - if (postbuf) - stub->args_cbk.poststat = *postbuf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_ftruncate_cbk_store (&stub->args_cbk, op_ret, op_errno, + prebuf, postbuf, xdata); out: return stub; @@ -319,10 +291,7 @@ fop_access_cbk_stub (call_frame_t *frame, fop_access_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.access = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_access_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -363,14 +332,8 @@ fop_readlink_cbk_stub (call_frame_t *frame, fop_readlink_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.readlink = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (path) - stub->args_cbk.buf = gf_strdup (path); - if (stbuf) - stub->args_cbk.stat = *stbuf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_readlink_cbk_store (&stub->args_cbk, op_ret, op_errno, path, + stbuf, xdata); out: return stub; } @@ -414,19 +377,8 @@ fop_mknod_cbk_stub (call_frame_t *frame, fop_mknod_cbk_t fn, int32_t op_ret, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.mknod = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); - + args_mknod_cbk_store (&stub->args_cbk, op_ret, op_errno, inode, buf, + preparent, postparent, xdata); out: return stub; } @@ -470,18 +422,8 @@ fop_mkdir_cbk_stub (call_frame_t *frame, fop_mkdir_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.mkdir = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_mkdir_cbk_store (&stub->args_cbk, op_ret, op_errno, inode, + buf, preparent, postparent, xdata); out: return stub; } @@ -523,14 +465,8 @@ fop_unlink_cbk_stub (call_frame_t *frame, fop_unlink_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.unlink = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_unlink_cbk_store (&stub->args_cbk, op_ret, op_errno, preparent, + postparent, xdata); out: return stub; } @@ -573,14 +509,8 @@ fop_rmdir_cbk_stub (call_frame_t *frame, fop_rmdir_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.rmdir = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_rmdir_cbk_store (&stub->args_cbk, op_ret, op_errno, preparent, + postparent, xdata); out: return stub; } @@ -625,18 +555,8 @@ fop_symlink_cbk_stub (call_frame_t *frame, fop_symlink_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.symlink = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_symlink_cbk_store (&stub->args_cbk, op_ret, op_errno, inode, buf, + preparent, postparent, xdata); out: return stub; } @@ -680,20 +600,9 @@ fop_rename_cbk_stub (call_frame_t *frame, fop_rename_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.rename = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (buf) - stub->args_cbk.stat = *buf; - if (preoldparent) - stub->args_cbk.preparent = *preoldparent; - if (postoldparent) - stub->args_cbk.postparent = *postoldparent; - if (prenewparent) - stub->args_cbk.preparent2 = *prenewparent; - if (postnewparent) - stub->args_cbk.postparent2 = *postnewparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_rename_cbk_store (&stub->args_cbk, op_ret, op_errno, buf, + preoldparent, postoldparent, prenewparent, + postnewparent, xdata); out: return stub; } @@ -738,18 +647,8 @@ fop_link_cbk_stub (call_frame_t *frame, fop_link_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.link = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_link_cbk_store (&stub->args_cbk, op_ret, op_errno, + inode, buf, preparent, postparent, xdata); out: return stub; } @@ -797,20 +696,8 @@ fop_create_cbk_stub (call_frame_t *frame, fop_create_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.create = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (fd) - stub->args_cbk.fd = fd_ref (fd); - if (inode) - stub->args_cbk.inode = inode_ref (inode); - if (buf) - stub->args_cbk.stat = *buf; - if (preparent) - stub->args_cbk.preparent = *preparent; - if (postparent) - stub->args_cbk.postparent = *postparent; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_create_cbk_store (&stub->args_cbk, op_ret, op_errno, fd, inode, + buf, preparent, postparent, xdata); out: return stub; } @@ -853,12 +740,7 @@ fop_open_cbk_stub (call_frame_t *frame, fop_open_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.open = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (fd) - stub->args_cbk.fd = fd_ref (fd); - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_open_cbk_store (&stub->args_cbk, op_ret, op_errno, fd, xdata); out: return stub; } @@ -904,16 +786,8 @@ fop_readv_cbk_stub (call_frame_t *frame, fop_readv_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.readv = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (op_ret >= 0) { - stub->args_cbk.vector = iov_dup (vector, count); - stub->args_cbk.count = count; - stub->args_cbk.stat = *stbuf; - stub->args_cbk.iobref = iobref_ref (iobref); - } - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_readv_cbk_store (&stub->args_cbk, op_ret, op_errno, vector, + count, stbuf, iobref, xdata); out: return stub; } @@ -960,14 +834,8 @@ fop_writev_cbk_stub (call_frame_t *frame, fop_writev_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.writev = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (op_ret >= 0) - stub->args_cbk.poststat = *postbuf; - if (prebuf) - stub->args_cbk.prestat = *prebuf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_writev_cbk_store (&stub->args_cbk, op_ret, op_errno, + prebuf, postbuf, xdata); out: return stub; } @@ -1006,10 +874,7 @@ fop_flush_cbk_stub (call_frame_t *frame, fop_flush_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.flush = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_flush_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1050,14 +915,8 @@ fop_fsync_cbk_stub (call_frame_t *frame, fop_fsync_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fsync = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (prebuf) - stub->args_cbk.prestat = *prebuf; - if (postbuf) - stub->args_cbk.poststat = *postbuf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fsync_cbk_store (&stub->args_cbk, op_ret, op_errno, + prebuf, postbuf, xdata); out: return stub; } @@ -1099,13 +958,7 @@ fop_opendir_cbk_stub (call_frame_t *frame, fop_opendir_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.opendir = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (fd) - stub->args_cbk.fd = fd_ref (fd); - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_opendir_cbk_store (&stub->args_cbk, op_ret, op_errno, fd, xdata); out: return stub; } @@ -1145,10 +998,7 @@ fop_fsyncdir_cbk_stub (call_frame_t *frame, fop_fsyncdir_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fsyncdir = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fsyncdir_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1188,12 +1038,7 @@ fop_statfs_cbk_stub (call_frame_t *frame, fop_statfs_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.statfs = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (op_ret == 0) - stub->args_cbk.statvfs = *buf; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_statfs_cbk_store (&stub->args_cbk, op_ret, op_errno, buf, xdata); out: return stub; } @@ -1239,10 +1084,7 @@ fop_setxattr_cbk_stub (call_frame_t *frame, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.setxattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_setxattr_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1285,13 +1127,8 @@ fop_getxattr_cbk_stub (call_frame_t *frame, fop_getxattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.getxattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - /* TODO */ - if (dict) - stub->args_cbk.xattr = dict_ref (dict); - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_getxattr_cbk_store (&stub->args_cbk, op_ret, op_errno, dict, + xdata); out: return stub; } @@ -1334,10 +1171,7 @@ fop_fsetxattr_cbk_stub (call_frame_t *frame, fop_fsetxattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fsetxattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fsetxattr_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1380,13 +1214,8 @@ fop_fgetxattr_cbk_stub (call_frame_t *frame, fop_fgetxattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fgetxattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (dict) - stub->args_cbk.xattr = dict_ref (dict); - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fgetxattr_cbk_store (&stub->args_cbk, op_ret, op_errno, dict, + xdata); out: return stub; } @@ -1427,10 +1256,7 @@ fop_removexattr_cbk_stub (call_frame_t *frame, fop_removexattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.removexattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_removexattr_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1471,10 +1297,7 @@ fop_fremovexattr_cbk_stub (call_frame_t *frame, fop_fremovexattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fremovexattr = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fremovexattr_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1518,12 +1341,7 @@ fop_lk_cbk_stub (call_frame_t *frame, fop_lk_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.lk = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (op_ret == 0) - stub->args_cbk.lock = *lock; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_lk_cbk_store (&stub->args_cbk, op_ret, op_errno, lock, xdata); out: return stub; } @@ -1569,11 +1387,7 @@ fop_inodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.inodelk = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_inodelk_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1622,11 +1436,7 @@ fop_finodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.finodelk = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_finodelk_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1676,11 +1486,7 @@ fop_entrylk_cbk_stub (call_frame_t *frame, fop_entrylk_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.entrylk = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_entrylk_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1729,11 +1535,7 @@ fop_fentrylk_cbk_stub (call_frame_t *frame, fop_fentrylk_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fentrylk = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fentrylk_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -1745,7 +1547,6 @@ fop_readdirp_cbk_stub (call_frame_t *frame, fop_readdirp_cbk_t fn, gf_dirent_t *entries, dict_t *xdata) { call_stub_t *stub = NULL; - gf_dirent_t *stub_entry = NULL, *entry = NULL; GF_VALIDATE_OR_GOTO ("call-stub", frame, out); @@ -1753,27 +1554,8 @@ fop_readdirp_cbk_stub (call_frame_t *frame, fop_readdirp_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.readdirp = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - GF_VALIDATE_OR_GOTO ("call-stub", entries, out); - - if (op_ret > 0) { - list_for_each_entry (entry, &entries->list, list) { - stub_entry = gf_dirent_for_name (entry->d_name); - if (!stub_entry) - goto out; - stub_entry->d_off = entry->d_off; - stub_entry->d_ino = entry->d_ino; - stub_entry->d_stat = entry->d_stat; - if (entry->inode) - stub_entry->inode = inode_ref (entry->inode); - list_add_tail (&stub_entry->list, - &stub->args_cbk.entries.list); - } - } - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_readdirp_cbk_store (&stub->args_cbk, op_ret, op_errno, entries, + xdata); out: return stub; } @@ -1785,7 +1567,6 @@ fop_readdir_cbk_stub (call_frame_t *frame, fop_readdir_cbk_t fn, gf_dirent_t *entries, dict_t *xdata) { call_stub_t *stub = NULL; - gf_dirent_t *stub_entry = NULL, *entry = NULL; GF_VALIDATE_OR_GOTO ("call-stub", frame, out); @@ -1793,25 +1574,8 @@ fop_readdir_cbk_stub (call_frame_t *frame, fop_readdir_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.readdir = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - GF_VALIDATE_OR_GOTO ("call-stub", entries, out); - - if (op_ret > 0) { - list_for_each_entry (entry, &entries->list, list) { - stub_entry = gf_dirent_for_name (entry->d_name); - if (!stub_entry) - goto out; - stub_entry->d_off = entry->d_off; - stub_entry->d_ino = entry->d_ino; - - list_add_tail (&stub_entry->list, - &stub->args_cbk.entries.list); - } - } - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_readdir_cbk_store (&stub->args_cbk, op_ret, op_errno, entries, + xdata); out: return stub; } @@ -1896,26 +1660,16 @@ fop_rchecksum_cbk_stub (call_frame_t *frame, fop_rchecksum_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.rchecksum = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (op_ret >= 0) { - stub->args_cbk.weak_checksum = - weak_checksum; - stub->args_cbk.strong_checksum = - memdup (strong_checksum, MD5_DIGEST_LENGTH); - } - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_rchecksum_cbk_store (&stub->args_cbk, op_ret, op_errno, + weak_checksum, strong_checksum, xdata); out: return stub; } call_stub_t * -fop_xattrop_cbk_stub (call_frame_t *frame, fop_xattrop_cbk_t fn, - int32_t op_ret, int32_t op_errno, dict_t *xdata) +fop_xattrop_cbk_stub (call_frame_t *frame, fop_xattrop_cbk_t fn, int32_t op_ret, + int32_t op_errno, dict_t *xattr, dict_t *xdata) { call_stub_t *stub = NULL; @@ -1925,11 +1679,8 @@ fop_xattrop_cbk_stub (call_frame_t *frame, fop_xattrop_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.xattrop = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_xattrop_cbk_store (&stub->args_cbk, op_ret, op_errno, xattr, + xdata); out: return stub; } @@ -1947,13 +1698,8 @@ fop_fxattrop_cbk_stub (call_frame_t *frame, fop_fxattrop_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fxattrop = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - if (xattr) - stub->args_cbk.xattr = dict_ref (xattr); - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_xattrop_cbk_store (&stub->args_cbk, op_ret, op_errno, xattr, + xdata); out: return stub; } @@ -2027,17 +1773,8 @@ fop_setattr_cbk_stub (call_frame_t *frame, fop_setattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.setattr = fn; - - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (statpre) - stub->args_cbk.prestat = *statpre; - if (statpost) - stub->args_cbk.poststat = *statpost; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_setattr_cbk_store (&stub->args_cbk, op_ret, op_errno, statpre, + statpost, xdata); out: return stub; } @@ -2057,16 +1794,8 @@ fop_fsetattr_cbk_stub (call_frame_t *frame, fop_setattr_cbk_t fn, GF_VALIDATE_OR_GOTO ("call-stub", stub, out); stub->fn_cbk.fsetattr = fn; - - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (statpre) - stub->args_cbk.prestat = *statpre; - if (statpost) - stub->args_cbk.poststat = *statpost; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fsetattr_cbk_store (&stub->args_cbk, op_ret, op_errno, statpre, + statpost, xdata); out: return stub; } @@ -2145,15 +1874,8 @@ fop_fallocate_cbk_stub(call_frame_t *frame, fop_fallocate_cbk_t fn, stub->fn_cbk.fallocate = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (statpre) - stub->args_cbk.prestat = *statpre; - if (statpost) - stub->args_cbk.poststat = *statpost; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_fallocate_cbk_store (&stub->args_cbk, op_ret, op_errno, statpre, + statpost, xdata); out: return stub; } @@ -2201,15 +1923,8 @@ fop_discard_cbk_stub(call_frame_t *frame, fop_discard_cbk_t fn, stub->fn_cbk.discard = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (statpre) - stub->args_cbk.prestat = *statpre; - if (statpost) - stub->args_cbk.poststat = *statpost; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_discard_cbk_store (&stub->args_cbk, op_ret, op_errno, statpre, + statpost, xdata); out: return stub; } @@ -2256,15 +1971,8 @@ fop_zerofill_cbk_stub(call_frame_t *frame, fop_zerofill_cbk_t fn, stub->fn_cbk.zerofill = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (statpre) - stub->args_cbk.prestat = *statpre; - if (statpost) - stub->args_cbk.poststat = *statpost; - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_zerofill_cbk_store (&stub->args_cbk, op_ret, op_errno, statpre, + statpost, xdata); out: return stub; } @@ -2310,11 +2018,7 @@ fop_ipc_cbk_stub (call_frame_t *frame, fop_ipc_cbk_t fn, stub->fn_cbk.ipc = fn; - stub->args_cbk.op_ret = op_ret; - stub->args_cbk.op_errno = op_errno; - - if (xdata) - stub->args_cbk.xdata = dict_ref (xdata); + args_ipc_cbk_store (&stub->args_cbk, op_ret, op_errno, xdata); out: return stub; } @@ -2833,29 +2537,7 @@ call_stub_wipe_args (call_stub_t *stub) static void call_stub_wipe_args_cbk (call_stub_t *stub) { - if (stub->args_cbk.inode) - inode_unref (stub->args_cbk.inode); - - GF_FREE ((char *)stub->args_cbk.buf); - - GF_FREE (stub->args_cbk.vector); - - if (stub->args_cbk.iobref) - iobref_unref (stub->args_cbk.iobref); - - if (stub->args_cbk.fd) - fd_unref (stub->args_cbk.fd); - - if (stub->args_cbk.xattr) - dict_unref (stub->args_cbk.xattr); - - GF_FREE (stub->args_cbk.strong_checksum); - - if (stub->args_cbk.xdata) - dict_unref (stub->args_cbk.xdata); - - if (!list_empty (&stub->args_cbk.entries.list)) - gf_dirent_free (&stub->args_cbk.entries); + args_cbk_wipe (&stub->args_cbk); } diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index fe110775fc6..954338be915 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -17,6 +17,7 @@ #endif #include "xlator.h" +#include "defaults.h" #include "stack.h" #include "list.h" @@ -153,30 +154,7 @@ typedef struct { dict_t *xdata; } args; - struct { - int op_ret; - int op_errno; - inode_t *inode; - struct iatt stat; - struct iatt prestat; - struct iatt poststat; - struct iatt preparent; // @preoldparent in rename_cbk - struct iatt postparent; // @postoldparent in rename_cbk - struct iatt preparent2; // @prenewparent in rename_cbk - struct iatt postparent2; // @postnewparent in rename_cbk - const char *buf; - struct iovec *vector; - int count; - struct iobref *iobref; - fd_t *fd; - struct statvfs statvfs; - dict_t *xattr; - struct gf_flock lock; - uint32_t weak_checksum; - uint8_t *strong_checksum; - dict_t *xdata; - gf_dirent_t entries; - } args_cbk; + default_args_cbk_t args_cbk; } call_stub_t; diff --git a/libglusterfs/src/cluster-syncop.c b/libglusterfs/src/cluster-syncop.c new file mode 100644 index 00000000000..9525bc55510 --- /dev/null +++ b/libglusterfs/src/cluster-syncop.c @@ -0,0 +1,1184 @@ +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +/* Perform fop on all subvolumes represented by list[] array and wait + for all callbacks to return */ + +/* NOTE: Cluster-syncop, like syncop blocks the executing thread until the + * responses are gathered if it is not executed as part of synctask. So it + * shouldn't be invoked in epoll worker thread */ +#include "cluster-syncop.h" +#include "defaults.h" + +#define FOP_ONLIST(subvols, on, numsubvols, replies, output, frame, fop, args ...) do {\ + int __i = 0; \ + int __count = 0; \ + cluster_local_t __local = {0,}; \ + void *__old_local = frame->local; \ + \ + __local.replies = replies; \ + memset (output, 0, numsubvols); \ + cluster_replies_wipe (replies, numsubvols); \ + for (__i = 0; __i < numsubvols; __i++) \ + INIT_LIST_HEAD (&replies[__i].entries.list); \ + if (syncbarrier_init (&__local.barrier)) \ + break; \ + frame->local = &__local; \ + for (__i = 0; __i < numsubvols; __i++) { \ + if (!on[__i]) \ + continue; \ + STACK_WIND_COOKIE (frame, cluster_##fop##_cbk, \ + (void *)(long) __i, subvols[__i], \ + subvols[__i]->fops->fop, args); \ + __count++; \ + } \ + syncbarrier_wait (&__local.barrier, __count); \ + syncbarrier_destroy (&__local.barrier); \ + frame->local = __old_local; \ + STACK_RESET (frame->root); \ + } while (0) + +#define FOP_SEQ(subvols, on, numsubvols, replies, output, frame, fop, args ...) do {\ + int __i = 0; \ + \ + cluster_local_t __local = {0,}; \ + void *__old_local = frame->local; \ + __local.replies = replies; \ + memset (output, 0, numsubvols); \ + cluster_replies_wipe (replies, numsubvols); \ + for (__i = 0; __i < numsubvols; __i++) \ + INIT_LIST_HEAD (&replies[__i].entries.list); \ + if (syncbarrier_init (&__local.barrier)) \ + break; \ + frame->local = &__local; \ + for (__i = 0; __i < numsubvols; __i++) { \ + if (!on[__i]) \ + continue; \ + STACK_WIND_COOKIE (frame, cluster_##fop##_cbk, \ + (void *)(long) __i, subvols[__i], \ + subvols[__i]->fops->fop, args); \ + syncbarrier_wait (&__local.barrier, 1); \ + } \ + syncbarrier_destroy (&__local.barrier); \ + frame->local = __old_local; \ + STACK_RESET (frame->root); \ + } while (0) + +#define FOP_CBK(fop, frame, cookie, args ...) do {\ + cluster_local_t *__local = frame->local; \ + int __i = (long)cookie; \ + args_##fop##_cbk_store (&__local->replies[__i], args); \ + __local->replies[__i].valid = 1; \ + syncbarrier_wake (&__local->barrier); \ + } while (0) + +static int +fop_success_fill (default_args_cbk_t *replies, int numsubvols, + unsigned char *success) +{ + int i = 0; + int count = 0; + + for (i = 0; i < numsubvols; i++) { + if (replies[i].valid && replies[i].op_ret >= 0) { + success[i] = 1; + count++; + } else { + success[i] = 0; + } + } + + return count; +} + +void +cluster_replies_wipe (default_args_cbk_t *replies, int numsubvols) +{ + int i = 0; + for (i = 0; i < numsubvols; i++) + args_cbk_wipe (&replies[i]); + memset (replies, 0, numsubvols * sizeof (*replies)); +} + +int32_t +cluster_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, dict_t *xdata, struct iatt *postparent) +{ + FOP_CBK (lookup, frame, cookie, op_ret, op_errno, inode, buf, + xdata, postparent); + return 0; +} + +int32_t +cluster_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + dict_t *xdata) +{ + FOP_CBK (stat, frame, cookie, op_ret, op_errno, buf, xdata); + return 0; +} + + +int32_t +cluster_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, + dict_t *xdata) +{ + FOP_CBK (truncate, frame, cookie, op_ret, op_errno, prebuf, + postbuf, xdata); + return 0; +} + +int32_t +cluster_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, + dict_t *xdata) +{ + FOP_CBK (ftruncate, frame, cookie, op_ret, op_errno, prebuf, + postbuf, xdata); + return 0; +} + +int32_t +cluster_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (access, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, const char *path, + struct iatt *buf, dict_t *xdata) +{ + FOP_CBK (readlink, frame, cookie, op_ret, op_errno, path, buf, + xdata); + return 0; +} + + +int32_t +cluster_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) +{ + FOP_CBK (mknod, frame, cookie, op_ret, op_errno, inode, + buf, preparent, postparent, xdata); + return 0; +} + +int32_t +cluster_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) +{ + FOP_CBK (mkdir, frame, cookie, op_ret, op_errno, inode, + buf, preparent, postparent, xdata); + return 0; +} + +int32_t +cluster_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) +{ + FOP_CBK (unlink, frame, cookie, op_ret, op_errno, preparent, + postparent, xdata); + return 0; +} + +int32_t +cluster_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *preparent, + struct iatt *postparent, + dict_t *xdata) +{ + FOP_CBK (rmdir, frame, cookie, op_ret, op_errno, preparent, + postparent, xdata); + return 0; +} + + +int32_t +cluster_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) +{ + FOP_CBK (symlink, frame, cookie, op_ret, op_errno, inode, buf, + preparent, postparent, xdata); + return 0; +} + + +int32_t +cluster_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + struct iatt *preoldparent, struct iatt *postoldparent, + struct iatt *prenewparent, struct iatt *postnewparent, + dict_t *xdata) +{ + FOP_CBK (rename, frame, cookie, op_ret, op_errno, buf, preoldparent, + postoldparent, prenewparent, postnewparent, xdata); + return 0; +} + + +int32_t +cluster_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, + dict_t *xdata) +{ + FOP_CBK (link, frame, cookie, op_ret, op_errno, inode, buf, + preparent, postparent, xdata); + return 0; +} + + +int32_t +cluster_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, + dict_t *xdata) +{ + FOP_CBK (create, frame, cookie, op_ret, op_errno, fd, inode, buf, + preparent, postparent, xdata); + return 0; +} + +int32_t +cluster_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, + dict_t *xdata) +{ + FOP_CBK (open, frame, cookie, op_ret, op_errno, fd, xdata); + return 0; +} + +int32_t +cluster_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iovec *vector, + int32_t count, struct iatt *stbuf, struct iobref *iobref, + dict_t *xdata) +{ + FOP_CBK (readv, frame, cookie, op_ret, op_errno, vector, count, + stbuf, iobref, xdata); + return 0; +} + + +int32_t +cluster_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, + dict_t *xdata) +{ + FOP_CBK (writev, frame, cookie, op_ret, op_errno, prebuf, postbuf, + xdata); + return 0; +} + + +int32_t +cluster_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (flush, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + + +int32_t +cluster_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, + dict_t *xdata) +{ + FOP_CBK (fsync, frame, cookie, op_ret, op_errno, prebuf, postbuf, + xdata); + return 0; +} + +int32_t +cluster_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + dict_t *xdata) +{ + FOP_CBK (fstat, frame, cookie, op_ret, op_errno, buf, xdata); + return 0; +} + +int32_t +cluster_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, + dict_t *xdata) +{ + FOP_CBK (opendir, frame, cookie, op_ret, op_errno, fd, xdata); + return 0; +} + +int32_t +cluster_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (fsyncdir, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct statvfs *buf, + dict_t *xdata) +{ + FOP_CBK (statfs, frame, cookie, op_ret, op_errno, buf, xdata); + return 0; +} + + +int32_t +cluster_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (setxattr, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + +int32_t +cluster_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (fsetxattr, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + + +int32_t +cluster_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + FOP_CBK (fgetxattr, frame, cookie, op_ret, op_errno, dict, xdata); + return 0; +} + + +int32_t +cluster_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + FOP_CBK (getxattr, frame, cookie, op_ret, op_errno, dict, xdata); + return 0; +} + +int32_t +cluster_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + FOP_CBK (xattrop, frame, cookie, op_ret, op_errno, dict, xdata); + return 0; +} + +int32_t +cluster_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + FOP_CBK (fxattrop, frame, cookie, op_ret, op_errno, dict, xdata); + return 0; +} + + +int32_t +cluster_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (removexattr, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + +int32_t +cluster_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (fremovexattr, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct gf_flock *lock, + dict_t *xdata) +{ + FOP_CBK (lk, frame, cookie, op_ret, op_errno, lock, xdata); + return 0; +} + +int32_t +cluster_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (inodelk, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + +int32_t +cluster_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (finodelk, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (entrylk, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + dict_t *xdata) +{ + FOP_CBK (fentrylk, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + + +int32_t +cluster_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, uint32_t weak_checksum, + uint8_t *strong_checksum, + dict_t *xdata) +{ + FOP_CBK (rchecksum, frame, cookie, op_ret, op_errno, weak_checksum, + strong_checksum, xdata); + return 0; +} + + +int32_t +cluster_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, + dict_t *xdata) +{ + FOP_CBK (readdir, frame, cookie, op_ret, op_errno, entries, xdata); + return 0; +} + + +int32_t +cluster_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, + dict_t *xdata) +{ + FOP_CBK (readdirp, frame, cookie, op_ret, op_errno, entries, xdata); + return 0; +} + +int32_t +cluster_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *statpre, + struct iatt *statpost, + dict_t *xdata) +{ + FOP_CBK (setattr, frame, cookie, op_ret, op_errno, statpre, + statpost, xdata); + return 0; +} + +int32_t +cluster_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *statpre, + struct iatt *statpost, + dict_t *xdata) +{ + FOP_CBK (fsetattr, frame, cookie, op_ret, op_errno, statpre, + statpost, xdata); + return 0; +} + +int32_t +cluster_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *pre, + struct iatt *post, dict_t *xdata) +{ + FOP_CBK (fallocate, frame, cookie, op_ret, op_errno, pre, post, xdata); + return 0; +} + +int32_t +cluster_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *pre, + struct iatt *post, dict_t *xdata) +{ + FOP_CBK (discard, frame, cookie, op_ret, op_errno, pre, post, xdata); + return 0; +} + +int32_t +cluster_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *pre, + struct iatt *post, dict_t *xdata) +{ + FOP_CBK (zerofill, frame, cookie, op_ret, op_errno, pre, + post, xdata); + return 0; +} + + +int32_t +cluster_ipc_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + FOP_CBK (ipc, frame, cookie, op_ret, op_errno, xdata); + return 0; +} + +int32_t +cluster_fgetxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fgetxattr, fd, + name, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fsetxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fsetxattr, fd, + dict, flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_setxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, setxattr, loc, + dict, flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_statfs (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, statfs, loc, + xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fsyncdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fsyncdir, fd, + flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_opendir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, opendir, loc, + fd, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fstat (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fstat, fd, + xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fsync (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fsync, fd, + flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_flush (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, flush, fd, + xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_writev (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + struct iovec *vector, int32_t count, off_t off, uint32_t flags, + struct iobref *iobref, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, writev, fd, + vector, count, off, flags, iobref, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_readv (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, readv, fd, size, + offset, flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_open (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, open, loc, + flags, fd, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_create (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, create, loc, + flags, mode, umask, fd, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_link (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, link, oldloc, + newloc, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_rename (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *oldloc, + loc_t *newloc, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, rename, oldloc, + newloc, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int +cluster_symlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, symlink, + linkpath, loc, umask, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_rmdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, rmdir, loc, + flags, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_unlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, unlink, loc, + xflag, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int +cluster_mkdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, mkdir, loc, + mode, umask, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int +cluster_mknod (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, mknod, loc, + mode, rdev, umask, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_readlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, readlink, loc, + size, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_access (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, access, loc, + mask, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_ftruncate (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, ftruncate, fd, + offset, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_getxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, getxattr, loc, + name, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_xattrop (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, xattrop, loc, + flags, dict, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fxattrop (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fxattrop, fd, + flags, dict, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_removexattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, removexattr, + loc, name, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fremovexattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fremovexattr, + fd, name, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_lk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + int32_t cmd, struct gf_flock *lock, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, lk, fd, cmd, + lock, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_rchecksum (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + int32_t len, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, rchecksum, fd, + offset, len, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_readdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, readdir, fd, + size, off, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_readdirp (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, readdirp, fd, + size, off, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_setattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + struct iatt *stbuf, int32_t valid, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, setattr, loc, + stbuf, valid, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_truncate (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, truncate, loc, + offset, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_stat (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, stat, loc, + xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_lookup (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, lookup, loc, + xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fsetattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + struct iatt *stbuf, int32_t valid, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, fsetattr, fd, + stbuf, valid, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_fallocate (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + int32_t keep_size, off_t offset, size_t len, dict_t *xdata) +{ + FOP_ONLIST(subvols, on, numsubvols, replies, output, frame, fallocate, fd, + keep_size, offset, len, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_discard (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + off_t offset, size_t len, dict_t *xdata) +{ + FOP_ONLIST(subvols, on, numsubvols, replies, output, frame, discard, fd, + offset, len, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int32_t +cluster_zerofill(xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, fd_t *fd, + off_t offset, off_t len, dict_t *xdata) +{ + FOP_ONLIST(subvols, on, numsubvols, replies, output, frame, zerofill, fd, + offset, len, xdata); + return fop_success_fill (replies, numsubvols, output); +} + + +int32_t +cluster_ipc (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) +{ + FOP_ONLIST (subvols, on, numsubvols, replies, output, frame, ipc, op, xdata); + return fop_success_fill (replies, numsubvols, output); +} + +int +cluster_uninodelk (xlator_t **subvols, unsigned char *locked_on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, off_t off, size_t size) +{ + loc_t loc = {0,}; + struct gf_flock flock = {0, }; + + + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + + flock.l_type = F_UNLCK; + flock.l_start = off; + flock.l_len = size; + + FOP_ONLIST (subvols, locked_on, numsubvols, replies, output, frame, inodelk, + dom, &loc, F_SETLK, &flock, NULL); + + loc_wipe (&loc); + + return fop_success_fill (replies, numsubvols, output); +} + +int +cluster_tryinodelk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, off_t off, size_t size) +{ + struct gf_flock flock = {0, }; + loc_t loc = {0}; + + flock.l_type = F_WRLCK; + flock.l_start = off; + flock.l_len = size; + + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + FOP_ONLIST (subvols, on, numsubvols, replies, locked_on, frame, inodelk, dom, + &loc, F_SETLK, &flock, NULL); + + loc_wipe (&loc); + return fop_success_fill (replies, numsubvols, locked_on); +} + +int +cluster_inodelk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, off_t off, size_t size) +{ + struct gf_flock flock = {0, }; + int i = 0; + loc_t loc = {0}; + unsigned char *output = NULL; + + flock.l_type = F_WRLCK; + flock.l_start = off; + flock.l_len = size; + + output = alloca(numsubvols); + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + FOP_ONLIST (subvols, on, numsubvols, replies, locked_on, frame, + inodelk, dom, &loc, F_SETLK, &flock, NULL); + + for (i = 0; i < numsubvols; i++) { + if (replies[i].op_ret == -1 && replies[i].op_errno == EAGAIN) { + fop_success_fill (replies, numsubvols, locked_on); + cluster_uninodelk (subvols, locked_on, numsubvols, + replies, output, frame, this, dom, inode, off, size); + + FOP_SEQ (subvols, on, numsubvols, replies, locked_on, + frame, inodelk, dom, &loc, F_SETLKW, &flock, + NULL); + break; + } + } + + loc_wipe (&loc); + return fop_success_fill (replies, numsubvols, locked_on); +} + + +int +cluster_unentrylk (xlator_t **subvols, unsigned char *locked_on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name) +{ + loc_t loc = {0,}; + + + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + + FOP_ONLIST (subvols, locked_on, numsubvols, replies, output, frame, + entrylk, dom, &loc, name, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, + NULL); + + loc_wipe (&loc); + + return fop_success_fill (replies, numsubvols, output); +} + +int +cluster_tryentrylk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name) +{ + loc_t loc = {0}; + + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + FOP_ONLIST (subvols, on, numsubvols, replies, locked_on, frame, + entrylk, dom, &loc, name, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, + NULL); + + loc_wipe (&loc); + return fop_success_fill (replies, numsubvols, locked_on); +} + +int +cluster_entrylk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name) +{ + int i = 0; + loc_t loc = {0}; + unsigned char *output = NULL; + + output = alloca(numsubvols); + loc.inode = inode_ref (inode); + gf_uuid_copy (loc.gfid, inode->gfid); + FOP_ONLIST (subvols, on, numsubvols, replies, locked_on, frame, + entrylk, dom, &loc, name, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, + NULL); + + for (i = 0; i < numsubvols; i++) { + if (replies[i].op_ret == -1 && replies[i].op_errno == EAGAIN) { + fop_success_fill (replies, numsubvols, locked_on); + cluster_unentrylk (subvols, locked_on, numsubvols, + replies, output, frame, this, dom, + inode, name); + FOP_ONLIST (subvols, on, numsubvols, replies, + locked_on, frame, entrylk, dom, &loc, name, + ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL); + break; + } + } + + loc_wipe (&loc); + return fop_success_fill (replies, numsubvols, locked_on); +} diff --git a/libglusterfs/src/cluster-syncop.h b/libglusterfs/src/cluster-syncop.h new file mode 100644 index 00000000000..2c94246ff1f --- /dev/null +++ b/libglusterfs/src/cluster-syncop.h @@ -0,0 +1,126 @@ +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + + +#ifndef _CLUSTER_SYNCOP_H +#define _CLUSTER_SYNCOP_H + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "xlator.h" +#include <sys/time.h> +#include <pthread.h> +#include <ucontext.h> +#include "defaults.h" +#include "syncop.h" + +typedef struct cluster_local_ { + default_args_cbk_t *replies; + syncbarrier_t barrier; +} cluster_local_t; + +int32_t +cluster_lookup (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); +int32_t +cluster_setattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + struct iatt *stbuf, int32_t valid, dict_t *xdata); +int32_t +cluster_getxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata); +int32_t +cluster_setxattr (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata); + +int +cluster_inodelk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, off_t off, size_t size); + +int +cluster_uninodelk (xlator_t **subvols, unsigned char *locked_on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, off_t off, size_t size); + +int +cluster_entrylk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name); + +int32_t +cluster_rmdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata); + +int32_t +cluster_unlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata); + +int +cluster_mkdir (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata); + +int32_t +cluster_readlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + dict_t *xdata); + +int +cluster_symlink (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata); + +int32_t +cluster_link (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); + +int +cluster_mknod (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata); + +int +cluster_unentrylk (xlator_t **subvols, unsigned char *locked_on, int numsubvols, + default_args_cbk_t *replies, unsigned char *output, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name); + +int +cluster_tryentrylk (xlator_t **subvols, unsigned char *on, int numsubvols, + default_args_cbk_t *replies, unsigned char *locked_on, + call_frame_t *frame, xlator_t *this, char *dom, + inode_t *inode, const char *name); + +void +cluster_replies_wipe (default_args_cbk_t *replies, int num_subvols); +#endif /* !_CLUSTER_SYNCOP_H */ diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c index ac08a70cf32..1414da90731 100644 --- a/libglusterfs/src/defaults.c +++ b/libglusterfs/src/defaults.c @@ -26,6 +26,7 @@ #endif #include "xlator.h" +#include "defaults.h" /* FAILURE_CBK function section */ @@ -2357,3 +2358,811 @@ default_mem_acct_init (xlator_t *this) return ret; } + +/*ARGS_ STORE section*/ +int +args_lookup_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + dict_t *xdata, struct iatt *postparent) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (inode) + args->inode = inode_ref (inode); + if (buf) + args->stat = *buf; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_stat_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *buf, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret == 0) + args->stat = *buf; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fstat_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *buf, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (buf) + args->stat = *buf; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_truncate_cbk_store (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); + + return 0; +} + + +int +args_ftruncate_cbk_store (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); + + return 0; +} + + +int +args_access_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_readlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + const char *path, struct iatt *stbuf, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (path) + args->buf = gf_strdup (path); + if (stbuf) + args->stat = *stbuf; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_mknod_cbk_store (default_args_cbk_t *args, int op_ret, + int32_t op_errno, inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + 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 (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_mkdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, 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 (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_unlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_rmdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_symlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + 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 (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_rename_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + struct iatt *preoldparent, struct iatt *postoldparent, + struct iatt *prenewparent, struct iatt *postnewparent, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (buf) + args->stat = *buf; + if (preoldparent) + args->preparent = *preoldparent; + if (postoldparent) + args->postparent = *postoldparent; + if (prenewparent) + args->preparent2 = *prenewparent; + if (postnewparent) + args->postparent2 = *postnewparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_link_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + 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 (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_create_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (fd) + args->fd = fd_ref (fd); + if (inode) + args->inode = inode_ref (inode); + if (buf) + args->stat = *buf; + if (preparent) + args->preparent = *preparent; + if (postparent) + args->postparent = *postparent; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_open_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (fd) + args->fd = fd_ref (fd); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_readv_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iovec *vector, + int32_t count, struct iatt *stbuf, + struct iobref *iobref, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret >= 0) { + args->vector = iov_dup (vector, count); + args->count = count; + args->stat = *stbuf; + args->iobref = iobref_ref (iobref); + } + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_writev_cbk_store (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 (op_ret >= 0) + args->poststat = *postbuf; + if (prebuf) + args->prestat = *prebuf; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_flush_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_fsync_cbk_store (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); + + return 0; +} + +int +args_opendir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (fd) + args->fd = fd_ref (fd); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fsyncdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_statfs_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct statvfs *buf, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret == 0) + args->statvfs = *buf; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_setxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, + int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_getxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *dict, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (dict) + args->xattr = dict_ref (dict); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fsetxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fgetxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *dict, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (dict) + args->xattr = dict_ref (dict); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_removexattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fremovexattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_lk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct gf_flock *lock, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret == 0) + args->lock = *lock; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_inodelk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_finodelk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_entrylk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fentrylk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_readdirp_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + gf_dirent_t *entries, dict_t *xdata) +{ + gf_dirent_t *stub_entry = NULL, *entry = NULL; + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret > 0) { + list_for_each_entry (entry, &entries->list, list) { + stub_entry = gf_dirent_for_name (entry->d_name); + if (!stub_entry) + goto out; + stub_entry->d_off = entry->d_off; + stub_entry->d_ino = entry->d_ino; + stub_entry->d_stat = entry->d_stat; + stub_entry->d_type = entry->d_type; + if (entry->inode) + stub_entry->inode = inode_ref (entry->inode); + if (entry->dict) + stub_entry->dict = dict_ref (entry->dict); + list_add_tail (&stub_entry->list, + &args->entries.list); + } + } + if (xdata) + args->xdata = dict_ref (xdata); +out: + return 0; +} + + +int +args_readdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + gf_dirent_t *entries, dict_t *xdata) +{ + gf_dirent_t *stub_entry = NULL, *entry = NULL; + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret > 0) { + list_for_each_entry (entry, &entries->list, list) { + stub_entry = gf_dirent_for_name (entry->d_name); + if (!stub_entry) + goto out; + stub_entry->d_off = entry->d_off; + stub_entry->d_ino = entry->d_ino; + stub_entry->d_type = entry->d_type; + list_add_tail (&stub_entry->list, + &args->entries.list); + } + } + if (xdata) + args->xdata = dict_ref (xdata); +out: + return 0; +} + + +int +args_rchecksum_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + uint32_t weak_checksum, uint8_t *strong_checksum, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret >= 0) { + args->weak_checksum = + weak_checksum; + args->strong_checksum = + memdup (strong_checksum, MD5_DIGEST_LENGTH); + } + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_xattrop_cbk_store (default_args_cbk_t *args, int32_t op_ret, + int32_t op_errno, dict_t *xattr, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xattr) + args->xattr = dict_ref (xattr); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_fxattrop_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *xattr, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xattr) + args->xattr = dict_ref (xattr); + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_setattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (statpre) + args->prestat = *statpre; + if (statpost) + args->poststat = *statpost; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + + +int +args_fsetattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (statpre) + args->prestat = *statpre; + if (statpost) + args->poststat = *statpost; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_fallocate_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (statpre) + args->prestat = *statpre; + if (statpost) + args->poststat = *statpost; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_discard_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (statpre) + args->prestat = *statpre; + if (statpost) + args->poststat = *statpost; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_zerofill_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (statpre) + args->prestat = *statpre; + if (statpost) + args->poststat = *statpost; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +int +args_ipc_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + return 0; +} + +void +args_cbk_wipe (default_args_cbk_t *args_cbk) +{ + if (!args_cbk) + return; + if (args_cbk->inode) + inode_unref (args_cbk->inode); + + GF_FREE ((char *)args_cbk->buf); + + GF_FREE (args_cbk->vector); + + if (args_cbk->iobref) + iobref_unref (args_cbk->iobref); + + if (args_cbk->fd) + fd_unref (args_cbk->fd); + + if (args_cbk->xattr) + dict_unref (args_cbk->xattr); + + GF_FREE (args_cbk->strong_checksum); + + if (args_cbk->xdata) + dict_unref (args_cbk->xdata); + + if (!list_empty (&args_cbk->entries.list)) + gf_dirent_free (&args_cbk->entries); +} +/* end of ARGS_ STORE section*/ diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index e29d62edfe1..a4ec7625409 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -22,6 +22,33 @@ #include "xlator.h" +typedef struct { + int op_ret; + int op_errno; + inode_t *inode; + struct iatt stat; + struct iatt prestat; + struct iatt poststat; + struct iatt preparent; /* @preoldparent in rename_cbk */ + struct iatt postparent; /* @postoldparent in rename_cbk */ + struct iatt preparent2; /* @prenewparent in rename_cbk */ + struct iatt postparent2; /* @postnewparent in rename_cbk */ + const char *buf; + struct iovec *vector; + int count; + struct iobref *iobref; + fd_t *fd; + struct statvfs statvfs; + dict_t *xattr; + struct gf_flock lock; + uint32_t weak_checksum; + uint8_t *strong_checksum; + dict_t *xdata; + gf_dirent_t entries; + int valid; /* If the response is valid or not. For call-stub it is + always valid irrespective of this */ +} default_args_cbk_t; + int32_t default_notify (xlator_t *this, int32_t event, void *data, @@ -1138,4 +1165,254 @@ default_getspec_failure_cbk (call_frame_t *frame, int32_t op_errno); int32_t default_mem_acct_init (xlator_t *this); +int +args_lookup_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + dict_t *xdata, struct iatt *postparent); + + +int +args_stat_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *buf, dict_t *xdata); + +int +args_fstat_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *buf, dict_t *xdata); + +int +args_truncate_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata); + + +int +args_ftruncate_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata); + + +int +args_access_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + + +int +args_readlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + const char *path, struct iatt *stbuf, dict_t *xdata); + +int +args_mknod_cbk_store (default_args_cbk_t *args, int32_t op_ret, + int32_t op_errno, inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + +int +args_mkdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata); + +int +args_unlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + +int +args_rmdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + +int +args_symlink_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + + +int +args_rename_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + struct iatt *preoldparent, struct iatt *postoldparent, + struct iatt *prenewparent, struct iatt *postnewparent, + dict_t *xdata); + +int +args_link_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + +int +args_create_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata); + +int +args_open_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, dict_t *xdata); + +int +args_readv_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, struct iovec *vector, + int32_t count, struct iatt *stbuf, + struct iobref *iobref, dict_t *xdata); + +int +args_writev_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata); + + +int +args_flush_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + + +int +args_fsync_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata); + +int +args_opendir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + fd_t *fd, dict_t *xdata); + +int +args_fsyncdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_statfs_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct statvfs *buf, dict_t *xdata); + +int +args_setxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, + int32_t op_errno, dict_t *xdata); + +int +args_getxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *dict, dict_t *xdata); + +int +args_fsetxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_fgetxattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *dict, dict_t *xdata); + +int +args_removexattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_fremovexattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_lk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct gf_flock *lock, dict_t *xdata); + + +int +args_inodelk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_finodelk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_entrylk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +args_fentrylk_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + + +int +args_readdirp_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + gf_dirent_t *entries, dict_t *xdata); + + +int +args_readdir_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + gf_dirent_t *entries, dict_t *xdata); + + +int +args_rchecksum_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + uint32_t weak_checksum, uint8_t *strong_checksum, + dict_t *xdata); + + +int +args_xattrop_cbk_store (default_args_cbk_t *args, int32_t op_ret, + int32_t op_errno, dict_t *xattr, dict_t *xdata); + + +int +args_fxattrop_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + dict_t *xattr, dict_t *xdata); + +int +args_setattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata); + + +int +args_fsetattr_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata); + +int +args_fallocate_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata); + +int +args_discard_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata); + +int +args_zerofill_cbk_store(default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, + struct iatt *statpre, struct iatt *statpost, + dict_t *xdata); + +int +args_ipc_cbk_store (default_args_cbk_t *args, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +void +args_cbk_wipe (default_args_cbk_t *args_cbk); +/* end of ARGS_ STORE section*/ #endif /* _DEFAULTS_H */ |