summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/stub/bit-rot-stub.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2015-11-25 15:25:26 +0530
committerVenky Shankar <vshankar@redhat.com>2015-12-16 07:58:00 -0800
commitf853ed9c61bf65cb39f859470a8ffe8973818868 (patch)
treee739e45efbcf99ec7d14682a132755809761558a /xlators/features/bit-rot/src/stub/bit-rot-stub.c
parent4eb7c968a682e59d97efcbc2afa41690dfdd22a2 (diff)
features/bit-rot-stub: delete the link for bad object in quarantine directory
When the bad object is deleted (as of now manually from the backend itself), along with its gfid handle, the entry for the bad object in the quarantne directory is left as it is (it also can be removed manually though). But the next lookup of the object upon not finding it in the backend, sends forget on the in-memory inode. If the stale link for the gfid still exists in the quarantine directory, bir-rot-stub will unlink the entry in its forget or in the next failed lookup on that object with errno being ENOENT. Change-Id: If84292d3e44707dfa11fa29023b3d9f691b8f0f3 BUG: 1285241 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/12743 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub.c')
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
index 27a5ff7..052b663 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
@@ -2575,6 +2575,44 @@ br_stub_readdirp (call_frame_t *frame, xlator_t *this,
/* lookup() */
+/**
+ * This function mainly handles the ENOENT error for the bad objects. Though
+ * br_stub_forget () handles removal of the link for the bad object from the
+ * quarantine directory, its better to handle it in lookup as well, where
+ * a failed lookup on a bad object with ENOENT, will trigger deletion of the
+ * link for the bad object from quarantine directory. So whoever comes first
+ * either forget () or lookup () will take care of removing the link.
+ */
+void
+br_stub_handle_lookup_error (xlator_t *this, inode_t *inode, int32_t op_errno)
+{
+ int32_t ret = -1;
+ uint64_t ctx_addr = 0;
+ br_stub_inode_ctx_t *ctx = NULL;
+
+ if (op_errno != ENOENT)
+ goto out;
+
+ if (!inode_is_linked (inode))
+ goto out;
+
+ ret = br_stub_get_inode_ctx (this, inode, &ctx_addr);
+ if (ret)
+ goto out;
+
+ ctx = (br_stub_inode_ctx_t *)(long)ctx_addr;
+
+ LOCK (&inode->lock);
+ {
+ if (__br_stub_is_bad_object (ctx))
+ (void) br_stub_del (this, inode->gfid);
+ }
+ UNLOCK (&inode->lock);
+
+out:
+ return;
+}
+
int
br_stub_lookup_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int op_ret, int op_errno, inode_t *inode,
@@ -2582,8 +2620,11 @@ br_stub_lookup_cbk (call_frame_t *frame, void *cookie,
{
int32_t ret = 0;
- if (op_ret < 0)
+ if (op_ret < 0) {
+ (void) br_stub_handle_lookup_error (this, inode, op_errno);
goto unwind;
+ }
+
if (!IA_ISREG (stbuf->ia_type))
goto unwind;
@@ -2737,6 +2778,20 @@ br_stub_forget (xlator_t *this, inode_t *inode)
return 0;
ctx = (br_stub_inode_ctx_t *) (long) ctx_addr;
+
+ LOCK (&inode->lock);
+ {
+ /**
+ * Ignoring the return value of br_stub_del ().
+ * There is not much that can be done if unlinking
+ * of the entry in the quarantine directory fails.
+ * The failure is logged.
+ */
+ if (__br_stub_is_bad_object (ctx))
+ (void) br_stub_del (this, inode->gfid);
+ }
+ UNLOCK (&inode->lock);
+
GF_FREE (ctx);
return 0;