[PATCH 20/21] btrfs: Add inode->i_count instead of calling ihold()

Goldwyn Rodrigues
2023-03-02T22:25:58Z

I am not sure of this patch, but put it to avoid the WARN_ON() in
ihold(). I am not sure why the i_count would drop below one at this
point of time since this is still called within writepages context.

Perhaps, there is a better way to solve this?
---
fs/btrfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c4e5eb5d9ee4..b5f5c1896dbb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1535,7 +1535,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
* igrab is called higher up in the call chain, take only the
* lightweight reference for the callback lifetime
*/
- ihold(&inode->vfs_inode);
+ atomic_inc(&inode->vfs_inode.i_count);
async_chunk[i].async_cow = ctx;
async_chunk[i].inode = inode;
async_chunk[i].start = start;
--
2.39.2