aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2011-03-22 19:33:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:07 -0400
commitf2090d2df51d7cdb2f952dcfdcd8baaac0aec444 (patch)
tree474daba281f890d44ee22b23137d99cb5021f381 /mm/swapfile.c
parent7de7fb6b3422e6d1dac00666a992834085e745dc (diff)
sys_swapon: remove bdev variable
The bdev variable is always equivalent to (S_ISBLK(inode->i_mode) ? p->bdev : NULL), as long as it being set is moved to a bit earlier. Use this fact to remove the bdev variable. Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net> Tested-by: Eric B Munson <emunson@mgebm.net> Acked-by: Eric B Munson <emunson@mgebm.net> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index e4dc94996c58..a314d42c0fa5 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1893,7 +1893,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1893{ 1893{
1894 struct swap_info_struct *p; 1894 struct swap_info_struct *p;
1895 char *name; 1895 char *name;
1896 struct block_device *bdev = NULL;
1897 struct file *swap_file = NULL; 1896 struct file *swap_file = NULL;
1898 struct address_space *mapping; 1897 struct address_space *mapping;
1899 int i, prev; 1898 int i, prev;
@@ -1944,19 +1943,19 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1944 } 1943 }
1945 1944
1946 if (S_ISBLK(inode->i_mode)) { 1945 if (S_ISBLK(inode->i_mode)) {
1947 bdev = bdgrab(I_BDEV(inode)); 1946 p->bdev = bdgrab(I_BDEV(inode));
1948 error = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, 1947 error = blkdev_get(p->bdev,
1948 FMODE_READ | FMODE_WRITE | FMODE_EXCL,
1949 sys_swapon); 1949 sys_swapon);
1950 if (error < 0) { 1950 if (error < 0) {
1951 bdev = NULL; 1951 p->bdev = NULL;
1952 error = -EINVAL; 1952 error = -EINVAL;
1953 goto bad_swap; 1953 goto bad_swap;
1954 } 1954 }
1955 p->old_block_size = block_size(bdev); 1955 p->old_block_size = block_size(p->bdev);
1956 error = set_blocksize(bdev, PAGE_SIZE); 1956 error = set_blocksize(p->bdev, PAGE_SIZE);
1957 if (error < 0) 1957 if (error < 0)
1958 goto bad_swap; 1958 goto bad_swap;
1959 p->bdev = bdev;
1960 p->flags |= SWP_BLKDEV; 1959 p->flags |= SWP_BLKDEV;
1961 } else if (S_ISREG(inode->i_mode)) { 1960 } else if (S_ISREG(inode->i_mode)) {
1962 p->bdev = inode->i_sb->s_bdev; 1961 p->bdev = inode->i_sb->s_bdev;
@@ -2140,9 +2139,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2140 error = 0; 2139 error = 0;
2141 goto out; 2140 goto out;
2142bad_swap: 2141bad_swap:
2143 if (bdev) { 2142 if (S_ISBLK(inode->i_mode) && p->bdev) {
2144 set_blocksize(bdev, p->old_block_size); 2143 set_blocksize(p->bdev, p->old_block_size);
2145 blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 2144 blkdev_put(p->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
2146 } 2145 }
2147 destroy_swap_extents(p); 2146 destroy_swap_extents(p);
2148 swap_cgroup_swapoff(p->type); 2147 swap_cgroup_swapoff(p->type);