Skip to content

Commit 798cb7f

Browse files
author
Al Viro
committed
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 <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 3a52c03 commit 798cb7f

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

include/linux/swap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ struct swap_info_struct {
301301
struct file *bdev_file; /* open handle of the bdev */
302302
struct block_device *bdev; /* swap device or bdev of swap file */
303303
struct file *swap_file; /* seldom referenced */
304-
unsigned int old_block_size; /* seldom referenced */
305304
struct completion comp; /* seldom referenced */
306305
spinlock_t lock; /*
307306
* protect map scan related fields like

mm/swapfile.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
24172417
struct inode *inode;
24182418
struct filename *pathname;
24192419
int err, found = 0;
2420-
unsigned int old_block_size;
24212420

24222421
if (!capable(CAP_SYS_ADMIN))
24232422
return -EPERM;
@@ -2529,7 +2528,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
25292528
}
25302529

25312530
swap_file = p->swap_file;
2532-
old_block_size = p->old_block_size;
25332531
p->swap_file = NULL;
25342532
p->max = 0;
25352533
swap_map = p->swap_map;
@@ -2553,7 +2551,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
25532551

25542552
inode = mapping->host;
25552553
if (p->bdev_file) {
2556-
set_blocksize(p->bdev, old_block_size);
25572554
fput(p->bdev_file);
25582555
p->bdev_file = NULL;
25592556
}
@@ -2782,21 +2779,15 @@ static struct swap_info_struct *alloc_swap_info(void)
27822779

27832780
static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
27842781
{
2785-
int error;
2786-
27872782
if (S_ISBLK(inode->i_mode)) {
27882783
p->bdev_file = bdev_file_open_by_dev(inode->i_rdev,
27892784
BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL);
27902785
if (IS_ERR(p->bdev_file)) {
2791-
error = PTR_ERR(p->bdev_file);
2786+
int error = PTR_ERR(p->bdev_file);
27922787
p->bdev_file = NULL;
27932788
return error;
27942789
}
27952790
p->bdev = file_bdev(p->bdev_file);
2796-
p->old_block_size = block_size(p->bdev);
2797-
error = set_blocksize(p->bdev, PAGE_SIZE);
2798-
if (error < 0)
2799-
return error;
28002791
/*
28012792
* Zoned block devices contain zones that have a sequential
28022793
* write only restriction. Hence zoned block devices are not
@@ -3235,7 +3226,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
32353226
free_percpu(p->cluster_next_cpu);
32363227
p->cluster_next_cpu = NULL;
32373228
if (p->bdev_file) {
3238-
set_blocksize(p->bdev, p->old_block_size);
32393229
fput(p->bdev_file);
32403230
p->bdev_file = NULL;
32413231
}

0 commit comments

Comments
 (0)