summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2015-07-09 15:06:49 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-04-21 03:01:38 -0700
commit63918789fbb5f3a2d381e0f960f2dcbaf1b7ff72 (patch)
tree885377e1dcb957a2215c73ef7e908f726e2109ae /libglusterfs/src
parente964dd74fa805124005a5b2cb031ecbc34198b9a (diff)
core: add lease fop
Change-Id: Ia27d66b1061b0377857827515590eb89b18515c9 BUG: 1319992 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/11596 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/call-stub.c46
-rw-r--r--libglusterfs/src/call-stub.h10
-rw-r--r--libglusterfs/src/common-utils.c56
-rw-r--r--libglusterfs/src/common-utils.h9
-rw-r--r--libglusterfs/src/default-args.c26
-rw-r--r--libglusterfs/src/default-args.h9
-rw-r--r--libglusterfs/src/defaults.h20
-rwxr-xr-xlibglusterfs/src/generator.py8
-rw-r--r--libglusterfs/src/globals.c44
-rw-r--r--libglusterfs/src/globals.h2
-rw-r--r--libglusterfs/src/glusterfs.h26
-rw-r--r--libglusterfs/src/libglusterfs-messages.h10
-rw-r--r--libglusterfs/src/syncop.c49
-rw-r--r--libglusterfs/src/syncop.h4
-rw-r--r--libglusterfs/src/upcall-utils.h1
-rw-r--r--libglusterfs/src/xlator.c1
-rw-r--r--libglusterfs/src/xlator.h10
17 files changed, 330 insertions, 1 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 3f64cbc7d3b..42ebca6b3cc 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -1803,6 +1803,43 @@ out:
}
+call_stub_t *
+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 *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+
+ stub = stub_new (frame, 0, GF_FOP_LEASE);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn_cbk.lease = fn;
+ args_lease_cbk_store (&stub->args_cbk, op_ret, op_errno, lease, xdata);
+out:
+ return stub;
+}
+
+call_stub_t *
+fop_lease_stub (call_frame_t *frame, fop_lease_t fn,
+ loc_t *loc, struct gf_lease *lease, dict_t *xdata)
+{
+ call_stub_t *stub = NULL;
+
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fn, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", lease, out);
+
+ stub = stub_new (frame, 1, GF_FOP_LEASE);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
+ stub->fn.lease = fn;
+ args_lease_store (&stub->args, loc, lease, xdata);
+out:
+ return stub;
+
+}
call_stub_t *
fop_seek_cbk_stub (call_frame_t *frame, fop_seek_cbk_t fn,
@@ -2085,6 +2122,11 @@ call_resume_wind (call_stub_t *stub)
stub->args.fd, stub->args.offset,
stub->args.what, stub->args.xdata);
break;
+ case GF_FOP_LEASE:
+ stub->fn.lease (stub->frame, stub->frame->this,
+ &stub->args.loc, &stub->args.lease,
+ stub->args.xdata);
+ break;
default:
gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL,
@@ -2299,6 +2341,10 @@ call_resume_unwind (call_stub_t *stub)
STUB_UNWIND (stub, seek, stub->args_cbk.offset,
stub->args_cbk.xdata);
break;
+ case GF_FOP_LEASE:
+ STUB_UNWIND (stub, lease, &stub->args_cbk.lease,
+ stub->args_cbk.xdata);
+ break;
default:
gf_msg_callingfn ("call-stub", GF_LOG_ERROR, EINVAL,
diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h
index cdc96ffcc9f..fa0ec69cb64 100644
--- a/libglusterfs/src/call-stub.h
+++ b/libglusterfs/src/call-stub.h
@@ -74,6 +74,7 @@ typedef struct _call_stub {
fop_zerofill_t zerofill;
fop_ipc_t ipc;
fop_seek_t seek;
+ fop_lease_t lease;
} fn;
union {
@@ -123,6 +124,7 @@ typedef struct _call_stub {
fop_zerofill_cbk_t zerofill;
fop_ipc_cbk_t ipc;
fop_seek_cbk_t seek;
+ fop_lease_cbk_t lease;
} fn_cbk;
default_args_t args;
@@ -729,6 +731,14 @@ fop_seek_cbk_stub (call_frame_t *frame, fop_seek_cbk_t fn,
int32_t op_ret, int32_t op_errno, off_t offset,
dict_t *xdata);
+call_stub_t *
+fop_lease_stub (call_frame_t *frame, fop_lease_t fn, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata);
+
+call_stub_t *
+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);
void call_resume (call_stub_t *stub);
void call_stub_destroy (call_stub_t *stub);
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index ac8babcc8ad..ef48aca056b 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -2547,6 +2547,61 @@ lkowner_utoa_r (gf_lkowner_t *lkowner, char *dst, int len)
return dst;
}
+gf_boolean_t
+is_valid_lease_id (const char *lease_id)
+{
+ int i = 0;
+ gf_boolean_t valid = _gf_false;
+
+ for (i = 0; i < LEASE_ID_SIZE; i++) {
+ if (lease_id[i] != 0) {
+ valid = _gf_true;
+ goto out;
+ }
+ }
+out:
+ return valid;
+}
+
+/* Lease_id can be a either in printable or non printable binary
+ * format. This function can be used to print any lease_id.
+ *
+ * This function returns a pointer to a buf, containing the ascii
+ * representation of the value in lease_id, in the following format:
+ * 4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum
+ *
+ * Eg: If lease_id = "lid1-clnt1" the printable string would be:
+ * 6c69-6431-2d63-6c6e-7431-0000-0000-0000
+ *
+ * Note: The pointer returned should not be stored for further use, as any
+ * subsequent call to this function will override the same buffer.
+ */
+char *
+leaseid_utoa (const char *lease_id)
+{
+ char *buf = NULL;
+ int i = 0;
+ int j = 0;
+
+ buf = glusterfs_leaseid_buf_get ();
+ if (!buf)
+ goto out;
+
+ for (i = 0; i < LEASE_ID_SIZE; i++) {
+ if (i && !(i % 2)) {
+ buf[j] = '-';
+ j++;
+ }
+ sprintf (&buf[j], "%02hhx", lease_id[i]);
+ j += 2;
+ if (j == GF_LEASE_ID_BUF_SIZE)
+ break;
+ }
+ buf[GF_LEASE_ID_BUF_SIZE - 1] = '\0';
+out:
+ return buf;
+}
+
void* gf_array_elem (void *a, int index, size_t elem_size)
{
uint8_t* ptr = a;
@@ -4199,6 +4254,7 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)
case GF_FOP_REMOVEXATTR:
case GF_FOP_FREMOVEXATTR:
case GF_FOP_IPC:
+ case GF_FOP_LEASE:
return "NORMAL";
case GF_FOP_READ:
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index bd1a491f1a9..acd5cb5303e 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -100,6 +100,13 @@ void trap (void);
#define GF_XATTR_SHARD_FILE_SIZE "trusted.glusterfs.shard.file-size"
#define SHARD_ROOT_GFID "be318638-e8a0-4c6d-977d-7a937aa84806"
+/* Lease: buffer length for stringified lease id
+ * Format: 4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum-4hexnum
+ * Eg:6c69-6431-2d63-6c6e-7431-0000-0000-0000
+ */
+#define GF_LEASE_ID_BUF_SIZE ((LEASE_ID_SIZE * 2) + \
+ (LEASE_ID_SIZE / 2))
+
enum _gf_boolean
{
_gf_false = 0,
@@ -719,6 +726,8 @@ char *uuid_utoa (uuid_t uuid);
char *uuid_utoa_r (uuid_t uuid, char *dst);
char *lkowner_utoa (gf_lkowner_t *lkowner);
char *lkowner_utoa_r (gf_lkowner_t *lkowner, char *dst, int len);
+char *leaseid_utoa (const char *lease_id);
+gf_boolean_t is_valid_lease_id (const char *lease_id);
void gf_array_insertionsort (void *a, int l, int r, size_t elem_size,
gf_cmp cmp);
diff --git a/libglusterfs/src/default-args.c b/libglusterfs/src/default-args.c
index cc9da678dda..29c8aeae9fd 100644
--- a/libglusterfs/src/default-args.c
+++ b/libglusterfs/src/default-args.c
@@ -1432,6 +1432,32 @@ args_seek_cbk_store (default_args_cbk_t *args, int32_t op_ret,
}
void
+args_lease_store (default_args_t *args, loc_t *loc, struct gf_lease *lease,
+ dict_t *xdata)
+{
+ loc_copy (&args->loc, loc);
+ args->lease = *lease;
+
+ if (xdata)
+ args->xdata = dict_ref (xdata);
+
+ return;
+}
+
+void
+args_lease_cbk_store (default_args_cbk_t *args,
+ int32_t op_ret, int32_t op_errno,
+ struct gf_lease *lease, dict_t *xdata)
+{
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+ if (op_ret == 0)
+ args->lease = *lease;
+ if (xdata)
+ args->xdata = dict_ref (xdata);
+}
+
+void
args_cbk_wipe (default_args_cbk_t *args_cbk)
{
if (!args_cbk)
diff --git a/libglusterfs/src/default-args.h b/libglusterfs/src/default-args.h
index 8b32a012a1d..a6ed0e484da 100644
--- a/libglusterfs/src/default-args.h
+++ b/libglusterfs/src/default-args.h
@@ -269,6 +269,11 @@ args_seek_cbk_store (default_args_cbk_t *args, int32_t op_ret,
int32_t op_errno, off_t offset, dict_t *xdata);
void
+args_lease_cbk_store (default_args_cbk_t *args,
+ int32_t op_ret, int32_t op_errno,
+ struct gf_lease *lease, dict_t *xdata);
+
+void
args_cbk_wipe (default_args_cbk_t *args_cbk);
int
@@ -459,4 +464,8 @@ int
args_seek_store (default_args_t *args, fd_t *fd,
off_t offset, gf_seek_what_t what, dict_t *xdata);
+void
+args_lease_store (default_args_t *args, loc_t *loc, struct gf_lease *lease,
+ dict_t *xdata);
+
#endif /* _DEFAULT_ARGS_H */
diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h
index 16790eb6af6..148dc84b1c5 100644
--- a/libglusterfs/src/defaults.h
+++ b/libglusterfs/src/defaults.h
@@ -43,6 +43,7 @@ typedef struct {
off_t offset; /* seek hole/data */
int valid; /* If the response is valid or not. For call-stub it is
always valid irrespective of this */
+ struct gf_lease lease;
} default_args_cbk_t;
typedef struct {
@@ -74,6 +75,7 @@ typedef struct {
struct iatt stat;
gf_seek_what_t what;
dict_t *xdata;
+ struct gf_lease lease;
} default_args_t;
int32_t default_notify (xlator_t *this,
@@ -323,6 +325,9 @@ int32_t default_ipc (call_frame_t *frame, xlator_t *this, int32_t op,
int32_t default_seek (call_frame_t *frame, xlator_t *this, fd_t *fd,
off_t offset, gf_seek_what_t what, dict_t *xdata);
+int32_t default_lease (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata);
+
/* Resume */
int32_t default_getspec_resume (call_frame_t *frame,
@@ -558,6 +563,8 @@ int32_t default_ipc_resume (call_frame_t *frame, xlator_t *this,
int32_t default_seek_resume (call_frame_t *frame, xlator_t *this, fd_t *fd,
off_t offset, gf_seek_what_t what, dict_t *xdata);
+int32_t default_lease_resume (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata);
/* _cbk_resume */
@@ -830,6 +837,11 @@ default_getspec_cbk_resume (call_frame_t * frame, void *cookie,
xlator_t * this, int32_t op_ret, int32_t op_errno,
char *spec_data);
+int32_t
+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);
+
/* _CBK */
int32_t
default_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -1063,6 +1075,11 @@ default_getspec_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, char *spec_data);
int32_t
+default_lease_cbk (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_lookup_failure_cbk (call_frame_t *frame, int32_t op_errno);
int32_t
@@ -1203,5 +1220,8 @@ int32_t
default_seek_failure_cbk (call_frame_t *frame, int32_t op_errno);
int32_t
+default_lease_failure_cbk (call_frame_t *frame, int32_t op_errno);
+
+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 8b854b2e7f7..15e31e3aa73 100755
--- a/libglusterfs/src/generator.py
+++ b/libglusterfs/src/generator.py
@@ -534,6 +534,14 @@ ops['getspec'] = (
('cbk-arg', 'spec_data', 'char *'),
)
+ops['lease'] = (
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'lease', 'struct gf_lease *'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'lease', 'struct gf_lease *'),
+ ('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 435921d64cc..0645ffadb10 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -69,6 +69,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = {
[GF_FOP_ZEROFILL] = "ZEROFILL",
[GF_FOP_IPC] = "IPC",
[GF_FOP_SEEK] = "SEEK",
+ [GF_FOP_LEASE] = "LEASE",
};
/* THIS */
@@ -84,6 +85,7 @@ static pthread_key_t uuid_buf_key;
static char global_uuid_buf[GF_UUID_BUF_SIZE];
static pthread_key_t lkowner_buf_key;
static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE];
+static pthread_key_t leaseid_buf_key;
static int gf_global_mem_acct_enable = 1;
static pthread_once_t globals_inited = PTHREAD_ONCE_INIT;
@@ -335,6 +337,41 @@ glusterfs_lkowner_buf_get ()
return buf;
}
+/* Leaseid buffer */
+void
+glusterfs_leaseid_buf_destroy (void *ptr)
+{
+ FREE (ptr);
+}
+
+int
+glusterfs_leaseid_buf_init ()
+{
+ int ret = 0;
+
+ ret = pthread_key_create (&leaseid_buf_key,
+ glusterfs_leaseid_buf_destroy);
+ return ret;
+}
+
+char *
+glusterfs_leaseid_buf_get ()
+{
+ char *buf = NULL;
+ int ret = 0;
+
+ buf = pthread_getspecific (leaseid_buf_key);
+ if (!buf) {
+ buf = CALLOC (1, GF_LEASE_ID_BUF_SIZE);
+ ret = pthread_setspecific (leaseid_buf_key, (void *) buf);
+ if (ret) {
+ FREE (buf);
+ buf = NULL;
+ }
+ }
+ return buf;
+}
+
static void
gf_globals_init_once ()
{
@@ -361,6 +398,13 @@ gf_globals_init_once ()
goto out;
}
+ ret = glusterfs_leaseid_buf_init ();
+ if (ret) {
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_LEASEID_BUF_INIT_FAILED,
+ "ERROR: glusterfs leaseid buffer init failed");
+ goto out;
+ }
+
ret = synctask_init ();
if (ret) {
gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCTASK_INIT_FAILED,
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
index 8319c2a7333..e1f96a75626 100644
--- a/libglusterfs/src/globals.h
+++ b/libglusterfs/src/globals.h
@@ -92,6 +92,8 @@ int synctask_set (void *);
char *glusterfs_uuid_buf_get ();
/* lkowner_buf */
char *glusterfs_lkowner_buf_get ();
+/* leaseid buf */
+char *glusterfs_leaseid_buf_get ();
/* init */
int glusterfs_globals_init (glusterfs_ctx_t *ctx);
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 3ffdeac1808..bcd84952f78 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -321,6 +321,7 @@ typedef enum {
GF_FOP_ZEROFILL,
GF_FOP_IPC,
GF_FOP_SEEK,
+ GF_FOP_LEASE,
GF_FOP_MAXVALUE,
} glusterfs_fop_t;
@@ -358,6 +359,23 @@ typedef enum {
GF_LK_EOL,
} glusterfs_lk_types_t;
+/* Lease Types */
+enum gf_lease_types {
+ NONE = 0,
+ GF_RD_LEASE = 1,
+ GF_RW_LEASE = 2,
+ GF_LEASE_MAX_TYPE,
+};
+typedef enum gf_lease_types gf_lease_types_t;
+
+/* Lease cmds */
+enum gf_lease_cmds {
+ GF_GET_LEASE = 1,
+ GF_SET_LEASE = 2,
+ GF_UNLK_LEASE = 3,
+};
+typedef enum gf_lease_cmds gf_lease_cmds_t;
+
typedef enum {
F_RESLK_LCK = 200,
F_RESLK_LCKW,
@@ -640,6 +658,14 @@ typedef enum {
GF_EVENT_MAXVAL,
} glusterfs_event_t;
+#define LEASE_ID_SIZE 16 /* 128bits */
+struct gf_lease {
+ gf_lease_cmds_t cmd;
+ gf_lease_types_t lease_type;
+ char lease_id[LEASE_ID_SIZE];
+ unsigned int lease_flags;
+};
+
struct gf_flock {
short l_type;
short l_whence;
diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h
index 68754e6b869..c0bcabac798 100644
--- a/libglusterfs/src/libglusterfs-messages.h
+++ b/libglusterfs/src/libglusterfs-messages.h
@@ -36,7 +36,7 @@
*/
#define GLFS_LG_BASE GLFS_MSGID_COMP_LIBGLUSTERFS
-#define GLFS_LG_NUM_MESSAGES 204
+#define GLFS_LG_NUM_MESSAGES 205
#define GLFS_LG_MSGID_END (GLFS_LG_BASE + GLFS_LG_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_lg GLFS_LG_BASE, "Invalid: Start of messages"
@@ -1746,6 +1746,14 @@
* @recommendedaction
*
*/
+#define LG_MSG_LEASEID_BUF_INIT_FAILED (GLFS_LG_BASE + 205)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
/*------------*/
#define glfs_msg_end_lg GLFS_LG_MSGID_END, "Invalid: End of messages"
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 3544562e44e..c820be8e151 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -2874,6 +2874,55 @@ syncop_seek (xlator_t *subvol, fd_t *fd, off_t offset, gf_seek_what_t what,
}
int
+syncop_lease_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, struct gf_lease *lease, 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);
+ if (lease)
+ args->lease = *lease;
+
+ __wake (args);
+
+ return 0;
+}
+
+int
+syncop_lease (xlator_t *subvol, loc_t *loc, struct gf_lease *lease,
+ dict_t *xdata_in, dict_t **xdata_out)
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_lease_cbk, subvol->fops->lease,
+ loc, lease, xdata_in);
+
+ *lease = args.lease;
+
+ if (args.xdata) {
+ if (xdata_out) {
+ /*
+ * We're passing this reference to the caller, along
+ * with the pointer itself. That means they're
+ * responsible for calling dict_unref at some point.
+ */
+ *xdata_out = args.xdata;
+ } else {
+ dict_unref(args.xdata);
+ }
+ }
+
+ if (args.op_ret < 0)
+ return -args.op_errno;
+ return args.op_ret;
+}
+
+int
syncop_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, struct gf_flock *flock,
dict_t *xdata)
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 1bad3506405..2301e6cefd0 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -155,6 +155,7 @@ struct syncargs {
char *buffer;
dict_t *xdata;
struct gf_flock flock;
+ struct gf_lease lease;
/* some more _cbk needs */
uuid_t uuid;
@@ -505,6 +506,9 @@ int syncop_inodelk (xlator_t *subvol, const char *volume, loc_t *loc,
int32_t cmd, struct gf_flock *lock, dict_t *xdata_in,
dict_t **xdata_out);
+int syncop_lease (xlator_t *subvol, loc_t *loc, struct gf_lease *lease,
+ dict_t *xdata_in, dict_t **xdata_out);
+
int syncop_ipc (xlator_t *subvol, int op, dict_t *xdata_in, dict_t **xdata_out);
int syncop_xattrop (xlator_t *subvol, loc_t *loc, gf_xattrop_flags_t flags,
diff --git a/libglusterfs/src/upcall-utils.h b/libglusterfs/src/upcall-utils.h
index 001566fd85e..e097a060670 100644
--- a/libglusterfs/src/upcall-utils.h
+++ b/libglusterfs/src/upcall-utils.h
@@ -18,6 +18,7 @@
typedef enum {
GF_UPCALL_EVENT_NULL,
GF_UPCALL_CACHE_INVALIDATION,
+ GF_UPCALL_RECALL_LEASE,
} gf_upcall_event_t;
struct gf_upcall {
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index c060cedfddb..3f0ff7f929c 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -81,6 +81,7 @@ fill_defaults (xlator_t *xl)
SET_DEFAULT_FOP (zerofill);
SET_DEFAULT_FOP (ipc);
SET_DEFAULT_FOP (seek);
+ SET_DEFAULT_FOP (lease);
SET_DEFAULT_FOP (getspec);
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index bc539254f29..84f48edba2c 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -448,6 +448,11 @@ typedef int32_t (*fop_seek_cbk_t) (call_frame_t *frame, void *cookie,
int32_t op_errno, off_t offset,
dict_t *xdata);
+typedef int32_t (*fop_lease_cbk_t) (call_frame_t *frame, void *cookie,
+ xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct gf_lease *lease,
+ dict_t *xdata);
+
typedef int32_t (*fop_lookup_t) (call_frame_t *frame,
xlator_t *this,
loc_t *loc,
@@ -694,6 +699,9 @@ typedef int32_t (*fop_seek_t) (call_frame_t *frame, xlator_t *this, fd_t *fd,
off_t offset, gf_seek_what_t what,
dict_t *xdata);
+typedef int32_t (*fop_lease_t) (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata);
+
struct xlator_fops {
fop_lookup_t lookup;
fop_stat_t stat;
@@ -742,6 +750,7 @@ struct xlator_fops {
fop_zerofill_t zerofill;
fop_ipc_t ipc;
fop_seek_t seek;
+ fop_lease_t lease;
/* these entries are used for a typechecking hack in STACK_WIND _only_ */
fop_lookup_cbk_t lookup_cbk;
@@ -791,6 +800,7 @@ struct xlator_fops {
fop_zerofill_cbk_t zerofill_cbk;
fop_ipc_cbk_t ipc_cbk;
fop_seek_cbk_t seek_cbk;
+ fop_lease_cbk_t lease_cbk;
};
typedef int32_t (*cbk_forget_t) (xlator_t *this,