diff options
author | Susant Palai <spalai@redhat.com> | 2016-04-17 10:21:59 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2016-05-01 18:04:42 -0700 |
commit | 30f5e460a814358668425860530e5186570e9530 (patch) | |
tree | 22051808de01bb00d075656a981130ecec7be758 | |
parent | 90a8d15ea9778b5089521767137b14cb52b9a2b3 (diff) |
core: add setactivelk () fop
Change-Id: Ic2ba77a1fdd27801a6e579e04e6c0dd93cd7127b
BUG: 1326085
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/14011
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r-- | libglusterfs/src/call-stub.c | 52 | ||||
-rw-r--r-- | libglusterfs/src/call-stub.h | 13 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/default-args.c | 38 | ||||
-rw-r--r-- | libglusterfs/src/default-args.h | 3 | ||||
-rw-r--r-- | libglusterfs/src/defaults-tmpl.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/defaults.h | 14 | ||||
-rwxr-xr-x | libglusterfs/src/generator.py | 7 | ||||
-rw-r--r-- | libglusterfs/src/globals.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/syncop.c | 44 | ||||
-rw-r--r-- | libglusterfs/src/syncop.h | 10 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 11 | ||||
-rw-r--r-- | rpc/xdr/src/glusterfs-fops.x | 1 |
14 files changed, 196 insertions, 1 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 13466e38551..9ed2493e80b 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -1924,6 +1924,50 @@ out: } +call_stub_t * +fop_setactivelk_cbk_stub (call_frame_t *frame, fop_setactivelk_cbk_t fn, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + call_stub_t *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + + stub = stub_new (frame, 0, GF_FOP_SETACTIVELK); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->fn_cbk.setactivelk = fn; + stub->args_cbk.op_ret = op_ret; + stub->args_cbk.op_errno = op_errno; + + if (xdata) + stub->args.xdata = dict_ref (xdata); + +out: + return stub; +} + +call_stub_t * +fop_setactivelk_stub (call_frame_t *frame, fop_setactivelk_t fn, + loc_t *loc, lock_migration_info_t *locklist, + dict_t *xdata) +{ + call_stub_t *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + GF_VALIDATE_OR_GOTO ("call-stub", fn, out); + + stub = stub_new (frame, 1, GF_FOP_SETACTIVELK); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->fn.setactivelk = fn; + + args_setactivelk_store (&stub->args, loc, locklist, xdata); + +out: + return stub; + +} + void call_resume_wind (call_stub_t *stub) { @@ -2175,6 +2219,11 @@ call_resume_wind (call_stub_t *stub) stub->fn.getactivelk (stub->frame, stub->frame->this, &stub->args.loc, stub->args.xdata); + case GF_FOP_SETACTIVELK: + stub->fn.setactivelk (stub->frame, stub->frame->this, + &stub->args.loc, &stub->args.locklist, + stub->args.xdata); + default: gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ENTRY, "Invalid value of FOP" @@ -2397,6 +2446,9 @@ call_resume_unwind (call_stub_t *stub) STUB_UNWIND (stub, getactivelk, &stub->args_cbk.locklist, stub->args_cbk.xdata); + case GF_FOP_SETACTIVELK: + STUB_UNWIND (stub, setactivelk, stub->args_cbk.xdata); + default: gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ENTRY, "Invalid value of FOP" diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index 9b73a154128..5779ee36e58 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -76,7 +76,8 @@ typedef struct _call_stub { fop_seek_t seek; fop_lease_t lease; fop_getactivelk_t getactivelk; - } fn; + fop_setactivelk_t setactivelk; + } fn; union { fop_lookup_cbk_t lookup; @@ -127,6 +128,7 @@ typedef struct _call_stub { fop_seek_cbk_t seek; fop_lease_cbk_t lease; fop_getactivelk_cbk_t getactivelk; + fop_setactivelk_cbk_t setactivelk; } fn_cbk; default_args_t args; @@ -751,6 +753,15 @@ fop_getactivelk_cbk_stub (call_frame_t *frame, fop_getactivelk_cbk_t fn, int32_t op_ret, int32_t op_errno, lock_migration_info_t *lmi, dict_t *xdata); +call_stub_t * +fop_setactivelk_stub (call_frame_t *frame, fop_setactivelk_t fn, + loc_t *loc, lock_migration_info_t *locklist, + dict_t *xdata); + +call_stub_t * +fop_setactivelk_cbk_stub (call_frame_t *frame, fop_setactivelk_cbk_t fn, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + void call_resume (call_stub_t *stub); void call_stub_destroy (call_stub_t *stub); void call_unwind_error (call_stub_t *stub, int op_ret, int op_errno); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 49b76871bab..56edc9f4a2b 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4307,6 +4307,7 @@ fop_enum_to_pri_string (glusterfs_fop_t fop) case GF_FOP_READDIR: case GF_FOP_READDIRP: case GF_FOP_GETACTIVELK: + case GF_FOP_SETACTIVELK: return "HIGH"; case GF_FOP_CREATE: diff --git a/libglusterfs/src/default-args.c b/libglusterfs/src/default-args.c index ca24c2fe08c..9f788011ecb 100644 --- a/libglusterfs/src/default-args.c +++ b/libglusterfs/src/default-args.c @@ -1472,6 +1472,44 @@ out: return ret; } +int +args_setactivelk_store (default_args_t *args, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata) +{ + lock_migration_info_t *stub_entry = NULL, *entry = NULL; + int ret = 0; + + list_for_each_entry (entry, &locklist->list, list) { + stub_entry = GF_CALLOC (1, sizeof (*stub_entry), + gf_common_mt_lock_mig); + if (!stub_entry) { + ret = -1; + goto out; + } + + INIT_LIST_HEAD (&stub_entry->list); + stub_entry->flock = entry->flock; + + stub_entry->client_uid = gf_strdup (entry->client_uid); + if (!stub_entry->client_uid) { + GF_FREE (stub_entry); + ret = -1; + goto out; + } + + list_add_tail (&stub_entry->list, + &args->locklist.list); + } + + loc_copy (&args->loc, loc); + + if (xdata) + args->xdata = dict_ref (xdata); + +out: + return ret; +} + void args_lease_store (default_args_t *args, loc_t *loc, struct gf_lease *lease, dict_t *xdata) diff --git a/libglusterfs/src/default-args.h b/libglusterfs/src/default-args.h index 3839c386078..93426ca43b6 100644 --- a/libglusterfs/src/default-args.h +++ b/libglusterfs/src/default-args.h @@ -476,4 +476,7 @@ args_getactivelk_cbk_store (default_args_cbk_t *args, int32_t op_ret, int32_t op_errno, lock_migration_info_t *locklist, dict_t *xdata); +int +args_setactivelk_store (default_args_t *args, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata); #endif /* _DEFAULT_ARGS_H */ diff --git a/libglusterfs/src/defaults-tmpl.c b/libglusterfs/src/defaults-tmpl.c index 2bbe3697451..b42c377ca31 100644 --- a/libglusterfs/src/defaults-tmpl.c +++ b/libglusterfs/src/defaults-tmpl.c @@ -80,6 +80,7 @@ struct xlator_fops _default_fops = { .getspec = default_getspec, .getactivelk = default_getactivelk, + .setactivelk = default_setactivelk, }; struct xlator_fops *default_fops = &_default_fops; diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index 87ab8f19dd5..2fc6a46de1f 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -77,6 +77,7 @@ typedef struct { gf_seek_what_t what; dict_t *xdata; struct gf_lease lease; + lock_migration_info_t locklist; } default_args_t; typedef struct { @@ -349,6 +350,10 @@ int32_t default_getactivelk (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); +int32_t +default_setactivelk (call_frame_t *frame, xlator_t *this, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata); + /* Resume */ int32_t default_getspec_resume (call_frame_t *frame, xlator_t *this, @@ -866,6 +871,11 @@ int32_t default_getactivelk_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); +int32_t +default_setactivelk_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata); + + /* _CBK */ int32_t default_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -1253,5 +1263,9 @@ default_getactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, dict_t *xdata); int32_t +default_setactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int32_t default_mem_acct_init (xlator_t *this); #endif /* _DEFAULTS_H */ diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py index 1596437f590..21f5cf7d387 100755 --- a/libglusterfs/src/generator.py +++ b/libglusterfs/src/generator.py @@ -549,6 +549,13 @@ ops['getactivelk'] = ( ('cbk-arg', 'xdata', 'dict_t *'), ) +ops['setactivelk'] = ( + ('fop-arg', 'loc', 'loc_t *'), + ('fop-arg', 'locklist', 'lock_migration_info_t *'), + ('fop-arg', 'xdata', 'dict_t *'), + ('cbk-arg', 'xdata', 'dict_t *'), +) + ##################################################################### xlator_cbks['forget'] = ( ('fn-arg', 'this', 'xlator_t *'), diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 67c0ed5fcd1..50ef4dbeea3 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -72,6 +72,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { [GF_FOP_LEASE] = "LEASE", [GF_FOP_COMPOUND] = "COMPOUND", [GF_FOP_GETACTIVELK] = "GETACTIVELK", + [GF_FOP_SETACTIVELK] = "SETACTIVELK", }; /* THIS */ diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 4fa23002e24..e3d48577d2c 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -3141,3 +3141,47 @@ syncop_getactivelk (xlator_t *subvol, loc_t *loc, return args.op_ret; } + +int +syncop_setactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + if (xdata) + args->xdata = dict_ref (xdata); + + + __wake (args); + + return 0; + +} + +int +syncop_setactivelk (xlator_t *subvol, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata_in, + dict_t **xdata_out) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_setactivelk_cbk, + subvol->fops->setactivelk, + loc, locklist, xdata_in); + + if (xdata_out) + *xdata_out = args.xdata; + else if (args.xdata) + dict_unref (args.xdata); + + if (args.op_ret < 0) + return -args.op_errno; + + return args.op_ret; + +} diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index 2f7237bcfb2..c2387e62cd2 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -527,4 +527,14 @@ syncop_seek (xlator_t *subvol, fd_t *fd, off_t offset, gf_seek_what_t what, int syncop_getactivelk (xlator_t *subvol, loc_t *loc, lock_migration_info_t *locklist, dict_t *xdata_in, dict_t **xdata_out); + +int +syncop_setactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); + +int +syncop_setactivelk (xlator_t *subvol, loc_t *loc, + lock_migration_info_t *locklist, dict_t *xdata_in, + dict_t **xdata_out); + #endif /* _SYNCOP_H */ diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index e762ac2afaa..2221332a092 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -83,6 +83,7 @@ fill_defaults (xlator_t *xl) SET_DEFAULT_FOP (seek); SET_DEFAULT_FOP (lease); SET_DEFAULT_FOP (getactivelk); + SET_DEFAULT_FOP (setactivelk); SET_DEFAULT_FOP (getspec); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index bb039c0a527..555916d2adb 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -463,6 +463,10 @@ typedef int32_t (*fop_getactivelk_cbk_t) (call_frame_t *frame, void *cookie, lock_migration_info_t *locklist, dict_t *xdata); +typedef int32_t (*fop_setactivelk_cbk_t) (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xdata); + typedef int32_t (*fop_lookup_t) (call_frame_t *frame, xlator_t *this, loc_t *loc, @@ -718,6 +722,11 @@ typedef int32_t (*fop_compound_t) (call_frame_t *frame, xlator_t *this, typedef int32_t (*fop_getactivelk_t) (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); +typedef int32_t (*fop_setactivelk_t) (call_frame_t *frame, xlator_t *this, + loc_t *loc, + lock_migration_info_t *locklist, + dict_t *xdata); + struct xlator_fops { fop_lookup_t lookup; fop_stat_t stat; @@ -769,6 +778,7 @@ struct xlator_fops { fop_lease_t lease; fop_compound_t compound; fop_getactivelk_t getactivelk; + fop_setactivelk_t setactivelk; /* these entries are used for a typechecking hack in STACK_WIND _only_ */ fop_lookup_cbk_t lookup_cbk; @@ -821,6 +831,7 @@ struct xlator_fops { fop_lease_cbk_t lease_cbk; fop_compound_cbk_t compound_cbk; fop_getactivelk_cbk_t getactivelk_cbk; + fop_setactivelk_cbk_t setactivelk_cbk; }; typedef int32_t (*cbk_forget_t) (xlator_t *this, diff --git a/rpc/xdr/src/glusterfs-fops.x b/rpc/xdr/src/glusterfs-fops.x index 74952919c3d..8462dcc258a 100644 --- a/rpc/xdr/src/glusterfs-fops.x +++ b/rpc/xdr/src/glusterfs-fops.x @@ -58,6 +58,7 @@ enum glusterfs_fop_t { GF_FOP_LEASE, GF_FOP_COMPOUND, GF_FOP_GETACTIVELK, + GF_FOP_SETACTIVELK, GF_FOP_MAXVALUE }; |