diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/call-stub.c | 51 | ||||
-rw-r--r-- | libglusterfs/src/call-stub.h | 11 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.c | 20 | ||||
-rw-r--r-- | libglusterfs/src/default-args.c | 41 | ||||
-rw-r--r-- | libglusterfs/src/default-args.h | 5 | ||||
-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/glusterfs.h | 9 | ||||
-rw-r--r-- | libglusterfs/src/syncop.c | 79 | ||||
-rw-r--r-- | libglusterfs/src/syncop.h | 5 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 1 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 12 |
14 files changed, 257 insertions, 0 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 99371ce8ff8..13466e38551 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -1880,6 +1880,49 @@ out: } +call_stub_t * +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 *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + + stub = stub_new (frame, 0, GF_FOP_GETACTIVELK); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->fn_cbk.getactivelk = fn; + + args_getactivelk_cbk_store (&stub->args_cbk, op_ret, op_errno, lmi, + xdata); +out: + return stub; +} + + +call_stub_t * +fop_getactivelk_stub (call_frame_t *frame, fop_getactivelk_t fn, loc_t *loc, + dict_t *xdata) +{ + call_stub_t *stub = NULL; + + GF_VALIDATE_OR_GOTO ("call-stub", frame, out); + GF_VALIDATE_OR_GOTO ("call-stub", fn, out); + + stub = stub_new (frame, 1, GF_FOP_GETACTIVELK); + GF_VALIDATE_OR_GOTO ("call-stub", stub, out); + + stub->fn.getactivelk = fn; + + loc_copy (&stub->args.loc, loc); + + if (xdata) + stub->args.xdata = dict_ref (xdata); +out: + return stub; + +} void call_resume_wind (call_stub_t *stub) @@ -2128,6 +2171,10 @@ call_resume_wind (call_stub_t *stub) stub->args.xdata); break; + case GF_FOP_GETACTIVELK: + stub->fn.getactivelk (stub->frame, stub->frame->this, + &stub->args.loc, stub->args.xdata); + default: gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ENTRY, "Invalid value of FOP" @@ -2346,6 +2393,10 @@ call_resume_unwind (call_stub_t *stub) stub->args_cbk.xdata); break; + case GF_FOP_GETACTIVELK: + STUB_UNWIND (stub, getactivelk, &stub->args_cbk.locklist, + 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 fa0ec69cb64..9b73a154128 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -75,6 +75,7 @@ typedef struct _call_stub { fop_ipc_t ipc; fop_seek_t seek; fop_lease_t lease; + fop_getactivelk_t getactivelk; } fn; union { @@ -125,6 +126,7 @@ typedef struct _call_stub { fop_ipc_cbk_t ipc; fop_seek_cbk_t seek; fop_lease_cbk_t lease; + fop_getactivelk_cbk_t getactivelk; } fn_cbk; default_args_t args; @@ -740,6 +742,15 @@ fop_lease_cbk_stub (call_frame_t *frame, fop_lease_cbk_t fn, int32_t op_ret, int32_t op_errno, struct gf_lease *lease, dict_t *xdata); +call_stub_t * +fop_getactivelk_stub (call_frame_t *frame, fop_getactivelk_t fn, + loc_t *loc, dict_t *xdata); + +call_stub_t * +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); + 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 a1a4c7d43ae..49b76871bab 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4213,6 +4213,25 @@ out: } void +gf_free_mig_locks (lock_migration_info_t *locks) +{ + lock_migration_info_t *current = NULL; + lock_migration_info_t *temp = NULL; + + if (!locks) + return; + + if (list_empty (&locks->list)) + return; + + list_for_each_entry_safe (current, temp, &locks->list, list) { + list_del_init (¤t->list); + GF_FREE (current->client_uid); + GF_FREE (current); + } +} + +void _mask_cancellation (void) { (void) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); @@ -4287,6 +4306,7 @@ fop_enum_to_pri_string (glusterfs_fop_t fop) case GF_FOP_STATFS: case GF_FOP_READDIR: case GF_FOP_READDIRP: + case GF_FOP_GETACTIVELK: return "HIGH"; case GF_FOP_CREATE: diff --git a/libglusterfs/src/default-args.c b/libglusterfs/src/default-args.c index 1ce907f6221..ca24c2fe08c 100644 --- a/libglusterfs/src/default-args.c +++ b/libglusterfs/src/default-args.c @@ -1431,6 +1431,47 @@ args_seek_cbk_store (default_args_cbk_t *args, int32_t op_ret, return 0; } +int +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) +{ + lock_migration_info_t *stub_entry = NULL, *entry = NULL; + int ret = 0; + + args->op_ret = op_ret; + args->op_errno = op_errno; + /*op_ret needs to carry the number of locks present in the list*/ + if (op_ret > 0) { + list_for_each_entry (entry, &locklist->list, list) { + stub_entry = GF_CALLOC (1, sizeof (*stub_entry), + gf_common_mt_char); + 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); + } + } + + 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 86dafe63e83..3839c386078 100644 --- a/libglusterfs/src/default-args.h +++ b/libglusterfs/src/default-args.h @@ -471,4 +471,9 @@ void args_lease_store (default_args_t *args, loc_t *loc, struct gf_lease *lease, dict_t *xdata); +int +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); + #endif /* _DEFAULT_ARGS_H */ diff --git a/libglusterfs/src/defaults-tmpl.c b/libglusterfs/src/defaults-tmpl.c index c5a0dcec2f0..2bbe3697451 100644 --- a/libglusterfs/src/defaults-tmpl.c +++ b/libglusterfs/src/defaults-tmpl.c @@ -79,6 +79,7 @@ struct xlator_fops _default_fops = { .seek = default_seek, .getspec = default_getspec, + .getactivelk = default_getactivelk, }; struct xlator_fops *default_fops = &_default_fops; diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index bcaac49b7af..87ab8f19dd5 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -44,6 +44,7 @@ typedef struct { int valid; /* If the response is valid or not. For call-stub it is always valid irrespective of this */ struct gf_lease lease; + lock_migration_info_t locklist; } default_args_cbk_t; typedef struct { @@ -344,6 +345,9 @@ int32_t default_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t default_lease (call_frame_t *frame, xlator_t *this, loc_t *loc, struct gf_lease *lease, dict_t *xdata); +int32_t +default_getactivelk (call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xdata); /* Resume */ int32_t default_getspec_resume (call_frame_t *frame, @@ -858,6 +862,10 @@ default_lease_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct gf_lease *lease, dict_t *xdata); +int32_t +default_getactivelk_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xdata); + /* _CBK */ int32_t default_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -1239,5 +1247,11 @@ int32_t default_lease_failure_cbk (call_frame_t *frame, int32_t op_errno); int32_t +default_getactivelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + lock_migration_info_t *locklist, + 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 15e31e3aa73..1596437f590 100755 --- a/libglusterfs/src/generator.py +++ b/libglusterfs/src/generator.py @@ -542,6 +542,13 @@ ops['lease'] = ( ('cbk-arg', 'xdata', 'dict_t *'), ) +ops['getactivelk'] = ( + ('fop-arg', 'loc', 'loc_t *'), + ('fop-arg', 'xdata', 'dict_t *'), + ('cbk-arg', 'locklist', 'lock_migration_info_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 997994f049e..67c0ed5fcd1 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -71,6 +71,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { [GF_FOP_SEEK] = "SEEK", [GF_FOP_LEASE] = "LEASE", [GF_FOP_COMPOUND] = "COMPOUND", + [GF_FOP_GETACTIVELK] = "GETACTIVELK", }; /* THIS */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 691492e10a5..86c3b2b81d9 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -501,6 +501,12 @@ struct gf_flock { gf_lkowner_t l_owner; }; +typedef struct lock_migration_info { + struct list_head list; + struct gf_flock flock; + char *client_uid; +} lock_migration_info_t; + #define GF_MUST_CHECK __attribute__((warn_unused_result)) /* * Some macros (e.g. ALLOC_OR_GOTO) set variables in function scope, but the @@ -540,4 +546,7 @@ glusterfs_graph_t *glusterfs_graph_new (); int glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph, glusterfs_graph_t *newgraph); +void +gf_free_mig_locks (lock_migration_info_t *locks); + #endif /* _GLUSTERFS_H */ diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 63b9973a2d1..4fa23002e24 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -3062,3 +3062,82 @@ syncop_fxattrop (xlator_t *subvol, fd_t *fd, gf_xattrop_flags_t flags, return args.op_ret; } + +int32_t +syncop_getactivelk_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + lock_migration_info_t *locklist, dict_t *xdata) +{ + struct syncargs *args = NULL; + lock_migration_info_t *tmp = NULL; + lock_migration_info_t *entry = NULL; + + args = cookie; + + INIT_LIST_HEAD (&args->locklist.list); + + args->op_ret = op_ret; + args->op_errno = op_errno; + if (xdata) + args->xdata = dict_ref (xdata); + + if (op_ret > 0) { + list_for_each_entry (tmp, &locklist->list, list) { + entry = GF_CALLOC (1, sizeof (lock_migration_info_t), + gf_common_mt_char); + + if (!entry) { + gf_msg (THIS->name, GF_LOG_ERROR, 0, 0, + "lock mem allocation failed"); + gf_free_mig_locks (&args->locklist); + + break; + } + + INIT_LIST_HEAD (&entry->list); + + entry->flock = tmp->flock; + + entry->client_uid = gf_strdup (tmp->client_uid); + + list_add_tail (&entry->list, &args->locklist.list); + + } + } + + __wake (args); + + return 0; + +} + +int +syncop_getactivelk (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_getactivelk_cbk, + subvol->fops->getactivelk, + loc, xdata_in); + + if (locklist) + list_splice_init (&args.locklist.list, &locklist->list); + else + gf_free_mig_locks (&args.locklist) ; + + 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 2301e6cefd0..2f7237bcfb2 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -173,6 +173,8 @@ struct syncargs { gf_dirent_t entries; off_t offset; + + lock_migration_info_t locklist; }; struct syncopctx { @@ -522,4 +524,7 @@ int syncop_seek (xlator_t *subvol, fd_t *fd, off_t offset, gf_seek_what_t what, dict_t *xdata_in, off_t *off); +int +syncop_getactivelk (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 3f0ff7f929c..e762ac2afaa 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -82,6 +82,7 @@ fill_defaults (xlator_t *xl) SET_DEFAULT_FOP (ipc); SET_DEFAULT_FOP (seek); SET_DEFAULT_FOP (lease); + SET_DEFAULT_FOP (getactivelk); SET_DEFAULT_FOP (getspec); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 052dd978a63..bb039c0a527 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -457,6 +457,12 @@ typedef int32_t (*fop_compound_cbk_t) (call_frame_t *frame, int32_t op_ret, int32_t op_errno, void *data, dict_t *xdata); +typedef int32_t (*fop_getactivelk_cbk_t) (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, + lock_migration_info_t *locklist, + dict_t *xdata); + typedef int32_t (*fop_lookup_t) (call_frame_t *frame, xlator_t *this, loc_t *loc, @@ -708,6 +714,10 @@ typedef int32_t (*fop_lease_t) (call_frame_t *frame, xlator_t *this, loc_t *loc, typedef int32_t (*fop_compound_t) (call_frame_t *frame, xlator_t *this, void *args, dict_t *xdata); + +typedef int32_t (*fop_getactivelk_t) (call_frame_t *frame, xlator_t *this, + loc_t *loc, dict_t *xdata); + struct xlator_fops { fop_lookup_t lookup; fop_stat_t stat; @@ -758,6 +768,7 @@ struct xlator_fops { fop_seek_t seek; fop_lease_t lease; fop_compound_t compound; + fop_getactivelk_t getactivelk; /* these entries are used for a typechecking hack in STACK_WIND _only_ */ fop_lookup_cbk_t lookup_cbk; @@ -809,6 +820,7 @@ struct xlator_fops { fop_seek_cbk_t seek_cbk; fop_lease_cbk_t lease_cbk; fop_compound_cbk_t compound_cbk; + fop_getactivelk_cbk_t getactivelk_cbk; }; typedef int32_t (*cbk_forget_t) (xlator_t *this, |