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,
unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
struct inode *inode;
if (len > TASK_SIZE)
return -ENOMEM;
if (!addr)
addr = TASK_UNMAPPED_BASE;
inode = filp ? filp->f_dentry->d_inode : NULL;
if (inode && (flags & MAP_SHARED)) {
addr = get_shared_area(inode->i_mapping, addr, len, pgoff);
if (filp && (flags & MAP_SHARED)) {
addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
} else {
addr = get_unshared_area(addr, len);
}
......
......@@ -659,6 +659,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
struct file *file;
struct inode *inode;
struct block_device *lo_device = NULL;
struct address_space *mapping;
unsigned lo_blocksize;
int lo_flags = 0;
int error;
......@@ -675,7 +676,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
if (!file)
goto out;
inode = file->f_dentry->d_inode;
mapping = file->f_mapping;
inode = mapping->host;
if (!(file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY;
......@@ -690,7 +692,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
if (bdev_read_only(lo_device))
lo_flags |= LO_FLAGS_READ_ONLY;
} 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,
* it's going to be read-only.
......@@ -724,9 +726,8 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
error = -EFBIG;
goto out_putf;
}
lo->old_gfp_mask = mapping_gfp_mask(inode->i_mapping);
mapping_set_gfp_mask(inode->i_mapping,
lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
lo->old_gfp_mask = mapping_gfp_mask(mapping);
mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
lo->lo_bio = lo->lo_biotail = NULL;
......
......@@ -229,8 +229,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
arg |= O_NONBLOCK;
if (arg & O_DIRECT) {
if (!inode->i_mapping || !inode->i_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO)
if (!filp->f_mapping || !filp->f_mapping->a_ops ||
!filp->f_mapping->a_ops->direct_IO)
return -EINVAL;
}
......
......@@ -22,7 +22,7 @@ static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
switch (cmd) {
case FIBMAP:
{
struct address_space *mapping = inode->i_mapping;
struct address_space *mapping = filp->f_mapping;
int res;
/* do we support this mess? */
if (!mapping->a_ops->bmap)
......
......@@ -1454,7 +1454,7 @@ int fcntl_setlk(struct file *filp, unsigned int cmd, struct flock __user *l)
*/
if (IS_MANDLOCK(inode) &&
(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)) {
error = -EAGAIN;
......@@ -1592,7 +1592,7 @@ int fcntl_setlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
*/
if (IS_MANDLOCK(inode) &&
(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)) {
error = -EAGAIN;
......
......@@ -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 */
if (f->f_flags & O_DIRECT) {
if (!inode->i_mapping || !inode->i_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO) {
if (!f->f_mapping || !f->f_mapping->a_ops ||
!f->f_mapping->a_ops->direct_IO) {
fput(f);
f = ERR_PTR(-EINVAL);
}
......
......@@ -316,9 +316,9 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
atomic_dec(&inode->i_writecount);
/* 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);
up(&inode->i_mapping->i_shared_sem);
up(&file->f_mapping->i_shared_sem);
}
/*
......
......@@ -23,7 +23,6 @@
asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
{
struct file *file = fget(fd);
struct inode *inode;
struct address_space *mapping;
struct backing_dev_info *bdi;
pgoff_t start_index;
......@@ -33,8 +32,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
if (!file)
return -EBADF;
inode = file->f_dentry->d_inode;
mapping = inode->i_mapping;
mapping = file->f_mapping;
if (!mapping) {
ret = -EINVAL;
goto out;
......
......@@ -80,11 +80,10 @@ static void remove_shared_vm_struct(struct vm_area_struct *vma)
struct file *file = vma->vm_file;
if (file) {
struct inode *inode = file->f_dentry->d_inode;
down(&inode->i_mapping->i_shared_sem);
__remove_shared_vm_struct(vma, inode);
up(&inode->i_mapping->i_shared_sem);
struct address_space *mapping = file->f_mapping;
down(&mapping->i_shared_sem);
__remove_shared_vm_struct(vma, file->f_dentry->d_inode);
up(&mapping->i_shared_sem);
}
}
......@@ -235,11 +234,10 @@ static inline void __vma_link_file(struct vm_area_struct *vma)
file = vma->vm_file;
if (file) {
struct inode * inode = file->f_dentry->d_inode;
struct address_space *mapping = inode->i_mapping;
struct address_space *mapping = file->f_mapping;
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)
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,
if (vm_flags & VM_SPECIAL)
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) {
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,
new->vm_ops->open(new);
if (vma->vm_file)
mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
mapping = vma->vm_file->f_mapping;
if (mapping)
down(&mapping->i_shared_sem);
......
......@@ -912,7 +912,7 @@ static int setup_swap_extents(struct swap_info_struct *sis)
sector_t last_block;
int ret;
inode = sis->swap_file->f_dentry->d_inode;
inode = sis->swap_file->f_mapping->host;
if (S_ISBLK(inode->i_mode)) {
ret = add_swap_extent(sis, 0, sis->max, 0);
goto done;
......@@ -1099,13 +1099,13 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
swap_device_unlock(p);
swap_list_unlock();
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;
bdev = swap_file->f_dentry->d_inode->i_bdev;
bdev = mapping->host->i_bdev;
set_blocksize(bdev, p->old_block_size);
bd_release(bdev);
} else {
up(&swap_file->f_mapping->host->i_sem);
up(&mapping->host->i_sem);
}
filp_close(swap_file, NULL);
err = 0;
......@@ -1231,8 +1231,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
int swapfilesize;
unsigned short *swap_map;
struct page *page = NULL;
struct inode *inode;
struct inode *downed_inode = NULL;
struct inode *inode = NULL;
int did_down = 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
......@@ -1279,8 +1279,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
}
p->swap_file = swap_file;
inode = swap_file->f_dentry->d_inode;
mapping = swap_file->f_mapping;
inode = mapping->host;
error = -EBUSY;
for (i = 0; i < nr_swapfiles; i++) {
......@@ -1307,13 +1307,13 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
p->bdev = bdev;
} else if (S_ISREG(inode->i_mode)) {
p->bdev = inode->i_sb->s_bdev;
downed_inode = mapping->host;
down(&downed_inode->i_sem);
down(&inode->i_sem);
did_down = 1;
} else {
goto bad_swap;
}
swapfilesize = i_size_read(mapping->host) >> PAGE_SHIFT;
swapfilesize = i_size_read(inode) >> PAGE_SHIFT;
/*
* Read the swap header.
......@@ -1465,8 +1465,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
}
if (name)
putname(name);
if (error && downed_inode)
up(&downed_inode->i_sem);
if (error && did_down)
up(&inode->i_sem);
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