diff options
author | Cesar Eduardo Barros <cesarb@cesarb.net> | 2011-03-22 19:33:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:07 -0400 |
commit | 83ef99befc324803a54cf2a5fab5a322df3a99d6 (patch) | |
tree | d56035f4683a387ac8bf0d37b21b15f7d04de672 /mm | |
parent | 28b36bd741bd44db30e12b1048a659aa346e9b76 (diff) |
sys_swapon: remove did_down variable
Since mutex_lock(&inode->i_mutex) is called just after setting inode,
did_down is always equivalent to (inode && S_ISREG(inode->i_mode)).
Use this fact to remove the did_down 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')
-rw-r--r-- | mm/swapfile.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 6f25ece88c4a..b261e55e0b82 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1907,7 +1907,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
1907 | unsigned char *swap_map = NULL; | 1907 | unsigned char *swap_map = NULL; |
1908 | struct page *page = NULL; | 1908 | struct page *page = NULL; |
1909 | struct inode *inode = NULL; | 1909 | struct inode *inode = NULL; |
1910 | int did_down = 0; | ||
1911 | 1910 | ||
1912 | if (!capable(CAP_SYS_ADMIN)) | 1911 | if (!capable(CAP_SYS_ADMIN)) |
1913 | return -EPERM; | 1912 | return -EPERM; |
@@ -1962,7 +1961,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
1962 | } else if (S_ISREG(inode->i_mode)) { | 1961 | } else if (S_ISREG(inode->i_mode)) { |
1963 | p->bdev = inode->i_sb->s_bdev; | 1962 | p->bdev = inode->i_sb->s_bdev; |
1964 | mutex_lock(&inode->i_mutex); | 1963 | mutex_lock(&inode->i_mutex); |
1965 | did_down = 1; | ||
1966 | if (IS_SWAPFILE(inode)) { | 1964 | if (IS_SWAPFILE(inode)) { |
1967 | error = -EBUSY; | 1965 | error = -EBUSY; |
1968 | goto bad_swap; | 1966 | goto bad_swap; |
@@ -2154,10 +2152,8 @@ bad_swap_2: | |||
2154 | spin_unlock(&swap_lock); | 2152 | spin_unlock(&swap_lock); |
2155 | vfree(swap_map); | 2153 | vfree(swap_map); |
2156 | if (swap_file) { | 2154 | if (swap_file) { |
2157 | if (did_down) { | 2155 | if (inode && S_ISREG(inode->i_mode)) |
2158 | mutex_unlock(&inode->i_mutex); | 2156 | mutex_unlock(&inode->i_mutex); |
2159 | did_down = 0; | ||
2160 | } | ||
2161 | filp_close(swap_file, NULL); | 2157 | filp_close(swap_file, NULL); |
2162 | } | 2158 | } |
2163 | out: | 2159 | out: |
@@ -2167,7 +2163,7 @@ out: | |||
2167 | } | 2163 | } |
2168 | if (name) | 2164 | if (name) |
2169 | putname(name); | 2165 | putname(name); |
2170 | if (did_down) { | 2166 | if (inode && S_ISREG(inode->i_mode)) { |
2171 | if (!error) | 2167 | if (!error) |
2172 | inode->i_flags |= S_SWAPFILE; | 2168 | inode->i_flags |= S_SWAPFILE; |
2173 | mutex_unlock(&inode->i_mutex); | 2169 | mutex_unlock(&inode->i_mutex); |