diff options
author | Krishnan Parthasarathi <kp@gluster.com> | 2011-09-21 11:53:45 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-09-23 06:11:32 -0700 |
commit | 1fdcbb61872b0a849490d1f0de4fdb545e2865aa (patch) | |
tree | 97c9fa63e621594bbd101d5715189435a65c713e | |
parent | 95876fa0ee03b0ee4cd31fa9874b4de596ae70a4 (diff) |
rpc: No timeouts for lock fops.
As of today, all fops bail out after 30 mins by default. This is not desirable
with lock fops since it could be 'rightfully blocked' for a really long time.
But the client would assume that the lock fop has 'expired' after 30 mins and
clean up its references to the locks. Later when the locks xlator decides to
grant it, we are left with an orphan (stale) lock .
This fix exempts lock fops from timeouts. Only on network disruptions both
client and server decide to 'clean up' the locks held.
Change-Id: If1d74ba21113650b976728e9b764c551a0a49e59
BUG: 3617
Reviewed-on: http://review.gluster.com/478
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 46 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 5 |
2 files changed, 48 insertions, 3 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index b2ea58004..f01ece0cd 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -69,6 +69,21 @@ __saved_frames_get_timedout (struct saved_frames *frames, uint32_t timeout, return bailout_frame; } +static int +_is_lock_fop (struct saved_frame *sframe) +{ + int fop = 0; + + if (SFRAME_GET_PROGNUM (sframe) == GLUSTER3_1_FOP_PROGRAM && + SFRAME_GET_PROGVER (sframe) == GLUSTER3_1_FOP_VERSION) + fop = SFRAME_GET_PROCNUM (sframe); + + return ((fop == GFS3_OP_LK) || + (fop == GFS3_OP_INODELK) || + (fop == GFS3_OP_FINODELK) || + (fop == GFS3_OP_ENTRYLK) || + (fop == GFS3_OP_FENTRYLK)); +} struct saved_frame * __saved_frames_put (struct saved_frames *frames, void *frame, @@ -90,7 +105,11 @@ __saved_frames_put (struct saved_frames *frames, void *frame, saved_frame->rpcreq = rpcreq; gettimeofday (&saved_frame->saved_at, NULL); - list_add_tail (&saved_frame->list, &frames->sf.list); + if (_is_lock_fop (saved_frame)) + list_add_tail (&saved_frame->list, &frames->lk_sf.list); + else + list_add_tail (&saved_frame->list, &frames->sf.list); + frames->count++; out: @@ -254,6 +273,7 @@ saved_frames_new (void) } INIT_LIST_HEAD (&saved_frames->sf.list); + INIT_LIST_HEAD (&saved_frames->lk_sf.list); return saved_frames; } @@ -275,7 +295,15 @@ __saved_frame_copy (struct saved_frames *frames, int64_t callid, if (tmp->rpcreq->xid == callid) { *saved_frame = *tmp; ret = 0; - break; + goto out; + } + } + + list_for_each_entry (tmp, &frames->lk_sf.list, list) { + if (tmp->rpcreq->xid == callid) { + *saved_frame = *tmp; + ret = 0; + goto out; } } @@ -295,10 +323,20 @@ __saved_frame_get (struct saved_frames *frames, int64_t callid) list_del_init (&tmp->list); frames->count--; saved_frame = tmp; - break; + goto out; + } + } + + list_for_each_entry (tmp, &frames->lk_sf.list, list) { + if (tmp->rpcreq->xid == callid) { + list_del_init (&tmp->list); + frames->count--; + saved_frame = tmp; + goto out; } } +out: if (saved_frame) { THIS = saved_frame->capital_this; } @@ -318,6 +356,8 @@ saved_frames_unwind (struct saved_frames *saved_frames) struct iovec iov = {0,}; + list_splice_init (&saved_frames->lk_sf.list, &saved_frames->sf.list); + list_for_each_entry_safe (trav, tmp, &saved_frames->sf.list, list) { frame_sent_tm = localtime (&trav->saved_at.tv_sec); strftime (timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index c2bc4c0b6..e3b2ec3f1 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -34,6 +34,10 @@ typedef enum { #define AUTH_GLUSTERFS 5 #define RPC_CLNT_MAX_AUTH_BYTES 1024 +#define SFRAME_GET_PROGNUM(sframe) (sframe->rpcreq->prog->prognum) +#define SFRAME_GET_PROGVER(sframe) (sframe->rpcreq->prog->progver) +#define SFRAME_GET_PROCNUM(sframe) (sframe->rpcreq->procnum) + struct xptr_clnt; struct rpc_req; struct rpc_clnt; @@ -66,6 +70,7 @@ struct saved_frame { struct saved_frames { int64_t count; struct saved_frame sf; + struct saved_frame lk_sf; }; |