diff options
author | Jiffin Tony Thottan <jthottan@redhat.com> | 2015-03-18 14:12:03 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-24 00:18:50 -0700 |
commit | 191ab5693d3c9a0cdedc66bb24dd5efa535963d9 (patch) | |
tree | 5e0e0544abfe5c6ed4a2c672626f41b4cfd13d93 /xlators/features | |
parent | 432355c9c6ca5937745f5d2b87ba391ad4877c92 (diff) |
features/trash: Handling hardlinks in trash translator
In the current code of trash translator, file is moved to
trash directory without checking whether it is the last
hardlink.This may lead to inconsistency for a file in that
gluster volume.To avoid those scenarios,so a file is moved
to trash directory only if it is the last hardlink.
Change-Id: Id098e53a2236c6406ef91e6e2599ea2cff9bace3
BUG: 1132465
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: http://review.gluster.org/9926
Reviewed-by: Anoop C S <achiraya@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/trash/src/trash.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 00e99b6266f..932f4696b78 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -879,8 +879,16 @@ trash_unlink_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } - /* if the file is too big just unlink it */ + /* Only last hardlink will be moved to trash directory */ + if (buf->ia_nlink > 1) { + STACK_WIND (frame, trash_common_unwind_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, &local->loc, + 0, xdata); + goto out; + } + /* if the file is too big just unlink it */ if (buf->ia_size > (priv->max_trash_file_size)) { gf_log (this->name, GF_LOG_DEBUG, "%s: file size too big (%"PRId64") to " @@ -1470,6 +1478,16 @@ trash_truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, NULL, xdata); goto out; } + + /* Only last hardlink will be moved to trash directory */ + if (buf->ia_nlink > 1) { + STACK_WIND (frame, trash_common_unwind_buf_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->truncate, + &local->loc, local->fop_offset, xdata); + goto out; + } + /* If the file is too big, just unlink it. */ if (buf->ia_size > (priv->max_trash_file_size)) { gf_log (this->name, GF_LOG_DEBUG, "%s: file too big, " @@ -1972,6 +1990,16 @@ trash_ftruncate_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, NULL, xdata); goto out; } + + /* Only last hardlink will be moved to trash directory */ + if (buf->ia_nlink > 1) { + STACK_WIND (frame, trash_common_unwind_buf_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->ftruncate, + local->fd, local->fop_offset, xdata); + goto out; + } + if ((buf->ia_size > (priv->max_trash_file_size))) { STACK_WIND (frame, trash_common_unwind_buf_cbk, |