Re: [PATCH vfs.tmpfs] shmem: move spinlock into shmem_recalc_inode() to fix quota support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 07, 2023 at 11:20:30AM +0200, Jan Kara wrote:
> On Thu 03-08-23 22:46:11, Hugh Dickins wrote:
> > Commit "shmem: fix quota lock nesting in huge hole handling" was not so
> > good: Smatch caught shmem_recalc_inode()'s shmem_inode_unacct_blocks()
> > descending into quota_send_warning(): where blocking GFP_NOFS is used,
> > yet shmem_recalc_inode() is called holding the shmem inode's info->lock.
> > 
> > Yes, both __dquot_alloc_space() and __dquot_free_space() are commented
> > "This operation can block, but only after everything is updated" - when
> > calling flush_warnings() at the end - both its print_warning() and its
> > quota_send_warning() may block.
> > 
> > Rework shmem_recalc_inode() to take the shmem inode's info->lock inside,
> > and drop it before calling shmem_inode_unacct_blocks().
> > 
> > And why were the spin_locks disabling interrupts?  That was just a relic
> > from when shmem_charge() and shmem_uncharge() were called while holding
> > i_pages xa_lock: stop disabling interrupts for info->lock now.
> > 
> > To help stop me from making the same mistake again, add a might_sleep()
> > into shmem_inode_acct_block() and shmem_inode_unacct_blocks(); and those
> > functions have grown, so let the compiler decide whether to inline them.
> > 
> > Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/linux-fsdevel/ffd7ca34-7f2a-44ee-b05d-b54d920ce076@moroto.mountain/
> > Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx>
> 
> Thanks for the fix Hugh! The patch looks good to me so feel free to add:
> 
> Reviewed-by: Jan Kara <jack@xxxxxxx>

Added, thank you!



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux