Commit df6a148f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] bdev: move i_mapping -> f_mapping conversions

From: viro@parcelfarce.linux.theplanet.co.uk <viro@parcelfarce.linux.theplanet.co.uk>

More uses of ->i_mapping switched to uses of ->f_mapping - stuff that was not
caught by the earlier f_mapping conversion.
parent 54df7662
...@@ -93,17 +93,13 @@ static unsigned long get_shared_area(struct address_space *mapping, ...@@ -93,17 +93,13 @@ static unsigned long get_shared_area(struct address_space *mapping,
unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags) unsigned long len, unsigned long pgoff, unsigned long flags)
{ {
struct inode *inode;
if (len > TASK_SIZE) if (len > TASK_SIZE)
return -ENOMEM; return -ENOMEM;
if (!addr) if (!addr)
addr = TASK_UNMAPPED_BASE; addr = TASK_UNMAPPED_BASE;
inode = filp ? filp->f_dentry->d_inode : NULL; if (filp && (flags & MAP_SHARED)) {
addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
if (inode && (flags & MAP_SHARED)) {
addr = get_shared_area(inode->i_mapping, addr, len, pgoff);
} else { } else {
addr = get_unshared_area(addr, len); addr = get_unshared_area(addr, len);
} }
......
...@@ -659,6 +659,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -659,6 +659,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
struct file *file; struct file *file;
struct inode *inode; struct inode *inode;
struct block_device *lo_device = NULL; struct block_device *lo_device = NULL;
struct address_space *mapping;
unsigned lo_blocksize; unsigned lo_blocksize;
int lo_flags = 0; int lo_flags = 0;
int error; int error;
...@@ -675,7 +676,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -675,7 +676,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
if (!file) if (!file)
goto out; goto out;
inode = file->f_dentry->d_inode; mapping = file->f_mapping;
inode = mapping->host;
if (!(file->f_mode & FMODE_WRITE)) if (!(file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY; lo_flags |= LO_FLAGS_READ_ONLY;
...@@ -690,7 +692,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -690,7 +692,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
if (bdev_read_only(lo_device)) if (bdev_read_only(lo_device))
lo_flags |= LO_FLAGS_READ_ONLY; lo_flags |= LO_FLAGS_READ_ONLY;
} else if (S_ISREG(inode->i_mode)) { } else if (S_ISREG(inode->i_mode)) {
struct address_space_operations *aops = inode->i_mapping->a_ops; struct address_space_operations *aops = mapping->a_ops;
/* /*
* If we can't read - sorry. If we only can't write - well, * If we can't read - sorry. If we only can't write - well,
* it's going to be read-only. * it's going to be read-only.
...@@ -724,9 +726,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -724,9 +726,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
error = -EFBIG; error = -EFBIG;
goto out_putf; goto out_putf;
} }
lo->old_gfp_mask = mapping_gfp_mask(inode->i_mapping); lo->old_gfp_mask = mapping_gfp_mask(mapping);
mapping_set_gfp_mask(inode->i_mapping, mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
lo->lo_bio = lo->lo_biotail = NULL; lo->lo_bio = lo->lo_biotail = NULL;
......
...@@ -229,8 +229,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg) ...@@ -229,8 +229,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
arg |= O_NONBLOCK; arg |= O_NONBLOCK;
if (arg & O_DIRECT) { if (arg & O_DIRECT) {
if (!inode->i_mapping || !inode->i_mapping->a_ops || if (!filp->f_mapping || !filp->f_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO) !filp->f_mapping->a_ops->direct_IO)
return -EINVAL; return -EINVAL;
} }
......
...@@ -22,7 +22,7 @@ static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg) ...@@ -22,7 +22,7 @@ static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
switch (cmd) { switch (cmd) {
case FIBMAP: case FIBMAP:
{ {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = filp->f_mapping;
int res; int res;
/* do we support this mess? */ /* do we support this mess? */
if (!mapping->a_ops->bmap) if (!mapping->a_ops->bmap)
......
...@@ -1454,7 +1454,7 @@ int fcntl_setlk(struct file *filp, unsigned int cmd, struct flock __user *l) ...@@ -1454,7 +1454,7 @@ int fcntl_setlk(struct file *filp, unsigned int cmd, struct flock __user *l)
*/ */
if (IS_MANDLOCK(inode) && if (IS_MANDLOCK(inode) &&
(inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) { (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = filp->f_mapping;
if (!list_empty(&mapping->i_mmap_shared)) { if (!list_empty(&mapping->i_mmap_shared)) {
error = -EAGAIN; error = -EAGAIN;
...@@ -1592,7 +1592,7 @@ int fcntl_setlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) ...@@ -1592,7 +1592,7 @@ int fcntl_setlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
*/ */
if (IS_MANDLOCK(inode) && if (IS_MANDLOCK(inode) &&
(inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) { (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = filp->f_mapping;
if (!list_empty(&mapping->i_mmap_shared)) { if (!list_empty(&mapping->i_mmap_shared)) {
error = -EAGAIN; error = -EAGAIN;
......
...@@ -793,8 +793,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) ...@@ -793,8 +793,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
/* NB: we're sure to have correct a_ops only after f_op->open */ /* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) { if (f->f_flags & O_DIRECT) {
if (!inode->i_mapping || !inode->i_mapping->a_ops || if (!f->f_mapping || !f->f_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO) { !f->f_mapping->a_ops->direct_IO) {
fput(f); fput(f);
f = ERR_PTR(-EINVAL); f = ERR_PTR(-EINVAL);
} }
......
...@@ -316,9 +316,9 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) ...@@ -316,9 +316,9 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
atomic_dec(&inode->i_writecount); atomic_dec(&inode->i_writecount);
/* insert tmp into the share list, just after mpnt */ /* insert tmp into the share list, just after mpnt */
down(&inode->i_mapping->i_shared_sem); down(&file->f_mapping->i_shared_sem);
list_add_tail(&tmp->shared, &mpnt->shared); list_add_tail(&tmp->shared, &mpnt->shared);
up(&inode->i_mapping->i_shared_sem); up(&file->f_mapping->i_shared_sem);
} }
/* /*
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
struct inode *inode;
struct address_space *mapping; struct address_space *mapping;
struct backing_dev_info *bdi; struct backing_dev_info *bdi;
pgoff_t start_index; pgoff_t start_index;
...@@ -33,8 +32,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) ...@@ -33,8 +32,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
if (!file) if (!file)
return -EBADF; return -EBADF;
inode = file->f_dentry->d_inode; mapping = file->f_mapping;
mapping = inode->i_mapping;
if (!mapping) { if (!mapping) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
......
...@@ -80,11 +80,10 @@ static void remove_shared_vm_struct(struct vm_area_struct *vma) ...@@ -80,11 +80,10 @@ static void remove_shared_vm_struct(struct vm_area_struct *vma)
struct file *file = vma->vm_file; struct file *file = vma->vm_file;
if (file) { if (file) {
struct inode *inode = file->f_dentry->d_inode; struct address_space *mapping = file->f_mapping;
down(&mapping->i_shared_sem);
down(&inode->i_mapping->i_shared_sem); __remove_shared_vm_struct(vma, file->f_dentry->d_inode);
__remove_shared_vm_struct(vma, inode); up(&mapping->i_shared_sem);
up(&inode->i_mapping->i_shared_sem);
} }
} }
...@@ -235,11 +234,10 @@ static inline void __vma_link_file(struct vm_area_struct *vma) ...@@ -235,11 +234,10 @@ static inline void __vma_link_file(struct vm_area_struct *vma)
file = vma->vm_file; file = vma->vm_file;
if (file) { if (file) {
struct inode * inode = file->f_dentry->d_inode; struct address_space *mapping = file->f_mapping;
struct address_space *mapping = inode->i_mapping;
if (vma->vm_flags & VM_DENYWRITE) if (vma->vm_flags & VM_DENYWRITE)
atomic_dec(&inode->i_writecount); atomic_dec(&file->f_dentry->d_inode->i_writecount);
if (vma->vm_flags & VM_SHARED) if (vma->vm_flags & VM_SHARED)
list_add_tail(&vma->shared, &mapping->i_mmap_shared); list_add_tail(&vma->shared, &mapping->i_mmap_shared);
...@@ -383,7 +381,7 @@ static int vma_merge(struct mm_struct *mm, struct vm_area_struct *prev, ...@@ -383,7 +381,7 @@ static int vma_merge(struct mm_struct *mm, struct vm_area_struct *prev,
if (vm_flags & VM_SPECIAL) if (vm_flags & VM_SPECIAL)
return 0; return 0;
i_shared_sem = file ? &inode->i_mapping->i_shared_sem : NULL; i_shared_sem = file ? &file->f_mapping->i_shared_sem : NULL;
if (!prev) { if (!prev) {
prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb); prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
...@@ -1207,7 +1205,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma, ...@@ -1207,7 +1205,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
new->vm_ops->open(new); new->vm_ops->open(new);
if (vma->vm_file) if (vma->vm_file)
mapping = vma->vm_file->f_dentry->d_inode->i_mapping; mapping = vma->vm_file->f_mapping;
if (mapping) if (mapping)
down(&mapping->i_shared_sem); down(&mapping->i_shared_sem);
......
...@@ -912,7 +912,7 @@ static int setup_swap_extents(struct swap_info_struct *sis) ...@@ -912,7 +912,7 @@ static int setup_swap_extents(struct swap_info_struct *sis)
sector_t last_block; sector_t last_block;
int ret; int ret;
inode = sis->swap_file->f_dentry->d_inode; inode = sis->swap_file->f_mapping->host;
if (S_ISBLK(inode->i_mode)) { if (S_ISBLK(inode->i_mode)) {
ret = add_swap_extent(sis, 0, sis->max, 0); ret = add_swap_extent(sis, 0, sis->max, 0);
goto done; goto done;
...@@ -1099,13 +1099,13 @@ asmlinkage long sys_swapoff(const char __user * specialfile) ...@@ -1099,13 +1099,13 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
swap_device_unlock(p); swap_device_unlock(p);
swap_list_unlock(); swap_list_unlock();
vfree(swap_map); vfree(swap_map);
if (S_ISBLK(swap_file->f_dentry->d_inode->i_mode)) { if (S_ISBLK(mapping->host->i_mode)) {
struct block_device *bdev; struct block_device *bdev;
bdev = swap_file->f_dentry->d_inode->i_bdev; bdev = mapping->host->i_bdev;
set_blocksize(bdev, p->old_block_size); set_blocksize(bdev, p->old_block_size);
bd_release(bdev); bd_release(bdev);
} else { } else {
up(&swap_file->f_mapping->host->i_sem); up(&mapping->host->i_sem);
} }
filp_close(swap_file, NULL); filp_close(swap_file, NULL);
err = 0; err = 0;
...@@ -1231,8 +1231,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1231,8 +1231,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
int swapfilesize; int swapfilesize;
unsigned short *swap_map; unsigned short *swap_map;
struct page *page = NULL; struct page *page = NULL;
struct inode *inode; struct inode *inode = NULL;
struct inode *downed_inode = NULL; int did_down = 0;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
...@@ -1279,8 +1279,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1279,8 +1279,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
} }
p->swap_file = swap_file; p->swap_file = swap_file;
inode = swap_file->f_dentry->d_inode;
mapping = swap_file->f_mapping; mapping = swap_file->f_mapping;
inode = mapping->host;
error = -EBUSY; error = -EBUSY;
for (i = 0; i < nr_swapfiles; i++) { for (i = 0; i < nr_swapfiles; i++) {
...@@ -1307,13 +1307,13 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1307,13 +1307,13 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
p->bdev = bdev; p->bdev = bdev;
} else if (S_ISREG(inode->i_mode)) { } else if (S_ISREG(inode->i_mode)) {
p->bdev = inode->i_sb->s_bdev; p->bdev = inode->i_sb->s_bdev;
downed_inode = mapping->host; down(&inode->i_sem);
down(&downed_inode->i_sem); did_down = 1;
} else { } else {
goto bad_swap; goto bad_swap;
} }
swapfilesize = i_size_read(mapping->host) >> PAGE_SHIFT; swapfilesize = i_size_read(inode) >> PAGE_SHIFT;
/* /*
* Read the swap header. * Read the swap header.
...@@ -1465,8 +1465,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1465,8 +1465,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
} }
if (name) if (name)
putname(name); putname(name);
if (error && downed_inode) if (error && did_down)
up(&downed_inode->i_sem); up(&inode->i_sem);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment