From 7af8d8edbd8554235348e0f54348edf222c0b46e Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Thu, 12 Mar 2009 16:21:51 +0530 Subject: Add extra 'volume' parameter to inodelk/entrylk calls Signed-off-by: Anand V. Avati --- libglusterfs/src/call-stub.c | 42 ++++++++++++++++++++++++++++++++++++------ libglusterfs/src/call-stub.h | 14 ++++++++++---- libglusterfs/src/defaults.c | 17 +++++++++-------- libglusterfs/src/defaults.h | 10 ++++++---- libglusterfs/src/protocol.h | 4 ++++ libglusterfs/src/xlator.h | 8 ++++++-- 6 files changed, 71 insertions(+), 24 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 92301a2dd..8a090ba83 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -1731,7 +1731,7 @@ out: call_stub_t * fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn, - loc_t *loc, int32_t cmd, struct flock *lock) + const char *volume, loc_t *loc, int32_t cmd, struct flock *lock) { call_stub_t *stub = NULL; @@ -1744,6 +1744,9 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn, stub->args.inodelk.fn = fn; + if (volume) + stub->args.inodelk.volume = strdup (volume); + loc_copy (&stub->args.inodelk.loc, loc); stub->args.inodelk.cmd = cmd; stub->args.inodelk.lock = *lock; @@ -1774,7 +1777,7 @@ fop_inodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn, call_stub_t * fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn, - fd_t *fd, int32_t cmd, struct flock *lock) + const char *volume, fd_t *fd, int32_t cmd, struct flock *lock) { call_stub_t *stub = NULL; @@ -1789,6 +1792,10 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn, if (fd) stub->args.finodelk.fd = fd_ref (fd); + + if (volume) + stub->args.finodelk.volume = strdup (volume); + stub->args.finodelk.cmd = cmd; stub->args.finodelk.lock = *lock; @@ -1819,7 +1826,7 @@ fop_finodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn, call_stub_t * fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn, - loc_t *loc, const char *name, + const char *volume, loc_t *loc, const char *name, entrylk_cmd cmd, entrylk_type type) { call_stub_t *stub = NULL; @@ -1832,6 +1839,10 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn, return NULL; stub->args.entrylk.fn = fn; + + if (volume) + stub->args.entrylk.volume = strdup (volume); + loc_copy (&stub->args.entrylk.loc, loc); stub->args.entrylk.cmd = cmd; @@ -1865,7 +1876,7 @@ fop_entrylk_cbk_stub (call_frame_t *frame, fop_entrylk_cbk_t fn, call_stub_t * fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn, - fd_t *fd, const char *name, + const char *volume, fd_t *fd, const char *name, entrylk_cmd cmd, entrylk_type type) { call_stub_t *stub = NULL; @@ -1878,7 +1889,10 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn, return NULL; stub->args.fentrylk.fn = fn; - + + if (volume) + stub->args.fentrylk.volume = strdup (volume); + if (fd) stub->args.fentrylk.fd = fd_ref (fd); stub->args.fentrylk.cmd = cmd; @@ -2536,6 +2550,7 @@ call_resume_wind (call_stub_t *stub) { stub->args.inodelk.fn (stub->frame, stub->frame->this, + stub->args.inodelk.volume, &stub->args.inodelk.loc, stub->args.inodelk.cmd, &stub->args.inodelk.lock); @@ -2546,6 +2561,7 @@ call_resume_wind (call_stub_t *stub) { stub->args.finodelk.fn (stub->frame, stub->frame->this, + stub->args.finodelk.volume, stub->args.finodelk.fd, stub->args.finodelk.cmd, &stub->args.finodelk.lock); @@ -2556,6 +2572,7 @@ call_resume_wind (call_stub_t *stub) { stub->args.entrylk.fn (stub->frame, stub->frame->this, + stub->args.entrylk.volume, &stub->args.entrylk.loc, stub->args.entrylk.name, stub->args.entrylk.cmd, @@ -2567,6 +2584,7 @@ call_resume_wind (call_stub_t *stub) { stub->args.fentrylk.fn (stub->frame, stub->frame->this, + stub->args.fentrylk.volume, stub->args.fentrylk.fd, stub->args.fentrylk.name, stub->args.fentrylk.cmd, @@ -3744,17 +3762,26 @@ call_stub_destroy_wind (call_stub_t *stub) case GF_FOP_INODELK: { + if (stub->args.inodelk.volume) + FREE (stub->args.inodelk.volume); + loc_wipe (&stub->args.inodelk.loc); break; } case GF_FOP_FINODELK: { + if (stub->args.finodelk.volume) + FREE (stub->args.finodelk.volume); + if (stub->args.finodelk.fd) fd_unref (stub->args.finodelk.fd); break; } case GF_FOP_ENTRYLK: { + if (stub->args.entrylk.volume) + FREE (stub->args.entrylk.volume); + if (stub->args.entrylk.name) FREE (stub->args.entrylk.name); loc_wipe (&stub->args.entrylk.loc); @@ -3762,10 +3789,13 @@ call_stub_destroy_wind (call_stub_t *stub) } case GF_FOP_FENTRYLK: { + if (stub->args.fentrylk.volume) + FREE (stub->args.fentrylk.volume); + if (stub->args.fentrylk.name) FREE (stub->args.fentrylk.name); - if (stub->args.fentrylk.fd) + if (stub->args.fentrylk.fd) fd_unref (stub->args.fentrylk.fd); break; } diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index d80ddd173..a970897bb 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -487,6 +487,7 @@ typedef struct { /* inodelk */ struct { fop_inodelk_t fn; + const char *volume; loc_t loc; int32_t cmd; struct flock lock; @@ -500,6 +501,7 @@ typedef struct { /* finodelk */ struct { fop_finodelk_t fn; + const char *volume; fd_t *fd; int32_t cmd; struct flock lock; @@ -514,6 +516,7 @@ typedef struct { struct { fop_entrylk_t fn; loc_t loc; + const char *volume; const char *name; entrylk_cmd cmd; entrylk_type type; @@ -528,6 +531,7 @@ typedef struct { struct { fop_fentrylk_t fn; fd_t *fd; + const char *volume; const char *name; entrylk_cmd cmd; entrylk_type type; @@ -1086,20 +1090,22 @@ fop_lk_cbk_stub (call_frame_t *frame, call_stub_t * fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn, - loc_t *loc, int32_t cmd, struct flock *lock); + const char *volume, loc_t *loc, int32_t cmd, + struct flock *lock); call_stub_t * fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn, - fd_t *fd, int32_t cmd, struct flock *lock); + const char *volume, fd_t *fd, int32_t cmd, + struct flock *lock); call_stub_t * fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn, - loc_t *loc, const char *basename, + const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type); call_stub_t * fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn, - fd_t *fd, const char *basename, + const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type); call_stub_t * diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c index dc2908633..724f5a792 100644 --- a/libglusterfs/src/defaults.c +++ b/libglusterfs/src/defaults.c @@ -1199,13 +1199,14 @@ default_inodelk_cbk (call_frame_t *frame, void *cookie, int32_t default_inodelk (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t cmd, struct flock *lock) + const char *volume, loc_t *loc, int32_t cmd, + struct flock *lock) { STACK_WIND (frame, default_inodelk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->inodelk, - loc, cmd, lock); + volume, loc, cmd, lock); return 0; } @@ -1222,13 +1223,13 @@ default_finodelk_cbk (call_frame_t *frame, void *cookie, int32_t default_finodelk (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t cmd, struct flock *lock) + const char *volume, fd_t *fd, int32_t cmd, struct flock *lock) { STACK_WIND (frame, default_finodelk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->finodelk, - fd, cmd, lock); + volume, fd, cmd, lock); return 0; } @@ -1244,13 +1245,13 @@ default_entrylk_cbk (call_frame_t *frame, void *cookie, int32_t default_entrylk (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *basename, + const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type) { STACK_WIND (frame, default_entrylk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->entrylk, - loc, basename, cmd, type); + volume, loc, basename, cmd, type); return 0; } @@ -1265,13 +1266,13 @@ default_fentrylk_cbk (call_frame_t *frame, void *cookie, int32_t default_fentrylk (call_frame_t *frame, xlator_t *this, - fd_t *fd, const char *basename, + const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type) { STACK_WIND (frame, default_fentrylk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fentrylk, - fd, basename, cmd, type); + volume, fd, basename, cmd, type); return 0; } diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index 615222300..98e15c5bf 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -230,17 +230,19 @@ int32_t default_lk (call_frame_t *frame, struct flock *flock); int32_t default_inodelk (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t cmd, struct flock *flock); + const char *volume, loc_t *loc, int32_t cmd, + struct flock *flock); int32_t default_finodelk (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t cmd, struct flock *flock); + const char *volume, fd_t *fd, int32_t cmd, + struct flock *flock); int32_t default_entrylk (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *basename, + const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type); int32_t default_fentrylk (call_frame_t *frame, xlator_t *this, - fd_t *fd, const char *basename, + const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type); int32_t default_readdir (call_frame_t *frame, diff --git a/libglusterfs/src/protocol.h b/libglusterfs/src/protocol.h index 35f172ab7..4bb379b2f 100644 --- a/libglusterfs/src/protocol.h +++ b/libglusterfs/src/protocol.h @@ -557,6 +557,7 @@ typedef struct { uint32_t type; struct gf_flock flock; char path[0]; + char volume[0]; } __attribute__((packed)) gf_fop_inodelk_req_t; typedef struct { } __attribute__((packed)) gf_fop_inodelk_rsp_t; @@ -567,6 +568,7 @@ typedef struct { uint32_t cmd; uint32_t type; struct gf_flock flock; + char volume[0]; } __attribute__((packed)) gf_fop_finodelk_req_t; typedef struct { } __attribute__((packed)) gf_fop_finodelk_rsp_t; @@ -578,6 +580,7 @@ typedef struct { uint64_t namelen; char path[0]; char name[0]; + char volume[0]; } __attribute__((packed)) gf_fop_entrylk_req_t; typedef struct { } __attribute__((packed)) gf_fop_entrylk_rsp_t; @@ -589,6 +592,7 @@ typedef struct { uint32_t type; uint64_t namelen; char name[0]; + char volume[0]; } __attribute__((packed)) gf_fop_fentrylk_req_t; typedef struct { } __attribute__((packed)) gf_fop_fentrylk_rsp_t; diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index a5a20e8b2..2f35643c3 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -626,23 +626,27 @@ typedef int32_t (*fop_lk_t) (call_frame_t *frame, typedef int32_t (*fop_inodelk_t) (call_frame_t *frame, xlator_t *this, + const char *volume, loc_t *loc, int32_t cmd, struct flock *flock); typedef int32_t (*fop_finodelk_t) (call_frame_t *frame, xlator_t *this, + const char *volume, fd_t *fd, int32_t cmd, struct flock *flock); typedef int32_t (*fop_entrylk_t) (call_frame_t *frame, - xlator_t *this, loc_t *loc, + xlator_t *this, + const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type); typedef int32_t (*fop_fentrylk_t) (call_frame_t *frame, - xlator_t *this, fd_t *fd, + xlator_t *this, + const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type); -- cgit