Re: [PATCH 06/10] xfs: zeroing already holds invalidate_lock

Christoph Hellwig
2024-09-24T05:44:15Z

On Mon, Sep 23, 2024 at 09:22:49AM -0700, Darrick J. Wong wrote:
> On Mon, Sep 23, 2024 at 05:28:20PM +0200, Christoph Hellwig wrote:
> > All XFS callers of iomap_zero_range already hold invalidate_lock, so we can't
> > take it again in iomap_file_buffered_write_punch_delalloc.
> >
> > Use the passed in flags argument to detect if we're called from a zeroing
> > operation and don't take the lock again in this case.
>
> Shouldn't this be a part of the previous patch? AFAICT taking the
> invalidation lock in xfs_file_write_zero_eof is why we need the change
> to rwsem_assert_held_write here, right?

Most callers of zeroing already hold the lock. So I can see arguments
for merging the patches now (don't make one case even worse before
fixing) or not (this is really two unrelated changes and easier to
understand).

Or now that the lockig is inside XFS we could even add a private iomap
flag to not do the locking for the eof zeroing, but that would create
even more special cases.