swapon(2)/swapoff(2): don't bother with block size
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 17 Apr 2024 22:26:54 +0000 (18:26 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 2 May 2024 21:23:30 +0000 (17:23 -0400)
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
mm/swapfile.c

index f53d608daa013176fc339366820d4dbd1548e635..a5b640cca459975351ba25afd36ee847563c5c12 100644 (file)
@@ -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
index 4919423cce76a3a44a2f26e6f31e2fd7c3577e0a..304f74d039f3ecbe521d27ef4ebfb20f2348dd8a 100644 (file)
@@ -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 @@ bad_swap:
        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;
        }