Commit 798cb7f9 authored by Al Viro's avatar Al Viro

swapon(2)/swapoff(2): don't bother with block size

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 3a52c03d
...@@ -301,7 +301,6 @@ struct swap_info_struct { ...@@ -301,7 +301,6 @@ struct swap_info_struct {
struct file *bdev_file; /* open handle of the bdev */ struct file *bdev_file; /* open handle of the bdev */
struct block_device *bdev; /* swap device or bdev of swap file */ struct block_device *bdev; /* swap device or bdev of swap file */
struct file *swap_file; /* seldom referenced */ struct file *swap_file; /* seldom referenced */
unsigned int old_block_size; /* seldom referenced */
struct completion comp; /* seldom referenced */ struct completion comp; /* seldom referenced */
spinlock_t lock; /* spinlock_t lock; /*
* protect map scan related fields like * protect map scan related fields like
......
...@@ -2417,7 +2417,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) ...@@ -2417,7 +2417,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
struct inode *inode; struct inode *inode;
struct filename *pathname; struct filename *pathname;
int err, found = 0; int err, found = 0;
unsigned int old_block_size;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
...@@ -2529,7 +2528,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) ...@@ -2529,7 +2528,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
} }
swap_file = p->swap_file; swap_file = p->swap_file;
old_block_size = p->old_block_size;
p->swap_file = NULL; p->swap_file = NULL;
p->max = 0; p->max = 0;
swap_map = p->swap_map; swap_map = p->swap_map;
...@@ -2553,7 +2551,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) ...@@ -2553,7 +2551,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
inode = mapping->host; inode = mapping->host;
if (p->bdev_file) { if (p->bdev_file) {
set_blocksize(p->bdev, old_block_size);
fput(p->bdev_file); fput(p->bdev_file);
p->bdev_file = NULL; p->bdev_file = NULL;
} }
...@@ -2782,21 +2779,15 @@ static struct swap_info_struct *alloc_swap_info(void) ...@@ -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) static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
{ {
int error;
if (S_ISBLK(inode->i_mode)) { if (S_ISBLK(inode->i_mode)) {
p->bdev_file = bdev_file_open_by_dev(inode->i_rdev, p->bdev_file = bdev_file_open_by_dev(inode->i_rdev,
BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL); BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL);
if (IS_ERR(p->bdev_file)) { if (IS_ERR(p->bdev_file)) {
error = PTR_ERR(p->bdev_file); int error = PTR_ERR(p->bdev_file);
p->bdev_file = NULL; p->bdev_file = NULL;
return error; return error;
} }
p->bdev = file_bdev(p->bdev_file); 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 * Zoned block devices contain zones that have a sequential
* write only restriction. Hence zoned block devices are not * write only restriction. Hence zoned block devices are not
...@@ -3235,7 +3226,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) ...@@ -3235,7 +3226,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
free_percpu(p->cluster_next_cpu); free_percpu(p->cluster_next_cpu);
p->cluster_next_cpu = NULL; p->cluster_next_cpu = NULL;
if (p->bdev_file) { if (p->bdev_file) {
set_blocksize(p->bdev, p->old_block_size);
fput(p->bdev_file); fput(p->bdev_file);
p->bdev_file = NULL; p->bdev_file = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment