All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Christian Brauner <brauner@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	linux-btrfs@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v2 2/9] pktcdvd: sort set_blocksize() calls out
Date: Fri,  3 May 2024 04:23:22 +0100	[thread overview]
Message-ID: <20240503032329.2392931-2-viro@zeniv.linux.org.uk> (raw)
In-Reply-To: <20240503032329.2392931-1-viro@zeniv.linux.org.uk>

1) it doesn't make any sense to have ->open() call set_blocksize() on the
device being opened - the caller will override that anyway.

2) setting block size on underlying device, OTOH, ought to be done when
we are opening it exclusive - i.e. as part of pkt_open_dev().  Having
it done at setup time doesn't guarantee us anything about the state
at the time we start talking to it.  Worse, if you happen to have
the underlying device containing e.g. ext2 with 4Kb blocks that
is currently mounted r/o, that set_blocksize() will confuse the hell
out of filesystem.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/block/pktcdvd.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 21728e9ea5c3..05933f25b397 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2215,6 +2215,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, bool write)
 		}
 		dev_info(ddev, "%lukB available on disc\n", lba << 1);
 	}
+	set_blocksize(file_bdev(bdev_file), CD_FRAMESIZE);
 
 	return 0;
 
@@ -2278,11 +2279,6 @@ static int pkt_open(struct gendisk *disk, blk_mode_t mode)
 		ret = pkt_open_dev(pd, mode & BLK_OPEN_WRITE);
 		if (ret)
 			goto out_dec;
-		/*
-		 * needed here as well, since ext2 (among others) may change
-		 * the blocksize at mount time
-		 */
-		set_blocksize(disk->part0, CD_FRAMESIZE);
 	}
 	mutex_unlock(&ctl_mutex);
 	mutex_unlock(&pktcdvd_mutex);
@@ -2526,7 +2522,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 	__module_get(THIS_MODULE);
 
 	pd->bdev_file = bdev_file;
-	set_blocksize(file_bdev(bdev_file), CD_FRAMESIZE);
 
 	atomic_set(&pd->cdrw.pending_bios, 0);
 	pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->disk->disk_name);
-- 
2.39.2


  reply	other threads:[~2024-05-03  3:23 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-27 21:09 [PATCHES][RFC] set_blocksize() rework Al Viro
2024-04-27 21:10 ` [PATCH 1/7] bcache_register(): don't bother with set_blocksize() Al Viro
2024-04-29  5:06   ` Christoph Hellwig
2024-04-29  8:37   ` Christian Brauner
2024-04-27 21:10 ` [PATCH 2/7] pktcdvd: sort set_blocksize() calls out Al Viro
2024-04-29  5:07   ` Christoph Hellwig
2024-04-29  8:38   ` Christian Brauner
2024-04-27 21:10 ` [PATCH 3/7] swapon(2)/swapoff(2): don't bother with block size Al Viro
2024-04-29  5:08   ` Christoph Hellwig
2024-04-29  8:38   ` Christian Brauner
2024-04-27 21:11 ` [PATCH 4/7] swapon(2): open swap with O_EXCL Al Viro
2024-04-27 21:40   ` Linus Torvalds
2024-04-27 23:46     ` Al Viro
2024-04-28  1:25       ` Al Viro
2024-04-28 18:19       ` Al Viro
2024-04-28 18:46         ` Linus Torvalds
2024-04-28 19:07           ` Al Viro
2024-04-29  5:10             ` Christoph Hellwig
2024-04-29  5:09   ` Christoph Hellwig
2024-04-29  8:39   ` Christian Brauner
2024-04-27 21:11 ` [PATCH 5/7] swsusp: don't bother with setting block size Al Viro
2024-04-29  5:10   ` Christoph Hellwig
2024-04-29  8:40   ` Christian Brauner
2024-04-27 21:12 ` [PATCH 6/7] btrfs_get_dev_args_from_path(): don't call set_blocksize() Al Viro
2024-04-29  5:11   ` Christoph Hellwig
2024-04-29  8:40   ` Christian Brauner
2024-04-29 15:11   ` David Sterba
2024-04-30  2:05     ` Al Viro
2024-04-27 21:13 ` [PATCH 7/7] set_blocksize(): switch to passing struct file *, fail if it's not opened exclusive Al Viro
2024-04-29  5:12   ` Christoph Hellwig
2024-04-29  8:42   ` Christian Brauner
2024-05-03  3:18 ` [PATCHES v2][RFC] set_blocksize() rework Al Viro
2024-05-03  3:23   ` [PATCH v2 1/9] bcache_register(): don't bother with set_blocksize() Al Viro
2024-05-03  3:23     ` Al Viro [this message]
2024-05-03  3:23     ` [PATCH v2 3/9] swapon(2)/swapoff(2): don't bother with block size Al Viro
2024-05-03  3:23     ` [PATCH v2 4/9] swapon(2): open swap with O_EXCL Al Viro
2024-05-03  3:23     ` [PATCH v2 5/9] zram: don't bother with reopening - just use O_EXCL for open Al Viro
2024-05-03  3:23     ` [PATCH v2 6/9] swsusp: don't bother with setting block size Al Viro
2024-05-03  3:23     ` [PATCH v2 7/9] btrfs_get_bdev_and_sb(): call set_blocksize() only for exclusive opens Al Viro
2024-05-10 13:41       ` David Sterba
2024-05-03  3:23     ` [PATCH v2 8/9] set_blocksize(): switch to passing struct file * Al Viro
2024-05-03  3:23     ` [PATCH v2 9/9] make set_blocksize() fail unless block device is opened exclusive Al Viro
2024-05-03  4:17   ` [PATCH v2 1/9] bcache_register(): don't bother with set_blocksize() Al Viro
2024-05-03  4:17     ` [PATCH v2 2/9] pktcdvd: sort set_blocksize() calls out Al Viro
2024-05-03  4:17     ` [PATCH v2 3/9] swapon(2)/swapoff(2): don't bother with block size Al Viro
2024-05-03  4:17     ` [PATCH v2 4/9] swapon(2): open swap with O_EXCL Al Viro
2024-05-03  4:17     ` [PATCH v2 5/9] zram: don't bother with reopening - just use O_EXCL for open Al Viro
2024-05-03  4:17     ` [PATCH v2 6/9] swsusp: don't bother with setting block size Al Viro
2024-05-03  4:17     ` [PATCH v2 7/9] btrfs_get_bdev_and_sb(): call set_blocksize() only for exclusive opens Al Viro
2024-05-03  4:17     ` [PATCH v2 8/9] set_blocksize(): switch to passing struct file * Al Viro
2024-05-03  4:17     ` [PATCH v2 9/9] make set_blocksize() fail unless block device is opened exclusive Al Viro

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=20240503032329.2392931-2-viro@zeniv.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.org \
    --cc=rafael@kernel.org \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.