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

Goldwyn Rodrigues
2023-03-08T23:05:02Z

On 9:06 07/03, Christoph Hellwig wrote:
> On Thu, Mar 02, 2023 at 04:25:05PM -0600, Goldwyn Rodrigues wrote:
> > From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> >
> > 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?
>
> How do you trigger the warning? Basically i_count could only be
> 0 when doing writeback from inode evication, and just incrementing
> i_count blindly will do the wrong thing there.

Without this patch, performing a writeback with async writeback
(mount option compress) will trigger this warning.

Yes, this patch is incorrect. However we have to hold on to an inode
reference in order to complete the asynchronous writeback.

--
Goldwyn