diff options
author | Vikas Gorur <vikas@zresearch.com> | 2009-03-12 16:21:51 +0530 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-03-12 16:29:45 +0530 |
commit | 7af8d8edbd8554235348e0f54348edf222c0b46e (patch) | |
tree | 21333449bf86e3481e8bc4197d17f69472398ef9 /xlators/protocol | |
parent | 31c817836c9c56eca1441b3b6f8b83db41c67f94 (diff) |
Add extra 'volume' parameter to inodelk/entrylk calls
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client-protocol.c | 46 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 19 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 4 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-protocol.c | 54 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-protocol.h | 2 |
5 files changed, 91 insertions, 34 deletions
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c index 58eba01ed0b..1d3fbfec783 100644 --- a/xlators/protocol/client/src/client-protocol.c +++ b/xlators/protocol/client/src/client-protocol.c @@ -3253,6 +3253,7 @@ unwind: int32_t client_inodelk (call_frame_t *frame, xlator_t *this, + const char *volume, loc_t *loc, int32_t cmd, struct flock *flock) @@ -3265,6 +3266,7 @@ client_inodelk (call_frame_t *frame, int32_t gf_type = 0; ino_t ino = 0; size_t pathlen = 0; + size_t vollen = 0; client_conf_t *conf = this->private; if (conf->child) { @@ -3273,12 +3275,14 @@ client_inodelk (call_frame_t *frame, default_inodelk_cbk, conf->child, conf->child->fops->inodelk, - loc, cmd, flock); + volume, loc, cmd, flock); return 0; } pathlen = STRLEN_0(loc->path); + vollen = STRLEN_0(volume); + ino = this_ino_get (loc, this, GF_CLIENT_INODE_SELF); if (cmd == F_GETLK || cmd == F_GETLK64) @@ -3305,13 +3309,14 @@ client_inodelk (call_frame_t *frame, break; } - hdrlen = gf_hdr_len (req, pathlen); - hdr = gf_hdr_new (req, pathlen); + hdrlen = gf_hdr_len (req, pathlen + vollen); + hdr = gf_hdr_new (req, pathlen + vollen); GF_VALIDATE_OR_GOTO(this->name, hdr, unwind); req = gf_param (hdr); strcpy (req->path, loc->path); + strcpy (req->path + pathlen, volume); req->ino = hton64 (ino); @@ -3349,6 +3354,7 @@ unwind: int32_t client_finodelk (call_frame_t *frame, xlator_t *this, + const char *volume, fd_t *fd, int32_t cmd, struct flock *flock) @@ -3357,6 +3363,7 @@ client_finodelk (call_frame_t *frame, gf_hdr_common_t *hdr = NULL; gf_fop_finodelk_req_t *req = NULL; size_t hdrlen = 0; + size_t vollen = 0; int32_t gf_cmd = 0; int32_t gf_type = 0; int64_t remote_fd = -1; @@ -3368,11 +3375,13 @@ client_finodelk (call_frame_t *frame, default_finodelk_cbk, conf->child, conf->child->fops->finodelk, - fd, cmd, flock); + volume, fd, cmd, flock); return 0; } + vollen = STRLEN_0(volume); + ret = this_fd_get (fd, this, &remote_fd); if (ret == -1) { gf_log (this->name, GF_LOG_DEBUG, @@ -3406,12 +3415,14 @@ client_finodelk (call_frame_t *frame, break; } - hdrlen = gf_hdr_len (req, 0); - hdr = gf_hdr_new (req, 0); + hdrlen = gf_hdr_len (req, vollen); + hdr = gf_hdr_new (req, vollen); GF_VALIDATE_OR_GOTO(this->name, hdr, unwind); req = gf_param (hdr); + strcpy (req->volume, volume); + req->fd = hton64 (remote_fd); req->cmd = hton32 (gf_cmd); @@ -3436,6 +3447,7 @@ unwind: int32_t client_entrylk (call_frame_t *frame, xlator_t *this, + const char *volume, loc_t *loc, const char *name, entrylk_cmd cmd, @@ -3444,6 +3456,7 @@ client_entrylk (call_frame_t *frame, gf_hdr_common_t *hdr = NULL; gf_fop_entrylk_req_t *req = NULL; size_t pathlen = 0; + size_t vollen = 0; size_t hdrlen = -1; int ret = -1; ino_t ino = 0; @@ -3455,19 +3468,21 @@ client_entrylk (call_frame_t *frame, STACK_WIND (frame, default_entrylk_cbk, conf->child, conf->child->fops->entrylk, - loc, name, cmd, type); + volume, loc, name, cmd, type); return 0; } pathlen = STRLEN_0(loc->path); + vollen = STRLEN_0(volume); + if (name) namelen = STRLEN_0(name); ino = this_ino_get (loc, this, GF_CLIENT_INODE_SELF); - hdrlen = gf_hdr_len (req, pathlen + namelen); - hdr = gf_hdr_new (req, pathlen + namelen); + hdrlen = gf_hdr_len (req, pathlen + vollen + namelen); + hdr = gf_hdr_new (req, pathlen + vollen + namelen); GF_VALIDATE_OR_GOTO(this->name, hdr, unwind); req = gf_param (hdr); @@ -3478,6 +3493,7 @@ client_entrylk (call_frame_t *frame, strcpy (req->path, loc->path); if (name) strcpy (req->name + pathlen, name); + strcpy (req->volume + pathlen + namelen, volume); req->cmd = hton32 (cmd); req->type = hton32 (type); @@ -3501,6 +3517,7 @@ unwind: int32_t client_fentrylk (call_frame_t *frame, xlator_t *this, + const char *volume, fd_t *fd, const char *name, entrylk_cmd cmd, @@ -3509,6 +3526,7 @@ client_fentrylk (call_frame_t *frame, gf_hdr_common_t *hdr = NULL; gf_fop_fentrylk_req_t *req = NULL; int64_t remote_fd = -1; + size_t vollen = 0; size_t namelen = 0; size_t hdrlen = -1; int ret = -1; @@ -3519,7 +3537,7 @@ client_fentrylk (call_frame_t *frame, STACK_WIND (frame, default_fentrylk_cbk, conf->child, conf->child->fops->fentrylk, - fd, name, cmd, type); + volume, fd, name, cmd, type); return 0; } @@ -3527,6 +3545,8 @@ client_fentrylk (call_frame_t *frame, if (name) namelen = STRLEN_0(name); + vollen = STRLEN_0(volume); + ret = this_fd_get (fd, this, &remote_fd); if (ret == -1) { gf_log (this->name, GF_LOG_DEBUG, @@ -3536,8 +3556,8 @@ client_fentrylk (call_frame_t *frame, return 0; } - hdrlen = gf_hdr_len (req, namelen); - hdr = gf_hdr_new (req, namelen); + hdrlen = gf_hdr_len (req, namelen + vollen); + hdr = gf_hdr_new (req, namelen + vollen); GF_VALIDATE_OR_GOTO(this->name, hdr, unwind); req = gf_param (hdr); @@ -3548,6 +3568,8 @@ client_fentrylk (call_frame_t *frame, if (name) strcpy (req->name, name); + strcpy (req->volume + namelen, volume); + req->cmd = hton32 (cmd); req->type = hton32 (type); diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index ebe00829f4a..1fa400d5fab 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -223,6 +223,7 @@ server_copy_frame (call_frame_t *frame) int32_t gf_add_locker (struct _lock_table *table, + const char *volume, loc_t *loc, fd_t *fd, pid_t pid) @@ -239,6 +240,8 @@ gf_add_locker (struct _lock_table *table, } INIT_LIST_HEAD (&new->lockers); + new->volume = strdup (volume); + if (fd == NULL) { loc_copy (&new->loc, loc); dir = S_ISDIR (new->loc.inode->st_mode); @@ -263,6 +266,7 @@ out: int32_t gf_del_locker (struct _lock_table *table, + const char *volume, loc_t *loc, fd_t *fd, pid_t pid) @@ -292,12 +296,14 @@ gf_del_locker (struct _lock_table *table, list_for_each_entry_safe (locker, tmp, head, lockers) { if (locker->fd && fd && - (locker->fd == fd) && (locker->pid == pid)) { + (locker->fd == fd) && (locker->pid == pid) + && !strcmp (locker->volume, volume)) { list_move_tail (&locker->lockers, &del); } else if (locker->loc.inode && loc && (locker->loc.inode == loc->inode) && - (locker->pid == pid)) { + (locker->pid == pid) + && !strcmp (locker->volume, volume)) { list_move_tail (&locker->lockers, &del); } } @@ -314,6 +320,7 @@ gf_del_locker (struct _lock_table *table, else loc_wipe (&locker->loc); + free (locker->volume); free (locker); } @@ -453,16 +460,20 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, bound_xl->fops->finodelk, + locker->volume, locker->fd, F_SETLK, &flock); fd_unref (locker->fd); } else { STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, bound_xl->fops->inodelk, + locker->volume, &(locker->loc), F_SETLK, &flock); loc_wipe (&locker->loc); } + free (locker->volume); + list_del_init (&locker->lockers); free (locker); } @@ -479,6 +490,7 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, bound_xl->fops->fentrylk, + locker->volume, locker->fd, NULL, ENTRYLK_UNLOCK, ENTRYLK_WRLCK); fd_unref (locker->fd); @@ -486,11 +498,14 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) STACK_WIND (tmp_frame, server_nop_cbk, bound_xl, bound_xl->fops->entrylk, + locker->volume, &(locker->loc), NULL, ENTRYLK_UNLOCK, ENTRYLK_WRLCK); loc_wipe (&locker->loc); } + free (locker->volume); + list_del_init (&locker->lockers); free (locker); } diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index 3fea9f66776..eb26de84f86 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -60,13 +60,13 @@ void free_state (server_state_t *state); void server_loc_wipe (loc_t *loc); int32_t -gf_add_locker (struct _lock_table *table, +gf_add_locker (struct _lock_table *table, const char *volume, loc_t *loc, fd_t *fd, pid_t pid); int32_t -gf_del_locker (struct _lock_table *table, +gf_del_locker (struct _lock_table *table, const char *volume, loc_t *loc, fd_t *fd, pid_t pid); diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 0a3e3e0110b..1153a545100 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -362,10 +362,10 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, if (op_ret >= 0) { if (state->flock.l_type == F_UNLCK) - gf_del_locker (conn->ltable, + gf_del_locker (conn->ltable, state->volume, &state->loc, NULL, frame->root->pid); else - gf_add_locker (conn->ltable, + gf_add_locker (conn->ltable, state->volume, &state->loc, NULL, frame->root->pid); } else if (op_errno != ENOSYS) { gf_log (this->name, GF_LOG_DEBUG, @@ -409,11 +409,13 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, if (op_ret >= 0) { if (state->flock.l_type == F_UNLCK) - gf_del_locker (conn->ltable, - NULL, state->fd, frame->root->pid); + gf_del_locker (conn->ltable, state->volume, + NULL, state->fd, + frame->root->pid); else - gf_add_locker (conn->ltable, - NULL, state->fd, frame->root->pid); + gf_add_locker (conn->ltable, state->volume, + NULL, state->fd, + frame->root->pid); } else if (op_errno != ENOSYS) { gf_log (this->name, GF_LOG_DEBUG, "%"PRId64": FINODELK %"PRId64" (%"PRId64") ==> %"PRId32" (%s)", @@ -465,10 +467,10 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, if (op_ret >= 0) { if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (conn->ltable, + gf_del_locker (conn->ltable, state->volume, &state->loc, NULL, frame->root->pid); else - gf_add_locker (conn->ltable, + gf_add_locker (conn->ltable, state->volume, &state->loc, NULL, frame->root->pid); } else if (op_errno != ENOSYS) { gf_log (this->name, GF_LOG_DEBUG, @@ -511,10 +513,10 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, if (op_ret >= 0) { state = CALL_STATE(frame); if (state->cmd == ENTRYLK_UNLOCK) - gf_del_locker (conn->ltable, + gf_del_locker (conn->ltable, state->volume, NULL, state->fd, frame->root->pid); else - gf_add_locker (conn->ltable, + gf_add_locker (conn->ltable, state->volume, NULL, state->fd, frame->root->pid); } else if (op_errno != ENOSYS) { gf_log (this->name, GF_LOG_DEBUG, @@ -6024,7 +6026,7 @@ server_utimens (call_frame_t *frame, int32_t server_inodelk_resume (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t cmd, + const char *volume, loc_t *loc, int32_t cmd, struct flock *flock) { server_state_t *state = NULL; @@ -6046,7 +6048,7 @@ server_inodelk_resume (call_frame_t *frame, server_inodelk_cbk, BOUND_XL(frame), BOUND_XL(frame)->fops->inodelk, - loc, cmd, flock); + volume, loc, cmd, flock); return 0; } @@ -6062,6 +6064,7 @@ server_inodelk (call_frame_t *frame, gf_fop_inodelk_req_t *req = NULL; server_state_t *state = NULL; size_t pathlen = 0; + size_t vollen = 0; req = gf_param (hdr); state = CALL_STATE(frame); @@ -6082,8 +6085,10 @@ server_inodelk (call_frame_t *frame, state->type = ntoh32 (req->type); pathlen = STRLEN_0(req->path); + vollen = STRLEN_0(req->volume + vollen); state->path = req->path; + state->volume = req->volume + vollen; state->ino = ntoh64 (req->ino); gf_flock_to_flock (&req->flock, &state->flock); @@ -6107,7 +6112,8 @@ server_inodelk (call_frame_t *frame, inodelk_stub = fop_inodelk_stub (frame, server_inodelk_resume, - &state->loc, state->cmd, &state->flock); + state->volume, &state->loc, + state->cmd, &state->flock); if ((state->loc.parent == NULL) || (state->loc.inode == NULL)) { @@ -6129,12 +6135,14 @@ server_finodelk (call_frame_t *frame, gf_fop_finodelk_req_t *req = NULL; server_state_t *state = NULL; server_connection_t *conn = NULL; - + conn = SERVER_CONNECTION(frame); req = gf_param (hdr); state = CALL_STATE(frame); { + state->volume = req->volume; + state->fd_no = ntoh64 (req->fd); if (state->fd_no >= 0) state->fd = gf_fd_fdptr_get (conn->fdtable, @@ -6188,7 +6196,7 @@ server_finodelk (call_frame_t *frame, STACK_WIND (frame, server_finodelk_cbk, BOUND_XL(frame), BOUND_XL(frame)->fops->finodelk, - state->fd, state->cmd, &state->flock); + state->volume, state->fd, state->cmd, &state->flock); return 0; } @@ -6196,7 +6204,7 @@ server_finodelk (call_frame_t *frame, int32_t server_entrylk_resume (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name, + const char *volume, loc_t *loc, const char *name, entrylk_cmd cmd, entrylk_type type) { server_state_t *state = NULL; @@ -6218,7 +6226,7 @@ server_entrylk_resume (call_frame_t *frame, server_entrylk_cbk, BOUND_XL(frame), BOUND_XL(frame)->fops->entrylk, - loc, name, cmd, type); + volume, loc, name, cmd, type); return 0; } @@ -6242,6 +6250,7 @@ server_entrylk (call_frame_t *frame, call_stub_t *entrylk_stub = NULL; size_t pathlen = 0; size_t namelen = 0; + size_t vollen = 0; req = gf_param (hdr); state = CALL_STATE(frame); @@ -6254,6 +6263,9 @@ server_entrylk (call_frame_t *frame, if (namelen) state->name = req->name + pathlen; + vollen = STRLEN_0(req->volume + pathlen + namelen); + state->volume = req->volume + pathlen + namelen; + state->cmd = ntoh32 (req->cmd); state->type = ntoh32 (req->type); } @@ -6264,6 +6276,7 @@ server_entrylk (call_frame_t *frame, entrylk_stub = fop_entrylk_stub (frame, server_entrylk_resume, + state->volume, &state->loc, state->name, state->cmd, state->type); @@ -6287,6 +6300,7 @@ server_fentrylk (call_frame_t *frame, gf_fop_fentrylk_req_t *req = NULL; server_state_t *state = NULL; size_t namelen = 0; + size_t vollen = 0; server_connection_t *conn = NULL; conn = SERVER_CONNECTION(frame); @@ -6305,6 +6319,9 @@ server_fentrylk (call_frame_t *frame, if (namelen) state->name = req->name; + + vollen = STRLEN_0(req->volume + namelen); + state->volume = req->volume + namelen; } if (state->fd == NULL) { @@ -6324,7 +6341,8 @@ server_fentrylk (call_frame_t *frame, STACK_WIND (frame, server_fentrylk_cbk, BOUND_XL(frame), BOUND_XL(frame)->fops->fentrylk, - state->fd, state->name, state->cmd, state->type); + state->volume, state->fd, state->name, + state->cmd, state->type); return 0; } diff --git a/xlators/protocol/server/src/server-protocol.h b/xlators/protocol/server/src/server-protocol.h index 30ccb91e756..f00b584fb25 100644 --- a/xlators/protocol/server/src/server-protocol.h +++ b/xlators/protocol/server/src/server-protocol.h @@ -42,6 +42,7 @@ typedef struct _server_state server_state_t; struct _locker { struct list_head lockers; + char *volume; loc_t loc; fd_t *fd; pid_t pid; @@ -138,6 +139,7 @@ struct _server_state { struct flock flock; struct timespec tv[2]; char *resolved; + const char *volume; }; |