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

[PATCH] bdev: add file.f_mapping

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

New field of struct file - ->f_mapping.  We maintain the following:
file->f_dentry->d_inode->i_mapping == file->f_mapping for all opened files.
parent 2b11e518
......@@ -2156,6 +2156,7 @@ pfm_alloc_fd(struct file **cfile)
d_add(file->f_dentry, inode);
file->f_vfsmnt = mntget(pfmfs_mnt);
file->f_mapping = inode->i_mapping;
file->f_op = &pfm_file_ops;
file->f_mode = FMODE_READ;
......
......@@ -74,6 +74,7 @@ static int raw_open(struct inode *inode, struct file *filp)
goto out;
}
filp->f_flags |= O_DIRECT;
filp->f_mapping = bdev->bd_inode->i_mapping;
if (++raw_devices[minor].inuse == 1)
filp->f_dentry->d_inode->i_mapping =
bdev->bd_inode->i_mapping;
......
......@@ -538,6 +538,7 @@ static int do_open(struct block_device *bdev, struct file *file)
int ret = -ENXIO;
int part;
file->f_mapping = bdev->bd_inode->i_mapping;
lock_kernel();
disk = get_gendisk(bdev->bd_dev, &part);
if (!disk) {
......
......@@ -89,6 +89,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
coda_inode = coda_file->f_dentry->d_inode;
host_inode = host_file->f_dentry->d_inode;
coda_file->f_mapping = host_file->f_mapping;
if (coda_inode->i_mapping == &coda_inode->i_data)
coda_inode->i_mapping = host_inode->i_mapping;
......
......@@ -740,6 +740,7 @@ static int ep_getfd(int *efd, struct inode **einode, struct file **efile)
d_add(dentry, inode);
file->f_vfsmnt = mntget(eventpoll_mnt);
file->f_dentry = dget(dentry);
file->f_mapping = inode->i_mapping;
file->f_pos = 0;
file->f_flags = O_RDONLY;
......
......@@ -120,6 +120,7 @@ int open_private_file(struct file *filp, struct dentry *dentry, int flags)
filp->f_mode = (flags+1) & O_ACCMODE;
atomic_set(&filp->f_count, 1);
filp->f_dentry = dentry;
filp->f_mapping = dentry->d_inode->i_mapping;
filp->f_uid = current->fsuid;
filp->f_gid = current->fsgid;
filp->f_op = dentry->d_inode->i_fop;
......
......@@ -788,6 +788,7 @@ struct file *hugetlb_zero_setup(size_t size)
inode->i_nlink = 0;
file->f_vfsmnt = mntget(hugetlbfs_vfsmount);
file->f_dentry = dentry;
file->f_mapping = inode->i_mapping;
file->f_op = &hugetlbfs_file_operations;
file->f_mode = FMODE_WRITE | FMODE_READ;
return file;
......
......@@ -2083,7 +2083,9 @@ static struct file *presto_filp_dopen(struct dentry *dentry, int flags)
}
}
/* XXX: where the fuck is ->f_vfsmnt? */
f->f_dentry = dentry;
f->f_mapping = dentry->d_inode->i_mapping;
f->f_pos = 0;
//f->f_reada = 0;
f->f_op = NULL;
......
......@@ -776,7 +776,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
goto cleanup_file;
}
file_ra_state_init(&f->f_ra, inode->i_mapping);
f->f_mapping = inode->i_mapping;
file_ra_state_init(&f->f_ra, f->f_mapping);
f->f_dentry = dentry;
f->f_vfsmnt = mnt;
f->f_pos = 0;
......
......@@ -650,6 +650,7 @@ int do_pipe(int *fd)
d_add(dentry, inode);
f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
f1->f_dentry = f2->f_dentry = dget(dentry);
f1->f_mapping = f2->f_mapping = inode->i_mapping;
/* read file */
f1->f_pos = f2->f_pos = 0;
......
......@@ -526,6 +526,7 @@ struct file {
/* Used by fs/eventpoll.c to link all the hooks to this file */
struct list_head f_ep_links;
spinlock_t f_ep_lock;
struct address_space *f_mapping;
};
extern spinlock_t files_lock;
#define file_list_lock() spin_lock(&files_lock);
......
......@@ -577,6 +577,7 @@ static int futex_fd(unsigned long uaddr, int signal)
filp->f_op = &futex_fops;
filp->f_vfsmnt = mntget(futex_mnt);
filp->f_dentry = dget(futex_mnt->mnt_root);
filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
if (signal) {
int err;
......
......@@ -1978,6 +1978,7 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
inode->i_nlink = 0; /* It is unlinked */
file->f_vfsmnt = mntget(shm_mnt);
file->f_dentry = dentry;
file->f_mapping = inode->i_mapping;
file->f_op = &shmem_file_operations;
file->f_mode = FMODE_WRITE | FMODE_READ;
return(file);
......
......@@ -394,6 +394,7 @@ int sock_map_fd(struct socket *sock)
file->f_dentry->d_op = &sockfs_dentry_operations;
d_add(file->f_dentry, SOCK_INODE(sock));
file->f_vfsmnt = mntget(sock_mnt);
file->f_mapping = file->f_dentry->d_inode->i_mapping;
sock->file = file;
file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
......
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