linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Mike Snitzer <snitzer@redhat.com>, dm-devel@lists.linux.dev
Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Ming Lei <ming.lei@redhat.com>,
	Zhong Changhui <czhong@redhat.com>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH] dm: core: put device mapper block device synchronously
Date: Tue, 16 Apr 2024 08:56:33 +0800	[thread overview]
Message-ID: <20240416005633.877153-1-ming.lei@redhat.com> (raw)

'dmsetup remove_all' actually depends on sync bdev release since
dm_lock_for_deletion() may return -EBUSY if the open count is > 0, and the
open count is dropped in dm_blk_close().

So if dm_blk_close() is delayed because of fput(), this device mapper
device is skipped in remove_all, and cause regression.

Fix the issue by using __fput_sync().

Reported-by: Zhong Changhui <czhong@redhat.com>
Fixes: a28d893eb327 ("md: port block device access to file")
Suggested-by: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/md/dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 56aa2a8b9d71..93f3d28b0f03 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -765,7 +765,7 @@ static struct table_device *open_table_device(struct mapped_device *md,
 	return td;
 
 out_blkdev_put:
-	fput(bdev_file);
+	__fput_sync(bdev_file);
 out_free_td:
 	kfree(td);
 	return ERR_PTR(r);
@@ -778,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);
-	fput(td->dm_dev.bdev_file);
+	__fput_sync(td->dm_dev.bdev_file);
 	put_dax(td->dm_dev.dax_dev);
 	list_del(&td->list);
 	kfree(td);
-- 
2.44.0


             reply	other threads:[~2024-04-16  0:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  0:56 Ming Lei [this message]
2024-04-16 15:28 ` [PATCH v2] dm: restore synchronous close of device mapper block device Mike Snitzer
2024-04-17  1:32   ` Ming Lei
2024-04-17  3:27     ` Mike Snitzer
2024-04-18  2:31   ` Changhui Zhong

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=20240416005633.877153-1-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=brauner@kernel.org \
    --cc=czhong@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /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).