diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2018-02-15 16:12:12 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2018-03-02 05:26:00 +0000 |
commit | a42137eee3c9e340ac9c82ebacca14eeb4b9d912 (patch) | |
tree | 19e2f5cbc589acc298cd0ee49d0675411b502947 /xlators/features | |
parent | e7b79c59590c203c65f7ac8548b30d068c232d33 (diff) |
features/shard: Fix shard inode refcount when it's part of priv->lru_list.
For as long as a shard's inode is in priv->lru_list, it should have a non-zero
ref-count. This patch achieves it by taking a ref on the inode when it
is added to lru list. When it's time for the inode to be evicted
from the lru list, a corresponding unref is done.
Change-Id: I289ffb41e7be5df7489c989bc1bbf53377433c86
BUG: 1468483
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/shard/src/shard.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 03504ab2743..48a87b8f72f 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -502,6 +502,10 @@ __shard_update_shards_inode_list (inode_t *linked_inode, xlator_t *this, * by empty list), and if there is still space in the priv list, * add this ctx to the tail of the list. */ + /* For as long as an inode is in lru list, we try to + * keep it alive by holding a ref on it. + */ + inode_ref (linked_inode); gf_uuid_copy (ctx->base_gfid, base_inode->gfid); ctx->block_num = block_num; list_add_tail (&ctx->ilist, &priv->ilist_head); @@ -527,8 +531,16 @@ __shard_update_shards_inode_list (inode_t *linked_inode, xlator_t *this, /* The following unref corresponds to the ref held by * inode_find() above. */ - inode_forget (lru_inode, 0); inode_unref (lru_inode); + /* The following unref corresponds to the ref held at + * the time the shard was created or looked up + */ + inode_unref (lru_inode); + inode_forget (lru_inode, 0); + /* For as long as an inode is in lru list, we try to + * keep it alive by holding a ref on it. + */ + inode_ref (linked_inode); gf_uuid_copy (ctx->base_gfid, base_inode->gfid); ctx->block_num = block_num; list_add_tail (&ctx->ilist, &priv->ilist_head); @@ -1658,11 +1670,6 @@ shard_link_block_inode (shard_local_t *local, int block_num, inode_t *inode, buf); inode_lookup (linked_inode); list_index = block_num - local->first_block; - - /* Defer unref'ing the inodes until write is complete. These inodes are - * unref'd in the event of a failure or after successful fop completion - * in shard_local_wipe(). - */ local->inode_list[list_index] = linked_inode; LOCK(&priv->lock); @@ -2520,10 +2527,11 @@ shard_unlink_block_inode (shard_local_t *local, int shard_block_num) if (!list_empty (&ctx->ilist)) { list_del_init (&ctx->ilist); priv->inode_count--; + GF_ASSERT (priv->inode_count >= 0); + inode_unlink (inode, priv->dot_shard_inode, block_bname); + inode_unref (inode); + inode_forget (inode, 0); } - GF_ASSERT (priv->inode_count >= 0); - inode_unlink (inode, priv->dot_shard_inode, block_bname); - inode_forget (inode, 0); } UNLOCK(&priv->lock); |