summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.h
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2014-09-10 23:22:03 +0530
committerNiels de Vos <ndevos@redhat.com>2014-10-01 03:33:51 -0700
commit53010998dc6c7bb5268cd1c124887ce9d9a3f032 (patch)
tree4600f6fb4ba573c29b7e510ef83bb4f9cb74c504 /xlators/cluster/dht/src/dht-common.h
parentbee0c740b54669a8be11acea405d021bb50d3c54 (diff)
cluster/dht: introduce dht locking api.
Change-Id: I41389ba91951d3e63e617aa32cd0bee848261c72 BUG: 1140348 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/8521 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> (cherry picked from commit a1fe3d72e373bf0deaed152842d12d94bb9129dc) Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/8722 Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.h')
-rw-r--r--xlators/cluster/dht/src/dht-common.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index b61600d88ea..50cc0801d66 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -109,6 +109,15 @@ struct dht_skip_linkto_unlink {
uuid_t hashed_gfid;
};
+typedef struct {
+ xlator_t *xl;
+ loc_t loc; /* contains/points to inode to lock on. */
+ short type; /* read/write lock. */
+ char *domain; /* Only locks within a single domain
+ * contend with each other
+ */
+ gf_boolean_t locked;
+} dht_lock_t;
struct dht_local {
int call_cnt;
@@ -201,6 +210,15 @@ struct dht_local {
struct dht_skip_linkto_unlink skip_unlink;
+ struct {
+ fop_inodelk_cbk_t inodelk_cbk;
+ dht_lock_t **locks;
+ int lk_count;
+
+ /* whether locking failed on _any_ of the "locks" above */
+ int op_ret;
+ int op_errno;
+ } lock;
};
typedef struct dht_local dht_local_t;
@@ -317,6 +335,8 @@ struct dht_conf {
char *xattr_name;
char *link_xattr_name;
char *wild_xattr_name;
+
+ struct mem_pool *lock_pool;
};
typedef struct dht_conf dht_conf_t;
@@ -806,4 +826,40 @@ dht_lookup_everywhere_done (call_frame_t *frame, xlator_t *this);
int
dht_fill_dict_to_avoid_unlink_of_migrating_file (dict_t *dict);
+
+
+/* Acquire non-blocking inodelk on a list of xlators.
+ *
+ * @lk_array: array of lock requests lock on.
+ *
+ * @lk_count: number of locks in @lk_array
+ *
+ * @inodelk_cbk: will be called after inodelk replies are received
+ *
+ * @retval: -1 if stack_winding inodelk fails. 0 otherwise.
+ * inodelk_cbk is called with appropriate error on errors.
+ * On failure to acquire lock on all members of list, successful
+ * locks are unlocked before invoking cbk.
+ */
+
+int
+dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array,
+ int lk_count, fop_inodelk_cbk_t inodelk_cbk);
+
+/* same as dht_nonblocking_inodelk, but issues sequential blocking locks on
+ * @lk_array directly. locks are issued on some order which remains same
+ * for a list of xlators (irrespective of order of xlators within list).
+ */
+int
+dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array,
+ int lk_count, fop_inodelk_cbk_t inodelk_cbk);
+
+int32_t
+dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count,
+ fop_inodelk_cbk_t inodelk_cbk);
+
+dht_lock_t *
+dht_lock_new (xlator_t *this, xlator_t *xl, loc_t *loc, short type,
+ const char *domain);
+
#endif/* _DHT_H */