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: Christoph Hellwig <hch@lst.de> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3a52c03d1e
commit
798cb7f9ae
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user