Re: [PATCH v2 04/34] md: port block device access to file

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

 



On Mon, Apr 15, 2024 at 06:22:10PM +0200, Jan Kara wrote:
> On Mon 15-04-24 23:11:50, Ming Lei wrote:
> > On Mon, Apr 15, 2024 at 04:53:42PM +0200, Christian Brauner wrote:
> > > On Mon, Apr 15, 2024 at 10:35:53PM +0800, Ming Lei wrote:
> > > > On Mon, Apr 15, 2024 at 02:35:17PM +0200, Christian Brauner wrote:
> > > > > On Mon, Apr 15, 2024 at 05:26:19PM +0800, Ming Lei wrote:
> > > > > > Hello,
> > > > > > 
> > > > > > On Tue, Jan 23, 2024 at 02:26:21PM +0100, Christian Brauner wrote:
> > > > > > > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
> > > > > > > ---
> > > > > > >  drivers/md/dm.c               | 23 +++++++++++++----------
> > > > > > >  drivers/md/md.c               | 12 ++++++------
> > > > > > >  drivers/md/md.h               |  2 +-
> > > > > > >  include/linux/device-mapper.h |  2 +-
> > > > > > >  4 files changed, 21 insertions(+), 18 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> > > > > > > index 8dcabf84d866..87de5b5682ad 100644
> > > > > > > --- a/drivers/md/dm.c
> > > > > > > +++ b/drivers/md/dm.c
> > > > > > 
> > > > > > ...
> > > > > > 
> > > > > > > @@ -775,7 +778,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md
> > > > > > >  {
> > > > > > >  	if (md->disk->slave_dir)
> > > > > > >  		bd_unlink_disk_holder(td->dm_dev.bdev, md->disk);
> > > > > > > -	bdev_release(td->dm_dev.bdev_handle);
> > > > > > > +	fput(td->dm_dev.bdev_file);
> > > > > > 
> > > > > > The above change caused regression on 'dmsetup remove_all'.
> > > > > > 
> > > > > > blkdev_release() is delayed because of fput(), so dm_lock_for_deletion
> > > > > > returns -EBUSY, then this dm disk is skipped in remove_all().
> > > > > > 
> > > > > > Force to mark DMF_DEFERRED_REMOVE might solve it, but need our device
> > > > > > mapper guys to check if it is safe.
> > > > > > 
> > > > > > Or other better solution?
> > > > > 
> > > > > Yeah, I think there is. You can just switch all fput() instances in
> > > > > device mapper to bdev_fput() which is mainline now. This will yield the
> > > > > device and make it able to be reclaimed. Should be as simple as the
> > > > > patch below. Could you test this and send a patch based on this (I'm on
> > > > > a prolonged vacation so I don't have time right now.):
> > > > 
> > > > Unfortunately it doesn't work.
> > > > 
> > > > Here the problem is that blkdev_release() is delayed, which changes
> > > > 'dmsetup remove_all' behavior, and causes that some of dm disks aren't
> > > > removed.
> > > > 
> > > > Please see dm_lock_for_deletion() and dm_blk_open()/dm_blk_close().
> > > 
> > > So you really need blkdev_release() itself to be synchronous? Groan, in
> > 
> > At least the current dm implementation relies on this way sort of, and
> > it could be addressed by forcing to mark DMF_DEFERRED_REMOVE in
> > remove_all().
> > 
> > > that case use __fput_sync() instead of fput() which ensures that this
> > > file is closed synchronously.
> > 
> > I tried __fput_sync(), but the following panic is caused:
> > 
> > [  113.486522] ------------[ cut here ]------------
> > [  113.486524] kernel BUG at fs/file_table.c:453!
> > [  113.486531] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
> > [  113.488878] CPU: 6 PID: 1919 Comm: dmsetup Kdump: loaded Not tainted 5.14.0+ #23
> 
> Wait, how come this is 5.14 kernel? Apparently you're crashing on:
> 
> BUG_ON(!(task->flags & PF_KTHREAD));
> 
> but that is not present in current upstream (BUG_ON was removed in 6.6-rc1
> by commit 021a160abf62c).

Indeed, just tried the change on v6.9-rc3, looks it does work. 


Thanks,
Ming





[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