summaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-05 06:47:02 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-05 06:47:02 +0000
commit99a7e12f34b3661a0d1354eef83a0eef4df5e34c (patch)
tree3560aca9ca86792f9ab7bd87861ea143a1b3c7a3 /mm/swapfile.c
parente73a04659c0b8cdee4dd40e58630e2cf63afb316 (diff)
Merge with Linux 2.3.38.
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 5d761bb40..53a561201 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -444,7 +444,6 @@ asmlinkage long sys_swapoff(const char * specialfile)
{
struct swap_info_struct * p = NULL;
struct dentry * dentry;
- struct file filp;
int i, type, prev;
int err = -EPERM;
@@ -508,17 +507,8 @@ asmlinkage long sys_swapoff(const char * specialfile)
p->flags = SWP_WRITEOK;
goto out_dput;
}
- if(p->swap_device){
- memset(&filp, 0, sizeof(filp));
- filp.f_dentry = dentry;
- filp.f_mode = 3; /* read write */
- /* open it again to get fops */
- if( !blkdev_open(dentry->d_inode, &filp) &&
- filp.f_op && filp.f_op->release){
- filp.f_op->release(dentry->d_inode,&filp);
- filp.f_op->release(dentry->d_inode,&filp);
- }
- }
+ if (p->swap_device)
+ blkdev_put(dentry->d_inode->i_bdev, BDEV_SWAP);
dput(dentry);
dentry = p->swap_file;
@@ -598,18 +588,17 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
unsigned int type;
int i, j, prev;
int error = -EPERM;
- struct file filp;
static int least_priority = 0;
union swap_header *swap_header = 0;
int swap_header_version;
int nr_good_pages = 0;
unsigned long maxpages;
int swapfilesize;
+ struct block_device *bdev = NULL;
lock_kernel();
if (!capable(CAP_SYS_ADMIN))
goto out;
- memset(&filp, 0, sizeof(filp));
p = swap_info;
for (type = 0 ; type < nr_swapfiles ; type++,p++)
if (!(p->flags & SWP_USED))
@@ -648,9 +637,9 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
p->swap_device = dev;
set_blocksize(dev, PAGE_SIZE);
- filp.f_dentry = swap_dentry;
- filp.f_mode = 3; /* read write */
- error = blkdev_open(swap_dentry->d_inode, &filp);
+ bdev = swap_dentry->d_inode->i_bdev;
+
+ error = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_SWAP);
if (error)
goto bad_swap_2;
set_blocksize(dev, PAGE_SIZE);
@@ -812,8 +801,8 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
error = 0;
goto out;
bad_swap:
- if(filp.f_op && filp.f_op->release)
- filp.f_op->release(filp.f_dentry->d_inode,&filp);
+ if (bdev)
+ blkdev_put(bdev, BDEV_SWAP);
bad_swap_2:
if (p->swap_map)
vfree(p->swap_map);