linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 3/9] swapon(2)/swapoff(2): don't bother with block size
Date: Fri,  3 May 2024 05:17:34 +0100	[thread overview]
Message-ID: <20240503041740.2404425-3-viro@zeniv.linux.org.uk> (raw)
In-Reply-To: <20240503041740.2404425-1-viro@zeniv.linux.org.uk>

once upon a time that used to matter; these days we do swap IO for
swap devices at the level that doesn't give a damn about block size,
buffer_head or anything of that sort - just attach the page to
bio, set the location and size (the latter to PAGE_SIZE) and feed
into queue.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 include/linux/swap.h |  1 -
 mm/swapfile.c        | 12 +-----------
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index f53d608daa01..a5b640cca459 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -301,7 +301,6 @@ struct swap_info_struct {
 	struct file *bdev_file;		/* open handle of the bdev */
 	struct block_device *bdev;	/* swap device or bdev of swap file */
 	struct file *swap_file;		/* seldom referenced */
-	unsigned int old_block_size;	/* seldom referenced */
 	struct completion comp;		/* seldom referenced */
 	spinlock_t lock;		/*
 					 * protect map scan related fields like
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 4919423cce76..304f74d039f3 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2417,7 +2417,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 	struct inode *inode;
 	struct filename *pathname;
 	int err, found = 0;
-	unsigned int old_block_size;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -2529,7 +2528,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 	}
 
 	swap_file = p->swap_file;
-	old_block_size = p->old_block_size;
 	p->swap_file = NULL;
 	p->max = 0;
 	swap_map = p->swap_map;
@@ -2553,7 +2551,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 
 	inode = mapping->host;
 	if (p->bdev_file) {
-		set_blocksize(p->bdev, old_block_size);
 		fput(p->bdev_file);
 		p->bdev_file = NULL;
 	}
@@ -2782,21 +2779,15 @@ static struct swap_info_struct *alloc_swap_info(void)
 
 static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
 {
-	int error;
-
 	if (S_ISBLK(inode->i_mode)) {
 		p->bdev_file = bdev_file_open_by_dev(inode->i_rdev,
 				BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL);
 		if (IS_ERR(p->bdev_file)) {
-			error = PTR_ERR(p->bdev_file);
+			int error = PTR_ERR(p->bdev_file);
 			p->bdev_file = NULL;
 			return error;
 		}
 		p->bdev = file_bdev(p->bdev_file);
-		p->old_block_size = block_size(p->bdev);
-		error = set_blocksize(p->bdev, PAGE_SIZE);
-		if (error < 0)
-			return error;
 		/*
 		 * Zoned block devices contain zones that have a sequential
 		 * write only restriction.  Hence zoned block devices are not
@@ -3235,7 +3226,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 	free_percpu(p->cluster_next_cpu);
 	p->cluster_next_cpu = NULL;
 	if (p->bdev_file) {
-		set_blocksize(p->bdev, p->old_block_size);
 		fput(p->bdev_file);
 		p->bdev_file = NULL;
 	}
-- 
2.39.2


  parent reply	other threads:[~2024-05-03  4:17 UTC|newest]

Thread overview: 41+ 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  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     ` Al Viro [this message]
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=20240503041740.2404425-3-viro@zeniv.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.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).