diff options
author | Anand V. Avati <avati@amp.gluster.com> | 2010-10-02 11:25:05 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-02 22:18:56 -0700 |
commit | 99caede76b0ef312d622b2387bf9524724e7c6df (patch) | |
tree | 7b6c8cc969b5e8460e4ac4b67734422e3fad782c | |
parent | 5a4e1e69b2ec65dcefa6b37b8ac7d058f3a2c29f (diff) |
rmdir: introduce extra flags parameter in FOP prototype
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
26 files changed, 115 insertions, 90 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 551fa99aecb..3b0e7f0b409 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -552,9 +552,8 @@ out: call_stub_t * -fop_rmdir_stub (call_frame_t *frame, - fop_rmdir_t fn, - loc_t *loc) +fop_rmdir_stub (call_frame_t *frame, fop_rmdir_t fn, + loc_t *loc, int flags) { call_stub_t *stub = NULL; @@ -566,6 +565,7 @@ fop_rmdir_stub (call_frame_t *frame, stub->args.rmdir.fn = fn; loc_copy (&stub->args.rmdir.loc, loc); + stub->args.rmdir.flags = flags; out: return stub; } @@ -2178,9 +2178,9 @@ call_resume_wind (call_stub_t *stub) case GF_FOP_RMDIR: { - stub->args.rmdir.fn (stub->frame, - stub->frame->this, - &stub->args.rmdir.loc); + stub->args.rmdir.fn (stub->frame, stub->frame->this, + &stub->args.rmdir.loc, + stub->args.rmdir.flags); } break; @@ -2672,13 +2672,13 @@ call_resume_unwind (call_stub_t *stub) &stub->args.rmdir_cbk.preparent, &stub->args.rmdir_cbk.postparent); else - stub->args.unlink_cbk.fn (stub->frame, - stub->frame->cookie, - stub->frame->this, - stub->args.rmdir_cbk.op_ret, - stub->args.rmdir_cbk.op_errno, - &stub->args.rmdir_cbk.preparent, - &stub->args.rmdir_cbk.postparent); + stub->args.rmdir_cbk.fn (stub->frame, + stub->frame->cookie, + stub->frame->this, + stub->args.rmdir_cbk.op_ret, + stub->args.rmdir_cbk.op_errno, + &stub->args.rmdir_cbk.preparent, + &stub->args.rmdir_cbk.postparent); break; } diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h index 340468c3e7c..834a38ec0ac 100644 --- a/libglusterfs/src/call-stub.h +++ b/libglusterfs/src/call-stub.h @@ -173,6 +173,7 @@ typedef struct { struct { fop_rmdir_t fn; loc_t loc; + int flags; } rmdir; struct { fop_rmdir_cbk_t fn; @@ -715,9 +716,8 @@ fop_unlink_cbk_stub (call_frame_t *frame, struct iatt *postparent); call_stub_t * -fop_rmdir_stub (call_frame_t *frame, - fop_rmdir_t fn, - loc_t *loc); +fop_rmdir_stub (call_frame_t *frame, fop_rmdir_t fn, + loc_t *loc, int flags); call_stub_t * fop_rmdir_cbk_stub (call_frame_t *frame, diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c index 3e271dde421..8af9c235ec8 100644 --- a/libglusterfs/src/defaults.c +++ b/libglusterfs/src/defaults.c @@ -574,10 +574,11 @@ default_symlink_resume (call_frame_t *frame, xlator_t *this, } int32_t -default_rmdir_resume (call_frame_t *frame, xlator_t *this, loc_t *loc) +default_rmdir_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, + int flags) { STACK_WIND (frame, default_rmdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc); + FIRST_CHILD(this)->fops->rmdir, loc, flags); return 0; } @@ -945,10 +946,10 @@ default_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, } int32_t -default_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +default_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { STACK_WIND (frame, default_rmdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc); + FIRST_CHILD(this)->fops->rmdir, loc, flags); return 0; } diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h index f0235821061..76cb78d7e35 100644 --- a/libglusterfs/src/defaults.h +++ b/libglusterfs/src/defaults.h @@ -87,9 +87,8 @@ int32_t default_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc); -int32_t default_rmdir (call_frame_t *frame, - xlator_t *this, - loc_t *loc); +int32_t default_rmdir (call_frame_t *frame, xlator_t *this, + loc_t *loc, int flags); int32_t default_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, loc_t *loc, dict_t *params); @@ -302,9 +301,8 @@ int32_t default_unlink_resume (call_frame_t *frame, xlator_t *this, loc_t *loc); -int32_t default_rmdir_resume (call_frame_t *frame, - xlator_t *this, - loc_t *loc); +int32_t default_rmdir_resume (call_frame_t *frame, xlator_t *this, + loc_t *loc, int flags); int32_t default_symlink_resume (call_frame_t *frame, xlator_t *this, const char *linkpath, loc_t *loc, dict_t *params); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 217ad97bb4c..db5e652890c 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -454,9 +454,8 @@ typedef int32_t (*fop_unlink_t) (call_frame_t *frame, xlator_t *this, loc_t *loc); -typedef int32_t (*fop_rmdir_t) (call_frame_t *frame, - xlator_t *this, - loc_t *loc); +typedef int32_t (*fop_rmdir_t) (call_frame_t *frame, xlator_t *this, + loc_t *loc, int flags); typedef int32_t (*fop_symlink_t) (call_frame_t *frame, xlator_t *this, const char *linkname, loc_t *loc, diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c index 1aa268f66e4..1226285f777 100644 --- a/xlators/cluster/afr/src/afr-dir-write.c +++ b/xlators/cluster/afr/src/afr-dir-write.c @@ -1900,7 +1900,7 @@ afr_rmdir_wind (call_frame_t *frame, xlator_t *this) (void *) (long) i, priv->children[i], priv->children[i]->fops->rmdir, - &local->loc); + &local->loc, local->cont.rmdir.flags); if (!--call_count) break; @@ -1926,7 +1926,7 @@ afr_rmdir_done (call_frame_t *frame, xlator_t *this) int afr_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, int flags) { afr_private_t * priv = NULL; afr_local_t * local = NULL; @@ -1960,6 +1960,7 @@ afr_rmdir (call_frame_t *frame, xlator_t *this, transaction_frame->local = local; + local->cont.rmdir.flags = flags; loc_copy (&local->loc, loc); if (loc->parent) diff --git a/xlators/cluster/afr/src/afr-dir-write.h b/xlators/cluster/afr/src/afr-dir-write.h index e2ed8c759d0..40aeb1f5850 100644 --- a/xlators/cluster/afr/src/afr-dir-write.h +++ b/xlators/cluster/afr/src/afr-dir-write.h @@ -39,7 +39,7 @@ afr_unlink (call_frame_t *frame, xlator_t *this, int32_t afr_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc); + loc_t *loc, int flags); int32_t afr_link (call_frame_t *frame, xlator_t *this, diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index ed50fdfbfd2..56a5fb106c3 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -531,6 +531,7 @@ typedef struct _afr_local { } unlink; struct { + int flags; ino_t parent_ino; int32_t op_ret; int32_t op_errno; diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c index 1a9277abc9b..39de7cbb9ba 100644 --- a/xlators/cluster/afr/src/pump.c +++ b/xlators/cluster/afr/src/pump.c @@ -1719,22 +1719,23 @@ pump_unlink (call_frame_t *frame, } -static int32_t -pump_rmdir (call_frame_t *frame, - xlator_t *this, - loc_t *loc) +static int +pump_rmdir (call_frame_t *frame, xlator_t *this, + loc_t *loc, int flags) { afr_private_t *priv = NULL; + priv = this->private; + if (!priv->use_afr_in_pump) { - STACK_WIND (frame, - default_rmdir_cbk, + STACK_WIND (frame, default_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } - afr_rmdir (frame, this, loc); + + afr_rmdir (frame, this, loc, flags); return 0; } diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index a262ba6ca67..6001cd3180a 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3860,7 +3860,7 @@ dht_rmdir_do (call_frame_t *frame, xlator_t *this) STACK_WIND (frame, dht_rmdir_cbk, conf->subvolumes[i], conf->subvolumes[i]->fops->rmdir, - &local->loc); + &local->loc, local->flags); } return 0; @@ -4127,7 +4127,7 @@ err: int -dht_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +dht_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { dht_local_t *local = NULL; dht_conf_t *conf = NULL; @@ -4163,6 +4163,8 @@ dht_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) goto err; } + local->flags = flags; + local->fd = fd_create (local->loc.inode, frame->root->pid); if (!local->fd) { gf_log (this->name, GF_LOG_ERROR, diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index 72c7b4515e2..f6118a6f048 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -1143,7 +1143,8 @@ stripe_first_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, while (trav) { STACK_WIND (frame, stripe_unlink_cbk, trav->xlator, - trav->xlator->fops->rmdir, &local->loc); + trav->xlator->fops->rmdir, &local->loc, + local->flags); trav = trav->next; } @@ -1155,7 +1156,7 @@ err: } int32_t -stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { xlator_list_t *trav = NULL; stripe_local_t *local = NULL; @@ -1187,10 +1188,11 @@ stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) local->op_ret = -1; frame->local = local; loc_copy (&local->loc, loc); + local->flags = flags; local->call_count = priv->child_count; STACK_WIND (frame, stripe_first_rmdir_cbk, trav->xlator, - trav->xlator->fops->rmdir, loc); + trav->xlator->fops->rmdir, loc, flags); return 0; err: diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index b9ed44b2101..7fd467a8b9a 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -807,7 +807,7 @@ error_gen_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int -error_gen_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +error_gen_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { int op_errno = 0; eg_t *egp = NULL; @@ -828,7 +828,7 @@ error_gen_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) STACK_WIND (frame, error_gen_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 2d56ecf6a0f..bf513184025 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -1044,7 +1044,7 @@ io_stats_unlink (call_frame_t *frame, xlator_t *this, int io_stats_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, int flags) { BUMP_FOP (RMDIR); @@ -1053,7 +1053,7 @@ io_stats_rmdir (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index c1de19104f8..1343d758d9d 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -1525,18 +1525,18 @@ trace_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) int -trace_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +trace_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { if (trace_fop_names[GF_FOP_RMDIR].enabled) { gf_log (this->name, GF_LOG_NORMAL, - "%"PRId64": (loc {path=%s, ino=%"PRIu64"})", - frame->root->unique, loc->path, loc->inode->ino); + "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d)", + frame->root->unique, loc->path, loc->inode->ino, flags); } STACK_WIND (frame, trace_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } diff --git a/xlators/features/access-control/src/access-control.c b/xlators/features/access-control/src/access-control.c index 34422f9ca0c..a8aae9780ff 100644 --- a/xlators/features/access-control/src/access-control.c +++ b/xlators/features/access-control/src/access-control.c @@ -788,11 +788,11 @@ out: } -int32_t -ac_rmdir_resume (call_frame_t *frame, xlator_t *this, loc_t *loc) +int +ac_rmdir_resume (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { STACK_WIND (frame, default_rmdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc); + FIRST_CHILD(this)->fops->rmdir, loc, flags); return 0; } @@ -827,14 +827,14 @@ out: } -int32_t -ac_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +int +ac_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { call_stub_t *stub = NULL; int ret = -EFAULT; loc_t parentloc = {0, }; - stub = fop_rmdir_stub (frame, ac_rmdir_resume, loc); + stub = fop_rmdir_stub (frame, ac_rmdir_resume, loc, flags); if (!stub) { gf_log (this->name, GF_LOG_ERROR, "cannot create call stub: " "(out of memory)"); diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c index 168e32373d5..32fac39bb0a 100644 --- a/xlators/features/quiesce/src/quiesce.c +++ b/xlators/features/quiesce/src/quiesce.c @@ -628,10 +628,9 @@ quiesce_symlink (call_frame_t *frame, xlator_t *this, return 0; } -int32_t -quiesce_rmdir (call_frame_t *frame, - xlator_t *this, - loc_t *loc) + +int +quiesce_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { quiesce_priv_t *priv = NULL; call_stub_t *stub = NULL; @@ -639,15 +638,14 @@ quiesce_rmdir (call_frame_t *frame, priv = this->private; if (priv->pass_through) { - STACK_WIND (frame, - default_rmdir_cbk, + STACK_WIND (frame, default_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } - stub = fop_rmdir_stub (frame, default_rmdir_resume, loc); + stub = fop_rmdir_stub (frame, default_rmdir_resume, loc, flags); if (!stub) { STACK_UNWIND_STRICT (rmdir, frame, -1, ENOMEM, NULL, NULL); return 0; diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 094b62d4a56..0f862e090b8 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -43,6 +43,7 @@ struct quota_local { struct iovec vector[MAX_IOVEC]; struct iobref *iobref; loc_t loc; + int flags; }; @@ -520,14 +521,14 @@ quota_rmdir_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, quota_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - &local->loc); + &local->loc, local->flags); return 0; } int -quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { struct quota_local *local = NULL; struct quota_priv *priv = NULL; @@ -540,6 +541,7 @@ quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) frame->local = local; loc_copy (&local->loc, loc); + local->flags = flags; STACK_WIND (frame, quota_rmdir_stat_cbk, FIRST_CHILD(this), @@ -550,7 +552,7 @@ quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) STACK_WIND (frame, quota_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc); + loc, flags); return 0; } diff --git a/xlators/features/read-only/src/read-only.c b/xlators/features/read-only/src/read-only.c index 8c71f0a0d78..fe0e95b9fd1 100644 --- a/xlators/features/read-only/src/read-only.c +++ b/xlators/features/read-only/src/read-only.c @@ -137,8 +137,9 @@ ro_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) return 0; } -int32_t -ro_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) + +int +ro_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { STACK_UNWIND_STRICT (rmdir, frame, -1, EROFS, NULL, NULL); return 0; diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index b6497b15efd..64ac765c0dc 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -1179,7 +1179,7 @@ fuse_rmdir_resume (fuse_state_t *state) state->loc.path); FUSE_FOP (state, fuse_unlink_cbk, GF_FOP_RMDIR, - rmdir, &state->loc); + rmdir, &state->loc, 0); } static void diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c index 3f342710b25..e9633748bcc 100644 --- a/xlators/nfs/server/src/nfs-fops.c +++ b/xlators/nfs/server/src/nfs-fops.c @@ -941,7 +941,7 @@ nfs_fop_rmdir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc, nfs_fop_save_root_ino (nfl, pathloc); STACK_WIND_COOKIE (frame, nfs_fop_rmdir_cbk, xl, xl, xl->fops->rmdir, - pathloc); + pathloc, 0); ret = 0; err: if (ret < 0) { diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index 3d072d20fca..458dd9cbf57 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -534,21 +534,21 @@ iot_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int -iot_rmdir_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc) +iot_rmdir_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { STACK_WIND (frame, iot_rmdir_cbk, FIRST_CHILD (this), - FIRST_CHILD (this)->fops->rmdir, loc); + FIRST_CHILD (this)->fops->rmdir, loc, flags); return 0; } int -iot_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +iot_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { call_stub_t *stub = NULL; int ret = -1; - stub = fop_rmdir_stub (frame, iot_rmdir_wrapper, loc); + stub = fop_rmdir_stub (frame, iot_rmdir_wrapper, loc, flags); if (!stub) { gf_log (this->name, GF_LOG_ERROR, "cannot create rmdir stub" "(out of memory)"); diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 76ae9d20980..e3ecb097ad0 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -2403,8 +2403,8 @@ out: } -int32_t -sp_rmdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc) +int +sp_rmdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { uint64_t value = 0; sp_inode_ctx_t *inode_ctx = NULL; @@ -2434,7 +2434,7 @@ sp_rmdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc) } STACK_WIND (frame, sp_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc); + FIRST_CHILD(this)->fops->rmdir, loc, flags); return 0; @@ -2444,8 +2444,8 @@ unwind: } -int32_t -sp_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +int +sp_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { int32_t ret = -1, op_errno = -1; call_stub_t *stub = NULL; @@ -2470,7 +2470,7 @@ sp_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; } - stub = fop_rmdir_stub (frame, sp_rmdir_helper, loc); + stub = fop_rmdir_stub (frame, sp_rmdir_helper, loc, flags); if (stub == NULL) { op_errno = ENOMEM; gf_log (this->name, GF_LOG_ERROR, "out of memory"); @@ -2489,7 +2489,7 @@ out: FIRST_CHILD(this)->fops->lookup, loc, NULL); } else if (can_wind) { STACK_WIND (frame, sp_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc); + FIRST_CHILD(this)->fops->rmdir, loc, flags); } return 0; diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 4297c628dc0..e64d8135fff 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -444,7 +444,7 @@ out: } int32_t -client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) +client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) { int ret = -1; clnt_conf_t *conf = NULL; @@ -456,6 +456,7 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; args.loc = loc; + args.flags = flags; proc = &conf->fops->proctable[GF_FOP_RMDIR]; if (proc->fn) diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index f4a9b198808..9b6d2bb7145 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -2855,6 +2855,7 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this, memcpy (req.pargfid, args->loc->parent->gfid, 16); req.path = (char *)args->loc->path; req.bname = (char *)args->loc->name; + req.flags = args->flags; conf = this->private; ret = client_submit_request (this, &req, frame, conf->fops, diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index d156e3cc386..b996778ef1c 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -1956,7 +1956,7 @@ server_rmdir_resume (call_frame_t *frame, xlator_t *bound_xl) goto err; STACK_WIND (frame, server_rmdir_cbk, - bound_xl, bound_xl->fops->rmdir, &state->loc); + bound_xl, bound_xl->fops->rmdir, &state->loc, state->flags); return 0; err: server_rmdir_cbk (frame, NULL, frame->this, state->resolve.op_ret, @@ -4256,6 +4256,8 @@ server_rmdir (rpcsvc_request_t *req) state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); + state->flags = args.flags; + resolve_and_resume (frame, server_rmdir_resume); out: return 0; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 398c1dd7e8b..d6874073bf1 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -54,6 +54,7 @@ #include "locking.h" #include "timer.h" #include "glusterfs3-xdr.h" +#include "hashfn.h" #undef HAVE_SET_FSID #ifdef HAVE_SET_FSID @@ -1480,9 +1481,10 @@ posix_unlink (call_frame_t *frame, xlator_t *this, return 0; } -int32_t + +int posix_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, int flags) { int32_t op_ret = -1; int32_t op_errno = 0; @@ -1491,6 +1493,7 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, char * parentpath = NULL; struct iatt preparent = {0,}; struct iatt postparent = {0,}; + struct posix_private *priv = NULL; DECLARE_OLD_FS_ID_VAR; @@ -1498,6 +1501,8 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (this, out); VALIDATE_OR_GOTO (loc, out); + priv = this->private; + SET_FS_ID (frame->root->uid, frame->root->gid); MAKE_REAL_PATH (real_path, this, loc->path); @@ -1515,7 +1520,17 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, goto out; } - op_ret = rmdir (real_path); + if (flags) { + uint32_t hashval = 0; + char *tmp_path = alloca (strlen (priv->trash_path) + 16); + + mkdir (priv->trash_path, 0755); + hashval = gf_dm_hashfn (real_path, strlen (real_path)); + sprintf (tmp_path, "%s/%u", priv->trash_path, hashval); + op_ret = rename (real_path, tmp_path); + } else { + op_ret = rmdir (real_path); + } op_errno = errno; if (op_errno == EEXIST) |