linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ming Lei <ming.lei@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	"Darrick J. Wong" <djwong@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
	Mike Snitzer <snitzer@kernel.org>,
	dm-devel@lists.linux.dev, Mikulas Patocka <mpatocka@redhat.com>
Subject: Re: [PATCH v2 04/34] md: port block device access to file
Date: Mon, 15 Apr 2024 18:22:10 +0200	[thread overview]
Message-ID: <20240415162210.zyoolbj27usnhk56@quack3> (raw)
In-Reply-To: <Zh1Dtvs8nst9P4J2@fedora>

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@kernel.org>
> > > > > > ---
> > > > > >  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).

								Honza

> [  113.490114] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-1.fc37 04/01/2014
> [  113.491661] RIP: 0010:__fput_sync+0x25/0x30
> [  113.492562] Code: 90 90 90 90 90 0f 1f 44 00 00 f0 48 ff 4f 38 75 14 65 48 8b 04 25 40 25 03 00 f6 40 36 20 74 0a e9 20 fd ff ff c3 cc cc cc cc <0f0
> [  113.493926] RSP: 0018:ffffb76581003c20 EFLAGS: 00010246
> [  113.494220] RAX: ffff92eca6ef8000 RBX: ffff92ed176c3c18 RCX: 000000008080007c
> [  113.494632] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff92ec844cac00
> [  113.495033] RBP: ffff92ed176c3c00 R08: 0000000000000001 R09: 0000000000000000
> [  113.495378] R10: ffffb76581003b00 R11: ffffb76581003b68 R12: ffff92ec8fccec20
> [  113.495723] R13: ffff92ec8431b400 R14: ffff92ec8431b508 R15: ffff92ec8fccec00
> [  113.496108] FS:  00007f5be5638840(0000) GS:ffff92f0ebb80000(0000) knlGS:0000000000000000
> [  113.496581] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  113.496907] CR2: 00007f5be54694b0 CR3: 0000000108e54003 CR4: 0000000000770ef0
> [  113.497308] PKRU: 55555554
> [  113.497469] Call Trace:
> [  113.497613]  <TASK>
> [  113.497741]  ? show_trace_log_lvl+0x1c4/0x2df
> [  113.497997]  ? show_trace_log_lvl+0x1c4/0x2df
> [  113.498251]  ? dm_put_table_device+0x64/0xd0 [dm_mod]
> [  113.498553]  ? __die_body.cold+0x8/0xd
> [  113.498768]  ? die+0x2b/0x50
> [  113.498937]  ? do_trap+0xce/0x120
> [  113.499129]  ? __fput_sync+0x25/0x30
> [  113.499337]  ? do_error_trap+0x65/0x80
> [  113.499577]  ? __fput_sync+0x25/0x30
> [  113.499787]  ? exc_invalid_op+0x4e/0x70
> [  113.500011]  ? __fput_sync+0x25/0x30
> [  113.500239]  ? asm_exc_invalid_op+0x16/0x20
> [  113.500842]  ? __fput_sync+0x25/0x30
> [  113.501387]  dm_put_table_device+0x64/0xd0 [dm_mod]
> [  113.502047]  dm_put_device+0x80/0x110 [dm_mod]
> [  113.502650]  stripe_dtr+0x2f/0x50 [dm_mod]
> [  113.503218]  dm_table_destroy+0x59/0x120 [dm_mod]
> [  113.503842]  __dm_destroy+0x114/0x1e0 [dm_mod]
> [  113.504402]  dm_hash_remove_all+0x63/0x160 [dm_mod]
> [  113.505028]  remove_all+0x1e/0x30 [dm_mod]
> [  113.505602]  ctl_ioctl+0x19f/0x290 [dm_mod]
> [  113.506146]  dm_ctl_ioctl+0xa/0x20 [dm_mod]
> [  113.506717]  __x64_sys_ioctl+0x87/0xc0
> [  113.507230]  do_syscall_64+0x5c/0xf0
> [  113.507755]  ? exc_page_fault+0x62/0x150
> [  113.508309]  entry_SYSCALL_64_after_hwframe+0x6e/0x76
> [  113.508945] RIP: 0033:0x7f5be543ec6b
> 
> 
> 
> Thanks. 
> Ming
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2024-04-15 16:22 UTC|newest]

Thread overview: 146+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 13:26 [PATCH v2 00/34] Open block devices as files Christian Brauner
2024-01-23 13:26 ` [PATCH v2 01/34] bdev: open block device " Christian Brauner
2024-01-29 16:02   ` Christoph Hellwig
2024-02-01 17:08     ` Christian Brauner
2024-02-02  6:43       ` Christoph Hellwig
2024-02-02 11:46         ` Christian Brauner
2024-02-09 11:39       ` Christian Brauner
2024-03-13  2:32   ` Christoph Hellwig
2024-03-14 11:10     ` Christian Brauner
2024-03-14 14:47       ` Christian Brauner
2024-03-14 16:45         ` Christian Brauner
2024-03-14 16:58         ` Jan Kara
2024-03-15 13:23           ` [PATCH] fs,block: get holder during claim Christian Brauner
2024-03-15 14:28             ` Jan Kara
2024-03-19 16:24               ` remove holder ops Christian Brauner
2024-03-19 17:03                 ` Matthew Wilcox
2024-03-19 23:13                 ` Christoph Hellwig
2024-03-17 20:53             ` [PATCH] fs,block: get holder during claim Christoph Hellwig
2024-03-18  8:33               ` Christian Brauner
2024-03-18  9:10             ` Yi Zhang
2024-01-23 13:26 ` [PATCH v2 02/34] block/ioctl: port blkdev_bszset() to file Christian Brauner
2024-01-29 16:14   ` Christoph Hellwig
2024-01-31 18:10   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 03/34] block/genhd: port disk_scan_partitions() " Christian Brauner
2024-01-29 16:14   ` Christoph Hellwig
2024-01-31 18:13   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 04/34] md: port block device access " Christian Brauner
2024-01-29 16:14   ` Christoph Hellwig
2024-01-31 18:15   ` Jan Kara
2024-04-15  9:26   ` Ming Lei
2024-04-15 12:35     ` Christian Brauner
2024-04-15 13:56       ` Mike Snitzer
2024-04-15 14:35       ` Ming Lei
2024-04-15 14:53         ` Christian Brauner
2024-04-15 15:11           ` Ming Lei
2024-04-15 15:53             ` Mike Snitzer
2024-04-15 16:22             ` Jan Kara [this message]
2024-04-16  0:27               ` Ming Lei
2024-01-23 13:26 ` [PATCH v2 05/34] swap: port block device usage " Christian Brauner
2024-01-29 16:15   ` Christoph Hellwig
2024-01-31 18:16   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 06/34] power: port block device access " Christian Brauner
2024-01-29 16:15   ` Christoph Hellwig
2024-01-31 18:17   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 07/34] xfs: port block device access to files Christian Brauner
2024-01-29 16:17   ` Christoph Hellwig
2024-02-01 14:33     ` Christian Brauner
2024-01-31 18:19   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 08/34] drbd: port block device access to file Christian Brauner
2024-01-31 18:22   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 09/34] pktcdvd: " Christian Brauner
2024-01-31 18:26   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 10/34] rnbd: " Christian Brauner
2024-01-31 18:28   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 11/34] xen: " Christian Brauner
2024-01-31 18:31   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 12/34] zram: " Christian Brauner
2024-01-31 18:32   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 13/34] bcache: port block device access to files Christian Brauner
2024-02-01  9:45   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 14/34] block2mtd: port " Christian Brauner
2024-02-01  9:47   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 15/34] nvme: port block device access to file Christian Brauner
2024-02-01  9:48   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 16/34] s390: " Christian Brauner
2024-02-01 10:11   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 17/34] target: " Christian Brauner
2024-02-01 10:12   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 18/34] bcachefs: " Christian Brauner
2024-02-01 10:13   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 19/34] btrfs: port " Christian Brauner
2024-02-01 10:16   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 20/34] erofs: " Christian Brauner
2024-02-01 10:16   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 21/34] ext4: port block " Christian Brauner
2024-02-01 10:18   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 22/34] f2fs: port block device access to files Christian Brauner
2024-02-01 10:19   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 23/34] jfs: port block device access to file Christian Brauner
2024-02-01 10:19   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 24/34] nfs: port block device access to files Christian Brauner
2024-02-01 10:22   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 25/34] ocfs2: port block device access to file Christian Brauner
2024-02-01 10:22   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 26/34] reiserfs: " Christian Brauner
2024-02-01 10:24   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 27/34] bdev: remove bdev_open_by_path() Christian Brauner
2024-01-29 16:17   ` Christoph Hellwig
2024-02-01 10:24   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 28/34] bdev: make bdev_release() private to block layer Christian Brauner
2024-01-29 16:19   ` Christoph Hellwig
2024-02-01 10:26   ` Jan Kara
2024-02-01 14:48     ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 29/34] bdev: make struct bdev_handle private to the " Christian Brauner
2024-01-29 16:22   ` Christoph Hellwig
2024-02-01 14:50     ` Christian Brauner
2024-02-01 10:54   ` Jan Kara
2024-02-01 15:07     ` Christian Brauner
2024-02-01 17:42       ` Jan Kara
2024-02-01 11:23   ` Jan Kara
2024-02-01 14:52     ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 30/34] bdev: remove bdev pointer from struct bdev_handle Christian Brauner
2024-01-29 16:22   ` Christoph Hellwig
2024-02-01 10:57   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes Christian Brauner
2024-01-29 16:49   ` Christoph Hellwig
2024-01-29 17:09     ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes^[ Christian Brauner
2024-01-30  8:32       ` Christoph Hellwig
2024-01-30  9:11         ` Christian Brauner
2024-02-01 11:08   ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes Jan Kara
2024-02-01 16:16     ` Christian Brauner
2024-02-01 17:36       ` Jan Kara
2024-02-02 11:45         ` Christian Brauner
2024-02-02 11:51           ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 32/34] block: remove bdev_handle completely Christian Brauner
2024-01-29 16:50   ` Christoph Hellwig
2024-02-01 11:20   ` Jan Kara
2024-02-01 16:18     ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 33/34] block: expose bdev_file_inode() Christian Brauner
2024-02-01 10:09   ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 34/34] ext4: rely on sb->f_bdev only Christian Brauner
2024-02-01 11:34   ` Jan Kara
2024-02-01 13:40     ` Christian Brauner
2024-01-29  6:17 ` [PATCH v2 00/34] Open block devices as files Christoph Hellwig
2024-01-29 10:17   ` Christian Brauner
2024-01-29 10:56 ` [PATCH RFC 0/2] fs & block: remove bd_inode Christian Brauner
2024-01-29 10:56   ` [PATCH RFC 1/2] fs & block: remove bdev->bd_inode Christian Brauner
2024-02-20 11:57     ` Yu Kuai
2024-02-21  7:36       ` Christian Brauner
2024-01-29 10:56   ` [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers Christian Brauner
2024-01-29 14:37     ` Christoph Hellwig
2024-01-29 15:29       ` Christian Brauner
2024-01-29 15:36         ` Christoph Hellwig
2024-02-19 13:34           ` Yu Kuai
2024-02-19 13:42           ` Yu Kuai
2024-02-05 11:55 ` [PATCH v2 00/34] Open block devices as files Christian Brauner
2024-02-05 14:19   ` Jan Kara
2024-02-06 13:39     ` Christian Brauner
2024-02-06 13:58       ` Jan Kara
2024-02-06 16:10         ` Christian Brauner
2024-03-21 22:17 ` Matthew Wilcox
2024-03-22  3:38   ` Kent Overstreet
2024-03-22 13:56     ` Christian Brauner
2024-03-22 12:31   ` Christian Brauner
2024-03-22 12:40     ` Matthew Wilcox
2024-03-22 13:53       ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415162210.zyoolbj27usnhk56@quack3 \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=djwong@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).