Commit 32d66678 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] bdev: switch to f_mapping

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

A lot of places used to use ->f_dentry->d_inode->i_mapping all over the
place.  Replaced with use of ->f_mapping.  For now - just the places where we
literally could do search-and-replace.
parent dd503c67
...@@ -140,8 +140,7 @@ figure_loop_size(struct loop_device *lo) ...@@ -140,8 +140,7 @@ figure_loop_size(struct loop_device *lo)
sector_t x; sector_t x;
/* Compute loopsize in bytes */ /* Compute loopsize in bytes */
size = i_size_read(lo->lo_backing_file->f_dentry-> size = i_size_read(lo->lo_backing_file->f_mapping->host);
d_inode->i_mapping->host);
offset = lo->lo_offset; offset = lo->lo_offset;
loopsize = size - offset; loopsize = size - offset;
if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
...@@ -175,7 +174,7 @@ static int ...@@ -175,7 +174,7 @@ static int
do_lo_send(struct loop_device *lo, struct bio_vec *bvec, int bsize, loff_t pos) do_lo_send(struct loop_device *lo, struct bio_vec *bvec, int bsize, loff_t pos)
{ {
struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */ struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct address_space_operations *aops = mapping->a_ops; struct address_space_operations *aops = mapping->a_ops;
struct page *page; struct page *page;
char *kaddr, *data; char *kaddr, *data;
...@@ -842,7 +841,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev) ...@@ -842,7 +841,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
memset(lo->lo_file_name, 0, LO_NAME_SIZE); memset(lo->lo_file_name, 0, LO_NAME_SIZE);
invalidate_bdev(bdev, 0); invalidate_bdev(bdev, 0);
set_capacity(disks[lo->lo_number], 0); set_capacity(disks[lo->lo_number], 0);
mapping_set_gfp_mask(filp->f_dentry->d_inode->i_mapping, gfp); mapping_set_gfp_mask(filp->f_mapping, gfp);
lo->lo_state = Lo_unbound; lo->lo_state = Lo_unbound;
fput(filp); fput(filp);
/* This is safe: open() is still holding a reference. */ /* This is safe: open() is still holding a reference. */
......
...@@ -128,7 +128,7 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ...@@ -128,7 +128,7 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs) loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
return blockdev_direct_IO(rw, iocb, inode, inode->i_bdev, iov, offset, return blockdev_direct_IO(rw, iocb, inode, inode->i_bdev, iov, offset,
nr_segs, blkdev_get_blocks, NULL); nr_segs, blkdev_get_blocks, NULL);
......
...@@ -659,7 +659,7 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ...@@ -659,7 +659,7 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs) loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, ext2_get_blocks, NULL); offset, nr_segs, ext2_get_blocks, NULL);
......
...@@ -1532,7 +1532,7 @@ static int ext3_direct_IO(int rw, struct kiocb *iocb, ...@@ -1532,7 +1532,7 @@ static int ext3_direct_IO(int rw, struct kiocb *iocb,
unsigned long nr_segs) unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
struct ext3_inode_info *ei = EXT3_I(inode); struct ext3_inode_info *ei = EXT3_I(inode);
handle_t *handle = NULL; handle_t *handle = NULL;
int ret; int ret;
......
...@@ -306,7 +306,7 @@ static int jfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ...@@ -306,7 +306,7 @@ static int jfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs) loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, jfs_get_blocks, NULL); offset, nr_segs, jfs_get_blocks, NULL);
......
...@@ -28,7 +28,7 @@ EXPORT_SYMBOL(generic_ro_fops); ...@@ -28,7 +28,7 @@ EXPORT_SYMBOL(generic_ro_fops);
loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
{ {
long long retval; long long retval;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
down(&inode->i_sem); down(&inode->i_sem);
switch (origin) { switch (origin) {
......
...@@ -2375,7 +2375,7 @@ static int reiserfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *io ...@@ -2375,7 +2375,7 @@ static int reiserfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *io
loff_t offset, unsigned long nr_segs) loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, reiserfs_get_blocks_direct_io, NULL); offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
......
...@@ -974,7 +974,7 @@ linvfs_direct_IO( ...@@ -974,7 +974,7 @@ linvfs_direct_IO(
unsigned long nr_segs) unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
page_buf_bmap_t pbmap; page_buf_bmap_t pbmap;
int maps = 1; int maps = 1;
......
...@@ -112,7 +112,7 @@ __linvfs_write( ...@@ -112,7 +112,7 @@ __linvfs_write(
{ {
struct iovec iov = {(void *)buf, count}; struct iovec iov = {(void *)buf, count};
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
int error; int error;
...@@ -160,7 +160,7 @@ __linvfs_readv( ...@@ -160,7 +160,7 @@ __linvfs_readv(
unsigned long nr_segs, unsigned long nr_segs,
loff_t *ppos) loff_t *ppos)
{ {
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
struct kiocb kiocb; struct kiocb kiocb;
int error; int error;
...@@ -207,7 +207,7 @@ __linvfs_writev( ...@@ -207,7 +207,7 @@ __linvfs_writev(
unsigned long nr_segs, unsigned long nr_segs,
loff_t *ppos) loff_t *ppos)
{ {
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
struct kiocb kiocb; struct kiocb kiocb;
int error; int error;
......
...@@ -1332,7 +1332,7 @@ static inline void do_generic_file_read(struct file * filp, loff_t *ppos, ...@@ -1332,7 +1332,7 @@ static inline void do_generic_file_read(struct file * filp, loff_t *ppos,
read_descriptor_t * desc, read_descriptor_t * desc,
read_actor_t actor) read_actor_t actor)
{ {
do_generic_mapping_read(filp->f_dentry->d_inode->i_mapping, do_generic_mapping_read(filp->f_mapping,
&filp->f_ra, &filp->f_ra,
filp, filp,
ppos, ppos,
......
...@@ -812,7 +812,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -812,7 +812,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
struct address_space *mapping; struct address_space *mapping;
struct inode *inode; struct inode *inode;
mapping = filp->f_dentry->d_inode->i_mapping; mapping = filp->f_mapping;
inode = mapping->host; inode = mapping->host;
retval = 0; retval = 0;
if (!count) if (!count)
...@@ -944,7 +944,7 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count) ...@@ -944,7 +944,7 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count)
file = fget(fd); file = fget(fd);
if (file) { if (file) {
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
unsigned long start = offset >> PAGE_CACHE_SHIFT; unsigned long start = offset >> PAGE_CACHE_SHIFT;
unsigned long end = (offset + count - 1) >> PAGE_CACHE_SHIFT; unsigned long end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
unsigned long len = end - start + 1; unsigned long len = end - start + 1;
...@@ -963,7 +963,7 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count) ...@@ -963,7 +963,7 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count)
static int FASTCALL(page_cache_read(struct file * file, unsigned long offset)); static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
static int page_cache_read(struct file * file, unsigned long offset) static int page_cache_read(struct file * file, unsigned long offset)
{ {
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct page *page; struct page *page;
int error; int error;
...@@ -1002,7 +1002,7 @@ struct page * filemap_nopage(struct vm_area_struct * area, unsigned long address ...@@ -1002,7 +1002,7 @@ struct page * filemap_nopage(struct vm_area_struct * area, unsigned long address
{ {
int error; int error;
struct file *file = area->vm_file; struct file *file = area->vm_file;
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct file_ra_state *ra = &file->f_ra; struct file_ra_state *ra = &file->f_ra;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct page *page; struct page *page;
...@@ -1187,7 +1187,7 @@ EXPORT_SYMBOL(filemap_nopage); ...@@ -1187,7 +1187,7 @@ EXPORT_SYMBOL(filemap_nopage);
static struct page * filemap_getpage(struct file *file, unsigned long pgoff, static struct page * filemap_getpage(struct file *file, unsigned long pgoff,
int nonblock) int nonblock)
{ {
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct page *page; struct page *page;
int error; int error;
...@@ -1299,7 +1299,7 @@ static int filemap_populate(struct vm_area_struct *vma, ...@@ -1299,7 +1299,7 @@ static int filemap_populate(struct vm_area_struct *vma,
int nonblock) int nonblock)
{ {
struct file *file = vma->vm_file; struct file *file = vma->vm_file;
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
unsigned long size; unsigned long size;
struct mm_struct *mm = vma->vm_mm; struct mm_struct *mm = vma->vm_mm;
...@@ -1358,7 +1358,7 @@ static struct vm_operations_struct generic_file_vm_ops = { ...@@ -1358,7 +1358,7 @@ static struct vm_operations_struct generic_file_vm_ops = {
int generic_file_mmap(struct file * file, struct vm_area_struct * vma) int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
{ {
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
if (!mapping->a_ops->readpage) if (!mapping->a_ops->readpage)
...@@ -1720,7 +1720,7 @@ generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov, ...@@ -1720,7 +1720,7 @@ generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t *ppos) unsigned long nr_segs, loff_t *ppos)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space * mapping = file->f_dentry->d_inode->i_mapping; struct address_space * mapping = file->f_mapping;
struct address_space_operations *a_ops = mapping->a_ops; struct address_space_operations *a_ops = mapping->a_ops;
size_t ocount; /* original count */ size_t ocount; /* original count */
size_t count; /* after file limit checks */ size_t count; /* after file limit checks */
...@@ -1920,7 +1920,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf, ...@@ -1920,7 +1920,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf,
size_t count, loff_t pos) size_t count, loff_t pos)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
ssize_t err; ssize_t err;
struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count }; struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
...@@ -1939,7 +1939,7 @@ EXPORT_SYMBOL(generic_file_aio_write); ...@@ -1939,7 +1939,7 @@ EXPORT_SYMBOL(generic_file_aio_write);
ssize_t generic_file_write(struct file *file, const char __user *buf, ssize_t generic_file_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct inode *inode = file->f_dentry->d_inode->i_mapping->host; struct inode *inode = file->f_mapping->host;
ssize_t err; ssize_t err;
struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count }; struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
...@@ -1986,7 +1986,7 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ...@@ -1986,7 +1986,7 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
loff_t offset, unsigned long nr_segs) loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_dentry->d_inode->i_mapping; struct address_space *mapping = file->f_mapping;
ssize_t retval; ssize_t retval;
if (mapping->nrpages) { if (mapping->nrpages) {
......
...@@ -65,7 +65,7 @@ static long madvise_willneed(struct vm_area_struct * vma, ...@@ -65,7 +65,7 @@ static long madvise_willneed(struct vm_area_struct * vma,
end = vma->vm_end; end = vma->vm_end;
end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
force_page_cache_readahead(file->f_dentry->d_inode->i_mapping, force_page_cache_readahead(file->f_mapping,
file, start, max_sane_readahead(end - start)); file, start, max_sane_readahead(end - start));
return 0; return 0;
} }
......
...@@ -1409,7 +1409,7 @@ do_no_page(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -1409,7 +1409,7 @@ do_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
spin_unlock(&mm->page_table_lock); spin_unlock(&mm->page_table_lock);
if (vma->vm_file) { if (vma->vm_file) {
mapping = vma->vm_file->f_dentry->d_inode->i_mapping; mapping = vma->vm_file->f_mapping;
sequence = atomic_read(&mapping->truncate_count); sequence = atomic_read(&mapping->truncate_count);
} }
smp_rmb(); /* Prevent CPU from reordering lock-free ->nopage() */ smp_rmb(); /* Prevent CPU from reordering lock-free ->nopage() */
......
...@@ -26,7 +26,7 @@ static unsigned char mincore_page(struct vm_area_struct * vma, ...@@ -26,7 +26,7 @@ static unsigned char mincore_page(struct vm_area_struct * vma,
unsigned long pgoff) unsigned long pgoff)
{ {
unsigned char present = 0; unsigned char present = 0;
struct address_space * as = vma->vm_file->f_dentry->d_inode->i_mapping; struct address_space * as = vma->vm_file->f_mapping;
struct page * page; struct page * page;
page = find_get_page(as, pgoff); page = find_get_page(as, pgoff);
......
...@@ -265,7 +265,7 @@ static void vma_link(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -265,7 +265,7 @@ static void vma_link(struct mm_struct *mm, struct vm_area_struct *vma,
struct address_space *mapping = NULL; struct address_space *mapping = NULL;
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);
......
...@@ -1031,13 +1031,13 @@ asmlinkage long sys_swapoff(const char __user * specialfile) ...@@ -1031,13 +1031,13 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
if (IS_ERR(victim)) if (IS_ERR(victim))
goto out; goto out;
mapping = victim->f_dentry->d_inode->i_mapping; mapping = victim->f_mapping;
prev = -1; prev = -1;
swap_list_lock(); swap_list_lock();
for (type = swap_list.head; type >= 0; type = swap_info[type].next) { for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
p = swap_info + type; p = swap_info + type;
if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) { if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
if (p->swap_file->f_dentry->d_inode->i_mapping==mapping) if (p->swap_file->f_mapping == mapping)
break; break;
} }
prev = type; prev = type;
...@@ -1105,7 +1105,7 @@ asmlinkage long sys_swapoff(const char __user * specialfile) ...@@ -1105,7 +1105,7 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
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_dentry->d_inode->i_mapping->host->i_sem); up(&swap_file->f_mapping->host->i_sem);
} }
filp_close(swap_file, NULL); filp_close(swap_file, NULL);
err = 0; err = 0;
...@@ -1280,7 +1280,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1280,7 +1280,7 @@ 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; inode = swap_file->f_dentry->d_inode;
mapping = swap_file->f_dentry->d_inode->i_mapping; mapping = swap_file->f_mapping;
error = -EBUSY; error = -EBUSY;
for (i = 0; i < nr_swapfiles; i++) { for (i = 0; i < nr_swapfiles; i++) {
...@@ -1288,7 +1288,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1288,7 +1288,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
if (i == type || !q->swap_file) if (i == type || !q->swap_file)
continue; continue;
if (mapping == q->swap_file->f_dentry->d_inode->i_mapping) if (mapping == q->swap_file->f_mapping)
goto bad_swap; goto bad_swap;
} }
......
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