aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
commitd895cb1af15c04c522a25c79cc429076987c089b (patch)
tree895dc9157e28f603d937a58be664e4e440d5530c /fs
parent9626357371b519f2b955fef399647181034a77fe (diff)
parentd3d009cb965eae7e002ea5badf603ea8f4c34915 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile (part one) from Al Viro: "Assorted stuff - cleaning namei.c up a bit, fixing ->d_name/->d_parent locking violations, etc. The most visible changes here are death of FS_REVAL_DOT (replaced with "has ->d_weak_revalidate()") and a new helper getting from struct file to inode. Some bits of preparation to xattr method interface changes. Misc patches by various people sent this cycle *and* ocfs2 fixes from several cycles ago that should've been upstream right then. PS: the next vfs pile will be xattr stuff." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits) saner proc_get_inode() calling conventions proc: avoid extra pde_put() in proc_fill_super() fs: change return values from -EACCES to -EPERM fs/exec.c: make bprm_mm_init() static ocfs2/dlm: use GFP_ATOMIC inside a spin_lock ocfs2: fix possible use-after-free with AIO ocfs2: Fix oops in ocfs2_fast_symlink_readpage() code path get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero target: writev() on single-element vector is pointless export kernel_write(), convert open-coded instances fs: encode_fh: return FILEID_INVALID if invalid fid_type kill f_vfsmnt vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op nfsd: handle vfs_getattr errors in acl protocol switch vfs_getattr() to struct path default SET_PERSONALITY() in linux/elf.h ceph: prepopulate inodes only when request is aborted d_hash_and_lookup(): export, switch open-coded instances 9p: switch v9fs_set_create_acl() to inode+fid, do it before d_instantiate() 9p: split dropping the acls from v9fs_set_create_acl() ...
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/acl.c37
-rw-r--r--fs/9p/acl.h20
-rw-r--r--fs/9p/vfs_dentry.c1
-rw-r--r--fs/9p/vfs_file.c10
-rw-r--r--fs/9p/vfs_inode_dotl.c75
-rw-r--r--fs/9p/vfs_super.c2
-rw-r--r--fs/9p/xattr.c33
-rw-r--r--fs/9p/xattr.h2
-rw-r--r--fs/adfs/dir.c2
-rw-r--r--fs/affs/dir.c2
-rw-r--r--fs/afs/dir.c4
-rw-r--r--fs/afs/flock.c4
-rw-r--r--fs/afs/write.c7
-rw-r--r--fs/anon_inodes.c10
-rw-r--r--fs/autofs4/autofs_i.h2
-rw-r--r--fs/autofs4/dev-ioctl.c2
-rw-r--r--fs/autofs4/root.c6
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/bfs/dir.c2
-rw-r--r--fs/binfmt_aout.c4
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/binfmt_elf_fdpic.c4
-rw-r--r--fs/binfmt_flat.c2
-rw-r--r--fs/binfmt_misc.c4
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/btrfs/export.c4
-rw-r--r--fs/btrfs/file.c8
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/ioctl.c52
-rw-r--r--fs/btrfs/send.c2
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/ceph/addr.c12
-rw-r--r--fs/ceph/dir.c6
-rw-r--r--fs/ceph/export.c4
-rw-r--r--fs/ceph/file.c10
-rw-r--r--fs/ceph/inode.c40
-rw-r--r--fs/ceph/ioctl.c16
-rw-r--r--fs/ceph/locks.c2
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/file.c26
-rw-r--r--fs/cifs/inode.c8
-rw-r--r--fs/cifs/ioctl.c2
-rw-r--r--fs/cifs/readdir.c12
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/coda/file.c12
-rw-r--r--fs/coda/inode.c2
-rw-r--r--fs/coda/pioctl.c2
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--fs/configfs/dir.c2
-rw-r--r--fs/coredump.c4
-rw-r--r--fs/cramfs/inode.c2
-rw-r--r--fs/dcache.c80
-rw-r--r--fs/direct-io.c2
-rw-r--r--fs/dlm/config.c2
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h6
-rw-r--r--fs/ecryptfs/file.c4
-rw-r--r--fs/ecryptfs/inode.c3
-rw-r--r--fs/ecryptfs/read_write.c6
-rw-r--r--fs/efs/dir.c2
-rw-r--r--fs/exec.c10
-rw-r--r--fs/exofs/dir.c2
-rw-r--r--fs/ext2/dir.c2
-rw-r--r--fs/ext2/ioctl.c2
-rw-r--r--fs/ext3/dir.c8
-rw-r--r--fs/ext3/ioctl.c2
-rw-r--r--fs/ext3/namei.c4
-rw-r--r--fs/ext4/dir.c8
-rw-r--r--fs/ext4/extents.c4
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/inline.c2
-rw-r--r--fs/ext4/inode.c6
-rw-r--r--fs/ext4/ioctl.c2
-rw-r--r--fs/ext4/move_extent.c6
-rw-r--r--fs/ext4/namei.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/f2fs/dir.c2
-rw-r--r--fs/fat/dir.c6
-rw-r--r--fs/fat/file.c4
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/file_table.c31
-rw-r--r--fs/freevxfs/vxfs_lookup.c2
-rw-r--r--fs/fuse/control.c2
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/gfs2/export.c4
-rw-r--r--fs/gfs2/file.c17
-rw-r--r--fs/gfs2/rgrp.c2
-rw-r--r--fs/gfs2/sys.c18
-rw-r--r--fs/hfs/dir.c2
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfsplus/dir.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hfsplus/ioctl.c4
-rw-r--r--fs/hostfs/hostfs_kern.c10
-rw-r--r--fs/hpfs/dir.c4
-rw-r--r--fs/hpfs/file.c2
-rw-r--r--fs/hppfs/hppfs.c8
-rw-r--r--fs/hugetlbfs/inode.c33
-rw-r--r--fs/inode.c2
-rw-r--r--fs/ioctl.c12
-rw-r--r--fs/isofs/compress.c2
-rw-r--r--fs/isofs/dir.c2
-rw-r--r--fs/isofs/export.c4
-rw-r--r--fs/jffs2/dir.c4
-rw-r--r--fs/jfs/ioctl.c2
-rw-r--r--fs/jfs/jfs_dtree.c2
-rw-r--r--fs/lockd/clntlock.c2
-rw-r--r--fs/lockd/clntproc.c2
-rw-r--r--fs/lockd/svclock.c16
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--fs/locks.c24
-rw-r--r--fs/logfs/dir.c4
-rw-r--r--fs/logfs/file.c2
-rw-r--r--fs/minix/dir.c2
-rw-r--r--fs/namei.c67
-rw-r--r--fs/namespace.c42
-rw-r--r--fs/ncpfs/dir.c10
-rw-r--r--fs/ncpfs/inode.c4
-rw-r--r--fs/ncpfs/ioctl.c4
-rw-r--r--fs/ncpfs/mmap.c2
-rw-r--r--fs/nfs/dir.c48
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfs/idmap.c2
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nfs/nfs3proc.c2
-rw-r--r--fs/nfs/nfs4file.c2
-rw-r--r--fs/nfs/nfs4super.c6
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/super.c6
-rw-r--r--fs/nfsd/fault_inject.c6
-rw-r--r--fs/nfsd/nfs2acl.c23
-rw-r--r--fs/nfsd/nfs3proc.c5
-rw-r--r--fs/nfsd/nfs3xdr.c10
-rw-r--r--fs/nfsd/nfs4xdr.c4
-rw-r--r--fs/nfsd/nfsctl.c2
-rw-r--r--fs/nfsd/nfsproc.c12
-rw-r--r--fs/nfsd/nfsxdr.c7
-rw-r--r--fs/nfsd/vfs.c6
-rw-r--r--fs/nfsd/vfs.h8
-rw-r--r--fs/nfsd/xdr.h2
-rw-r--r--fs/nfsd/xdr3.h2
-rw-r--r--fs/nilfs2/dir.c2
-rw-r--r--fs/nilfs2/file.c2
-rw-r--r--fs/nilfs2/ioctl.c2
-rw-r--r--fs/nilfs2/namei.c4
-rw-r--r--fs/notify/dnotify/dnotify.c4
-rw-r--r--fs/notify/fanotify/fanotify_user.c2
-rw-r--r--fs/ntfs/dir.c2
-rw-r--r--fs/ocfs2/aops.c6
-rw-r--r--fs/ocfs2/dir.c4
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c2
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c6
-rw-r--r--fs/ocfs2/export.c4
-rw-r--r--fs/ocfs2/file.c14
-rw-r--r--fs/ocfs2/ioctl.c4
-rw-r--r--fs/ocfs2/mmap.c10
-rw-r--r--fs/ocfs2/move_extents.c2
-rw-r--r--fs/ocfs2/refcounttree.c4
-rw-r--r--fs/ocfs2/symlink.c2
-rw-r--r--fs/omfs/dir.c4
-rw-r--r--fs/open.c34
-rw-r--r--fs/openpromfs/inode.c2
-rw-r--r--fs/pipe.c20
-rw-r--r--fs/proc/base.c45
-rw-r--r--fs/proc/generic.c31
-rw-r--r--fs/proc/inode.c43
-rw-r--r--fs/proc/nommu.c2
-rw-r--r--fs/proc/proc_net.c2
-rw-r--r--fs/proc/proc_sysctl.c4
-rw-r--r--fs/proc/task_mmu.c6
-rw-r--r--fs/proc/task_nommu.c2
-rw-r--r--fs/qnx4/dir.c2
-rw-r--r--fs/qnx6/dir.c2
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--fs/read_write.c8
-rw-r--r--fs/readdir.c2
-rw-r--r--fs/reiserfs/file.c2
-rw-r--r--fs/reiserfs/inode.c4
-rw-r--r--fs/reiserfs/ioctl.c2
-rw-r--r--fs/reiserfs/procfs.c2
-rw-r--r--fs/romfs/super.c2
-rw-r--r--fs/splice.c7
-rw-r--r--fs/squashfs/dir.c2
-rw-r--r--fs/stat.c13
-rw-r--r--fs/sync.c2
-rw-r--r--fs/sysfs/bin.c6
-rw-r--r--fs/sysv/dir.c2
-rw-r--r--fs/ubifs/dir.c2
-rw-r--r--fs/ubifs/file.c2
-rw-r--r--fs/ubifs/ioctl.c2
-rw-r--r--fs/udf/dir.c2
-rw-r--r--fs/udf/file.c6
-rw-r--r--fs/udf/namei.c4
-rw-r--r--fs/ufs/dir.c2
-rw-r--r--fs/xfs/xfs_dfrag.c8
-rw-r--r--fs/xfs/xfs_export.c4
-rw-r--r--fs/xfs/xfs_file.c4
-rw-r--r--fs/xfs/xfs_ioctl.c6
-rw-r--r--fs/xfs/xfs_ioctl32.c2
199 files changed, 793 insertions, 775 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 15b679166201..7af425f53bee 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -23,6 +23,7 @@
23#include "acl.h" 23#include "acl.h"
24#include "v9fs.h" 24#include "v9fs.h"
25#include "v9fs_vfs.h" 25#include "v9fs_vfs.h"
26#include "fid.h"
26 27
27static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) 28static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name)
28{ 29{
@@ -113,16 +114,12 @@ struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type)
113 114
114} 115}
115 116
116static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) 117static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
117{ 118{
118 int retval; 119 int retval;
119 char *name; 120 char *name;
120 size_t size; 121 size_t size;
121 void *buffer; 122 void *buffer;
122 struct inode *inode = dentry->d_inode;
123
124 set_cached_acl(inode, type, acl);
125
126 if (!acl) 123 if (!acl)
127 return 0; 124 return 0;
128 125
@@ -144,17 +141,16 @@ static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl)
144 default: 141 default:
145 BUG(); 142 BUG();
146 } 143 }
147 retval = v9fs_xattr_set(dentry, name, buffer, size, 0); 144 retval = v9fs_fid_xattr_set(fid, name, buffer, size, 0);
148err_free_out: 145err_free_out:
149 kfree(buffer); 146 kfree(buffer);
150 return retval; 147 return retval;
151} 148}
152 149
153int v9fs_acl_chmod(struct dentry *dentry) 150int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid)
154{ 151{
155 int retval = 0; 152 int retval = 0;
156 struct posix_acl *acl; 153 struct posix_acl *acl;
157 struct inode *inode = dentry->d_inode;
158 154
159 if (S_ISLNK(inode->i_mode)) 155 if (S_ISLNK(inode->i_mode))
160 return -EOPNOTSUPP; 156 return -EOPNOTSUPP;
@@ -163,25 +159,30 @@ int v9fs_acl_chmod(struct dentry *dentry)
163 retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 159 retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
164 if (retval) 160 if (retval)
165 return retval; 161 return retval;
166 retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, acl); 162 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
163 retval = v9fs_set_acl(fid, ACL_TYPE_ACCESS, acl);
167 posix_acl_release(acl); 164 posix_acl_release(acl);
168 } 165 }
169 return retval; 166 return retval;
170} 167}
171 168
172int v9fs_set_create_acl(struct dentry *dentry, 169int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
173 struct posix_acl **dpacl, struct posix_acl **pacl) 170 struct posix_acl *dacl, struct posix_acl *acl)
174{ 171{
175 if (dentry) { 172 set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl);
176 v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl); 173 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
177 v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl); 174 v9fs_set_acl(fid, ACL_TYPE_DEFAULT, dacl);
178 } 175 v9fs_set_acl(fid, ACL_TYPE_ACCESS, acl);
179 posix_acl_release(*dpacl);
180 posix_acl_release(*pacl);
181 *dpacl = *pacl = NULL;
182 return 0; 176 return 0;
183} 177}
184 178
179void v9fs_put_acl(struct posix_acl *dacl,
180 struct posix_acl *acl)
181{
182 posix_acl_release(dacl);
183 posix_acl_release(acl);
184}
185
185int v9fs_acl_mode(struct inode *dir, umode_t *modep, 186int v9fs_acl_mode(struct inode *dir, umode_t *modep,
186 struct posix_acl **dpacl, struct posix_acl **pacl) 187 struct posix_acl **dpacl, struct posix_acl **pacl)
187{ 188{
diff --git a/fs/9p/acl.h b/fs/9p/acl.h
index 559556411965..e4f7e882272b 100644
--- a/fs/9p/acl.h
+++ b/fs/9p/acl.h
@@ -17,27 +17,33 @@
17#ifdef CONFIG_9P_FS_POSIX_ACL 17#ifdef CONFIG_9P_FS_POSIX_ACL
18extern int v9fs_get_acl(struct inode *, struct p9_fid *); 18extern int v9fs_get_acl(struct inode *, struct p9_fid *);
19extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type); 19extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type);
20extern int v9fs_acl_chmod(struct dentry *); 20extern int v9fs_acl_chmod(struct inode *, struct p9_fid *);
21extern int v9fs_set_create_acl(struct dentry *, 21extern int v9fs_set_create_acl(struct inode *, struct p9_fid *,
22 struct posix_acl **, struct posix_acl **); 22 struct posix_acl *, struct posix_acl *);
23extern int v9fs_acl_mode(struct inode *dir, umode_t *modep, 23extern int v9fs_acl_mode(struct inode *dir, umode_t *modep,
24 struct posix_acl **dpacl, struct posix_acl **pacl); 24 struct posix_acl **dpacl, struct posix_acl **pacl);
25extern void v9fs_put_acl(struct posix_acl *dacl, struct posix_acl *acl);
25#else 26#else
26#define v9fs_iop_get_acl NULL 27#define v9fs_iop_get_acl NULL
27static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) 28static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
28{ 29{
29 return 0; 30 return 0;
30} 31}
31static inline int v9fs_acl_chmod(struct dentry *dentry) 32static inline int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid)
32{ 33{
33 return 0; 34 return 0;
34} 35}
35static inline int v9fs_set_create_acl(struct dentry *dentry, 36static inline int v9fs_set_create_acl(struct inode *inode,
36 struct posix_acl **dpacl, 37 struct p9_fid *fid,
37 struct posix_acl **pacl) 38 struct posix_acl *dacl,
39 struct posix_acl *acl)
38{ 40{
39 return 0; 41 return 0;
40} 42}
43static inline void v9fs_put_acl(struct posix_acl *dacl,
44 struct posix_acl *acl)
45{
46}
41static inline int v9fs_acl_mode(struct inode *dir, umode_t *modep, 47static inline int v9fs_acl_mode(struct inode *dir, umode_t *modep,
42 struct posix_acl **dpacl, 48 struct posix_acl **dpacl,
43 struct posix_acl **pacl) 49 struct posix_acl **pacl)
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 64600b5d0522..9ad68628522c 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -137,6 +137,7 @@ out_valid:
137 137
138const struct dentry_operations v9fs_cached_dentry_operations = { 138const struct dentry_operations v9fs_cached_dentry_operations = {
139 .d_revalidate = v9fs_lookup_revalidate, 139 .d_revalidate = v9fs_lookup_revalidate,
140 .d_weak_revalidate = v9fs_lookup_revalidate,
140 .d_delete = v9fs_cached_dentry_delete, 141 .d_delete = v9fs_cached_dentry_delete,
141 .d_release = v9fs_dentry_release, 142 .d_release = v9fs_dentry_release,
142}; 143};
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index c921ac92ea4c..d384a8b77ee8 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -129,7 +129,7 @@ out_error:
129static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) 129static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
130{ 130{
131 int res = 0; 131 int res = 0;
132 struct inode *inode = filp->f_path.dentry->d_inode; 132 struct inode *inode = file_inode(filp);
133 133
134 p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); 134 p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
135 135
@@ -298,7 +298,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
298 298
299static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl) 299static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
300{ 300{
301 struct inode *inode = filp->f_path.dentry->d_inode; 301 struct inode *inode = file_inode(filp);
302 int ret = -ENOLCK; 302 int ret = -ENOLCK;
303 303
304 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", 304 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n",
@@ -334,7 +334,7 @@ out_err:
334static int v9fs_file_flock_dotl(struct file *filp, int cmd, 334static int v9fs_file_flock_dotl(struct file *filp, int cmd,
335 struct file_lock *fl) 335 struct file_lock *fl)
336{ 336{
337 struct inode *inode = filp->f_path.dentry->d_inode; 337 struct inode *inode = file_inode(filp);
338 int ret = -ENOLCK; 338 int ret = -ENOLCK;
339 339
340 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", 340 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n",
@@ -525,7 +525,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
525 if (!count) 525 if (!count)
526 goto out; 526 goto out;
527 527
528 retval = v9fs_file_write_internal(filp->f_path.dentry->d_inode, 528 retval = v9fs_file_write_internal(file_inode(filp),
529 filp->private_data, 529 filp->private_data,
530 data, count, &origin, 1); 530 data, count, &origin, 1);
531 /* update offset on successful write */ 531 /* update offset on successful write */
@@ -600,7 +600,7 @@ v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
600 struct v9fs_inode *v9inode; 600 struct v9fs_inode *v9inode;
601 struct page *page = vmf->page; 601 struct page *page = vmf->page;
602 struct file *filp = vma->vm_file; 602 struct file *filp = vma->vm_file;
603 struct inode *inode = filp->f_path.dentry->d_inode; 603 struct inode *inode = file_inode(filp);
604 604
605 605
606 p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n", 606 p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n",
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 07f409288d1b..61e4fa70a6fa 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -330,14 +330,14 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
330 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err); 330 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err);
331 goto error; 331 goto error;
332 } 332 }
333 /* Now set the ACL based on the default value */
334 v9fs_set_create_acl(inode, fid, dacl, pacl);
335
333 err = v9fs_fid_add(dentry, fid); 336 err = v9fs_fid_add(dentry, fid);
334 if (err < 0) 337 if (err < 0)
335 goto error; 338 goto error;
336 d_instantiate(dentry, inode); 339 d_instantiate(dentry, inode);
337 340
338 /* Now set the ACL based on the default value */
339 v9fs_set_create_acl(dentry, &dacl, &pacl);
340
341 v9inode = V9FS_I(inode); 341 v9inode = V9FS_I(inode);
342 mutex_lock(&v9inode->v_mutex); 342 mutex_lock(&v9inode->v_mutex);
343 if (v9ses->cache && !v9inode->writeback_fid && 343 if (v9ses->cache && !v9inode->writeback_fid &&
@@ -369,6 +369,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
369#endif 369#endif
370 *opened |= FILE_CREATED; 370 *opened |= FILE_CREATED;
371out: 371out:
372 v9fs_put_acl(dacl, pacl);
372 dput(res); 373 dput(res);
373 return err; 374 return err;
374 375
@@ -378,7 +379,6 @@ error:
378err_clunk_old_fid: 379err_clunk_old_fid:
379 if (ofid) 380 if (ofid)
380 p9_client_clunk(ofid); 381 p9_client_clunk(ofid);
381 v9fs_set_create_acl(NULL, &dacl, &pacl);
382 goto out; 382 goto out;
383} 383}
384 384
@@ -435,17 +435,17 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
435 if (err < 0) 435 if (err < 0)
436 goto error; 436 goto error;
437 437
438 fid = p9_client_walk(dfid, 1, &name, 1);
439 if (IS_ERR(fid)) {
440 err = PTR_ERR(fid);
441 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
442 err);
443 fid = NULL;
444 goto error;
445 }
446
438 /* instantiate inode and assign the unopened fid to the dentry */ 447 /* instantiate inode and assign the unopened fid to the dentry */
439 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 448 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
440 fid = p9_client_walk(dfid, 1, &name, 1);
441 if (IS_ERR(fid)) {
442 err = PTR_ERR(fid);
443 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
444 err);
445 fid = NULL;
446 goto error;
447 }
448
449 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 449 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
450 if (IS_ERR(inode)) { 450 if (IS_ERR(inode)) {
451 err = PTR_ERR(inode); 451 err = PTR_ERR(inode);
@@ -456,6 +456,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
456 err = v9fs_fid_add(dentry, fid); 456 err = v9fs_fid_add(dentry, fid);
457 if (err < 0) 457 if (err < 0)
458 goto error; 458 goto error;
459 v9fs_set_create_acl(inode, fid, dacl, pacl);
459 d_instantiate(dentry, inode); 460 d_instantiate(dentry, inode);
460 fid = NULL; 461 fid = NULL;
461 } else { 462 } else {
@@ -469,16 +470,15 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
469 err = PTR_ERR(inode); 470 err = PTR_ERR(inode);
470 goto error; 471 goto error;
471 } 472 }
473 v9fs_set_create_acl(inode, fid, dacl, pacl);
472 d_instantiate(dentry, inode); 474 d_instantiate(dentry, inode);
473 } 475 }
474 /* Now set the ACL based on the default value */
475 v9fs_set_create_acl(dentry, &dacl, &pacl);
476 inc_nlink(dir); 476 inc_nlink(dir);
477 v9fs_invalidate_inode_attr(dir); 477 v9fs_invalidate_inode_attr(dir);
478error: 478error:
479 if (fid) 479 if (fid)
480 p9_client_clunk(fid); 480 p9_client_clunk(fid);
481 v9fs_set_create_acl(NULL, &dacl, &pacl); 481 v9fs_put_acl(dacl, pacl);
482 return err; 482 return err;
483} 483}
484 484
@@ -572,10 +572,11 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
572 struct v9fs_session_info *v9ses; 572 struct v9fs_session_info *v9ses;
573 struct p9_fid *fid; 573 struct p9_fid *fid;
574 struct p9_iattr_dotl p9attr; 574 struct p9_iattr_dotl p9attr;
575 struct inode *inode = dentry->d_inode;
575 576
576 p9_debug(P9_DEBUG_VFS, "\n"); 577 p9_debug(P9_DEBUG_VFS, "\n");
577 578
578 retval = inode_change_ok(dentry->d_inode, iattr); 579 retval = inode_change_ok(inode, iattr);
579 if (retval) 580 if (retval)
580 return retval; 581 return retval;
581 582
@@ -596,23 +597,23 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
596 return PTR_ERR(fid); 597 return PTR_ERR(fid);
597 598
598 /* Write all dirty data */ 599 /* Write all dirty data */
599 if (S_ISREG(dentry->d_inode->i_mode)) 600 if (S_ISREG(inode->i_mode))
600 filemap_write_and_wait(dentry->d_inode->i_mapping); 601 filemap_write_and_wait(inode->i_mapping);
601 602
602 retval = p9_client_setattr(fid, &p9attr); 603 retval = p9_client_setattr(fid, &p9attr);
603 if (retval < 0) 604 if (retval < 0)
604 return retval; 605 return retval;
605 606
606 if ((iattr->ia_valid & ATTR_SIZE) && 607 if ((iattr->ia_valid & ATTR_SIZE) &&
607 iattr->ia_size != i_size_read(dentry->d_inode)) 608 iattr->ia_size != i_size_read(inode))
608 truncate_setsize(dentry->d_inode, iattr->ia_size); 609 truncate_setsize(inode, iattr->ia_size);
609 610
610 v9fs_invalidate_inode_attr(dentry->d_inode); 611 v9fs_invalidate_inode_attr(inode);
611 setattr_copy(dentry->d_inode, iattr); 612 setattr_copy(inode, iattr);
612 mark_inode_dirty(dentry->d_inode); 613 mark_inode_dirty(inode);
613 if (iattr->ia_valid & ATTR_MODE) { 614 if (iattr->ia_valid & ATTR_MODE) {
614 /* We also want to update ACL when we update mode bits */ 615 /* We also want to update ACL when we update mode bits */
615 retval = v9fs_acl_chmod(dentry); 616 retval = v9fs_acl_chmod(inode, fid);
616 if (retval < 0) 617 if (retval < 0)
617 return retval; 618 return retval;
618 } 619 }
@@ -880,17 +881,17 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
880 goto error; 881 goto error;
881 882
882 v9fs_invalidate_inode_attr(dir); 883 v9fs_invalidate_inode_attr(dir);
884 fid = p9_client_walk(dfid, 1, &name, 1);
885 if (IS_ERR(fid)) {
886 err = PTR_ERR(fid);
887 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
888 err);
889 fid = NULL;
890 goto error;
891 }
892
883 /* instantiate inode and assign the unopened fid to the dentry */ 893 /* instantiate inode and assign the unopened fid to the dentry */
884 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 894 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
885 fid = p9_client_walk(dfid, 1, &name, 1);
886 if (IS_ERR(fid)) {
887 err = PTR_ERR(fid);
888 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
889 err);
890 fid = NULL;
891 goto error;
892 }
893
894 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 895 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
895 if (IS_ERR(inode)) { 896 if (IS_ERR(inode)) {
896 err = PTR_ERR(inode); 897 err = PTR_ERR(inode);
@@ -898,6 +899,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
898 err); 899 err);
899 goto error; 900 goto error;
900 } 901 }
902 v9fs_set_create_acl(inode, fid, dacl, pacl);
901 err = v9fs_fid_add(dentry, fid); 903 err = v9fs_fid_add(dentry, fid);
902 if (err < 0) 904 if (err < 0)
903 goto error; 905 goto error;
@@ -913,14 +915,13 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
913 err = PTR_ERR(inode); 915 err = PTR_ERR(inode);
914 goto error; 916 goto error;
915 } 917 }
918 v9fs_set_create_acl(inode, fid, dacl, pacl);
916 d_instantiate(dentry, inode); 919 d_instantiate(dentry, inode);
917 } 920 }
918 /* Now set the ACL based on the default value */
919 v9fs_set_create_acl(dentry, &dacl, &pacl);
920error: 921error:
921 if (fid) 922 if (fid)
922 p9_client_clunk(fid); 923 p9_client_clunk(fid);
923 v9fs_set_create_acl(NULL, &dacl, &pacl); 924 v9fs_put_acl(dacl, pacl);
924 return err; 925 return err;
925} 926}
926 927
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 137d50396898..91dad63e5a2d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -363,5 +363,5 @@ struct file_system_type v9fs_fs_type = {
363 .mount = v9fs_mount, 363 .mount = v9fs_mount,
364 .kill_sb = v9fs_kill_super, 364 .kill_sb = v9fs_kill_super,
365 .owner = THIS_MODULE, 365 .owner = THIS_MODULE,
366 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT, 366 .fs_flags = FS_RENAME_DOES_D_MOVE,
367}; 367};
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index 29653b70a9c3..c45e016b190f 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -111,19 +111,26 @@ ssize_t v9fs_xattr_get(struct dentry *dentry, const char *name,
111int v9fs_xattr_set(struct dentry *dentry, const char *name, 111int v9fs_xattr_set(struct dentry *dentry, const char *name,
112 const void *value, size_t value_len, int flags) 112 const void *value, size_t value_len, int flags)
113{ 113{
114 struct p9_fid *fid = v9fs_fid_lookup(dentry);
115 if (IS_ERR(fid))
116 return PTR_ERR(fid);
117 return v9fs_fid_xattr_set(fid, name, value, value_len, flags);
118}
119
120int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
121 const void *value, size_t value_len, int flags)
122{
114 u64 offset = 0; 123 u64 offset = 0;
115 int retval, msize, write_count; 124 int retval, msize, write_count;
116 struct p9_fid *fid = NULL;
117 125
118 p9_debug(P9_DEBUG_VFS, "name = %s value_len = %zu flags = %d\n", 126 p9_debug(P9_DEBUG_VFS, "name = %s value_len = %zu flags = %d\n",
119 name, value_len, flags); 127 name, value_len, flags);
120 128
121 fid = v9fs_fid_clone(dentry); 129 /* Clone it */
122 if (IS_ERR(fid)) { 130 fid = p9_client_walk(fid, 0, NULL, 1);
123 retval = PTR_ERR(fid); 131 if (IS_ERR(fid))
124 fid = NULL; 132 return PTR_ERR(fid);
125 goto error; 133
126 }
127 /* 134 /*
128 * On success fid points to xattr 135 * On success fid points to xattr
129 */ 136 */
@@ -131,7 +138,8 @@ int v9fs_xattr_set(struct dentry *dentry, const char *name,
131 if (retval < 0) { 138 if (retval < 0) {
132 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n", 139 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n",
133 retval); 140 retval);
134 goto error; 141 p9_client_clunk(fid);
142 return retval;
135 } 143 }
136 msize = fid->clnt->msize; 144 msize = fid->clnt->msize;
137 while (value_len) { 145 while (value_len) {
@@ -144,17 +152,12 @@ int v9fs_xattr_set(struct dentry *dentry, const char *name,
144 if (write_count < 0) { 152 if (write_count < 0) {
145 /* error in xattr write */ 153 /* error in xattr write */
146 retval = write_count; 154 retval = write_count;
147 goto error; 155 break;
148 } 156 }
149 offset += write_count; 157 offset += write_count;
150 value_len -= write_count; 158 value_len -= write_count;
151 } 159 }
152 /* Total read xattr bytes */ 160 return p9_client_clunk(fid);
153 retval = offset;
154error:
155 if (fid)
156 retval = p9_client_clunk(fid);
157 return retval;
158} 161}
159 162
160ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 163ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
diff --git a/fs/9p/xattr.h b/fs/9p/xattr.h
index eaa837c53bd5..eec348a3df71 100644
--- a/fs/9p/xattr.h
+++ b/fs/9p/xattr.h
@@ -27,6 +27,8 @@ extern ssize_t v9fs_fid_xattr_get(struct p9_fid *, const char *,
27 void *, size_t); 27 void *, size_t);
28extern ssize_t v9fs_xattr_get(struct dentry *, const char *, 28extern ssize_t v9fs_xattr_get(struct dentry *, const char *,
29 void *, size_t); 29 void *, size_t);
30extern int v9fs_fid_xattr_set(struct p9_fid *, const char *,
31 const void *, size_t, int);
30extern int v9fs_xattr_set(struct dentry *, const char *, 32extern int v9fs_xattr_set(struct dentry *, const char *,
31 const void *, size_t, int); 33 const void *, size_t, int);
32extern ssize_t v9fs_listxattr(struct dentry *, char *, size_t); 34extern ssize_t v9fs_listxattr(struct dentry *, char *, size_t);
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index b3be2e7c5643..9cf874ce8336 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -19,7 +19,7 @@ static DEFINE_RWLOCK(adfs_dir_lock);
19static int 19static int
20adfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 20adfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
21{ 21{
22 struct inode *inode = filp->f_path.dentry->d_inode; 22 struct inode *inode = file_inode(filp);
23 struct super_block *sb = inode->i_sb; 23 struct super_block *sb = inode->i_sb;
24 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; 24 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
25 struct object_info obj; 25 struct object_info obj;
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index 8ca8f3a55599..fd11a6d608ee 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -42,7 +42,7 @@ const struct inode_operations affs_dir_inode_operations = {
42static int 42static int
43affs_readdir(struct file *filp, void *dirent, filldir_t filldir) 43affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
44{ 44{
45 struct inode *inode = filp->f_path.dentry->d_inode; 45 struct inode *inode = file_inode(filp);
46 struct super_block *sb = inode->i_sb; 46 struct super_block *sb = inode->i_sb;
47 struct buffer_head *dir_bh; 47 struct buffer_head *dir_bh;
48 struct buffer_head *fh_bh; 48 struct buffer_head *fh_bh;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index db477906ba4f..7a465ed04444 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -393,12 +393,12 @@ static int afs_readdir(struct file *file, void *cookie, filldir_t filldir)
393 int ret; 393 int ret;
394 394
395 _enter("{%Ld,{%lu}}", 395 _enter("{%Ld,{%lu}}",
396 file->f_pos, file->f_path.dentry->d_inode->i_ino); 396 file->f_pos, file_inode(file)->i_ino);
397 397
398 ASSERT(file->private_data != NULL); 398 ASSERT(file->private_data != NULL);
399 399
400 fpos = file->f_pos; 400 fpos = file->f_pos;
401 ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos, 401 ret = afs_dir_iterate(file_inode(file), &fpos,
402 cookie, filldir, file->private_data); 402 cookie, filldir, file->private_data);
403 file->f_pos = fpos; 403 file->f_pos = fpos;
404 404
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 757d664575dd..2497bf306c70 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -514,7 +514,7 @@ error:
514 */ 514 */
515int afs_lock(struct file *file, int cmd, struct file_lock *fl) 515int afs_lock(struct file *file, int cmd, struct file_lock *fl)
516{ 516{
517 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 517 struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
518 518
519 _enter("{%x:%u},%d,{t=%x,fl=%x,r=%Ld:%Ld}", 519 _enter("{%x:%u},%d,{t=%x,fl=%x,r=%Ld:%Ld}",
520 vnode->fid.vid, vnode->fid.vnode, cmd, 520 vnode->fid.vid, vnode->fid.vnode, cmd,
@@ -537,7 +537,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl)
537 */ 537 */
538int afs_flock(struct file *file, int cmd, struct file_lock *fl) 538int afs_flock(struct file *file, int cmd, struct file_lock *fl)
539{ 539{
540 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 540 struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
541 541
542 _enter("{%x:%u},%d,{t=%x,fl=%x}", 542 _enter("{%x:%u},%d,{t=%x,fl=%x}",
543 vnode->fid.vid, vnode->fid.vnode, cmd, 543 vnode->fid.vid, vnode->fid.vnode, cmd,
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 9aa52d93c73c..7e03eadb40c0 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -120,7 +120,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
120 struct page **pagep, void **fsdata) 120 struct page **pagep, void **fsdata)
121{ 121{
122 struct afs_writeback *candidate, *wb; 122 struct afs_writeback *candidate, *wb;
123 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 123 struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
124 struct page *page; 124 struct page *page;
125 struct key *key = file->private_data; 125 struct key *key = file->private_data;
126 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 126 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
@@ -245,7 +245,7 @@ int afs_write_end(struct file *file, struct address_space *mapping,
245 loff_t pos, unsigned len, unsigned copied, 245 loff_t pos, unsigned len, unsigned copied,
246 struct page *page, void *fsdata) 246 struct page *page, void *fsdata)
247{ 247{
248 struct afs_vnode *vnode = AFS_FS_I(file->f_dentry->d_inode); 248 struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
249 loff_t i_size, maybe_i_size; 249 loff_t i_size, maybe_i_size;
250 250
251 _enter("{%x:%u},{%lx}", 251 _enter("{%x:%u},{%lx}",
@@ -627,8 +627,7 @@ void afs_pages_written_back(struct afs_vnode *vnode, struct afs_call *call)
627ssize_t afs_file_write(struct kiocb *iocb, const struct iovec *iov, 627ssize_t afs_file_write(struct kiocb *iocb, const struct iovec *iov,
628 unsigned long nr_segs, loff_t pos) 628 unsigned long nr_segs, loff_t pos)
629{ 629{
630 struct dentry *dentry = iocb->ki_filp->f_path.dentry; 630 struct afs_vnode *vnode = AFS_FS_I(file_inode(iocb->ki_filp));
631 struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode);
632 ssize_t result; 631 ssize_t result;
633 size_t count = iov_length(iov, nr_segs); 632 size_t count = iov_length(iov, nr_segs);
634 633
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 28d39fb84ae3..47a65df8c871 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -131,7 +131,6 @@ struct file *anon_inode_getfile(const char *name,
131 struct qstr this; 131 struct qstr this;
132 struct path path; 132 struct path path;
133 struct file *file; 133 struct file *file;
134 int error;
135 134
136 if (IS_ERR(anon_inode_inode)) 135 if (IS_ERR(anon_inode_inode))
137 return ERR_PTR(-ENODEV); 136 return ERR_PTR(-ENODEV);
@@ -143,7 +142,7 @@ struct file *anon_inode_getfile(const char *name,
143 * Link the inode to a directory entry by creating a unique name 142 * Link the inode to a directory entry by creating a unique name
144 * using the inode sequence number. 143 * using the inode sequence number.
145 */ 144 */
146 error = -ENOMEM; 145 file = ERR_PTR(-ENOMEM);
147 this.name = name; 146 this.name = name;
148 this.len = strlen(name); 147 this.len = strlen(name);
149 this.hash = 0; 148 this.hash = 0;
@@ -160,15 +159,12 @@ struct file *anon_inode_getfile(const char *name,
160 159
161 d_instantiate(path.dentry, anon_inode_inode); 160 d_instantiate(path.dentry, anon_inode_inode);
162 161
163 error = -ENFILE;
164 file = alloc_file(&path, OPEN_FMODE(flags), fops); 162 file = alloc_file(&path, OPEN_FMODE(flags), fops);
165 if (!file) 163 if (IS_ERR(file))
166 goto err_dput; 164 goto err_dput;
167 file->f_mapping = anon_inode_inode->i_mapping; 165 file->f_mapping = anon_inode_inode->i_mapping;
168 166
169 file->f_pos = 0;
170 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); 167 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
171 file->f_version = 0;
172 file->private_data = priv; 168 file->private_data = priv;
173 169
174 return file; 170 return file;
@@ -177,7 +173,7 @@ err_dput:
177 path_put(&path); 173 path_put(&path);
178err_module: 174err_module:
179 module_put(fops->owner); 175 module_put(fops->owner);
180 return ERR_PTR(error); 176 return file;
181} 177}
182EXPORT_SYMBOL_GPL(anon_inode_getfile); 178EXPORT_SYMBOL_GPL(anon_inode_getfile);
183 179
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index b785e7707959..3f1128b37e46 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -273,7 +273,7 @@ static inline int autofs_prepare_pipe(struct file *pipe)
273{ 273{
274 if (!pipe->f_op || !pipe->f_op->write) 274 if (!pipe->f_op || !pipe->f_op->write)
275 return -EINVAL; 275 return -EINVAL;
276 if (!S_ISFIFO(pipe->f_dentry->d_inode->i_mode)) 276 if (!S_ISFIFO(file_inode(pipe)->i_mode))
277 return -EINVAL; 277 return -EINVAL;
278 /* We want a packet pipe */ 278 /* We want a packet pipe */
279 pipe->f_flags |= O_DIRECT; 279 pipe->f_flags |= O_DIRECT;
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 9f68a37bb2b2..743c7c2c949d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -159,7 +159,7 @@ static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f)
159 struct inode *inode; 159 struct inode *inode;
160 160
161 if (f) { 161 if (f) {
162 inode = f->f_path.dentry->d_inode; 162 inode = file_inode(f);
163 sbi = autofs4_sbi(inode->i_sb); 163 sbi = autofs4_sbi(inode->i_sb);
164 } 164 }
165 return sbi; 165 return sbi;
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index c93447604da8..230bd2aad4f4 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -587,7 +587,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
587 587
588 /* This allows root to remove symlinks */ 588 /* This allows root to remove symlinks */
589 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) 589 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
590 return -EACCES; 590 return -EPERM;
591 591
592 if (atomic_dec_and_test(&ino->count)) { 592 if (atomic_dec_and_test(&ino->count)) {
593 p_ino = autofs4_dentry_ino(dentry->d_parent); 593 p_ino = autofs4_dentry_ino(dentry->d_parent);
@@ -874,7 +874,7 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
874static long autofs4_root_ioctl(struct file *filp, 874static long autofs4_root_ioctl(struct file *filp,
875 unsigned int cmd, unsigned long arg) 875 unsigned int cmd, unsigned long arg)
876{ 876{
877 struct inode *inode = filp->f_dentry->d_inode; 877 struct inode *inode = file_inode(filp);
878 return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 878 return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
879} 879}
880 880
@@ -882,7 +882,7 @@ static long autofs4_root_ioctl(struct file *filp,
882static long autofs4_root_compat_ioctl(struct file *filp, 882static long autofs4_root_compat_ioctl(struct file *filp,
883 unsigned int cmd, unsigned long arg) 883 unsigned int cmd, unsigned long arg)
884{ 884{
885 struct inode *inode = filp->f_path.dentry->d_inode; 885 struct inode *inode = file_inode(filp);
886 int ret; 886 int ret;
887 887
888 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) 888 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 2b3bda8d5e68..c8f4e25eb9e2 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -213,7 +213,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
213static int 213static int
214befs_readdir(struct file *filp, void *dirent, filldir_t filldir) 214befs_readdir(struct file *filp, void *dirent, filldir_t filldir)
215{ 215{
216 struct inode *inode = filp->f_path.dentry->d_inode; 216 struct inode *inode = file_inode(filp);
217 struct super_block *sb = inode->i_sb; 217 struct super_block *sb = inode->i_sb;
218 befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; 218 befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
219 befs_off_t value; 219 befs_off_t value;
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 2785ef91191a..3f422f6bb5ca 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -28,7 +28,7 @@ static struct buffer_head *bfs_find_entry(struct inode *dir,
28 28
29static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) 29static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
30{ 30{
31 struct inode *dir = f->f_path.dentry->d_inode; 31 struct inode *dir = file_inode(f);
32 struct buffer_head *bh; 32 struct buffer_head *bh;
33 struct bfs_dirent *de; 33 struct bfs_dirent *de;
34 struct bfs_sb_info *info = BFS_SB(dir->i_sb); 34 struct bfs_sb_info *info = BFS_SB(dir->i_sb);
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 6043567b95c2..bbc8f8827eac 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -214,7 +214,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
214 if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC && 214 if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
215 N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) || 215 N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
216 N_TRSIZE(ex) || N_DRSIZE(ex) || 216 N_TRSIZE(ex) || N_DRSIZE(ex) ||
217 i_size_read(bprm->file->f_path.dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) { 217 i_size_read(file_inode(bprm->file)) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
218 return -ENOEXEC; 218 return -ENOEXEC;
219 } 219 }
220 220
@@ -367,7 +367,7 @@ static int load_aout_library(struct file *file)
367 int retval; 367 int retval;
368 struct exec ex; 368 struct exec ex;
369 369
370 inode = file->f_path.dentry->d_inode; 370 inode = file_inode(file);
371 371
372 retval = -ENOEXEC; 372 retval = -ENOEXEC;
373 error = kernel_read(file, 0, (char *) &ex, sizeof(ex)); 373 error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index ff9dbc630efa..a5702d74d2bd 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1141,7 +1141,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
1141 1141
1142 /* By default, dump shared memory if mapped from an anonymous file. */ 1142 /* By default, dump shared memory if mapped from an anonymous file. */
1143 if (vma->vm_flags & VM_SHARED) { 1143 if (vma->vm_flags & VM_SHARED) {
1144 if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0 ? 1144 if (file_inode(vma->vm_file)->i_nlink == 0 ?
1145 FILTER(ANON_SHARED) : FILTER(MAPPED_SHARED)) 1145 FILTER(ANON_SHARED) : FILTER(MAPPED_SHARED))
1146 goto whole; 1146 goto whole;
1147 return 0; 1147 return 0;
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index cb240dd3b402..9c13e023e2b7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -909,7 +909,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
909 909
910dynamic_error: 910dynamic_error:
911 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n", 911 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n",
912 what, file->f_path.dentry->d_inode->i_ino); 912 what, file_inode(file)->i_ino);
913 return -ELIBBAD; 913 return -ELIBBAD;
914} 914}
915 915
@@ -1219,7 +1219,7 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
1219 1219
1220 /* By default, dump shared memory if mapped from an anonymous file. */ 1220 /* By default, dump shared memory if mapped from an anonymous file. */
1221 if (vma->vm_flags & VM_SHARED) { 1221 if (vma->vm_flags & VM_SHARED) {
1222 if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0) { 1222 if (file_inode(vma->vm_file)->i_nlink == 0) {
1223 dump_ok = test_bit(MMF_DUMP_ANON_SHARED, &mm_flags); 1223 dump_ok = test_bit(MMF_DUMP_ANON_SHARED, &mm_flags);
1224 kdcore("%08lx: %08lx: %s (share)", vma->vm_start, 1224 kdcore("%08lx: %08lx: %s (share)", vma->vm_start,
1225 vma->vm_flags, dump_ok ? "yes" : "no"); 1225 vma->vm_flags, dump_ok ? "yes" : "no");
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index b56371981d16..2036d21baaef 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -438,7 +438,7 @@ static int load_flat_file(struct linux_binprm * bprm,
438 int ret; 438 int ret;
439 439
440 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */ 440 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
441 inode = bprm->file->f_path.dentry->d_inode; 441 inode = file_inode(bprm->file);
442 442
443 text_len = ntohl(hdr->data_start); 443 text_len = ntohl(hdr->data_start);
444 data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start); 444 data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start);
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 0c8869fdd14e..fecbbf3f8ff2 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -531,7 +531,7 @@ static void kill_node(Node *e)
531static ssize_t 531static ssize_t
532bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) 532bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
533{ 533{
534 Node *e = file->f_path.dentry->d_inode->i_private; 534 Node *e = file_inode(file)->i_private;
535 ssize_t res; 535 ssize_t res;
536 char *page; 536 char *page;
537 537
@@ -550,7 +550,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
550 size_t count, loff_t *ppos) 550 size_t count, loff_t *ppos)
551{ 551{
552 struct dentry *root; 552 struct dentry *root;
553 Node *e = file->f_path.dentry->d_inode->i_private; 553 Node *e = file_inode(file)->i_private;
554 int res = parse_command(buffer, count); 554 int res = parse_command(buffer, count);
555 555
556 switch (res) { 556 switch (res) {
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 78333a37f49d..53f5fae5cfbe 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -318,7 +318,7 @@ static int blkdev_write_end(struct file *file, struct address_space *mapping,
318 318
319/* 319/*
320 * private llseek: 320 * private llseek:
321 * for a block special file file->f_path.dentry->d_inode->i_size is zero 321 * for a block special file file_inode(file)->i_size is zero
322 * so we compute the size by hand (just as in block_read/write above) 322 * so we compute the size by hand (just as in block_read/write above)
323 */ 323 */
324static loff_t block_llseek(struct file *file, loff_t offset, int whence) 324static loff_t block_llseek(struct file *file, loff_t offset, int whence)
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 614f34a899c2..81ee29eeb7ca 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -22,10 +22,10 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
22 22
23 if (parent && (len < BTRFS_FID_SIZE_CONNECTABLE)) { 23 if (parent && (len < BTRFS_FID_SIZE_CONNECTABLE)) {
24 *max_len = BTRFS_FID_SIZE_CONNECTABLE; 24 *max_len = BTRFS_FID_SIZE_CONNECTABLE;
25 return 255; 25 return FILEID_INVALID;
26 } else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) { 26 } else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) {
27 *max_len = BTRFS_FID_SIZE_NON_CONNECTABLE; 27 *max_len = BTRFS_FID_SIZE_NON_CONNECTABLE;
28 return 255; 28 return FILEID_INVALID;
29 } 29 }
30 30
31 len = BTRFS_FID_SIZE_NON_CONNECTABLE; 31 len = BTRFS_FID_SIZE_NON_CONNECTABLE;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index aeb84469d2c4..4b241fe9d2fe 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1225,7 +1225,7 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
1225 struct extent_state *cached_state = NULL; 1225 struct extent_state *cached_state = NULL;
1226 int i; 1226 int i;
1227 unsigned long index = pos >> PAGE_CACHE_SHIFT; 1227 unsigned long index = pos >> PAGE_CACHE_SHIFT;
1228 struct inode *inode = fdentry(file)->d_inode; 1228 struct inode *inode = file_inode(file);
1229 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); 1229 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
1230 int err = 0; 1230 int err = 0;
1231 int faili = 0; 1231 int faili = 0;
@@ -1312,7 +1312,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
1312 struct iov_iter *i, 1312 struct iov_iter *i,
1313 loff_t pos) 1313 loff_t pos)
1314{ 1314{
1315 struct inode *inode = fdentry(file)->d_inode; 1315 struct inode *inode = file_inode(file);
1316 struct btrfs_root *root = BTRFS_I(inode)->root; 1316 struct btrfs_root *root = BTRFS_I(inode)->root;
1317 struct page **pages = NULL; 1317 struct page **pages = NULL;
1318 unsigned long first_index; 1318 unsigned long first_index;
@@ -1500,7 +1500,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1500 unsigned long nr_segs, loff_t pos) 1500 unsigned long nr_segs, loff_t pos)
1501{ 1501{
1502 struct file *file = iocb->ki_filp; 1502 struct file *file = iocb->ki_filp;
1503 struct inode *inode = fdentry(file)->d_inode; 1503 struct inode *inode = file_inode(file);
1504 struct btrfs_root *root = BTRFS_I(inode)->root; 1504 struct btrfs_root *root = BTRFS_I(inode)->root;
1505 loff_t *ppos = &iocb->ki_pos; 1505 loff_t *ppos = &iocb->ki_pos;
1506 u64 start_pos; 1506 u64 start_pos;
@@ -2102,7 +2102,7 @@ out:
2102static long btrfs_fallocate(struct file *file, int mode, 2102static long btrfs_fallocate(struct file *file, int mode,
2103 loff_t offset, loff_t len) 2103 loff_t offset, loff_t len)
2104{ 2104{
2105 struct inode *inode = file->f_path.dentry->d_inode; 2105 struct inode *inode = file_inode(file);
2106 struct extent_state *cached_state = NULL; 2106 struct extent_state *cached_state = NULL;
2107 u64 cur_offset; 2107 u64 cur_offset;
2108 u64 last_byte; 2108 u64 last_byte;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cc93b23ca352..55c07b650378 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4391,7 +4391,7 @@ unsigned char btrfs_filetype_table[] = {
4391static int btrfs_real_readdir(struct file *filp, void *dirent, 4391static int btrfs_real_readdir(struct file *filp, void *dirent,
4392 filldir_t filldir) 4392 filldir_t filldir)
4393{ 4393{
4394 struct inode *inode = filp->f_dentry->d_inode; 4394 struct inode *inode = file_inode(filp);
4395 struct btrfs_root *root = BTRFS_I(inode)->root; 4395 struct btrfs_root *root = BTRFS_I(inode)->root;
4396 struct btrfs_item *item; 4396 struct btrfs_item *item;
4397 struct btrfs_dir_item *di; 4397 struct btrfs_dir_item *di;
@@ -6791,7 +6791,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset)
6791int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 6791int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
6792{ 6792{
6793 struct page *page = vmf->page; 6793 struct page *page = vmf->page;
6794 struct inode *inode = fdentry(vma->vm_file)->d_inode; 6794 struct inode *inode = file_inode(vma->vm_file);
6795 struct btrfs_root *root = BTRFS_I(inode)->root; 6795 struct btrfs_root *root = BTRFS_I(inode)->root;
6796 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 6796 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
6797 struct btrfs_ordered_extent *ordered; 6797 struct btrfs_ordered_extent *ordered;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 338f2597bf7f..c3f09f71bedd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -152,7 +152,7 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
152 152
153static int btrfs_ioctl_getflags(struct file *file, void __user *arg) 153static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
154{ 154{
155 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode); 155 struct btrfs_inode *ip = BTRFS_I(file_inode(file));
156 unsigned int flags = btrfs_flags_to_ioctl(ip->flags); 156 unsigned int flags = btrfs_flags_to_ioctl(ip->flags);
157 157
158 if (copy_to_user(arg, &flags, sizeof(flags))) 158 if (copy_to_user(arg, &flags, sizeof(flags)))
@@ -177,7 +177,7 @@ static int check_flags(unsigned int flags)
177 177
178static int btrfs_ioctl_setflags(struct file *file, void __user *arg) 178static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
179{ 179{
180 struct inode *inode = file->f_path.dentry->d_inode; 180 struct inode *inode = file_inode(file);
181 struct btrfs_inode *ip = BTRFS_I(inode); 181 struct btrfs_inode *ip = BTRFS_I(inode);
182 struct btrfs_root *root = ip->root; 182 struct btrfs_root *root = ip->root;
183 struct btrfs_trans_handle *trans; 183 struct btrfs_trans_handle *trans;
@@ -310,7 +310,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
310 310
311static int btrfs_ioctl_getversion(struct file *file, int __user *arg) 311static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
312{ 312{
313 struct inode *inode = file->f_path.dentry->d_inode; 313 struct inode *inode = file_inode(file);
314 314
315 return put_user(inode->i_generation, arg); 315 return put_user(inode->i_generation, arg);
316} 316}
@@ -1320,7 +1320,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
1320 u64 new_size; 1320 u64 new_size;
1321 u64 old_size; 1321 u64 old_size;
1322 u64 devid = 1; 1322 u64 devid = 1;
1323 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 1323 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
1324 struct btrfs_ioctl_vol_args *vol_args; 1324 struct btrfs_ioctl_vol_args *vol_args;
1325 struct btrfs_trans_handle *trans; 1325 struct btrfs_trans_handle *trans;
1326 struct btrfs_device *device = NULL; 1326 struct btrfs_device *device = NULL;
@@ -1489,8 +1489,8 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
1489 goto out_drop_write; 1489 goto out_drop_write;
1490 } 1490 }
1491 1491
1492 src_inode = src.file->f_path.dentry->d_inode; 1492 src_inode = file_inode(src.file);
1493 if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) { 1493 if (src_inode->i_sb != file_inode(file)->i_sb) {
1494 printk(KERN_INFO "btrfs: Snapshot src from " 1494 printk(KERN_INFO "btrfs: Snapshot src from "
1495 "another FS\n"); 1495 "another FS\n");
1496 ret = -EINVAL; 1496 ret = -EINVAL;
@@ -1582,7 +1582,7 @@ out:
1582static noinline int btrfs_ioctl_subvol_getflags(struct file *file, 1582static noinline int btrfs_ioctl_subvol_getflags(struct file *file,
1583 void __user *arg) 1583 void __user *arg)
1584{ 1584{
1585 struct inode *inode = fdentry(file)->d_inode; 1585 struct inode *inode = file_inode(file);
1586 struct btrfs_root *root = BTRFS_I(inode)->root; 1586 struct btrfs_root *root = BTRFS_I(inode)->root;
1587 int ret = 0; 1587 int ret = 0;
1588 u64 flags = 0; 1588 u64 flags = 0;
@@ -1604,7 +1604,7 @@ static noinline int btrfs_ioctl_subvol_getflags(struct file *file,
1604static noinline int btrfs_ioctl_subvol_setflags(struct file *file, 1604static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
1605 void __user *arg) 1605 void __user *arg)
1606{ 1606{
1607 struct inode *inode = fdentry(file)->d_inode; 1607 struct inode *inode = file_inode(file);
1608 struct btrfs_root *root = BTRFS_I(inode)->root; 1608 struct btrfs_root *root = BTRFS_I(inode)->root;
1609 struct btrfs_trans_handle *trans; 1609 struct btrfs_trans_handle *trans;
1610 u64 root_flags; 1610 u64 root_flags;
@@ -1898,7 +1898,7 @@ static noinline int btrfs_ioctl_tree_search(struct file *file,
1898 if (IS_ERR(args)) 1898 if (IS_ERR(args))
1899 return PTR_ERR(args); 1899 return PTR_ERR(args);
1900 1900
1901 inode = fdentry(file)->d_inode; 1901 inode = file_inode(file);
1902 ret = search_ioctl(inode, args); 1902 ret = search_ioctl(inode, args);
1903 if (ret == 0 && copy_to_user(argp, args, sizeof(*args))) 1903 if (ret == 0 && copy_to_user(argp, args, sizeof(*args)))
1904 ret = -EFAULT; 1904 ret = -EFAULT;
@@ -2008,7 +2008,7 @@ static noinline int btrfs_ioctl_ino_lookup(struct file *file,
2008 if (IS_ERR(args)) 2008 if (IS_ERR(args))
2009 return PTR_ERR(args); 2009 return PTR_ERR(args);
2010 2010
2011 inode = fdentry(file)->d_inode; 2011 inode = file_inode(file);
2012 2012
2013 if (args->treeid == 0) 2013 if (args->treeid == 0)
2014 args->treeid = BTRFS_I(inode)->root->root_key.objectid; 2014 args->treeid = BTRFS_I(inode)->root->root_key.objectid;
@@ -2184,7 +2184,7 @@ out:
2184 2184
2185static int btrfs_ioctl_defrag(struct file *file, void __user *argp) 2185static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
2186{ 2186{
2187 struct inode *inode = fdentry(file)->d_inode; 2187 struct inode *inode = file_inode(file);
2188 struct btrfs_root *root = BTRFS_I(inode)->root; 2188 struct btrfs_root *root = BTRFS_I(inode)->root;
2189 struct btrfs_ioctl_defrag_range_args *range; 2189 struct btrfs_ioctl_defrag_range_args *range;
2190 int ret; 2190 int ret;
@@ -2244,7 +2244,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
2244 /* the rest are all set to zero by kzalloc */ 2244 /* the rest are all set to zero by kzalloc */
2245 range->len = (u64)-1; 2245 range->len = (u64)-1;
2246 } 2246 }
2247 ret = btrfs_defrag_file(fdentry(file)->d_inode, file, 2247 ret = btrfs_defrag_file(file_inode(file), file,
2248 range, 0, 0); 2248 range, 0, 0);
2249 if (ret > 0) 2249 if (ret > 0)
2250 ret = 0; 2250 ret = 0;
@@ -2292,7 +2292,7 @@ out:
2292 2292
2293static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) 2293static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
2294{ 2294{
2295 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 2295 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
2296 struct btrfs_ioctl_vol_args *vol_args; 2296 struct btrfs_ioctl_vol_args *vol_args;
2297 int ret; 2297 int ret;
2298 2298
@@ -2415,7 +2415,7 @@ out:
2415static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, 2415static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2416 u64 off, u64 olen, u64 destoff) 2416 u64 off, u64 olen, u64 destoff)
2417{ 2417{
2418 struct inode *inode = fdentry(file)->d_inode; 2418 struct inode *inode = file_inode(file);
2419 struct btrfs_root *root = BTRFS_I(inode)->root; 2419 struct btrfs_root *root = BTRFS_I(inode)->root;
2420 struct fd src_file; 2420 struct fd src_file;
2421 struct inode *src; 2421 struct inode *src;
@@ -2461,7 +2461,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2461 if (src_file.file->f_path.mnt != file->f_path.mnt) 2461 if (src_file.file->f_path.mnt != file->f_path.mnt)
2462 goto out_fput; 2462 goto out_fput;
2463 2463
2464 src = src_file.file->f_dentry->d_inode; 2464 src = file_inode(src_file.file);
2465 2465
2466 ret = -EINVAL; 2466 ret = -EINVAL;
2467 if (src == inode) 2467 if (src == inode)
@@ -2823,7 +2823,7 @@ static long btrfs_ioctl_clone_range(struct file *file, void __user *argp)
2823 */ 2823 */
2824static long btrfs_ioctl_trans_start(struct file *file) 2824static long btrfs_ioctl_trans_start(struct file *file)
2825{ 2825{
2826 struct inode *inode = fdentry(file)->d_inode; 2826 struct inode *inode = file_inode(file);
2827 struct btrfs_root *root = BTRFS_I(inode)->root; 2827 struct btrfs_root *root = BTRFS_I(inode)->root;
2828 struct btrfs_trans_handle *trans; 2828 struct btrfs_trans_handle *trans;
2829 int ret; 2829 int ret;
@@ -2863,7 +2863,7 @@ out:
2863 2863
2864static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) 2864static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
2865{ 2865{
2866 struct inode *inode = fdentry(file)->d_inode; 2866 struct inode *inode = file_inode(file);
2867 struct btrfs_root *root = BTRFS_I(inode)->root; 2867 struct btrfs_root *root = BTRFS_I(inode)->root;
2868 struct btrfs_root *new_root; 2868 struct btrfs_root *new_root;
2869 struct btrfs_dir_item *di; 2869 struct btrfs_dir_item *di;
@@ -3087,7 +3087,7 @@ out:
3087 */ 3087 */
3088long btrfs_ioctl_trans_end(struct file *file) 3088long btrfs_ioctl_trans_end(struct file *file)
3089{ 3089{
3090 struct inode *inode = fdentry(file)->d_inode; 3090 struct inode *inode = file_inode(file);
3091 struct btrfs_root *root = BTRFS_I(inode)->root; 3091 struct btrfs_root *root = BTRFS_I(inode)->root;
3092 struct btrfs_trans_handle *trans; 3092 struct btrfs_trans_handle *trans;
3093 3093
@@ -3149,7 +3149,7 @@ static noinline long btrfs_ioctl_wait_sync(struct btrfs_root *root,
3149 3149
3150static long btrfs_ioctl_scrub(struct file *file, void __user *arg) 3150static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
3151{ 3151{
3152 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3152 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3153 struct btrfs_ioctl_scrub_args *sa; 3153 struct btrfs_ioctl_scrub_args *sa;
3154 int ret; 3154 int ret;
3155 3155
@@ -3440,7 +3440,7 @@ void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock,
3440 3440
3441static long btrfs_ioctl_balance(struct file *file, void __user *arg) 3441static long btrfs_ioctl_balance(struct file *file, void __user *arg)
3442{ 3442{
3443 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3443 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3444 struct btrfs_fs_info *fs_info = root->fs_info; 3444 struct btrfs_fs_info *fs_info = root->fs_info;
3445 struct btrfs_ioctl_balance_args *bargs; 3445 struct btrfs_ioctl_balance_args *bargs;
3446 struct btrfs_balance_control *bctl; 3446 struct btrfs_balance_control *bctl;
@@ -3630,7 +3630,7 @@ out:
3630 3630
3631static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg) 3631static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
3632{ 3632{
3633 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3633 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3634 struct btrfs_ioctl_quota_ctl_args *sa; 3634 struct btrfs_ioctl_quota_ctl_args *sa;
3635 struct btrfs_trans_handle *trans = NULL; 3635 struct btrfs_trans_handle *trans = NULL;
3636 int ret; 3636 int ret;
@@ -3689,7 +3689,7 @@ drop_write:
3689 3689
3690static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg) 3690static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
3691{ 3691{
3692 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3692 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3693 struct btrfs_ioctl_qgroup_assign_args *sa; 3693 struct btrfs_ioctl_qgroup_assign_args *sa;
3694 struct btrfs_trans_handle *trans; 3694 struct btrfs_trans_handle *trans;
3695 int ret; 3695 int ret;
@@ -3736,7 +3736,7 @@ drop_write:
3736 3736
3737static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg) 3737static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
3738{ 3738{
3739 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3739 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3740 struct btrfs_ioctl_qgroup_create_args *sa; 3740 struct btrfs_ioctl_qgroup_create_args *sa;
3741 struct btrfs_trans_handle *trans; 3741 struct btrfs_trans_handle *trans;
3742 int ret; 3742 int ret;
@@ -3787,7 +3787,7 @@ drop_write:
3787 3787
3788static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg) 3788static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg)
3789{ 3789{
3790 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3790 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3791 struct btrfs_ioctl_qgroup_limit_args *sa; 3791 struct btrfs_ioctl_qgroup_limit_args *sa;
3792 struct btrfs_trans_handle *trans; 3792 struct btrfs_trans_handle *trans;
3793 int ret; 3793 int ret;
@@ -3837,7 +3837,7 @@ static long btrfs_ioctl_set_received_subvol(struct file *file,
3837 void __user *arg) 3837 void __user *arg)
3838{ 3838{
3839 struct btrfs_ioctl_received_subvol_args *sa = NULL; 3839 struct btrfs_ioctl_received_subvol_args *sa = NULL;
3840 struct inode *inode = fdentry(file)->d_inode; 3840 struct inode *inode = file_inode(file);
3841 struct btrfs_root *root = BTRFS_I(inode)->root; 3841 struct btrfs_root *root = BTRFS_I(inode)->root;
3842 struct btrfs_root_item *root_item = &root->root_item; 3842 struct btrfs_root_item *root_item = &root->root_item;
3843 struct btrfs_trans_handle *trans; 3843 struct btrfs_trans_handle *trans;
@@ -3917,7 +3917,7 @@ out:
3917long btrfs_ioctl(struct file *file, unsigned int 3917long btrfs_ioctl(struct file *file, unsigned int
3918 cmd, unsigned long arg) 3918 cmd, unsigned long arg)
3919{ 3919{
3920 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root; 3920 struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
3921 void __user *argp = (void __user *)arg; 3921 void __user *argp = (void __user *)arg;
3922 3922
3923 switch (cmd) { 3923 switch (cmd) {
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 321b7fb4e441..f4ab7a9260eb 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4544,7 +4544,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
4544 if (!capable(CAP_SYS_ADMIN)) 4544 if (!capable(CAP_SYS_ADMIN))
4545 return -EPERM; 4545 return -EPERM;
4546 4546
4547 send_root = BTRFS_I(fdentry(mnt_file)->d_inode)->root; 4547 send_root = BTRFS_I(file_inode(mnt_file))->root;
4548 fs_info = send_root->fs_info; 4548 fs_info = send_root->fs_info;
4549 4549
4550 arg = memdup_user(arg_, sizeof(*arg)); 4550 arg = memdup_user(arg_, sizeof(*arg));
diff --git a/fs/buffer.c b/fs/buffer.c
index 62169c192c21..8e18281b4077 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2332,7 +2332,7 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
2332 get_block_t get_block) 2332 get_block_t get_block)
2333{ 2333{
2334 struct page *page = vmf->page; 2334 struct page *page = vmf->page;
2335 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 2335 struct inode *inode = file_inode(vma->vm_file);
2336 unsigned long end; 2336 unsigned long end;
2337 loff_t size; 2337 loff_t size;
2338 int ret; 2338 int ret;
@@ -2371,7 +2371,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
2371 get_block_t get_block) 2371 get_block_t get_block)
2372{ 2372{
2373 int ret; 2373 int ret;
2374 struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb; 2374 struct super_block *sb = file_inode(vma->vm_file)->i_sb;
2375 2375
2376 sb_start_pagefault(sb); 2376 sb_start_pagefault(sb);
2377 2377
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 064d1a68d2c1..d4f81edd9a5d 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -195,7 +195,7 @@ static int ceph_releasepage(struct page *page, gfp_t g)
195 */ 195 */
196static int readpage_nounlock(struct file *filp, struct page *page) 196static int readpage_nounlock(struct file *filp, struct page *page)
197{ 197{
198 struct inode *inode = filp->f_dentry->d_inode; 198 struct inode *inode = file_inode(filp);
199 struct ceph_inode_info *ci = ceph_inode(inode); 199 struct ceph_inode_info *ci = ceph_inode(inode);
200 struct ceph_osd_client *osdc = 200 struct ceph_osd_client *osdc =
201 &ceph_inode_to_client(inode)->client->osdc; 201 &ceph_inode_to_client(inode)->client->osdc;
@@ -370,7 +370,7 @@ out:
370static int ceph_readpages(struct file *file, struct address_space *mapping, 370static int ceph_readpages(struct file *file, struct address_space *mapping,
371 struct list_head *page_list, unsigned nr_pages) 371 struct list_head *page_list, unsigned nr_pages)
372{ 372{
373 struct inode *inode = file->f_dentry->d_inode; 373 struct inode *inode = file_inode(file);
374 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 374 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
375 int rc = 0; 375 int rc = 0;
376 int max = 0; 376 int max = 0;
@@ -977,7 +977,7 @@ static int ceph_update_writeable_page(struct file *file,
977 loff_t pos, unsigned len, 977 loff_t pos, unsigned len,
978 struct page *page) 978 struct page *page)
979{ 979{
980 struct inode *inode = file->f_dentry->d_inode; 980 struct inode *inode = file_inode(file);
981 struct ceph_inode_info *ci = ceph_inode(inode); 981 struct ceph_inode_info *ci = ceph_inode(inode);
982 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc; 982 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
983 loff_t page_off = pos & PAGE_CACHE_MASK; 983 loff_t page_off = pos & PAGE_CACHE_MASK;
@@ -1086,7 +1086,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
1086 loff_t pos, unsigned len, unsigned flags, 1086 loff_t pos, unsigned len, unsigned flags,
1087 struct page **pagep, void **fsdata) 1087 struct page **pagep, void **fsdata)
1088{ 1088{
1089 struct inode *inode = file->f_dentry->d_inode; 1089 struct inode *inode = file_inode(file);
1090 struct ceph_inode_info *ci = ceph_inode(inode); 1090 struct ceph_inode_info *ci = ceph_inode(inode);
1091 struct ceph_file_info *fi = file->private_data; 1091 struct ceph_file_info *fi = file->private_data;
1092 struct page *page; 1092 struct page *page;
@@ -1144,7 +1144,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
1144 loff_t pos, unsigned len, unsigned copied, 1144 loff_t pos, unsigned len, unsigned copied,
1145 struct page *page, void *fsdata) 1145 struct page *page, void *fsdata)
1146{ 1146{
1147 struct inode *inode = file->f_dentry->d_inode; 1147 struct inode *inode = file_inode(file);
1148 struct ceph_inode_info *ci = ceph_inode(inode); 1148 struct ceph_inode_info *ci = ceph_inode(inode);
1149 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 1149 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
1150 struct ceph_mds_client *mdsc = fsc->mdsc; 1150 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1228,7 +1228,7 @@ const struct address_space_operations ceph_aops = {
1228 */ 1228 */
1229static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 1229static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
1230{ 1230{
1231 struct inode *inode = vma->vm_file->f_dentry->d_inode; 1231 struct inode *inode = file_inode(vma->vm_file);
1232 struct page *page = vmf->page; 1232 struct page *page = vmf->page;
1233 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc; 1233 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
1234 loff_t off = page_offset(page); 1234 loff_t off = page_offset(page);
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 8c1aabe93b67..6d797f46d772 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -238,7 +238,7 @@ static int note_last_dentry(struct ceph_file_info *fi, const char *name,
238static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir) 238static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
239{ 239{
240 struct ceph_file_info *fi = filp->private_data; 240 struct ceph_file_info *fi = filp->private_data;
241 struct inode *inode = filp->f_dentry->d_inode; 241 struct inode *inode = file_inode(filp);
242 struct ceph_inode_info *ci = ceph_inode(inode); 242 struct ceph_inode_info *ci = ceph_inode(inode);
243 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 243 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
244 struct ceph_mds_client *mdsc = fsc->mdsc; 244 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1138,7 +1138,7 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
1138 loff_t *ppos) 1138 loff_t *ppos)
1139{ 1139{
1140 struct ceph_file_info *cf = file->private_data; 1140 struct ceph_file_info *cf = file->private_data;
1141 struct inode *inode = file->f_dentry->d_inode; 1141 struct inode *inode = file_inode(file);
1142 struct ceph_inode_info *ci = ceph_inode(inode); 1142 struct ceph_inode_info *ci = ceph_inode(inode);
1143 int left; 1143 int left;
1144 const int bufsize = 1024; 1144 const int bufsize = 1024;
@@ -1188,7 +1188,7 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
1188static int ceph_dir_fsync(struct file *file, loff_t start, loff_t end, 1188static int ceph_dir_fsync(struct file *file, loff_t start, loff_t end,
1189 int datasync) 1189 int datasync)
1190{ 1190{
1191 struct inode *inode = file->f_path.dentry->d_inode; 1191 struct inode *inode = file_inode(file);
1192 struct ceph_inode_info *ci = ceph_inode(inode); 1192 struct ceph_inode_info *ci = ceph_inode(inode);
1193 struct list_head *head = &ci->i_unsafe_dirops; 1193 struct list_head *head = &ci->i_unsafe_dirops;
1194 struct ceph_mds_request *req; 1194 struct ceph_mds_request *req;
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index ca3ab3f9ca70..16796be53ca5 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -81,7 +81,7 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
81 if (parent_inode) { 81 if (parent_inode) {
82 /* nfsd wants connectable */ 82 /* nfsd wants connectable */
83 *max_len = connected_handle_length; 83 *max_len = connected_handle_length;
84 type = 255; 84 type = FILEID_INVALID;
85 } else { 85 } else {
86 dout("encode_fh %p\n", dentry); 86 dout("encode_fh %p\n", dentry);
87 fh->ino = ceph_ino(inode); 87 fh->ino = ceph_ino(inode);
@@ -90,7 +90,7 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
90 } 90 }
91 } else { 91 } else {
92 *max_len = handle_length; 92 *max_len = handle_length;
93 type = 255; 93 type = FILEID_INVALID;
94 } 94 }
95 if (dentry) 95 if (dentry)
96 dput(dentry); 96 dput(dentry);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index e51558fca3a3..11b57c2c8f15 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -393,7 +393,7 @@ more:
393static ssize_t ceph_sync_read(struct file *file, char __user *data, 393static ssize_t ceph_sync_read(struct file *file, char __user *data,
394 unsigned len, loff_t *poff, int *checkeof) 394 unsigned len, loff_t *poff, int *checkeof)
395{ 395{
396 struct inode *inode = file->f_dentry->d_inode; 396 struct inode *inode = file_inode(file);
397 struct page **pages; 397 struct page **pages;
398 u64 off = *poff; 398 u64 off = *poff;
399 int num_pages, ret; 399 int num_pages, ret;
@@ -466,7 +466,7 @@ static void sync_write_commit(struct ceph_osd_request *req,
466static ssize_t ceph_sync_write(struct file *file, const char __user *data, 466static ssize_t ceph_sync_write(struct file *file, const char __user *data,
467 size_t left, loff_t *offset) 467 size_t left, loff_t *offset)
468{ 468{
469 struct inode *inode = file->f_dentry->d_inode; 469 struct inode *inode = file_inode(file);
470 struct ceph_inode_info *ci = ceph_inode(inode); 470 struct ceph_inode_info *ci = ceph_inode(inode);
471 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 471 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
472 struct ceph_osd_request *req; 472 struct ceph_osd_request *req;
@@ -483,7 +483,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
483 int ret; 483 int ret;
484 struct timespec mtime = CURRENT_TIME; 484 struct timespec mtime = CURRENT_TIME;
485 485
486 if (ceph_snap(file->f_dentry->d_inode) != CEPH_NOSNAP) 486 if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
487 return -EROFS; 487 return -EROFS;
488 488
489 dout("sync_write on file %p %lld~%u %s\n", file, *offset, 489 dout("sync_write on file %p %lld~%u %s\n", file, *offset,
@@ -637,7 +637,7 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
637 struct ceph_file_info *fi = filp->private_data; 637 struct ceph_file_info *fi = filp->private_data;
638 loff_t *ppos = &iocb->ki_pos; 638 loff_t *ppos = &iocb->ki_pos;
639 size_t len = iov->iov_len; 639 size_t len = iov->iov_len;
640 struct inode *inode = filp->f_dentry->d_inode; 640 struct inode *inode = file_inode(filp);
641 struct ceph_inode_info *ci = ceph_inode(inode); 641 struct ceph_inode_info *ci = ceph_inode(inode);
642 void __user *base = iov->iov_base; 642 void __user *base = iov->iov_base;
643 ssize_t ret; 643 ssize_t ret;
@@ -707,7 +707,7 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
707{ 707{
708 struct file *file = iocb->ki_filp; 708 struct file *file = iocb->ki_filp;
709 struct ceph_file_info *fi = file->private_data; 709 struct ceph_file_info *fi = file->private_data;
710 struct inode *inode = file->f_dentry->d_inode; 710 struct inode *inode = file_inode(file);
711 struct ceph_inode_info *ci = ceph_inode(inode); 711 struct ceph_inode_info *ci = ceph_inode(inode);
712 struct ceph_osd_client *osdc = 712 struct ceph_osd_client *osdc =
713 &ceph_sb_to_client(inode->i_sb)->client->osdc; 713 &ceph_sb_to_client(inode->i_sb)->client->osdc;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index d45895f4a04d..851814d951cd 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1131,8 +1131,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
1131 req->r_request_started); 1131 req->r_request_started);
1132 dout(" final dn %p\n", dn); 1132 dout(" final dn %p\n", dn);
1133 i++; 1133 i++;
1134 } else if (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || 1134 } else if ((req->r_op == CEPH_MDS_OP_LOOKUPSNAP ||
1135 req->r_op == CEPH_MDS_OP_MKSNAP) { 1135 req->r_op == CEPH_MDS_OP_MKSNAP) && !req->r_aborted) {
1136 struct dentry *dn = req->r_dentry; 1136 struct dentry *dn = req->r_dentry;
1137 1137
1138 /* fill out a snapdir LOOKUPSNAP dentry */ 1138 /* fill out a snapdir LOOKUPSNAP dentry */
@@ -1196,6 +1196,39 @@ done:
1196/* 1196/*
1197 * Prepopulate our cache with readdir results, leases, etc. 1197 * Prepopulate our cache with readdir results, leases, etc.
1198 */ 1198 */
1199static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
1200 struct ceph_mds_session *session)
1201{
1202 struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
1203 int i, err = 0;
1204
1205 for (i = 0; i < rinfo->dir_nr; i++) {
1206 struct ceph_vino vino;
1207 struct inode *in;
1208 int rc;
1209
1210 vino.ino = le64_to_cpu(rinfo->dir_in[i].in->ino);
1211 vino.snap = le64_to_cpu(rinfo->dir_in[i].in->snapid);
1212
1213 in = ceph_get_inode(req->r_dentry->d_sb, vino);
1214 if (IS_ERR(in)) {
1215 err = PTR_ERR(in);
1216 dout("new_inode badness got %d\n", err);
1217 continue;
1218 }
1219 rc = fill_inode(in, &rinfo->dir_in[i], NULL, session,
1220 req->r_request_started, -1,
1221 &req->r_caps_reservation);
1222 if (rc < 0) {
1223 pr_err("fill_inode badness on %p got %d\n", in, rc);
1224 err = rc;
1225 continue;
1226 }
1227 }
1228
1229 return err;
1230}
1231
1199int ceph_readdir_prepopulate(struct ceph_mds_request *req, 1232int ceph_readdir_prepopulate(struct ceph_mds_request *req,
1200 struct ceph_mds_session *session) 1233 struct ceph_mds_session *session)
1201{ 1234{
@@ -1210,6 +1243,9 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
1210 u64 frag = le32_to_cpu(rhead->args.readdir.frag); 1243 u64 frag = le32_to_cpu(rhead->args.readdir.frag);
1211 struct ceph_dentry_info *di; 1244 struct ceph_dentry_info *di;
1212 1245
1246 if (req->r_aborted)
1247 return readdir_prepopulate_inodes_only(req, session);
1248
1213 if (le32_to_cpu(rinfo->head->op) == CEPH_MDS_OP_LSSNAP) { 1249 if (le32_to_cpu(rinfo->head->op) == CEPH_MDS_OP_LSSNAP) {
1214 snapdir = ceph_get_snapdir(parent->d_inode); 1250 snapdir = ceph_get_snapdir(parent->d_inode);
1215 parent = d_find_alias(snapdir); 1251 parent = d_find_alias(snapdir);
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 36549a46e311..f5ed767806df 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -16,11 +16,11 @@
16 */ 16 */
17static long ceph_ioctl_get_layout(struct file *file, void __user *arg) 17static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
18{ 18{
19 struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode); 19 struct ceph_inode_info *ci = ceph_inode(file_inode(file));
20 struct ceph_ioctl_layout l; 20 struct ceph_ioctl_layout l;
21 int err; 21 int err;
22 22
23 err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT); 23 err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT);
24 if (!err) { 24 if (!err) {
25 l.stripe_unit = ceph_file_layout_su(ci->i_layout); 25 l.stripe_unit = ceph_file_layout_su(ci->i_layout);
26 l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout); 26 l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
@@ -63,12 +63,12 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
63 63
64static long ceph_ioctl_set_layout(struct file *file, void __user *arg) 64static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
65{ 65{
66 struct inode *inode = file->f_dentry->d_inode; 66 struct inode *inode = file_inode(file);
67 struct inode *parent_inode; 67 struct inode *parent_inode;
68 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; 68 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
69 struct ceph_mds_request *req; 69 struct ceph_mds_request *req;
70 struct ceph_ioctl_layout l; 70 struct ceph_ioctl_layout l;
71 struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode); 71 struct ceph_inode_info *ci = ceph_inode(file_inode(file));
72 struct ceph_ioctl_layout nl; 72 struct ceph_ioctl_layout nl;
73 int err; 73 int err;
74 74
@@ -76,7 +76,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
76 return -EFAULT; 76 return -EFAULT;
77 77
78 /* validate changed params against current layout */ 78 /* validate changed params against current layout */
79 err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT); 79 err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT);
80 if (err) 80 if (err)
81 return err; 81 return err;
82 82
@@ -136,7 +136,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
136 */ 136 */
137static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) 137static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
138{ 138{
139 struct inode *inode = file->f_dentry->d_inode; 139 struct inode *inode = file_inode(file);
140 struct ceph_mds_request *req; 140 struct ceph_mds_request *req;
141 struct ceph_ioctl_layout l; 141 struct ceph_ioctl_layout l;
142 int err; 142 int err;
@@ -179,7 +179,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
179static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) 179static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
180{ 180{
181 struct ceph_ioctl_dataloc dl; 181 struct ceph_ioctl_dataloc dl;
182 struct inode *inode = file->f_dentry->d_inode; 182 struct inode *inode = file_inode(file);
183 struct ceph_inode_info *ci = ceph_inode(inode); 183 struct ceph_inode_info *ci = ceph_inode(inode);
184 struct ceph_osd_client *osdc = 184 struct ceph_osd_client *osdc =
185 &ceph_sb_to_client(inode->i_sb)->client->osdc; 185 &ceph_sb_to_client(inode->i_sb)->client->osdc;
@@ -234,7 +234,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
234static long ceph_ioctl_lazyio(struct file *file) 234static long ceph_ioctl_lazyio(struct file *file)
235{ 235{
236 struct ceph_file_info *fi = file->private_data; 236 struct ceph_file_info *fi = file->private_data;
237 struct inode *inode = file->f_dentry->d_inode; 237 struct inode *inode = file_inode(file);
238 struct ceph_inode_info *ci = ceph_inode(inode); 238 struct ceph_inode_info *ci = ceph_inode(inode);
239 239
240 if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) { 240 if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) {
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 80576d05d687..202dd3d68be0 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -13,7 +13,7 @@
13static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file, 13static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
14 int cmd, u8 wait, struct file_lock *fl) 14 int cmd, u8 wait, struct file_lock *fl)
15{ 15{
16 struct inode *inode = file->f_dentry->d_inode; 16 struct inode *inode = file_inode(file);
17 struct ceph_mds_client *mdsc = 17 struct ceph_mds_client *mdsc =
18 ceph_sb_to_client(inode->i_sb)->mdsc; 18 ceph_sb_to_client(inode->i_sb)->mdsc;
19 struct ceph_mds_request *req; 19 struct ceph_mds_request *req;
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9be09b21b4e0..4bad7b16271f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -683,7 +683,7 @@ out_nls:
683static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 683static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
684 unsigned long nr_segs, loff_t pos) 684 unsigned long nr_segs, loff_t pos)
685{ 685{
686 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 686 struct inode *inode = file_inode(iocb->ki_filp);
687 ssize_t written; 687 ssize_t written;
688 int rc; 688 int rc;
689 689
@@ -707,7 +707,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
707 */ 707 */
708 if (whence != SEEK_SET && whence != SEEK_CUR) { 708 if (whence != SEEK_SET && whence != SEEK_CUR) {
709 int rc; 709 int rc;
710 struct inode *inode = file->f_path.dentry->d_inode; 710 struct inode *inode = file_inode(file);
711 711
712 /* 712 /*
713 * We need to be sure that all dirty pages are written and the 713 * We need to be sure that all dirty pages are written and the
@@ -739,7 +739,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
739{ 739{
740 /* note that this is called by vfs setlease with lock_flocks held 740 /* note that this is called by vfs setlease with lock_flocks held
741 to protect *lease from going away */ 741 to protect *lease from going away */
742 struct inode *inode = file->f_path.dentry->d_inode; 742 struct inode *inode = file_inode(file);
743 struct cifsFileInfo *cfile = file->private_data; 743 struct cifsFileInfo *cfile = file->private_data;
744 744
745 if (!(S_ISREG(inode->i_mode))) 745 if (!(S_ISREG(inode->i_mode)))
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index a8d8b589ee0e..c16d2a018ab8 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -947,7 +947,7 @@ static int
947cifs_posix_lock_test(struct file *file, struct file_lock *flock) 947cifs_posix_lock_test(struct file *file, struct file_lock *flock)
948{ 948{
949 int rc = 0; 949 int rc = 0;
950 struct cifsInodeInfo *cinode = CIFS_I(file->f_path.dentry->d_inode); 950 struct cifsInodeInfo *cinode = CIFS_I(file_inode(file));
951 unsigned char saved_type = flock->fl_type; 951 unsigned char saved_type = flock->fl_type;
952 952
953 if ((flock->fl_flags & FL_POSIX) == 0) 953 if ((flock->fl_flags & FL_POSIX) == 0)
@@ -974,7 +974,7 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
974static int 974static int
975cifs_posix_lock_set(struct file *file, struct file_lock *flock) 975cifs_posix_lock_set(struct file *file, struct file_lock *flock)
976{ 976{
977 struct cifsInodeInfo *cinode = CIFS_I(file->f_path.dentry->d_inode); 977 struct cifsInodeInfo *cinode = CIFS_I(file_inode(file));
978 int rc = 1; 978 int rc = 1;
979 979
980 if ((flock->fl_flags & FL_POSIX) == 0) 980 if ((flock->fl_flags & FL_POSIX) == 0)
@@ -1548,7 +1548,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
1548 1548
1549 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1549 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1550 netfid = cfile->fid.netfid; 1550 netfid = cfile->fid.netfid;
1551 cinode = CIFS_I(file->f_path.dentry->d_inode); 1551 cinode = CIFS_I(file_inode(file));
1552 1552
1553 if (cap_unix(tcon->ses) && 1553 if (cap_unix(tcon->ses) &&
1554 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 1554 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
@@ -2171,7 +2171,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
2171 struct cifs_tcon *tcon; 2171 struct cifs_tcon *tcon;
2172 struct TCP_Server_Info *server; 2172 struct TCP_Server_Info *server;
2173 struct cifsFileInfo *smbfile = file->private_data; 2173 struct cifsFileInfo *smbfile = file->private_data;
2174 struct inode *inode = file->f_path.dentry->d_inode; 2174 struct inode *inode = file_inode(file);
2175 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2175 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
2176 2176
2177 rc = filemap_write_and_wait_range(inode->i_mapping, start, end); 2177 rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
@@ -2246,7 +2246,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
2246 */ 2246 */
2247int cifs_flush(struct file *file, fl_owner_t id) 2247int cifs_flush(struct file *file, fl_owner_t id)
2248{ 2248{
2249 struct inode *inode = file->f_path.dentry->d_inode; 2249 struct inode *inode = file_inode(file);
2250 int rc = 0; 2250 int rc = 0;
2251 2251
2252 if (file->f_mode & FMODE_WRITE) 2252 if (file->f_mode & FMODE_WRITE)
@@ -2480,7 +2480,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
2480 ssize_t written; 2480 ssize_t written;
2481 struct inode *inode; 2481 struct inode *inode;
2482 2482
2483 inode = iocb->ki_filp->f_path.dentry->d_inode; 2483 inode = file_inode(iocb->ki_filp);
2484 2484
2485 /* 2485 /*
2486 * BB - optimize the way when signing is disabled. We can drop this 2486 * BB - optimize the way when signing is disabled. We can drop this
@@ -2543,7 +2543,7 @@ ssize_t
2543cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, 2543cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
2544 unsigned long nr_segs, loff_t pos) 2544 unsigned long nr_segs, loff_t pos)
2545{ 2545{
2546 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 2546 struct inode *inode = file_inode(iocb->ki_filp);
2547 struct cifsInodeInfo *cinode = CIFS_I(inode); 2547 struct cifsInodeInfo *cinode = CIFS_I(inode);
2548 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2548 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
2549 struct cifsFileInfo *cfile = (struct cifsFileInfo *) 2549 struct cifsFileInfo *cfile = (struct cifsFileInfo *)
@@ -2915,7 +2915,7 @@ ssize_t
2915cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, 2915cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,
2916 unsigned long nr_segs, loff_t pos) 2916 unsigned long nr_segs, loff_t pos)
2917{ 2917{
2918 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 2918 struct inode *inode = file_inode(iocb->ki_filp);
2919 struct cifsInodeInfo *cinode = CIFS_I(inode); 2919 struct cifsInodeInfo *cinode = CIFS_I(inode);
2920 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2920 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
2921 struct cifsFileInfo *cfile = (struct cifsFileInfo *) 2921 struct cifsFileInfo *cfile = (struct cifsFileInfo *)
@@ -3063,7 +3063,7 @@ static struct vm_operations_struct cifs_file_vm_ops = {
3063int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) 3063int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
3064{ 3064{
3065 int rc, xid; 3065 int rc, xid;
3066 struct inode *inode = file->f_path.dentry->d_inode; 3066 struct inode *inode = file_inode(file);
3067 3067
3068 xid = get_xid(); 3068 xid = get_xid();
3069 3069
@@ -3356,7 +3356,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
3356 int rc; 3356 int rc;
3357 3357
3358 /* Is the page cached? */ 3358 /* Is the page cached? */
3359 rc = cifs_readpage_from_fscache(file->f_path.dentry->d_inode, page); 3359 rc = cifs_readpage_from_fscache(file_inode(file), page);
3360 if (rc == 0) 3360 if (rc == 0)
3361 goto read_complete; 3361 goto read_complete;
3362 3362
@@ -3371,8 +3371,8 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
3371 else 3371 else
3372 cFYI(1, "Bytes read %d", rc); 3372 cFYI(1, "Bytes read %d", rc);
3373 3373
3374 file->f_path.dentry->d_inode->i_atime = 3374 file_inode(file)->i_atime =
3375 current_fs_time(file->f_path.dentry->d_inode->i_sb); 3375 current_fs_time(file_inode(file)->i_sb);
3376 3376
3377 if (PAGE_CACHE_SIZE > rc) 3377 if (PAGE_CACHE_SIZE > rc)
3378 memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc); 3378 memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc);
@@ -3381,7 +3381,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
3381 SetPageUptodate(page); 3381 SetPageUptodate(page);
3382 3382
3383 /* send this page to the cache */ 3383 /* send this page to the cache */
3384 cifs_readpage_to_fscache(file->f_path.dentry->d_inode, page); 3384 cifs_readpage_to_fscache(file_inode(file), page);
3385 3385
3386 rc = 0; 3386 rc = 0;
3387 3387
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9638233964fc..d2a833999bcc 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -299,7 +299,7 @@ cifs_get_file_info_unix(struct file *filp)
299 unsigned int xid; 299 unsigned int xid;
300 FILE_UNIX_BASIC_INFO find_data; 300 FILE_UNIX_BASIC_INFO find_data;
301 struct cifs_fattr fattr; 301 struct cifs_fattr fattr;
302 struct inode *inode = filp->f_path.dentry->d_inode; 302 struct inode *inode = file_inode(filp);
303 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 303 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
304 struct cifsFileInfo *cfile = filp->private_data; 304 struct cifsFileInfo *cfile = filp->private_data;
305 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 305 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
@@ -568,7 +568,7 @@ cifs_get_file_info(struct file *filp)
568 unsigned int xid; 568 unsigned int xid;
569 FILE_ALL_INFO find_data; 569 FILE_ALL_INFO find_data;
570 struct cifs_fattr fattr; 570 struct cifs_fattr fattr;
571 struct inode *inode = filp->f_path.dentry->d_inode; 571 struct inode *inode = file_inode(filp);
572 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 572 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
573 struct cifsFileInfo *cfile = filp->private_data; 573 struct cifsFileInfo *cfile = filp->private_data;
574 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 574 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
@@ -1688,7 +1688,7 @@ cifs_invalidate_mapping(struct inode *inode)
1688int cifs_revalidate_file_attr(struct file *filp) 1688int cifs_revalidate_file_attr(struct file *filp)
1689{ 1689{
1690 int rc = 0; 1690 int rc = 0;
1691 struct inode *inode = filp->f_path.dentry->d_inode; 1691 struct inode *inode = file_inode(filp);
1692 struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data; 1692 struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
1693 1693
1694 if (!cifs_inode_needs_reval(inode)) 1694 if (!cifs_inode_needs_reval(inode))
@@ -1745,7 +1745,7 @@ out:
1745int cifs_revalidate_file(struct file *filp) 1745int cifs_revalidate_file(struct file *filp)
1746{ 1746{
1747 int rc; 1747 int rc;
1748 struct inode *inode = filp->f_path.dentry->d_inode; 1748 struct inode *inode = file_inode(filp);
1749 1749
1750 rc = cifs_revalidate_file_attr(filp); 1750 rc = cifs_revalidate_file_attr(filp);
1751 if (rc) 1751 if (rc)
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index fd5009d56f9f..6c9f1214cf0b 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,7 +30,7 @@
30 30
31long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) 31long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
32{ 32{
33 struct inode *inode = filep->f_dentry->d_inode; 33 struct inode *inode = file_inode(filep);
34 int rc = -ENOTTY; /* strange error - but the precedent */ 34 int rc = -ENOTTY; /* strange error - but the precedent */
35 unsigned int xid; 35 unsigned int xid;
36 struct cifs_sb_info *cifs_sb; 36 struct cifs_sb_info *cifs_sb;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index cdd6ff48246b..df40cc5fd13a 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -82,12 +82,10 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
82 82
83 cFYI(1, "%s: for %s", __func__, name->name); 83 cFYI(1, "%s: for %s", __func__, name->name);
84 84
85 if (parent->d_op && parent->d_op->d_hash) 85 dentry = d_hash_and_lookup(parent, name);
86 parent->d_op->d_hash(parent, parent->d_inode, name); 86 if (unlikely(IS_ERR(dentry)))
87 else 87 return;
88 name->hash = full_name_hash(name->name, name->len);
89 88
90 dentry = d_lookup(parent, name);
91 if (dentry) { 89 if (dentry) {
92 int err; 90 int err;
93 91
@@ -505,7 +503,7 @@ static int cifs_entry_is_dot(struct cifs_dirent *de, bool is_unicode)
505 whether we can use the cached search results from the previous search */ 503 whether we can use the cached search results from the previous search */
506static int is_dir_changed(struct file *file) 504static int is_dir_changed(struct file *file)
507{ 505{
508 struct inode *inode = file->f_path.dentry->d_inode; 506 struct inode *inode = file_inode(file);
509 struct cifsInodeInfo *cifsInfo = CIFS_I(inode); 507 struct cifsInodeInfo *cifsInfo = CIFS_I(inode);
510 508
511 if (cifsInfo->time == 0) 509 if (cifsInfo->time == 0)
@@ -778,7 +776,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
778 switch ((int) file->f_pos) { 776 switch ((int) file->f_pos) {
779 case 0: 777 case 0:
780 if (filldir(direntry, ".", 1, file->f_pos, 778 if (filldir(direntry, ".", 1, file->f_pos,
781 file->f_path.dentry->d_inode->i_ino, DT_DIR) < 0) { 779 file_inode(file)->i_ino, DT_DIR) < 0) {
782 cERROR(1, "Filldir for current dir failed"); 780 cERROR(1, "Filldir for current dir failed");
783 rc = -ENOMEM; 781 rc = -ENOMEM;
784 break; 782 break;
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 49fe52d25600..b7d3a05c062c 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -397,7 +397,7 @@ static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
397 * We can't use vfs_readdir because we have to keep the file 397 * We can't use vfs_readdir because we have to keep the file
398 * position in sync between the coda_file and the host_file. 398 * position in sync between the coda_file and the host_file.
399 * and as such we need grab the inode mutex. */ 399 * and as such we need grab the inode mutex. */
400 struct inode *host_inode = host_file->f_path.dentry->d_inode; 400 struct inode *host_inode = file_inode(host_file);
401 401
402 mutex_lock(&host_inode->i_mutex); 402 mutex_lock(&host_inode->i_mutex);
403 host_file->f_pos = coda_file->f_pos; 403 host_file->f_pos = coda_file->f_pos;
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 8edd404e6419..fa4c100bdc7d 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -66,7 +66,7 @@ coda_file_splice_read(struct file *coda_file, loff_t *ppos,
66static ssize_t 66static ssize_t
67coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos) 67coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos)
68{ 68{
69 struct inode *host_inode, *coda_inode = coda_file->f_path.dentry->d_inode; 69 struct inode *host_inode, *coda_inode = file_inode(coda_file);
70 struct coda_file_info *cfi; 70 struct coda_file_info *cfi;
71 struct file *host_file; 71 struct file *host_file;
72 ssize_t ret; 72 ssize_t ret;
@@ -78,7 +78,7 @@ coda_file_write(struct file *coda_file, const char __user *buf, size_t count, lo
78 if (!host_file->f_op || !host_file->f_op->write) 78 if (!host_file->f_op || !host_file->f_op->write)
79 return -EINVAL; 79 return -EINVAL;
80 80
81 host_inode = host_file->f_path.dentry->d_inode; 81 host_inode = file_inode(host_file);
82 mutex_lock(&coda_inode->i_mutex); 82 mutex_lock(&coda_inode->i_mutex);
83 83
84 ret = host_file->f_op->write(host_file, buf, count, ppos); 84 ret = host_file->f_op->write(host_file, buf, count, ppos);
@@ -106,8 +106,8 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
106 if (!host_file->f_op || !host_file->f_op->mmap) 106 if (!host_file->f_op || !host_file->f_op->mmap)
107 return -ENODEV; 107 return -ENODEV;
108 108
109 coda_inode = coda_file->f_path.dentry->d_inode; 109 coda_inode = file_inode(coda_file);
110 host_inode = host_file->f_path.dentry->d_inode; 110 host_inode = file_inode(host_file);
111 111
112 cii = ITOC(coda_inode); 112 cii = ITOC(coda_inode);
113 spin_lock(&cii->c_lock); 113 spin_lock(&cii->c_lock);
@@ -178,7 +178,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
178 err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), 178 err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
179 coda_flags, coda_file->f_cred->fsuid); 179 coda_flags, coda_file->f_cred->fsuid);
180 180
181 host_inode = cfi->cfi_container->f_path.dentry->d_inode; 181 host_inode = file_inode(cfi->cfi_container);
182 cii = ITOC(coda_inode); 182 cii = ITOC(coda_inode);
183 183
184 /* did we mmap this file? */ 184 /* did we mmap this file? */
@@ -202,7 +202,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
202int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync) 202int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
203{ 203{
204 struct file *host_file; 204 struct file *host_file;
205 struct inode *coda_inode = coda_file->f_path.dentry->d_inode; 205 struct inode *coda_inode = file_inode(coda_file);
206 struct coda_file_info *cfi; 206 struct coda_file_info *cfi;
207 int err; 207 int err;
208 208
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index cf674e9179a3..dada9d0abede 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -130,7 +130,7 @@ static int get_device_index(struct coda_mount_data *data)
130 f = fdget(data->fd); 130 f = fdget(data->fd);
131 if (!f.file) 131 if (!f.file)
132 goto Ebadf; 132 goto Ebadf;
133 inode = f.file->f_path.dentry->d_inode; 133 inode = file_inode(f.file);
134 if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) { 134 if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
135 fdput(f); 135 fdput(f);
136 goto Ebadf; 136 goto Ebadf;
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index ee0981f1375b..3f5de96bbb58 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -52,7 +52,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
52 struct path path; 52 struct path path;
53 int error; 53 int error;
54 struct PioctlData data; 54 struct PioctlData data;
55 struct inode *inode = filp->f_dentry->d_inode; 55 struct inode *inode = file_inode(filp);
56 struct inode *target_inode = NULL; 56 struct inode *target_inode = NULL;
57 struct coda_inode_info *cnp; 57 struct coda_inode_info *cnp;
58 58
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index e2f57a007029..3ced75f765ca 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1582,7 +1582,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1582 case FIBMAP: 1582 case FIBMAP:
1583 case FIGETBSZ: 1583 case FIGETBSZ:
1584 case FIONREAD: 1584 case FIONREAD:
1585 if (S_ISREG(f.file->f_path.dentry->d_inode->i_mode)) 1585 if (S_ISREG(file_inode(f.file)->i_mode))
1586 break; 1586 break;
1587 /*FALL THROUGH*/ 1587 /*FALL THROUGH*/
1588 1588
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index e9dcfa3c208c..7aabc6ad4e9b 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1626,7 +1626,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
1626 if (offset >= 0) 1626 if (offset >= 0)
1627 break; 1627 break;
1628 default: 1628 default:
1629 mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); 1629 mutex_unlock(&file_inode(file)->i_mutex);
1630 return -EINVAL; 1630 return -EINVAL;
1631 } 1631 }
1632 if (offset != file->f_pos) { 1632 if (offset != file->f_pos) {
diff --git a/fs/coredump.c b/fs/coredump.c
index 177493272a61..69baf903d3bd 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -411,7 +411,7 @@ static void wait_for_dump_helpers(struct file *file)
411{ 411{
412 struct pipe_inode_info *pipe; 412 struct pipe_inode_info *pipe;
413 413
414 pipe = file->f_path.dentry->d_inode->i_pipe; 414 pipe = file_inode(file)->i_pipe;
415 415
416 pipe_lock(pipe); 416 pipe_lock(pipe);
417 pipe->readers++; 417 pipe->readers++;
@@ -600,7 +600,7 @@ void do_coredump(siginfo_t *siginfo)
600 if (IS_ERR(cprm.file)) 600 if (IS_ERR(cprm.file))
601 goto fail_unlock; 601 goto fail_unlock;
602 602
603 inode = cprm.file->f_path.dentry->d_inode; 603 inode = file_inode(cprm.file);
604 if (inode->i_nlink > 1) 604 if (inode->i_nlink > 1)
605 goto close_fail; 605 goto close_fail;
606 if (d_unhashed(cprm.file->f_path.dentry)) 606 if (d_unhashed(cprm.file->f_path.dentry))
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index c6c3f91ecf06..3ceb9ec976e1 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -351,7 +351,7 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
351 */ 351 */
352static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 352static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
353{ 353{
354 struct inode *inode = filp->f_path.dentry->d_inode; 354 struct inode *inode = file_inode(filp);
355 struct super_block *sb = inode->i_sb; 355 struct super_block *sb = inode->i_sb;
356 char *buf; 356 char *buf;
357 unsigned int offset; 357 unsigned int offset;
diff --git a/fs/dcache.c b/fs/dcache.c
index 19153a0a810c..68220dd0c135 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1358,6 +1358,7 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
1358 WARN_ON_ONCE(dentry->d_flags & (DCACHE_OP_HASH | 1358 WARN_ON_ONCE(dentry->d_flags & (DCACHE_OP_HASH |
1359 DCACHE_OP_COMPARE | 1359 DCACHE_OP_COMPARE |
1360 DCACHE_OP_REVALIDATE | 1360 DCACHE_OP_REVALIDATE |
1361 DCACHE_OP_WEAK_REVALIDATE |
1361 DCACHE_OP_DELETE )); 1362 DCACHE_OP_DELETE ));
1362 dentry->d_op = op; 1363 dentry->d_op = op;
1363 if (!op) 1364 if (!op)
@@ -1368,6 +1369,8 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
1368 dentry->d_flags |= DCACHE_OP_COMPARE; 1369 dentry->d_flags |= DCACHE_OP_COMPARE;
1369 if (op->d_revalidate) 1370 if (op->d_revalidate)
1370 dentry->d_flags |= DCACHE_OP_REVALIDATE; 1371 dentry->d_flags |= DCACHE_OP_REVALIDATE;
1372 if (op->d_weak_revalidate)
1373 dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE;
1371 if (op->d_delete) 1374 if (op->d_delete)
1372 dentry->d_flags |= DCACHE_OP_DELETE; 1375 dentry->d_flags |= DCACHE_OP_DELETE;
1373 if (op->d_prune) 1376 if (op->d_prune)
@@ -1672,7 +1675,6 @@ EXPORT_SYMBOL(d_splice_alias);
1672struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, 1675struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1673 struct qstr *name) 1676 struct qstr *name)
1674{ 1677{
1675 int error;
1676 struct dentry *found; 1678 struct dentry *found;
1677 struct dentry *new; 1679 struct dentry *new;
1678 1680
@@ -1681,10 +1683,12 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1681 * if not go ahead and create it now. 1683 * if not go ahead and create it now.
1682 */ 1684 */
1683 found = d_hash_and_lookup(dentry->d_parent, name); 1685 found = d_hash_and_lookup(dentry->d_parent, name);
1686 if (unlikely(IS_ERR(found)))
1687 goto err_out;
1684 if (!found) { 1688 if (!found) {
1685 new = d_alloc(dentry->d_parent, name); 1689 new = d_alloc(dentry->d_parent, name);
1686 if (!new) { 1690 if (!new) {
1687 error = -ENOMEM; 1691 found = ERR_PTR(-ENOMEM);
1688 goto err_out; 1692 goto err_out;
1689 } 1693 }
1690 1694
@@ -1725,7 +1729,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1725 1729
1726err_out: 1730err_out:
1727 iput(inode); 1731 iput(inode);
1728 return ERR_PTR(error); 1732 return found;
1729} 1733}
1730EXPORT_SYMBOL(d_add_ci); 1734EXPORT_SYMBOL(d_add_ci);
1731 1735
@@ -1889,7 +1893,7 @@ seqretry:
1889 * dentry is returned. The caller must use dput to free the entry when it has 1893 * dentry is returned. The caller must use dput to free the entry when it has
1890 * finished using it. %NULL is returned if the dentry does not exist. 1894 * finished using it. %NULL is returned if the dentry does not exist.
1891 */ 1895 */
1892struct dentry *d_lookup(struct dentry *parent, struct qstr *name) 1896struct dentry *d_lookup(const struct dentry *parent, const struct qstr *name)
1893{ 1897{
1894 struct dentry *dentry; 1898 struct dentry *dentry;
1895 unsigned seq; 1899 unsigned seq;
@@ -1919,7 +1923,7 @@ EXPORT_SYMBOL(d_lookup);
1919 * 1923 *
1920 * __d_lookup callers must be commented. 1924 * __d_lookup callers must be commented.
1921 */ 1925 */
1922struct dentry *__d_lookup(struct dentry *parent, struct qstr *name) 1926struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
1923{ 1927{
1924 unsigned int len = name->len; 1928 unsigned int len = name->len;
1925 unsigned int hash = name->hash; 1929 unsigned int hash = name->hash;
@@ -1997,12 +2001,10 @@ next:
1997 * @dir: Directory to search in 2001 * @dir: Directory to search in
1998 * @name: qstr of name we wish to find 2002 * @name: qstr of name we wish to find
1999 * 2003 *
2000 * On hash failure or on lookup failure NULL is returned. 2004 * On lookup failure NULL is returned; on bad name - ERR_PTR(-error)
2001 */ 2005 */
2002struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) 2006struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
2003{ 2007{
2004 struct dentry *dentry = NULL;
2005
2006 /* 2008 /*
2007 * Check for a fs-specific hash function. Note that we must 2009 * Check for a fs-specific hash function. Note that we must
2008 * calculate the standard hash first, as the d_op->d_hash() 2010 * calculate the standard hash first, as the d_op->d_hash()
@@ -2010,13 +2012,13 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
2010 */ 2012 */
2011 name->hash = full_name_hash(name->name, name->len); 2013 name->hash = full_name_hash(name->name, name->len);
2012 if (dir->d_flags & DCACHE_OP_HASH) { 2014 if (dir->d_flags & DCACHE_OP_HASH) {
2013 if (dir->d_op->d_hash(dir, dir->d_inode, name) < 0) 2015 int err = dir->d_op->d_hash(dir, dir->d_inode, name);
2014 goto out; 2016 if (unlikely(err < 0))
2017 return ERR_PTR(err);
2015 } 2018 }
2016 dentry = d_lookup(dir, name); 2019 return d_lookup(dir, name);
2017out:
2018 return dentry;
2019} 2020}
2021EXPORT_SYMBOL(d_hash_and_lookup);
2020 2022
2021/** 2023/**
2022 * d_validate - verify dentry provided from insecure source (deprecated) 2024 * d_validate - verify dentry provided from insecure source (deprecated)
@@ -2394,7 +2396,7 @@ out_err:
2394 */ 2396 */
2395static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon) 2397static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
2396{ 2398{
2397 struct dentry *dparent, *aparent; 2399 struct dentry *dparent;
2398 2400
2399 dentry_lock_for_move(anon, dentry); 2401 dentry_lock_for_move(anon, dentry);
2400 2402
@@ -2402,24 +2404,15 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
2402 write_seqcount_begin(&anon->d_seq); 2404 write_seqcount_begin(&anon->d_seq);
2403 2405
2404 dparent = dentry->d_parent; 2406 dparent = dentry->d_parent;
2405 aparent = anon->d_parent;
2406 2407
2407 switch_names(dentry, anon); 2408 switch_names(dentry, anon);
2408 swap(dentry->d_name.hash, anon->d_name.hash); 2409 swap(dentry->d_name.hash, anon->d_name.hash);
2409 2410
2410 dentry->d_parent = (aparent == anon) ? dentry : aparent; 2411 dentry->d_parent = dentry;
2411 list_del(&dentry->d_u.d_child); 2412 list_del_init(&dentry->d_u.d_child);
2412 if (!IS_ROOT(dentry)) 2413 anon->d_parent = dparent;
2413 list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
2414 else
2415 INIT_LIST_HEAD(&dentry->d_u.d_child);
2416
2417 anon->d_parent = (dparent == dentry) ? anon : dparent;
2418 list_del(&anon->d_u.d_child); 2414 list_del(&anon->d_u.d_child);
2419 if (!IS_ROOT(anon)) 2415 list_add(&anon->d_u.d_child, &dparent->d_subdirs);
2420 list_add(&anon->d_u.d_child, &anon->d_parent->d_subdirs);
2421 else
2422 INIT_LIST_HEAD(&anon->d_u.d_child);
2423 2416
2424 write_seqcount_end(&dentry->d_seq); 2417 write_seqcount_end(&dentry->d_seq);
2425 write_seqcount_end(&anon->d_seq); 2418 write_seqcount_end(&anon->d_seq);
@@ -2722,37 +2715,6 @@ char *d_path(const struct path *path, char *buf, int buflen)
2722} 2715}
2723EXPORT_SYMBOL(d_path); 2716EXPORT_SYMBOL(d_path);
2724 2717
2725/**
2726 * d_path_with_unreachable - return the path of a dentry
2727 * @path: path to report
2728 * @buf: buffer to return value in
2729 * @buflen: buffer length
2730 *
2731 * The difference from d_path() is that this prepends "(unreachable)"
2732 * to paths which are unreachable from the current process' root.
2733 */
2734char *d_path_with_unreachable(const struct path *path, char *buf, int buflen)
2735{
2736 char *res = buf + buflen;
2737 struct path root;
2738 int error;
2739
2740 if (path->dentry->d_op && path->dentry->d_op->d_dname)
2741 return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
2742
2743 get_fs_root(current->fs, &root);
2744 write_seqlock(&rename_lock);
2745 error = path_with_deleted(path, &root, &res, &buflen);
2746 if (error > 0)
2747 error = prepend_unreachable(&res, &buflen);
2748 write_sequnlock(&rename_lock);
2749 path_put(&root);
2750 if (error)
2751 res = ERR_PTR(error);
2752
2753 return res;
2754}
2755
2756/* 2718/*
2757 * Helper function for dentry_operations.d_dname() members 2719 * Helper function for dentry_operations.d_dname() members
2758 */ 2720 */
@@ -3035,7 +2997,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name)
3035 ino_t ino = 0; 2997 ino_t ino = 0;
3036 2998
3037 dentry = d_hash_and_lookup(dir, name); 2999 dentry = d_hash_and_lookup(dir, name);
3038 if (dentry) { 3000 if (!IS_ERR_OR_NULL(dentry)) {
3039 if (dentry->d_inode) 3001 if (dentry->d_inode)
3040 ino = dentry->d_inode->i_ino; 3002 ino = dentry->d_inode->i_ino;
3041 dput(dentry); 3003 dput(dentry);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index cf5b44b10c67..f853263cf74f 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -261,9 +261,9 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is
261 dio->end_io(dio->iocb, offset, transferred, 261 dio->end_io(dio->iocb, offset, transferred,
262 dio->private, ret, is_async); 262 dio->private, ret, is_async);
263 } else { 263 } else {
264 inode_dio_done(dio->inode);
264 if (is_async) 265 if (is_async)
265 aio_complete(dio->iocb, ret, 0); 266 aio_complete(dio->iocb, ret, 0);
266 inode_dio_done(dio->inode);
267 } 267 }
268 268
269 return ret; 269 return ret;
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index a0387dd8b1f0..7d58d5b112b5 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -158,7 +158,7 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
158 unsigned int x; 158 unsigned int x;
159 159
160 if (!capable(CAP_SYS_ADMIN)) 160 if (!capable(CAP_SYS_ADMIN))
161 return -EACCES; 161 return -EPERM;
162 162
163 x = simple_strtoul(buf, NULL, 0); 163 x = simple_strtoul(buf, NULL, 0);
164 164
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index cfb4b9fed520..7e2c6f5d7985 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -509,6 +509,12 @@ ecryptfs_dentry_to_lower_mnt(struct dentry *dentry)
509 return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt; 509 return ((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt;
510} 510}
511 511
512static inline struct path *
513ecryptfs_dentry_to_lower_path(struct dentry *dentry)
514{
515 return &((struct ecryptfs_dentry_info *)dentry->d_fsdata)->lower_path;
516}
517
512static inline void 518static inline void
513ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) 519ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
514{ 520{
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index d45ba4568128..53acc9d0c138 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -118,7 +118,7 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
118 118
119 lower_file = ecryptfs_file_to_lower(file); 119 lower_file = ecryptfs_file_to_lower(file);
120 lower_file->f_pos = file->f_pos; 120 lower_file->f_pos = file->f_pos;
121 inode = file->f_path.dentry->d_inode; 121 inode = file_inode(file);
122 memset(&buf, 0, sizeof(buf)); 122 memset(&buf, 0, sizeof(buf));
123 buf.dirent = dirent; 123 buf.dirent = dirent;
124 buf.dentry = file->f_path.dentry; 124 buf.dentry = file->f_path.dentry;
@@ -133,7 +133,7 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
133 goto out; 133 goto out;
134 if (rc >= 0) 134 if (rc >= 0)
135 fsstack_copy_attr_atime(inode, 135 fsstack_copy_attr_atime(inode,
136 lower_file->f_path.dentry->d_inode); 136 file_inode(lower_file));
137out: 137out:
138 return rc; 138 return rc;
139} 139}
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index cc7709e7c508..e0f07fb6d56b 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1027,8 +1027,7 @@ int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1027 struct kstat lower_stat; 1027 struct kstat lower_stat;
1028 int rc; 1028 int rc;
1029 1029
1030 rc = vfs_getattr(ecryptfs_dentry_to_lower_mnt(dentry), 1030 rc = vfs_getattr(ecryptfs_dentry_to_lower_path(dentry), &lower_stat);
1031 ecryptfs_dentry_to_lower(dentry), &lower_stat);
1032 if (!rc) { 1031 if (!rc) {
1033 fsstack_copy_attr_all(dentry->d_inode, 1032 fsstack_copy_attr_all(dentry->d_inode,
1034 ecryptfs_inode_to_lower(dentry->d_inode)); 1033 ecryptfs_inode_to_lower(dentry->d_inode));
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index b2a34a192f4f..6a160539cd23 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -40,16 +40,12 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
40 loff_t offset, size_t size) 40 loff_t offset, size_t size)
41{ 41{
42 struct file *lower_file; 42 struct file *lower_file;
43 mm_segment_t fs_save;
44 ssize_t rc; 43 ssize_t rc;
45 44
46 lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file; 45 lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
47 if (!lower_file) 46 if (!lower_file)
48 return -EIO; 47 return -EIO;
49 fs_save = get_fs(); 48 rc = kernel_write(lower_file, data, size, offset);
50 set_fs(get_ds());
51 rc = vfs_write(lower_file, data, size, &offset);
52 set_fs(fs_save);
53 mark_inode_dirty_sync(ecryptfs_inode); 49 mark_inode_dirty_sync(ecryptfs_inode);
54 return rc; 50 return rc;
55} 51}
diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index 7ee6f7e3a608..055a9e9ca747 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -20,7 +20,7 @@ const struct inode_operations efs_dir_inode_operations = {
20}; 20};
21 21
22static int efs_readdir(struct file *filp, void *dirent, filldir_t filldir) { 22static int efs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
23 struct inode *inode = filp->f_path.dentry->d_inode; 23 struct inode *inode = file_inode(filp);
24 struct buffer_head *bh; 24 struct buffer_head *bh;
25 25
26 struct efs_dir *dirblock; 26 struct efs_dir *dirblock;
diff --git a/fs/exec.c b/fs/exec.c
index 20df02c1cc70..864c50df660a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -123,7 +123,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
123 goto out; 123 goto out;
124 124
125 error = -EINVAL; 125 error = -EINVAL;
126 if (!S_ISREG(file->f_path.dentry->d_inode->i_mode)) 126 if (!S_ISREG(file_inode(file)->i_mode))
127 goto exit; 127 goto exit;
128 128
129 error = -EACCES; 129 error = -EACCES;
@@ -355,7 +355,7 @@ static bool valid_arg_len(struct linux_binprm *bprm, long len)
355 * flags, permissions, and offset, so we use temporary values. We'll update 355 * flags, permissions, and offset, so we use temporary values. We'll update
356 * them later in setup_arg_pages(). 356 * them later in setup_arg_pages().
357 */ 357 */
358int bprm_mm_init(struct linux_binprm *bprm) 358static int bprm_mm_init(struct linux_binprm *bprm)
359{ 359{
360 int err; 360 int err;
361 struct mm_struct *mm = NULL; 361 struct mm_struct *mm = NULL;
@@ -764,7 +764,7 @@ struct file *open_exec(const char *name)
764 goto out; 764 goto out;
765 765
766 err = -EACCES; 766 err = -EACCES;
767 if (!S_ISREG(file->f_path.dentry->d_inode->i_mode)) 767 if (!S_ISREG(file_inode(file)->i_mode))
768 goto exit; 768 goto exit;
769 769
770 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) 770 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
@@ -1098,7 +1098,7 @@ EXPORT_SYMBOL(flush_old_exec);
1098 1098
1099void would_dump(struct linux_binprm *bprm, struct file *file) 1099void would_dump(struct linux_binprm *bprm, struct file *file)
1100{ 1100{
1101 if (inode_permission(file->f_path.dentry->d_inode, MAY_READ) < 0) 1101 if (inode_permission(file_inode(file), MAY_READ) < 0)
1102 bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP; 1102 bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
1103} 1103}
1104EXPORT_SYMBOL(would_dump); 1104EXPORT_SYMBOL(would_dump);
@@ -1270,7 +1270,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
1270int prepare_binprm(struct linux_binprm *bprm) 1270int prepare_binprm(struct linux_binprm *bprm)
1271{ 1271{
1272 umode_t mode; 1272 umode_t mode;
1273 struct inode * inode = bprm->file->f_path.dentry->d_inode; 1273 struct inode * inode = file_inode(bprm->file);
1274 int retval; 1274 int retval;
1275 1275
1276 mode = inode->i_mode; 1276 mode = inode->i_mode;
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index c61e62ac231c..46375896cfc0 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -242,7 +242,7 @@ static int
242exofs_readdir(struct file *filp, void *dirent, filldir_t filldir) 242exofs_readdir(struct file *filp, void *dirent, filldir_t filldir)
243{ 243{
244 loff_t pos = filp->f_pos; 244 loff_t pos = filp->f_pos;
245 struct inode *inode = filp->f_path.dentry->d_inode; 245 struct inode *inode = file_inode(filp);
246 unsigned int offset = pos & ~PAGE_CACHE_MASK; 246 unsigned int offset = pos & ~PAGE_CACHE_MASK;
247 unsigned long n = pos >> PAGE_CACHE_SHIFT; 247 unsigned long n = pos >> PAGE_CACHE_SHIFT;
248 unsigned long npages = dir_pages(inode); 248 unsigned long npages = dir_pages(inode);
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 0f4f5c929257..4237722bfd27 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -290,7 +290,7 @@ static int
290ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) 290ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
291{ 291{
292 loff_t pos = filp->f_pos; 292 loff_t pos = filp->f_pos;
293 struct inode *inode = filp->f_path.dentry->d_inode; 293 struct inode *inode = file_inode(filp);
294 struct super_block *sb = inode->i_sb; 294 struct super_block *sb = inode->i_sb;
295 unsigned int offset = pos & ~PAGE_CACHE_MASK; 295 unsigned int offset = pos & ~PAGE_CACHE_MASK;
296 unsigned long n = pos >> PAGE_CACHE_SHIFT; 296 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 2de655f5d625..5d46c09863f0 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -19,7 +19,7 @@
19 19
20long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 20long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
21{ 21{
22 struct inode *inode = filp->f_dentry->d_inode; 22 struct inode *inode = file_inode(filp);
23 struct ext2_inode_info *ei = EXT2_I(inode); 23 struct ext2_inode_info *ei = EXT2_I(inode);
24 unsigned int flags; 24 unsigned int flags;
25 unsigned short rsv_window_size; 25 unsigned short rsv_window_size;
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index dd91264ba94f..87eccbbca255 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -99,7 +99,7 @@ static int ext3_readdir(struct file * filp,
99 int i, stored; 99 int i, stored;
100 struct ext3_dir_entry_2 *de; 100 struct ext3_dir_entry_2 *de;
101 int err; 101 int err;
102 struct inode *inode = filp->f_path.dentry->d_inode; 102 struct inode *inode = file_inode(filp);
103 struct super_block *sb = inode->i_sb; 103 struct super_block *sb = inode->i_sb;
104 int ret = 0; 104 int ret = 0;
105 int dir_has_error = 0; 105 int dir_has_error = 0;
@@ -114,7 +114,7 @@ static int ext3_readdir(struct file * filp,
114 * We don't set the inode dirty flag since it's not 114 * We don't set the inode dirty flag since it's not
115 * critical that it get flushed back to the disk. 115 * critical that it get flushed back to the disk.
116 */ 116 */
117 EXT3_I(filp->f_path.dentry->d_inode)->i_flags &= ~EXT3_INDEX_FL; 117 EXT3_I(file_inode(filp))->i_flags &= ~EXT3_INDEX_FL;
118 } 118 }
119 stored = 0; 119 stored = 0;
120 offset = filp->f_pos & (sb->s_blocksize - 1); 120 offset = filp->f_pos & (sb->s_blocksize - 1);
@@ -457,7 +457,7 @@ static int call_filldir(struct file * filp, void * dirent,
457{ 457{
458 struct dir_private_info *info = filp->private_data; 458 struct dir_private_info *info = filp->private_data;
459 loff_t curr_pos; 459 loff_t curr_pos;
460 struct inode *inode = filp->f_path.dentry->d_inode; 460 struct inode *inode = file_inode(filp);
461 struct super_block * sb; 461 struct super_block * sb;
462 int error; 462 int error;
463 463
@@ -487,7 +487,7 @@ static int ext3_dx_readdir(struct file * filp,
487 void * dirent, filldir_t filldir) 487 void * dirent, filldir_t filldir)
488{ 488{
489 struct dir_private_info *info = filp->private_data; 489 struct dir_private_info *info = filp->private_data;
490 struct inode *inode = filp->f_path.dentry->d_inode; 490 struct inode *inode = file_inode(filp);
491 struct fname *fname; 491 struct fname *fname;
492 int ret; 492 int ret;
493 493
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index 677a5c27dc69..4d96e9a64532 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -14,7 +14,7 @@
14 14
15long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 15long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
16{ 16{
17 struct inode *inode = filp->f_dentry->d_inode; 17 struct inode *inode = file_inode(filp);
18 struct ext3_inode_info *ei = EXT3_I(inode); 18 struct ext3_inode_info *ei = EXT3_I(inode);
19 unsigned int flags; 19 unsigned int flags;
20 unsigned short rsv_window_size; 20 unsigned short rsv_window_size;
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 88f64eb1b6fa..692de13e3596 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -623,7 +623,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
623 623
624 dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash, 624 dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
625 start_minor_hash)); 625 start_minor_hash));
626 dir = dir_file->f_path.dentry->d_inode; 626 dir = file_inode(dir_file);
627 if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) { 627 if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) {
628 hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version; 628 hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version;
629 if (hinfo.hash_version <= DX_HASH_TEA) 629 if (hinfo.hash_version <= DX_HASH_TEA)
@@ -637,7 +637,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
637 } 637 }
638 hinfo.hash = start_hash; 638 hinfo.hash = start_hash;
639 hinfo.minor_hash = 0; 639 hinfo.minor_hash = 0;
640 frame = dx_probe(NULL, dir_file->f_path.dentry->d_inode, &hinfo, frames, &err); 640 frame = dx_probe(NULL, file_inode(dir_file), &hinfo, frames, &err);
641 if (!frame) 641 if (!frame)
642 return err; 642 return err;
643 643
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 3882fbc5e215..6dda04f05ef4 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -110,7 +110,7 @@ static int ext4_readdir(struct file *filp,
110 int i, stored; 110 int i, stored;
111 struct ext4_dir_entry_2 *de; 111 struct ext4_dir_entry_2 *de;
112 int err; 112 int err;
113 struct inode *inode = filp->f_path.dentry->d_inode; 113 struct inode *inode = file_inode(filp);
114 struct super_block *sb = inode->i_sb; 114 struct super_block *sb = inode->i_sb;
115 int ret = 0; 115 int ret = 0;
116 int dir_has_error = 0; 116 int dir_has_error = 0;
@@ -133,7 +133,7 @@ static int ext4_readdir(struct file *filp,
133 * We don't set the inode dirty flag since it's not 133 * We don't set the inode dirty flag since it's not
134 * critical that it get flushed back to the disk. 134 * critical that it get flushed back to the disk.
135 */ 135 */
136 ext4_clear_inode_flag(filp->f_path.dentry->d_inode, 136 ext4_clear_inode_flag(file_inode(filp),
137 EXT4_INODE_INDEX); 137 EXT4_INODE_INDEX);
138 } 138 }
139 stored = 0; 139 stored = 0;
@@ -495,7 +495,7 @@ static int call_filldir(struct file *filp, void *dirent,
495{ 495{
496 struct dir_private_info *info = filp->private_data; 496 struct dir_private_info *info = filp->private_data;
497 loff_t curr_pos; 497 loff_t curr_pos;
498 struct inode *inode = filp->f_path.dentry->d_inode; 498 struct inode *inode = file_inode(filp);
499 struct super_block *sb; 499 struct super_block *sb;
500 int error; 500 int error;
501 501
@@ -527,7 +527,7 @@ static int ext4_dx_readdir(struct file *filp,
527 void *dirent, filldir_t filldir) 527 void *dirent, filldir_t filldir)
528{ 528{
529 struct dir_private_info *info = filp->private_data; 529 struct dir_private_info *info = filp->private_data;
530 struct inode *inode = filp->f_path.dentry->d_inode; 530 struct inode *inode = file_inode(filp);
531 struct fname *fname; 531 struct fname *fname;
532 int ret; 532 int ret;
533 533
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 372b2cbee07e..28dd8eeea6a9 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4309,7 +4309,7 @@ static void ext4_falloc_update_inode(struct inode *inode,
4309 */ 4309 */
4310long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 4310long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4311{ 4311{
4312 struct inode *inode = file->f_path.dentry->d_inode; 4312 struct inode *inode = file_inode(file);
4313 handle_t *handle; 4313 handle_t *handle;
4314 loff_t new_size; 4314 loff_t new_size;
4315 unsigned int max_blocks; 4315 unsigned int max_blocks;
@@ -4571,7 +4571,7 @@ static int ext4_xattr_fiemap(struct inode *inode,
4571 */ 4571 */
4572int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) 4572int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
4573{ 4573{
4574 struct inode *inode = file->f_path.dentry->d_inode; 4574 struct inode *inode = file_inode(file);
4575 struct super_block *sb = inode->i_sb; 4575 struct super_block *sb = inode->i_sb;
4576 ext4_lblk_t first_block, stop_block; 4576 ext4_lblk_t first_block, stop_block;
4577 struct address_space *mapping = inode->i_mapping; 4577 struct address_space *mapping = inode->i_mapping;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 7e85a10a6f4f..64848b595b24 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -167,7 +167,7 @@ static ssize_t
167ext4_file_write(struct kiocb *iocb, const struct iovec *iov, 167ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
168 unsigned long nr_segs, loff_t pos) 168 unsigned long nr_segs, loff_t pos)
169{ 169{
170 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 170 struct inode *inode = file_inode(iocb->ki_filp);
171 ssize_t ret; 171 ssize_t ret;
172 172
173 /* 173 /*
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index bc5f871f0893..c0fd1a123f7d 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1298,7 +1298,7 @@ int ext4_read_inline_dir(struct file *filp,
1298 int i, stored; 1298 int i, stored;
1299 struct ext4_dir_entry_2 *de; 1299 struct ext4_dir_entry_2 *de;
1300 struct super_block *sb; 1300 struct super_block *sb;
1301 struct inode *inode = filp->f_path.dentry->d_inode; 1301 struct inode *inode = file_inode(filp);
1302 int ret, inline_size = 0; 1302 int ret, inline_size = 0;
1303 struct ext4_iloc iloc; 1303 struct ext4_iloc iloc;
1304 void *dir_buf = NULL; 1304 void *dir_buf = NULL;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 88049d8d30cb..9c4f4b1c97f8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2948,7 +2948,7 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
2948 ssize_t size, void *private, int ret, 2948 ssize_t size, void *private, int ret,
2949 bool is_async) 2949 bool is_async)
2950{ 2950{
2951 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 2951 struct inode *inode = file_inode(iocb->ki_filp);
2952 ext4_io_end_t *io_end = iocb->private; 2952 ext4_io_end_t *io_end = iocb->private;
2953 2953
2954 /* if not async direct IO or dio with 0 bytes write, just return */ 2954 /* if not async direct IO or dio with 0 bytes write, just return */
@@ -3483,7 +3483,7 @@ int ext4_can_truncate(struct inode *inode)
3483 3483
3484int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) 3484int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
3485{ 3485{
3486 struct inode *inode = file->f_path.dentry->d_inode; 3486 struct inode *inode = file_inode(file);
3487 if (!S_ISREG(inode->i_mode)) 3487 if (!S_ISREG(inode->i_mode))
3488 return -EOPNOTSUPP; 3488 return -EOPNOTSUPP;
3489 3489
@@ -4855,7 +4855,7 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
4855 unsigned long len; 4855 unsigned long len;
4856 int ret; 4856 int ret;
4857 struct file *file = vma->vm_file; 4857 struct file *file = vma->vm_file;
4858 struct inode *inode = file->f_path.dentry->d_inode; 4858 struct inode *inode = file_inode(file);
4859 struct address_space *mapping = inode->i_mapping; 4859 struct address_space *mapping = inode->i_mapping;
4860 handle_t *handle; 4860 handle_t *handle;
4861 get_block_t *get_block; 4861 get_block_t *get_block;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 31f4f56a32d6..721f4d33e148 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -22,7 +22,7 @@
22 22
23long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 23long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
24{ 24{
25 struct inode *inode = filp->f_dentry->d_inode; 25 struct inode *inode = file_inode(filp);
26 struct super_block *sb = inode->i_sb; 26 struct super_block *sb = inode->i_sb;
27 struct ext4_inode_info *ei = EXT4_I(inode); 27 struct ext4_inode_info *ei = EXT4_I(inode);
28 unsigned int flags; 28 unsigned int flags;
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index d78c33eed7e5..4e81d47aa8cb 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -900,7 +900,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
900 pgoff_t orig_page_offset, int data_offset_in_page, 900 pgoff_t orig_page_offset, int data_offset_in_page,
901 int block_len_in_page, int uninit, int *err) 901 int block_len_in_page, int uninit, int *err)
902{ 902{
903 struct inode *orig_inode = o_filp->f_dentry->d_inode; 903 struct inode *orig_inode = file_inode(o_filp);
904 struct page *pagep[2] = {NULL, NULL}; 904 struct page *pagep[2] = {NULL, NULL};
905 handle_t *handle; 905 handle_t *handle;
906 ext4_lblk_t orig_blk_offset; 906 ext4_lblk_t orig_blk_offset;
@@ -1279,8 +1279,8 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
1279 __u64 orig_start, __u64 donor_start, __u64 len, 1279 __u64 orig_start, __u64 donor_start, __u64 len,
1280 __u64 *moved_len) 1280 __u64 *moved_len)
1281{ 1281{
1282 struct inode *orig_inode = o_filp->f_dentry->d_inode; 1282 struct inode *orig_inode = file_inode(o_filp);
1283 struct inode *donor_inode = d_filp->f_dentry->d_inode; 1283 struct inode *donor_inode = file_inode(d_filp);
1284 struct ext4_ext_path *orig_path = NULL, *holecheck_path = NULL; 1284 struct ext4_ext_path *orig_path = NULL, *holecheck_path = NULL;
1285 struct ext4_extent *ext_prev, *ext_cur, *ext_dummy; 1285 struct ext4_extent *ext_prev, *ext_cur, *ext_dummy;
1286 ext4_lblk_t block_start = orig_start; 1286 ext4_lblk_t block_start = orig_start;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 2a7015d06a75..3825d6aa8336 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -964,7 +964,7 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
964 964
965 dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n", 965 dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n",
966 start_hash, start_minor_hash)); 966 start_hash, start_minor_hash));
967 dir = dir_file->f_path.dentry->d_inode; 967 dir = file_inode(dir_file);
968 if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) { 968 if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) {
969 hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version; 969 hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
970 if (hinfo.hash_version <= DX_HASH_TEA) 970 if (hinfo.hash_version <= DX_HASH_TEA)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 373d46cd5d3f..620cf5615ba2 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -450,7 +450,7 @@ void ext4_error_file(struct file *file, const char *function,
450 va_list args; 450 va_list args;
451 struct va_format vaf; 451 struct va_format vaf;
452 struct ext4_super_block *es; 452 struct ext4_super_block *es;
453 struct inode *inode = file->f_dentry->d_inode; 453 struct inode *inode = file_inode(file);
454 char pathname[80], *path; 454 char pathname[80], *path;
455 455
456 es = EXT4_SB(inode->i_sb)->s_es; 456 es = EXT4_SB(inode->i_sb)->s_es;
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index c395c5012973..a1f38443ecee 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -600,7 +600,7 @@ bool f2fs_empty_dir(struct inode *dir)
600static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) 600static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
601{ 601{
602 unsigned long pos = file->f_pos; 602 unsigned long pos = file->f_pos;
603 struct inode *inode = file->f_dentry->d_inode; 603 struct inode *inode = file_inode(file);
604 unsigned long npages = dir_blocks(inode); 604 unsigned long npages = dir_blocks(inode);
605 unsigned char *types = NULL; 605 unsigned char *types = NULL;
606 unsigned int bit_pos = 0, start_bit_pos = 0; 606 unsigned int bit_pos = 0, start_bit_pos = 0;
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 58bf744dbf39..165012ef363a 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -698,7 +698,7 @@ out:
698 698
699static int fat_readdir(struct file *filp, void *dirent, filldir_t filldir) 699static int fat_readdir(struct file *filp, void *dirent, filldir_t filldir)
700{ 700{
701 struct inode *inode = filp->f_path.dentry->d_inode; 701 struct inode *inode = file_inode(filp);
702 return __fat_readdir(inode, filp, dirent, filldir, 0, 0); 702 return __fat_readdir(inode, filp, dirent, filldir, 0, 0);
703} 703}
704 704
@@ -779,7 +779,7 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp,
779static long fat_dir_ioctl(struct file *filp, unsigned int cmd, 779static long fat_dir_ioctl(struct file *filp, unsigned int cmd,
780 unsigned long arg) 780 unsigned long arg)
781{ 781{
782 struct inode *inode = filp->f_path.dentry->d_inode; 782 struct inode *inode = file_inode(filp);
783 struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg; 783 struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg;
784 int short_only, both; 784 int short_only, both;
785 785
@@ -819,7 +819,7 @@ FAT_IOCTL_FILLDIR_FUNC(fat_compat_ioctl_filldir, compat_dirent)
819static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd, 819static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd,
820 unsigned long arg) 820 unsigned long arg)
821{ 821{
822 struct inode *inode = filp->f_path.dentry->d_inode; 822 struct inode *inode = file_inode(filp);
823 struct compat_dirent __user *d1 = compat_ptr(arg); 823 struct compat_dirent __user *d1 = compat_ptr(arg);
824 int short_only, both; 824 int short_only, both;
825 825
diff --git a/fs/fat/file.c b/fs/fat/file.c
index a62e0ecbe2db..3978f8ca1823 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -32,7 +32,7 @@ static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
32 32
33static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr) 33static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
34{ 34{
35 struct inode *inode = file->f_path.dentry->d_inode; 35 struct inode *inode = file_inode(file);
36 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); 36 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
37 int is_dir = S_ISDIR(inode->i_mode); 37 int is_dir = S_ISDIR(inode->i_mode);
38 u32 attr, oldattr; 38 u32 attr, oldattr;
@@ -116,7 +116,7 @@ out:
116 116
117long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 117long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
118{ 118{
119 struct inode *inode = filp->f_path.dentry->d_inode; 119 struct inode *inode = file_inode(filp);
120 u32 __user *user_attr = (u32 __user *)arg; 120 u32 __user *user_attr = (u32 __user *)arg;
121 121
122 switch (cmd) { 122 switch (cmd) {
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 71a600a19f06..6599222536eb 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -30,7 +30,7 @@
30 30
31static int setfl(int fd, struct file * filp, unsigned long arg) 31static int setfl(int fd, struct file * filp, unsigned long arg)
32{ 32{
33 struct inode * inode = filp->f_path.dentry->d_inode; 33 struct inode * inode = file_inode(filp);
34 int error = 0; 34 int error = 0;
35 35
36 /* 36 /*
diff --git a/fs/file_table.c b/fs/file_table.c
index de9e9653d611..aa07d3684a2e 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -94,8 +94,8 @@ int proc_nr_files(ctl_table *table, int write,
94#endif 94#endif
95 95
96/* Find an unused file structure and return a pointer to it. 96/* Find an unused file structure and return a pointer to it.
97 * Returns NULL, if there are no more free file structures or 97 * Returns an error pointer if some error happend e.g. we over file
98 * we run out of memory. 98 * structures limit, run out of memory or operation is not permitted.
99 * 99 *
100 * Be very careful using this. You are responsible for 100 * Be very careful using this. You are responsible for
101 * getting write access to any mount that you might assign 101 * getting write access to any mount that you might assign
@@ -107,7 +107,8 @@ struct file *get_empty_filp(void)
107{ 107{
108 const struct cred *cred = current_cred(); 108 const struct cred *cred = current_cred();
109 static long old_max; 109 static long old_max;
110 struct file * f; 110 struct file *f;
111 int error;
111 112
112 /* 113 /*
113 * Privileged users can go above max_files 114 * Privileged users can go above max_files
@@ -122,13 +123,16 @@ struct file *get_empty_filp(void)
122 } 123 }
123 124
124 f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL); 125 f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
125 if (f == NULL) 126 if (unlikely(!f))
126 goto fail; 127 return ERR_PTR(-ENOMEM);
127 128
128 percpu_counter_inc(&nr_files); 129 percpu_counter_inc(&nr_files);
129 f->f_cred = get_cred(cred); 130 f->f_cred = get_cred(cred);
130 if (security_file_alloc(f)) 131 error = security_file_alloc(f);
131 goto fail_sec; 132 if (unlikely(error)) {
133 file_free(f);
134 return ERR_PTR(error);
135 }
132 136
133 INIT_LIST_HEAD(&f->f_u.fu_list); 137 INIT_LIST_HEAD(&f->f_u.fu_list);
134 atomic_long_set(&f->f_count, 1); 138 atomic_long_set(&f->f_count, 1);
@@ -144,12 +148,7 @@ over:
144 pr_info("VFS: file-max limit %lu reached\n", get_max_files()); 148 pr_info("VFS: file-max limit %lu reached\n", get_max_files());
145 old_max = get_nr_files(); 149 old_max = get_nr_files();
146 } 150 }
147 goto fail; 151 return ERR_PTR(-ENFILE);
148
149fail_sec:
150 file_free(f);
151fail:
152 return NULL;
153} 152}
154 153
155/** 154/**
@@ -173,8 +172,8 @@ struct file *alloc_file(struct path *path, fmode_t mode,
173 struct file *file; 172 struct file *file;
174 173
175 file = get_empty_filp(); 174 file = get_empty_filp();
176 if (!file) 175 if (IS_ERR(file))
177 return NULL; 176 return file;
178 177
179 file->f_path = *path; 178 file->f_path = *path;
180 file->f_mapping = path->dentry->d_inode->i_mapping; 179 file->f_mapping = path->dentry->d_inode->i_mapping;
@@ -447,7 +446,7 @@ void mark_files_ro(struct super_block *sb)
447 446
448 lg_global_lock(&files_lglock); 447 lg_global_lock(&files_lglock);
449 do_file_list_for_each_entry(sb, f) { 448 do_file_list_for_each_entry(sb, f) {
450 if (!S_ISREG(f->f_path.dentry->d_inode->i_mode)) 449 if (!S_ISREG(file_inode(f)->i_mode))
451 continue; 450 continue;
452 if (!file_count(f)) 451 if (!file_count(f))
453 continue; 452 continue;
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index bd447e88f208..664b07a53870 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -237,7 +237,7 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, unsigned int flags)
237static int 237static int
238vxfs_readdir(struct file *fp, void *retp, filldir_t filler) 238vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
239{ 239{
240 struct inode *ip = fp->f_path.dentry->d_inode; 240 struct inode *ip = file_inode(fp);
241 struct super_block *sbp = ip->i_sb; 241 struct super_block *sbp = ip->i_sb;
242 u_long bsize = sbp->s_blocksize; 242 u_long bsize = sbp->s_blocksize;
243 u_long page, npages, block, pblocks, nblocks, offset; 243 u_long page, npages, block, pblocks, nblocks, offset;
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 75a20c092dd4..b7978b9f75ef 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -23,7 +23,7 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
23{ 23{
24 struct fuse_conn *fc; 24 struct fuse_conn *fc;
25 mutex_lock(&fuse_mutex); 25 mutex_lock(&fuse_mutex);
26 fc = file->f_path.dentry->d_inode->i_private; 26 fc = file_inode(file)->i_private;
27 if (fc) 27 if (fc)
28 fc = fuse_conn_get(fc); 28 fc = fuse_conn_get(fc);
29 mutex_unlock(&fuse_mutex); 29 mutex_unlock(&fuse_mutex);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 85065221a58a..ff15522481d4 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1325,7 +1325,7 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
1325 int plus, err; 1325 int plus, err;
1326 size_t nbytes; 1326 size_t nbytes;
1327 struct page *page; 1327 struct page *page;
1328 struct inode *inode = file->f_path.dentry->d_inode; 1328 struct inode *inode = file_inode(file);
1329 struct fuse_conn *fc = get_fuse_conn(inode); 1329 struct fuse_conn *fc = get_fuse_conn(inode);
1330 struct fuse_req *req; 1330 struct fuse_req *req;
1331 u64 attr_version = 0; 1331 u64 attr_version = 0;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 01353ed75750..df00993ed108 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -679,7 +679,7 @@ static int fuse_encode_fh(struct inode *inode, u32 *fh, int *max_len,
679 679
680 if (*max_len < len) { 680 if (*max_len < len) {
681 *max_len = len; 681 *max_len = len;
682 return 255; 682 return FILEID_INVALID;
683 } 683 }
684 684
685 nodeid = get_fuse_inode(inode)->nodeid; 685 nodeid = get_fuse_inode(inode)->nodeid;
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index 4767774a5f3e..9973df4ff565 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -37,10 +37,10 @@ static int gfs2_encode_fh(struct inode *inode, __u32 *p, int *len,
37 37
38 if (parent && (*len < GFS2_LARGE_FH_SIZE)) { 38 if (parent && (*len < GFS2_LARGE_FH_SIZE)) {
39 *len = GFS2_LARGE_FH_SIZE; 39 *len = GFS2_LARGE_FH_SIZE;
40 return 255; 40 return FILEID_INVALID;
41 } else if (*len < GFS2_SMALL_FH_SIZE) { 41 } else if (*len < GFS2_SMALL_FH_SIZE) {
42 *len = GFS2_SMALL_FH_SIZE; 42 *len = GFS2_SMALL_FH_SIZE;
43 return 255; 43 return FILEID_INVALID;
44 } 44 }
45 45
46 fh[0] = cpu_to_be32(ip->i_no_formal_ino >> 32); 46 fh[0] = cpu_to_be32(ip->i_no_formal_ino >> 32);
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 2687f50d98cb..019f45e45097 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -157,7 +157,7 @@ static const u32 gfs2_to_fsflags[32] = {
157 157
158static int gfs2_get_flags(struct file *filp, u32 __user *ptr) 158static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
159{ 159{
160 struct inode *inode = filp->f_path.dentry->d_inode; 160 struct inode *inode = file_inode(filp);
161 struct gfs2_inode *ip = GFS2_I(inode); 161 struct gfs2_inode *ip = GFS2_I(inode);
162 struct gfs2_holder gh; 162 struct gfs2_holder gh;
163 int error; 163 int error;
@@ -217,7 +217,7 @@ void gfs2_set_inode_flags(struct inode *inode)
217 */ 217 */
218static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) 218static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
219{ 219{
220 struct inode *inode = filp->f_path.dentry->d_inode; 220 struct inode *inode = file_inode(filp);
221 struct gfs2_inode *ip = GFS2_I(inode); 221 struct gfs2_inode *ip = GFS2_I(inode);
222 struct gfs2_sbd *sdp = GFS2_SB(inode); 222 struct gfs2_sbd *sdp = GFS2_SB(inode);
223 struct buffer_head *bh; 223 struct buffer_head *bh;
@@ -293,7 +293,7 @@ out_drop_write:
293 293
294static int gfs2_set_flags(struct file *filp, u32 __user *ptr) 294static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
295{ 295{
296 struct inode *inode = filp->f_path.dentry->d_inode; 296 struct inode *inode = file_inode(filp);
297 u32 fsflags, gfsflags; 297 u32 fsflags, gfsflags;
298 298
299 if (get_user(fsflags, ptr)) 299 if (get_user(fsflags, ptr))
@@ -336,7 +336,7 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
336 336
337static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size) 337static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)
338{ 338{
339 struct inode *inode = filep->f_dentry->d_inode; 339 struct inode *inode = file_inode(filep);
340 struct gfs2_sbd *sdp = GFS2_SB(inode); 340 struct gfs2_sbd *sdp = GFS2_SB(inode);
341 struct gfs2_inode *ip = GFS2_I(inode); 341 struct gfs2_inode *ip = GFS2_I(inode);
342 size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift; 342 size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift;
@@ -386,7 +386,7 @@ static int gfs2_allocate_page_backing(struct page *page)
386static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 386static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
387{ 387{
388 struct page *page = vmf->page; 388 struct page *page = vmf->page;
389 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 389 struct inode *inode = file_inode(vma->vm_file);
390 struct gfs2_inode *ip = GFS2_I(inode); 390 struct gfs2_inode *ip = GFS2_I(inode);
391 struct gfs2_sbd *sdp = GFS2_SB(inode); 391 struct gfs2_sbd *sdp = GFS2_SB(inode);
392 unsigned long last_index; 392 unsigned long last_index;
@@ -673,8 +673,7 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
673{ 673{
674 struct file *file = iocb->ki_filp; 674 struct file *file = iocb->ki_filp;
675 size_t writesize = iov_length(iov, nr_segs); 675 size_t writesize = iov_length(iov, nr_segs);
676 struct dentry *dentry = file->f_dentry; 676 struct gfs2_inode *ip = GFS2_I(file_inode(file));
677 struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
678 int ret; 677 int ret;
679 678
680 ret = gfs2_rs_alloc(ip); 679 ret = gfs2_rs_alloc(ip);
@@ -772,7 +771,7 @@ static void calc_max_reserv(struct gfs2_inode *ip, loff_t max, loff_t *len,
772static long gfs2_fallocate(struct file *file, int mode, loff_t offset, 771static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
773 loff_t len) 772 loff_t len)
774{ 773{
775 struct inode *inode = file->f_path.dentry->d_inode; 774 struct inode *inode = file_inode(file);
776 struct gfs2_sbd *sdp = GFS2_SB(inode); 775 struct gfs2_sbd *sdp = GFS2_SB(inode);
777 struct gfs2_inode *ip = GFS2_I(inode); 776 struct gfs2_inode *ip = GFS2_I(inode);
778 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 777 unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
@@ -938,7 +937,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
938{ 937{
939 struct gfs2_file *fp = file->private_data; 938 struct gfs2_file *fp = file->private_data;
940 struct gfs2_holder *fl_gh = &fp->f_fl_gh; 939 struct gfs2_holder *fl_gh = &fp->f_fl_gh;
941 struct gfs2_inode *ip = GFS2_I(file->f_path.dentry->d_inode); 940 struct gfs2_inode *ip = GFS2_I(file_inode(file));
942 struct gfs2_glock *gl; 941 struct gfs2_glock *gl;
943 unsigned int state; 942 unsigned int state;
944 int flags; 943 int flags;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 52c2aeaf45ce..d1f51fd73f86 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1257,7 +1257,7 @@ fail:
1257 1257
1258int gfs2_fitrim(struct file *filp, void __user *argp) 1258int gfs2_fitrim(struct file *filp, void __user *argp)
1259{ 1259{
1260 struct inode *inode = filp->f_dentry->d_inode; 1260 struct inode *inode = file_inode(filp);
1261 struct gfs2_sbd *sdp = GFS2_SB(inode); 1261 struct gfs2_sbd *sdp = GFS2_SB(inode);
1262 struct request_queue *q = bdev_get_queue(sdp->sd_vfs->s_bdev); 1262 struct request_queue *q = bdev_get_queue(sdp->sd_vfs->s_bdev);
1263 struct buffer_head *bh; 1263 struct buffer_head *bh;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 597a612834dc..aa5c48044966 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -103,7 +103,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
103 int n = simple_strtol(buf, NULL, 0); 103 int n = simple_strtol(buf, NULL, 0);
104 104
105 if (!capable(CAP_SYS_ADMIN)) 105 if (!capable(CAP_SYS_ADMIN))
106 return -EACCES; 106 return -EPERM;
107 107
108 switch (n) { 108 switch (n) {
109 case 0: 109 case 0:
@@ -133,7 +133,7 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
133static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 133static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
134{ 134{
135 if (!capable(CAP_SYS_ADMIN)) 135 if (!capable(CAP_SYS_ADMIN))
136 return -EACCES; 136 return -EPERM;
137 137
138 if (simple_strtol(buf, NULL, 0) != 1) 138 if (simple_strtol(buf, NULL, 0) != 1)
139 return -EINVAL; 139 return -EINVAL;
@@ -148,7 +148,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
148 size_t len) 148 size_t len)
149{ 149{
150 if (!capable(CAP_SYS_ADMIN)) 150 if (!capable(CAP_SYS_ADMIN))
151 return -EACCES; 151 return -EPERM;
152 152
153 if (simple_strtol(buf, NULL, 0) != 1) 153 if (simple_strtol(buf, NULL, 0) != 1)
154 return -EINVAL; 154 return -EINVAL;
@@ -161,7 +161,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
161 size_t len) 161 size_t len)
162{ 162{
163 if (!capable(CAP_SYS_ADMIN)) 163 if (!capable(CAP_SYS_ADMIN))
164 return -EACCES; 164 return -EPERM;
165 165
166 if (simple_strtol(buf, NULL, 0) != 1) 166 if (simple_strtol(buf, NULL, 0) != 1)
167 return -EINVAL; 167 return -EINVAL;
@@ -178,7 +178,7 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
178 u32 id; 178 u32 id;
179 179
180 if (!capable(CAP_SYS_ADMIN)) 180 if (!capable(CAP_SYS_ADMIN))
181 return -EACCES; 181 return -EPERM;
182 182
183 id = simple_strtoul(buf, NULL, 0); 183 id = simple_strtoul(buf, NULL, 0);
184 184
@@ -198,7 +198,7 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
198 u32 id; 198 u32 id;
199 199
200 if (!capable(CAP_SYS_ADMIN)) 200 if (!capable(CAP_SYS_ADMIN))
201 return -EACCES; 201 return -EPERM;
202 202
203 id = simple_strtoul(buf, NULL, 0); 203 id = simple_strtoul(buf, NULL, 0);
204 204
@@ -221,7 +221,7 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len
221 int rv; 221 int rv;
222 222
223 if (!capable(CAP_SYS_ADMIN)) 223 if (!capable(CAP_SYS_ADMIN))
224 return -EACCES; 224 return -EPERM;
225 225
226 rv = sscanf(buf, "%u:%llu %15s", &gltype, &glnum, 226 rv = sscanf(buf, "%u:%llu %15s", &gltype, &glnum,
227 mode); 227 mode);
@@ -532,7 +532,7 @@ static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,
532 unsigned int x, y; 532 unsigned int x, y;
533 533
534 if (!capable(CAP_SYS_ADMIN)) 534 if (!capable(CAP_SYS_ADMIN))
535 return -EACCES; 535 return -EPERM;
536 536
537 if (sscanf(buf, "%u %u", &x, &y) != 2 || !y) 537 if (sscanf(buf, "%u %u", &x, &y) != 2 || !y)
538 return -EINVAL; 538 return -EINVAL;
@@ -551,7 +551,7 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
551 unsigned int x; 551 unsigned int x;
552 552
553 if (!capable(CAP_SYS_ADMIN)) 553 if (!capable(CAP_SYS_ADMIN))
554 return -EACCES; 554 return -EPERM;
555 555
556 x = simple_strtoul(buf, NULL, 0); 556 x = simple_strtoul(buf, NULL, 0);
557 557
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 422dde2ec0a1..5f7f1abd5f6d 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -51,7 +51,7 @@ done:
51 */ 51 */
52static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 52static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
53{ 53{
54 struct inode *inode = filp->f_path.dentry->d_inode; 54 struct inode *inode = file_inode(filp);
55 struct super_block *sb = inode->i_sb; 55 struct super_block *sb = inode->i_sb;
56 int len, err; 56 int len, err;
57 char strbuf[HFS_MAX_NAMELEN]; 57 char strbuf[HFS_MAX_NAMELEN];
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index d47f11658c17..3031dfdd2358 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -128,7 +128,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
128{ 128{
129 struct file *file = iocb->ki_filp; 129 struct file *file = iocb->ki_filp;
130 struct address_space *mapping = file->f_mapping; 130 struct address_space *mapping = file->f_mapping;
131 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; 131 struct inode *inode = file_inode(file)->i_mapping->host;
132 ssize_t ret; 132 ssize_t ret;
133 133
134 ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs, 134 ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 6b9f921ef2fa..074e04589248 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -122,7 +122,7 @@ fail:
122 122
123static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir) 123static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
124{ 124{
125 struct inode *inode = filp->f_path.dentry->d_inode; 125 struct inode *inode = file_inode(filp);
126 struct super_block *sb = inode->i_sb; 126 struct super_block *sb = inode->i_sb;
127 int len, err; 127 int len, err;
128 char strbuf[HFSPLUS_MAX_STRLEN + 1]; 128 char strbuf[HFSPLUS_MAX_STRLEN + 1];
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 799b336b59f9..dcd05be5344b 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -124,7 +124,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
124{ 124{
125 struct file *file = iocb->ki_filp; 125 struct file *file = iocb->ki_filp;
126 struct address_space *mapping = file->f_mapping; 126 struct address_space *mapping = file->f_mapping;
127 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; 127 struct inode *inode = file_inode(file)->i_mapping->host;
128 ssize_t ret; 128 ssize_t ret;
129 129
130 ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs, 130 ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index 09addc8615fa..e3c4c4209428 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -59,7 +59,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
59 59
60static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags) 60static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
61{ 61{
62 struct inode *inode = file->f_path.dentry->d_inode; 62 struct inode *inode = file_inode(file);
63 struct hfsplus_inode_info *hip = HFSPLUS_I(inode); 63 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
64 unsigned int flags = 0; 64 unsigned int flags = 0;
65 65
@@ -75,7 +75,7 @@ static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
75 75
76static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags) 76static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
77{ 77{
78 struct inode *inode = file->f_path.dentry->d_inode; 78 struct inode *inode = file_inode(file);
79 struct hfsplus_inode_info *hip = HFSPLUS_I(inode); 79 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
80 unsigned int flags; 80 unsigned int flags;
81 int err = 0; 81 int err = 0;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 457addc5c91f..fbabb906066f 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -30,7 +30,7 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
30 return list_entry(inode, struct hostfs_inode_info, vfs_inode); 30 return list_entry(inode, struct hostfs_inode_info, vfs_inode);
31} 31}
32 32
33#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode) 33#define FILE_HOSTFS_I(file) HOSTFS_I(file_inode(file))
34 34
35static int hostfs_d_delete(const struct dentry *dentry) 35static int hostfs_d_delete(const struct dentry *dentry)
36{ 36{
@@ -861,14 +861,6 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
861} 861}
862 862
863static const struct inode_operations hostfs_iops = { 863static const struct inode_operations hostfs_iops = {
864 .create = hostfs_create,
865 .link = hostfs_link,
866 .unlink = hostfs_unlink,
867 .symlink = hostfs_symlink,
868 .mkdir = hostfs_mkdir,
869 .rmdir = hostfs_rmdir,
870 .mknod = hostfs_mknod,
871 .rename = hostfs_rename,
872 .permission = hostfs_permission, 864 .permission = hostfs_permission,
873 .setattr = hostfs_setattr, 865 .setattr = hostfs_setattr,
874}; 866};
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 78e12b2e0ea2..546f6d39713a 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -25,7 +25,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
25 loff_t new_off = off + (whence == 1 ? filp->f_pos : 0); 25 loff_t new_off = off + (whence == 1 ? filp->f_pos : 0);
26 loff_t pos; 26 loff_t pos;
27 struct quad_buffer_head qbh; 27 struct quad_buffer_head qbh;
28 struct inode *i = filp->f_path.dentry->d_inode; 28 struct inode *i = file_inode(filp);
29 struct hpfs_inode_info *hpfs_inode = hpfs_i(i); 29 struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
30 struct super_block *s = i->i_sb; 30 struct super_block *s = i->i_sb;
31 31
@@ -57,7 +57,7 @@ fail:
57 57
58static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 58static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
59{ 59{
60 struct inode *inode = filp->f_path.dentry->d_inode; 60 struct inode *inode = file_inode(filp);
61 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); 61 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
62 struct quad_buffer_head qbh; 62 struct quad_buffer_head qbh;
63 struct hpfs_dirent *de; 63 struct hpfs_dirent *de;
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index fbfe2df5624b..9f9dbeceeee7 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -152,7 +152,7 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf,
152 retval = do_sync_write(file, buf, count, ppos); 152 retval = do_sync_write(file, buf, count, ppos);
153 if (retval > 0) { 153 if (retval > 0) {
154 hpfs_lock(file->f_path.dentry->d_sb); 154 hpfs_lock(file->f_path.dentry->d_sb);
155 hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1; 155 hpfs_i(file_inode(file))->i_dirty = 1;
156 hpfs_unlock(file->f_path.dentry->d_sb); 156 hpfs_unlock(file->f_path.dentry->d_sb);
157 } 157 }
158 return retval; 158 return retval;
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 43b315f2002b..74f55703be49 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -180,7 +180,7 @@ static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count,
180 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); 180 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
181 ssize_t n; 181 ssize_t n;
182 182
183 read = file->f_path.dentry->d_inode->i_fop->read; 183 read = file_inode(file)->i_fop->read;
184 184
185 if (!is_user) 185 if (!is_user)
186 set_fs(KERNEL_DS); 186 set_fs(KERNEL_DS);
@@ -288,7 +288,7 @@ static ssize_t hppfs_write(struct file *file, const char __user *buf,
288 struct file *proc_file = data->proc_file; 288 struct file *proc_file = data->proc_file;
289 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 289 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
290 290
291 write = proc_file->f_path.dentry->d_inode->i_fop->write; 291 write = file_inode(proc_file)->i_fop->write;
292 return (*write)(proc_file, buf, len, ppos); 292 return (*write)(proc_file, buf, len, ppos);
293} 293}
294 294
@@ -513,7 +513,7 @@ static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
513 loff_t (*llseek)(struct file *, loff_t, int); 513 loff_t (*llseek)(struct file *, loff_t, int);
514 loff_t ret; 514 loff_t ret;
515 515
516 llseek = proc_file->f_path.dentry->d_inode->i_fop->llseek; 516 llseek = file_inode(proc_file)->i_fop->llseek;
517 if (llseek != NULL) { 517 if (llseek != NULL) {
518 ret = (*llseek)(proc_file, off, where); 518 ret = (*llseek)(proc_file, off, where);
519 if (ret < 0) 519 if (ret < 0)
@@ -561,7 +561,7 @@ static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
561 }); 561 });
562 int err; 562 int err;
563 563
564 readdir = proc_file->f_path.dentry->d_inode->i_fop->readdir; 564 readdir = file_inode(proc_file)->i_fop->readdir;
565 565
566 proc_file->f_pos = file->f_pos; 566 proc_file->f_pos = file->f_pos;
567 err = (*readdir)(proc_file, &dirent, hppfs_filldir); 567 err = (*readdir)(proc_file, &dirent, hppfs_filldir);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 78bde32ea951..7f94e0cbc69c 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -97,7 +97,7 @@ static void huge_pagevec_release(struct pagevec *pvec)
97 97
98static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) 98static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
99{ 99{
100 struct inode *inode = file->f_path.dentry->d_inode; 100 struct inode *inode = file_inode(file);
101 loff_t len, vma_len; 101 loff_t len, vma_len;
102 int ret; 102 int ret;
103 struct hstate *h = hstate_file(file); 103 struct hstate *h = hstate_file(file);
@@ -918,16 +918,25 @@ static int get_hstate_idx(int page_size_log)
918 return h - hstates; 918 return h - hstates;
919} 919}
920 920
921static char *hugetlb_dname(struct dentry *dentry, char *buffer, int buflen)
922{
923 return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)",
924 dentry->d_name.name);
925}
926
927static struct dentry_operations anon_ops = {
928 .d_dname = hugetlb_dname
929};
930
921struct file *hugetlb_file_setup(const char *name, unsigned long addr, 931struct file *hugetlb_file_setup(const char *name, unsigned long addr,
922 size_t size, vm_flags_t acctflag, 932 size_t size, vm_flags_t acctflag,
923 struct user_struct **user, 933 struct user_struct **user,
924 int creat_flags, int page_size_log) 934 int creat_flags, int page_size_log)
925{ 935{
926 int error = -ENOMEM; 936 struct file *file = ERR_PTR(-ENOMEM);
927 struct file *file;
928 struct inode *inode; 937 struct inode *inode;
929 struct path path; 938 struct path path;
930 struct dentry *root; 939 struct super_block *sb;
931 struct qstr quick_string; 940 struct qstr quick_string;
932 struct hstate *hstate; 941 struct hstate *hstate;
933 unsigned long num_pages; 942 unsigned long num_pages;
@@ -955,17 +964,18 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
955 } 964 }
956 } 965 }
957 966
958 root = hugetlbfs_vfsmount[hstate_idx]->mnt_root; 967 sb = hugetlbfs_vfsmount[hstate_idx]->mnt_sb;
959 quick_string.name = name; 968 quick_string.name = name;
960 quick_string.len = strlen(quick_string.name); 969 quick_string.len = strlen(quick_string.name);
961 quick_string.hash = 0; 970 quick_string.hash = 0;
962 path.dentry = d_alloc(root, &quick_string); 971 path.dentry = d_alloc_pseudo(sb, &quick_string);
963 if (!path.dentry) 972 if (!path.dentry)
964 goto out_shm_unlock; 973 goto out_shm_unlock;
965 974
975 d_set_d_op(path.dentry, &anon_ops);
966 path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]); 976 path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]);
967 error = -ENOSPC; 977 file = ERR_PTR(-ENOSPC);
968 inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0); 978 inode = hugetlbfs_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0);
969 if (!inode) 979 if (!inode)
970 goto out_dentry; 980 goto out_dentry;
971 981
@@ -973,7 +983,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
973 size += addr & ~huge_page_mask(hstate); 983 size += addr & ~huge_page_mask(hstate);
974 num_pages = ALIGN(size, huge_page_size(hstate)) >> 984 num_pages = ALIGN(size, huge_page_size(hstate)) >>
975 huge_page_shift(hstate); 985 huge_page_shift(hstate);
976 error = -ENOMEM; 986 file = ERR_PTR(-ENOMEM);
977 if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag)) 987 if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag))
978 goto out_inode; 988 goto out_inode;
979 989
@@ -981,10 +991,9 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
981 inode->i_size = size; 991 inode->i_size = size;
982 clear_nlink(inode); 992 clear_nlink(inode);
983 993
984 error = -ENFILE;
985 file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 994 file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
986 &hugetlbfs_file_operations); 995 &hugetlbfs_file_operations);
987 if (!file) 996 if (IS_ERR(file))
988 goto out_dentry; /* inode is already attached */ 997 goto out_dentry; /* inode is already attached */
989 998
990 return file; 999 return file;
@@ -998,7 +1007,7 @@ out_shm_unlock:
998 user_shm_unlock(size, *user); 1007 user_shm_unlock(size, *user);
999 *user = NULL; 1008 *user = NULL;
1000 } 1009 }
1001 return ERR_PTR(error); 1010 return file;
1002} 1011}
1003 1012
1004static int __init init_hugetlbfs_fs(void) 1013static int __init init_hugetlbfs_fs(void)
diff --git a/fs/inode.c b/fs/inode.c
index 14084b72b259..67880e604399 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1655,7 +1655,7 @@ EXPORT_SYMBOL(file_remove_suid);
1655 1655
1656int file_update_time(struct file *file) 1656int file_update_time(struct file *file)
1657{ 1657{
1658 struct inode *inode = file->f_path.dentry->d_inode; 1658 struct inode *inode = file_inode(file);
1659 struct timespec now; 1659 struct timespec now;
1660 int sync_it = 0; 1660 int sync_it = 0;
1661 int ret; 1661 int ret;
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 3bdad6d1f268..fd507fb460f8 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -175,7 +175,7 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
175 struct fiemap fiemap; 175 struct fiemap fiemap;
176 struct fiemap __user *ufiemap = (struct fiemap __user *) arg; 176 struct fiemap __user *ufiemap = (struct fiemap __user *) arg;
177 struct fiemap_extent_info fieinfo = { 0, }; 177 struct fiemap_extent_info fieinfo = { 0, };
178 struct inode *inode = filp->f_path.dentry->d_inode; 178 struct inode *inode = file_inode(filp);
179 struct super_block *sb = inode->i_sb; 179 struct super_block *sb = inode->i_sb;
180 u64 len; 180 u64 len;
181 int error; 181 int error;
@@ -424,7 +424,7 @@ EXPORT_SYMBOL(generic_block_fiemap);
424 */ 424 */
425int ioctl_preallocate(struct file *filp, void __user *argp) 425int ioctl_preallocate(struct file *filp, void __user *argp)
426{ 426{
427 struct inode *inode = filp->f_path.dentry->d_inode; 427 struct inode *inode = file_inode(filp);
428 struct space_resv sr; 428 struct space_resv sr;
429 429
430 if (copy_from_user(&sr, argp, sizeof(sr))) 430 if (copy_from_user(&sr, argp, sizeof(sr)))
@@ -449,7 +449,7 @@ int ioctl_preallocate(struct file *filp, void __user *argp)
449static int file_ioctl(struct file *filp, unsigned int cmd, 449static int file_ioctl(struct file *filp, unsigned int cmd,
450 unsigned long arg) 450 unsigned long arg)
451{ 451{
452 struct inode *inode = filp->f_path.dentry->d_inode; 452 struct inode *inode = file_inode(filp);
453 int __user *p = (int __user *)arg; 453 int __user *p = (int __user *)arg;
454 454
455 switch (cmd) { 455 switch (cmd) {
@@ -512,7 +512,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
512 512
513static int ioctl_fsfreeze(struct file *filp) 513static int ioctl_fsfreeze(struct file *filp)
514{ 514{
515 struct super_block *sb = filp->f_path.dentry->d_inode->i_sb; 515 struct super_block *sb = file_inode(filp)->i_sb;
516 516
517 if (!capable(CAP_SYS_ADMIN)) 517 if (!capable(CAP_SYS_ADMIN))
518 return -EPERM; 518 return -EPERM;
@@ -527,7 +527,7 @@ static int ioctl_fsfreeze(struct file *filp)
527 527
528static int ioctl_fsthaw(struct file *filp) 528static int ioctl_fsthaw(struct file *filp)
529{ 529{
530 struct super_block *sb = filp->f_path.dentry->d_inode->i_sb; 530 struct super_block *sb = file_inode(filp)->i_sb;
531 531
532 if (!capable(CAP_SYS_ADMIN)) 532 if (!capable(CAP_SYS_ADMIN))
533 return -EPERM; 533 return -EPERM;
@@ -548,7 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
548{ 548{
549 int error = 0; 549 int error = 0;
550 int __user *argp = (int __user *)arg; 550 int __user *argp = (int __user *)arg;
551 struct inode *inode = filp->f_path.dentry->d_inode; 551 struct inode *inode = file_inode(filp);
552 552
553 switch (cmd) { 553 switch (cmd) {
554 case FIOCLEX: 554 case FIOCLEX:
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index 0b3fa7974fa8..592e5115a561 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -296,7 +296,7 @@ static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,
296 */ 296 */
297static int zisofs_readpage(struct file *file, struct page *page) 297static int zisofs_readpage(struct file *file, struct page *page)
298{ 298{
299 struct inode *inode = file->f_path.dentry->d_inode; 299 struct inode *inode = file_inode(file);
300 struct address_space *mapping = inode->i_mapping; 300 struct address_space *mapping = inode->i_mapping;
301 int err; 301 int err;
302 int i, pcount, full_page; 302 int i, pcount, full_page;
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index f20437c068a0..a7d5c3c3d4e6 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -253,7 +253,7 @@ static int isofs_readdir(struct file *filp,
253 int result; 253 int result;
254 char *tmpname; 254 char *tmpname;
255 struct iso_directory_record *tmpde; 255 struct iso_directory_record *tmpde;
256 struct inode *inode = filp->f_path.dentry->d_inode; 256 struct inode *inode = file_inode(filp);
257 257
258 tmpname = (char *)__get_free_page(GFP_KERNEL); 258 tmpname = (char *)__get_free_page(GFP_KERNEL);
259 if (tmpname == NULL) 259 if (tmpname == NULL)
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index 2b4f2358eadb..12088d8de3fa 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -125,10 +125,10 @@ isofs_export_encode_fh(struct inode *inode,
125 */ 125 */
126 if (parent && (len < 5)) { 126 if (parent && (len < 5)) {
127 *max_len = 5; 127 *max_len = 5;
128 return 255; 128 return FILEID_INVALID;
129 } else if (len < 3) { 129 } else if (len < 3) {
130 *max_len = 3; 130 *max_len = 3;
131 return 255; 131 return FILEID_INVALID;
132 } 132 }
133 133
134 len = 3; 134 len = 3;
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index ad7774d32095..acd46a4160cb 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -117,12 +117,12 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
117static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) 117static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
118{ 118{
119 struct jffs2_inode_info *f; 119 struct jffs2_inode_info *f;
120 struct inode *inode = filp->f_path.dentry->d_inode; 120 struct inode *inode = file_inode(filp);
121 struct jffs2_full_dirent *fd; 121 struct jffs2_full_dirent *fd;
122 unsigned long offset, curofs; 122 unsigned long offset, curofs;
123 123
124 jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", 124 jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n",
125 filp->f_path.dentry->d_inode->i_ino); 125 file_inode(filp)->i_ino);
126 126
127 f = JFFS2_INODE_INFO(inode); 127 f = JFFS2_INODE_INFO(inode);
128 128
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index bc555ff417e9..93a1232894f6 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -58,7 +58,7 @@ static long jfs_map_ext2(unsigned long flags, int from)
58 58
59long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 59long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
60{ 60{
61 struct inode *inode = filp->f_dentry->d_inode; 61 struct inode *inode = file_inode(filp);
62 struct jfs_inode_info *jfs_inode = JFS_IP(inode); 62 struct jfs_inode_info *jfs_inode = JFS_IP(inode);
63 unsigned int flags; 63 unsigned int flags;
64 64
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 9197a1b0d02d..0ddbeceafc62 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -3004,7 +3004,7 @@ static inline struct jfs_dirent *next_jfs_dirent(struct jfs_dirent *dirent)
3004 */ 3004 */
3005int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 3005int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
3006{ 3006{
3007 struct inode *ip = filp->f_path.dentry->d_inode; 3007 struct inode *ip = file_inode(filp);
3008 struct nls_table *codepage = JFS_SBI(ip->i_sb)->nls_tab; 3008 struct nls_table *codepage = JFS_SBI(ip->i_sb)->nls_tab;
3009 int rc = 0; 3009 int rc = 0;
3010 loff_t dtpos; /* legacy OS/2 style position */ 3010 loff_t dtpos; /* legacy OS/2 style position */
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index ca0a08001449..a2717408c478 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -178,7 +178,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
178 continue; 178 continue;
179 if (!rpc_cmp_addr(nlm_addr(block->b_host), addr)) 179 if (!rpc_cmp_addr(nlm_addr(block->b_host), addr))
180 continue; 180 continue;
181 if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0) 181 if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->fl_file)) ,fh) != 0)
182 continue; 182 continue;
183 /* Alright, we found a lock. Set the return status 183 /* Alright, we found a lock. Set the return status
184 * and wake up the caller 184 * and wake up the caller
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 52e5120bb159..366277190b82 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -127,7 +127,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
127 struct nlm_lock *lock = &argp->lock; 127 struct nlm_lock *lock = &argp->lock;
128 128
129 nlmclnt_next_cookie(&argp->cookie); 129 nlmclnt_next_cookie(&argp->cookie);
130 memcpy(&lock->fh, NFS_FH(fl->fl_file->f_path.dentry->d_inode), sizeof(struct nfs_fh)); 130 memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh));
131 lock->caller = utsname()->nodename; 131 lock->caller = utsname()->nodename;
132 lock->oh.data = req->a_owner; 132 lock->oh.data = req->a_owner;
133 lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s", 133 lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 8d80c990dffd..e703318c41df 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -406,8 +406,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
406 __be32 ret; 406 __be32 ret;
407 407
408 dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n", 408 dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
409 file->f_file->f_path.dentry->d_inode->i_sb->s_id, 409 file_inode(file->f_file)->i_sb->s_id,
410 file->f_file->f_path.dentry->d_inode->i_ino, 410 file_inode(file->f_file)->i_ino,
411 lock->fl.fl_type, lock->fl.fl_pid, 411 lock->fl.fl_type, lock->fl.fl_pid,
412 (long long)lock->fl.fl_start, 412 (long long)lock->fl.fl_start,
413 (long long)lock->fl.fl_end, 413 (long long)lock->fl.fl_end,
@@ -513,8 +513,8 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
513 __be32 ret; 513 __be32 ret;
514 514
515 dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n", 515 dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
516 file->f_file->f_path.dentry->d_inode->i_sb->s_id, 516 file_inode(file->f_file)->i_sb->s_id,
517 file->f_file->f_path.dentry->d_inode->i_ino, 517 file_inode(file->f_file)->i_ino,
518 lock->fl.fl_type, 518 lock->fl.fl_type,
519 (long long)lock->fl.fl_start, 519 (long long)lock->fl.fl_start,
520 (long long)lock->fl.fl_end); 520 (long long)lock->fl.fl_end);
@@ -606,8 +606,8 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock)
606 int error; 606 int error;
607 607
608 dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n", 608 dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
609 file->f_file->f_path.dentry->d_inode->i_sb->s_id, 609 file_inode(file->f_file)->i_sb->s_id,
610 file->f_file->f_path.dentry->d_inode->i_ino, 610 file_inode(file->f_file)->i_ino,
611 lock->fl.fl_pid, 611 lock->fl.fl_pid,
612 (long long)lock->fl.fl_start, 612 (long long)lock->fl.fl_start,
613 (long long)lock->fl.fl_end); 613 (long long)lock->fl.fl_end);
@@ -635,8 +635,8 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l
635 int status = 0; 635 int status = 0;
636 636
637 dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n", 637 dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
638 file->f_file->f_path.dentry->d_inode->i_sb->s_id, 638 file_inode(file->f_file)->i_sb->s_id,
639 file->f_file->f_path.dentry->d_inode->i_ino, 639 file_inode(file->f_file)->i_ino,
640 lock->fl.fl_pid, 640 lock->fl.fl_pid,
641 (long long)lock->fl.fl_start, 641 (long long)lock->fl.fl_start,
642 (long long)lock->fl.fl_end); 642 (long long)lock->fl.fl_end);
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 0deb5f6c9dd4..b3a24b07d981 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -45,7 +45,7 @@ static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f)
45 45
46static inline void nlm_debug_print_file(char *msg, struct nlm_file *file) 46static inline void nlm_debug_print_file(char *msg, struct nlm_file *file)
47{ 47{
48 struct inode *inode = file->f_file->f_path.dentry->d_inode; 48 struct inode *inode = file_inode(file->f_file);
49 49
50 dprintk("lockd: %s %s/%ld\n", 50 dprintk("lockd: %s %s/%ld\n",
51 msg, inode->i_sb->s_id, inode->i_ino); 51 msg, inode->i_sb->s_id, inode->i_ino);
diff --git a/fs/locks.c b/fs/locks.c
index a94e331a52a2..cb424a4fed71 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -334,7 +334,7 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
334 start = filp->f_pos; 334 start = filp->f_pos;
335 break; 335 break;
336 case SEEK_END: 336 case SEEK_END:
337 start = i_size_read(filp->f_path.dentry->d_inode); 337 start = i_size_read(file_inode(filp));
338 break; 338 break;
339 default: 339 default:
340 return -EINVAL; 340 return -EINVAL;
@@ -384,7 +384,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
384 start = filp->f_pos; 384 start = filp->f_pos;
385 break; 385 break;
386 case SEEK_END: 386 case SEEK_END:
387 start = i_size_read(filp->f_path.dentry->d_inode); 387 start = i_size_read(file_inode(filp));
388 break; 388 break;
389 default: 389 default:
390 return -EINVAL; 390 return -EINVAL;
@@ -627,7 +627,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
627 struct file_lock *cfl; 627 struct file_lock *cfl;
628 628
629 lock_flocks(); 629 lock_flocks();
630 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { 630 for (cfl = file_inode(filp)->i_flock; cfl; cfl = cfl->fl_next) {
631 if (!IS_POSIX(cfl)) 631 if (!IS_POSIX(cfl))
632 continue; 632 continue;
633 if (posix_locks_conflict(fl, cfl)) 633 if (posix_locks_conflict(fl, cfl))
@@ -708,7 +708,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
708{ 708{
709 struct file_lock *new_fl = NULL; 709 struct file_lock *new_fl = NULL;
710 struct file_lock **before; 710 struct file_lock **before;
711 struct inode * inode = filp->f_path.dentry->d_inode; 711 struct inode * inode = file_inode(filp);
712 int error = 0; 712 int error = 0;
713 int found = 0; 713 int found = 0;
714 714
@@ -1002,7 +1002,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
1002int posix_lock_file(struct file *filp, struct file_lock *fl, 1002int posix_lock_file(struct file *filp, struct file_lock *fl,
1003 struct file_lock *conflock) 1003 struct file_lock *conflock)
1004{ 1004{
1005 return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock); 1005 return __posix_lock_file(file_inode(filp), fl, conflock);
1006} 1006}
1007EXPORT_SYMBOL(posix_lock_file); 1007EXPORT_SYMBOL(posix_lock_file);
1008 1008
@@ -1326,8 +1326,8 @@ int fcntl_getlease(struct file *filp)
1326 int type = F_UNLCK; 1326 int type = F_UNLCK;
1327 1327
1328 lock_flocks(); 1328 lock_flocks();
1329 time_out_leases(filp->f_path.dentry->d_inode); 1329 time_out_leases(file_inode(filp));
1330 for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl); 1330 for (fl = file_inode(filp)->i_flock; fl && IS_LEASE(fl);
1331 fl = fl->fl_next) { 1331 fl = fl->fl_next) {
1332 if (fl->fl_file == filp) { 1332 if (fl->fl_file == filp) {
1333 type = target_leasetype(fl); 1333 type = target_leasetype(fl);
@@ -1843,7 +1843,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
1843 if (copy_from_user(&flock, l, sizeof(flock))) 1843 if (copy_from_user(&flock, l, sizeof(flock)))
1844 goto out; 1844 goto out;
1845 1845
1846 inode = filp->f_path.dentry->d_inode; 1846 inode = file_inode(filp);
1847 1847
1848 /* Don't allow mandatory locks on files that may be memory mapped 1848 /* Don't allow mandatory locks on files that may be memory mapped
1849 * and shared. 1849 * and shared.
@@ -1961,7 +1961,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
1961 if (copy_from_user(&flock, l, sizeof(flock))) 1961 if (copy_from_user(&flock, l, sizeof(flock)))
1962 goto out; 1962 goto out;
1963 1963
1964 inode = filp->f_path.dentry->d_inode; 1964 inode = file_inode(filp);
1965 1965
1966 /* Don't allow mandatory locks on files that may be memory mapped 1966 /* Don't allow mandatory locks on files that may be memory mapped
1967 * and shared. 1967 * and shared.
@@ -2030,7 +2030,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
2030 * posix_lock_file(). Another process could be setting a lock on this 2030 * posix_lock_file(). Another process could be setting a lock on this
2031 * file at the same time, but we wouldn't remove that lock anyway. 2031 * file at the same time, but we wouldn't remove that lock anyway.
2032 */ 2032 */
2033 if (!filp->f_path.dentry->d_inode->i_flock) 2033 if (!file_inode(filp)->i_flock)
2034 return; 2034 return;
2035 2035
2036 lock.fl_type = F_UNLCK; 2036 lock.fl_type = F_UNLCK;
@@ -2056,7 +2056,7 @@ EXPORT_SYMBOL(locks_remove_posix);
2056 */ 2056 */
2057void locks_remove_flock(struct file *filp) 2057void locks_remove_flock(struct file *filp)
2058{ 2058{
2059 struct inode * inode = filp->f_path.dentry->d_inode; 2059 struct inode * inode = file_inode(filp);
2060 struct file_lock *fl; 2060 struct file_lock *fl;
2061 struct file_lock **before; 2061 struct file_lock **before;
2062 2062
@@ -2152,7 +2152,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2152 fl_pid = fl->fl_pid; 2152 fl_pid = fl->fl_pid;
2153 2153
2154 if (fl->fl_file != NULL) 2154 if (fl->fl_file != NULL)
2155 inode = fl->fl_file->f_path.dentry->d_inode; 2155 inode = file_inode(fl->fl_file);
2156 2156
2157 seq_printf(f, "%lld:%s ", id, pfx); 2157 seq_printf(f, "%lld:%s ", id, pfx);
2158 if (IS_POSIX(fl)) { 2158 if (IS_POSIX(fl)) {
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 26e4a941532f..b82751082112 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -284,7 +284,7 @@ static int logfs_rmdir(struct inode *dir, struct dentry *dentry)
284#define IMPLICIT_NODES 2 284#define IMPLICIT_NODES 2
285static int __logfs_readdir(struct file *file, void *buf, filldir_t filldir) 285static int __logfs_readdir(struct file *file, void *buf, filldir_t filldir)
286{ 286{
287 struct inode *dir = file->f_dentry->d_inode; 287 struct inode *dir = file_inode(file);
288 loff_t pos = file->f_pos - IMPLICIT_NODES; 288 loff_t pos = file->f_pos - IMPLICIT_NODES;
289 struct page *page; 289 struct page *page;
290 struct logfs_disk_dentry *dd; 290 struct logfs_disk_dentry *dd;
@@ -320,7 +320,7 @@ static int __logfs_readdir(struct file *file, void *buf, filldir_t filldir)
320 320
321static int logfs_readdir(struct file *file, void *buf, filldir_t filldir) 321static int logfs_readdir(struct file *file, void *buf, filldir_t filldir)
322{ 322{
323 struct inode *inode = file->f_dentry->d_inode; 323 struct inode *inode = file_inode(file);
324 ino_t pino = parent_ino(file->f_dentry); 324 ino_t pino = parent_ino(file->f_dentry);
325 int err; 325 int err;
326 326
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 3886cded283c..c2219a6dd3c8 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -183,7 +183,7 @@ static int logfs_releasepage(struct page *page, gfp_t only_xfs_uses_this)
183 183
184long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 184long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
185{ 185{
186 struct inode *inode = file->f_path.dentry->d_inode; 186 struct inode *inode = file_inode(file);
187 struct logfs_inode *li = logfs_inode(inode); 187 struct logfs_inode *li = logfs_inode(inode);
188 unsigned int oldflags, flags; 188 unsigned int oldflags, flags;
189 int err; 189 int err;
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index 685b2d981b87..a9ed6f36e6ea 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -85,7 +85,7 @@ static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi)
85static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir) 85static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
86{ 86{
87 unsigned long pos = filp->f_pos; 87 unsigned long pos = filp->f_pos;
88 struct inode *inode = filp->f_path.dentry->d_inode; 88 struct inode *inode = file_inode(filp);
89 struct super_block *sb = inode->i_sb; 89 struct super_block *sb = inode->i_sb;
90 unsigned offset = pos & ~PAGE_CACHE_MASK; 90 unsigned offset = pos & ~PAGE_CACHE_MASK;
91 unsigned long n = pos >> PAGE_CACHE_SHIFT; 91 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/namei.c b/fs/namei.c
index 43a97ee1d4c8..dc984fee5532 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -600,14 +600,10 @@ static int complete_walk(struct nameidata *nd)
600 if (likely(!(nd->flags & LOOKUP_JUMPED))) 600 if (likely(!(nd->flags & LOOKUP_JUMPED)))
601 return 0; 601 return 0;
602 602
603 if (likely(!(dentry->d_flags & DCACHE_OP_REVALIDATE))) 603 if (likely(!(dentry->d_flags & DCACHE_OP_WEAK_REVALIDATE)))
604 return 0; 604 return 0;
605 605
606 if (likely(!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT))) 606 status = dentry->d_op->d_weak_revalidate(dentry, nd->flags);
607 return 0;
608
609 /* Note: we do not d_invalidate() */
610 status = d_revalidate(dentry, nd->flags);
611 if (status > 0) 607 if (status > 0)
612 return 0; 608 return 0;
613 609
@@ -1342,7 +1338,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
1342 * small and for now I'd prefer to have fast path as straight as possible. 1338 * small and for now I'd prefer to have fast path as straight as possible.
1343 * It _is_ time-critical. 1339 * It _is_ time-critical.
1344 */ 1340 */
1345static int lookup_fast(struct nameidata *nd, struct qstr *name, 1341static int lookup_fast(struct nameidata *nd,
1346 struct path *path, struct inode **inode) 1342 struct path *path, struct inode **inode)
1347{ 1343{
1348 struct vfsmount *mnt = nd->path.mnt; 1344 struct vfsmount *mnt = nd->path.mnt;
@@ -1358,7 +1354,7 @@ static int lookup_fast(struct nameidata *nd, struct qstr *name,
1358 */ 1354 */
1359 if (nd->flags & LOOKUP_RCU) { 1355 if (nd->flags & LOOKUP_RCU) {
1360 unsigned seq; 1356 unsigned seq;
1361 dentry = __d_lookup_rcu(parent, name, &seq, nd->inode); 1357 dentry = __d_lookup_rcu(parent, &nd->last, &seq, nd->inode);
1362 if (!dentry) 1358 if (!dentry)
1363 goto unlazy; 1359 goto unlazy;
1364 1360
@@ -1400,7 +1396,7 @@ unlazy:
1400 if (unlazy_walk(nd, dentry)) 1396 if (unlazy_walk(nd, dentry))
1401 return -ECHILD; 1397 return -ECHILD;
1402 } else { 1398 } else {
1403 dentry = __d_lookup(parent, name); 1399 dentry = __d_lookup(parent, &nd->last);
1404 } 1400 }
1405 1401
1406 if (unlikely(!dentry)) 1402 if (unlikely(!dentry))
@@ -1436,8 +1432,7 @@ need_lookup:
1436} 1432}
1437 1433
1438/* Fast lookup failed, do it the slow way */ 1434/* Fast lookup failed, do it the slow way */
1439static int lookup_slow(struct nameidata *nd, struct qstr *name, 1435static int lookup_slow(struct nameidata *nd, struct path *path)
1440 struct path *path)
1441{ 1436{
1442 struct dentry *dentry, *parent; 1437 struct dentry *dentry, *parent;
1443 int err; 1438 int err;
@@ -1446,7 +1441,7 @@ static int lookup_slow(struct nameidata *nd, struct qstr *name,
1446 BUG_ON(nd->inode != parent->d_inode); 1441 BUG_ON(nd->inode != parent->d_inode);
1447 1442
1448 mutex_lock(&parent->d_inode->i_mutex); 1443 mutex_lock(&parent->d_inode->i_mutex);
1449 dentry = __lookup_hash(name, parent, nd->flags); 1444 dentry = __lookup_hash(&nd->last, parent, nd->flags);
1450 mutex_unlock(&parent->d_inode->i_mutex); 1445 mutex_unlock(&parent->d_inode->i_mutex);
1451 if (IS_ERR(dentry)) 1446 if (IS_ERR(dentry))
1452 return PTR_ERR(dentry); 1447 return PTR_ERR(dentry);
@@ -1519,7 +1514,7 @@ static inline int should_follow_link(struct inode *inode, int follow)
1519} 1514}
1520 1515
1521static inline int walk_component(struct nameidata *nd, struct path *path, 1516static inline int walk_component(struct nameidata *nd, struct path *path,
1522 struct qstr *name, int type, int follow) 1517 int follow)
1523{ 1518{
1524 struct inode *inode; 1519 struct inode *inode;
1525 int err; 1520 int err;
@@ -1528,14 +1523,14 @@ static inline int walk_component(struct nameidata *nd, struct path *path,
1528 * to be able to know about the current root directory and 1523 * to be able to know about the current root directory and
1529 * parent relationships. 1524 * parent relationships.
1530 */ 1525 */
1531 if (unlikely(type != LAST_NORM)) 1526 if (unlikely(nd->last_type != LAST_NORM))
1532 return handle_dots(nd, type); 1527 return handle_dots(nd, nd->last_type);
1533 err = lookup_fast(nd, name, path, &inode); 1528 err = lookup_fast(nd, path, &inode);
1534 if (unlikely(err)) { 1529 if (unlikely(err)) {
1535 if (err < 0) 1530 if (err < 0)
1536 goto out_err; 1531 goto out_err;
1537 1532
1538 err = lookup_slow(nd, name, path); 1533 err = lookup_slow(nd, path);
1539 if (err < 0) 1534 if (err < 0)
1540 goto out_err; 1535 goto out_err;
1541 1536
@@ -1594,8 +1589,7 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
1594 res = follow_link(&link, nd, &cookie); 1589 res = follow_link(&link, nd, &cookie);
1595 if (res) 1590 if (res)
1596 break; 1591 break;
1597 res = walk_component(nd, path, &nd->last, 1592 res = walk_component(nd, path, LOOKUP_FOLLOW);
1598 nd->last_type, LOOKUP_FOLLOW);
1599 put_link(nd, &link, cookie); 1593 put_link(nd, &link, cookie);
1600 } while (res > 0); 1594 } while (res > 0);
1601 1595
@@ -1802,8 +1796,11 @@ static int link_path_walk(const char *name, struct nameidata *nd)
1802 } 1796 }
1803 } 1797 }
1804 1798
1799 nd->last = this;
1800 nd->last_type = type;
1801
1805 if (!name[len]) 1802 if (!name[len])
1806 goto last_component; 1803 return 0;
1807 /* 1804 /*
1808 * If it wasn't NUL, we know it was '/'. Skip that 1805 * If it wasn't NUL, we know it was '/'. Skip that
1809 * slash, and continue until no more slashes. 1806 * slash, and continue until no more slashes.
@@ -1812,10 +1809,11 @@ static int link_path_walk(const char *name, struct nameidata *nd)
1812 len++; 1809 len++;
1813 } while (unlikely(name[len] == '/')); 1810 } while (unlikely(name[len] == '/'));
1814 if (!name[len]) 1811 if (!name[len])
1815 goto last_component; 1812 return 0;
1813
1816 name += len; 1814 name += len;
1817 1815
1818 err = walk_component(nd, &next, &this, type, LOOKUP_FOLLOW); 1816 err = walk_component(nd, &next, LOOKUP_FOLLOW);
1819 if (err < 0) 1817 if (err < 0)
1820 return err; 1818 return err;
1821 1819
@@ -1824,16 +1822,10 @@ static int link_path_walk(const char *name, struct nameidata *nd)
1824 if (err) 1822 if (err)
1825 return err; 1823 return err;
1826 } 1824 }
1827 if (can_lookup(nd->inode)) 1825 if (!can_lookup(nd->inode)) {
1828 continue; 1826 err = -ENOTDIR;
1829 err = -ENOTDIR; 1827 break;
1830 break; 1828 }
1831 /* here ends the main loop */
1832
1833last_component:
1834 nd->last = this;
1835 nd->last_type = type;
1836 return 0;
1837 } 1829 }
1838 terminate_walk(nd); 1830 terminate_walk(nd);
1839 return err; 1831 return err;
@@ -1932,8 +1924,7 @@ static inline int lookup_last(struct nameidata *nd, struct path *path)
1932 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; 1924 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
1933 1925
1934 nd->flags &= ~LOOKUP_PARENT; 1926 nd->flags &= ~LOOKUP_PARENT;
1935 return walk_component(nd, path, &nd->last, nd->last_type, 1927 return walk_component(nd, path, nd->flags & LOOKUP_FOLLOW);
1936 nd->flags & LOOKUP_FOLLOW);
1937} 1928}
1938 1929
1939/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ 1930/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
@@ -2732,7 +2723,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2732 if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) 2723 if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW))
2733 symlink_ok = true; 2724 symlink_ok = true;
2734 /* we _can_ be in RCU mode here */ 2725 /* we _can_ be in RCU mode here */
2735 error = lookup_fast(nd, &nd->last, path, &inode); 2726 error = lookup_fast(nd, path, &inode);
2736 if (likely(!error)) 2727 if (likely(!error))
2737 goto finish_lookup; 2728 goto finish_lookup;
2738 2729
@@ -2778,7 +2769,7 @@ retry_lookup:
2778 goto out; 2769 goto out;
2779 2770
2780 if ((*opened & FILE_CREATED) || 2771 if ((*opened & FILE_CREATED) ||
2781 !S_ISREG(file->f_path.dentry->d_inode->i_mode)) 2772 !S_ISREG(file_inode(file)->i_mode))
2782 will_truncate = false; 2773 will_truncate = false;
2783 2774
2784 audit_inode(name, file->f_path.dentry, 0); 2775 audit_inode(name, file->f_path.dentry, 0);
@@ -2941,8 +2932,8 @@ static struct file *path_openat(int dfd, struct filename *pathname,
2941 int error; 2932 int error;
2942 2933
2943 file = get_empty_filp(); 2934 file = get_empty_filp();
2944 if (!file) 2935 if (IS_ERR(file))
2945 return ERR_PTR(-ENFILE); 2936 return file;
2946 2937
2947 file->f_flags = op->open_flag; 2938 file->f_flags = op->open_flag;
2948 2939
diff --git a/fs/namespace.c b/fs/namespace.c
index edac42c6eff2..50ca17d3cb45 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -384,7 +384,7 @@ EXPORT_SYMBOL_GPL(mnt_clone_write);
384 */ 384 */
385int __mnt_want_write_file(struct file *file) 385int __mnt_want_write_file(struct file *file)
386{ 386{
387 struct inode *inode = file->f_dentry->d_inode; 387 struct inode *inode = file_inode(file);
388 388
389 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode)) 389 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode))
390 return __mnt_want_write(file->f_path.mnt); 390 return __mnt_want_write(file->f_path.mnt);
@@ -1300,24 +1300,6 @@ SYSCALL_DEFINE1(oldumount, char __user *, name)
1300 1300
1301#endif 1301#endif
1302 1302
1303static int mount_is_safe(struct path *path)
1304{
1305 if (may_mount())
1306 return 0;
1307 return -EPERM;
1308#ifdef notyet
1309 if (S_ISLNK(path->dentry->d_inode->i_mode))
1310 return -EPERM;
1311 if (path->dentry->d_inode->i_mode & S_ISVTX) {
1312 if (current_uid() != path->dentry->d_inode->i_uid)
1313 return -EPERM;
1314 }
1315 if (inode_permission(path->dentry->d_inode, MAY_WRITE))
1316 return -EPERM;
1317 return 0;
1318#endif
1319}
1320
1321static bool mnt_ns_loop(struct path *path) 1303static bool mnt_ns_loop(struct path *path)
1322{ 1304{
1323 /* Could bind mounting the mount namespace inode cause a 1305 /* Could bind mounting the mount namespace inode cause a
@@ -1640,9 +1622,6 @@ static int do_change_type(struct path *path, int flag)
1640 int type; 1622 int type;
1641 int err = 0; 1623 int err = 0;
1642 1624
1643 if (!may_mount())
1644 return -EPERM;
1645
1646 if (path->dentry != path->mnt->mnt_root) 1625 if (path->dentry != path->mnt->mnt_root)
1647 return -EINVAL; 1626 return -EINVAL;
1648 1627
@@ -1676,9 +1655,7 @@ static int do_loopback(struct path *path, const char *old_name,
1676 LIST_HEAD(umount_list); 1655 LIST_HEAD(umount_list);
1677 struct path old_path; 1656 struct path old_path;
1678 struct mount *mnt = NULL, *old; 1657 struct mount *mnt = NULL, *old;
1679 int err = mount_is_safe(path); 1658 int err;
1680 if (err)
1681 return err;
1682 if (!old_name || !*old_name) 1659 if (!old_name || !*old_name)
1683 return -EINVAL; 1660 return -EINVAL;
1684 err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path); 1661 err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);
@@ -1755,9 +1732,6 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1755 struct super_block *sb = path->mnt->mnt_sb; 1732 struct super_block *sb = path->mnt->mnt_sb;
1756 struct mount *mnt = real_mount(path->mnt); 1733 struct mount *mnt = real_mount(path->mnt);
1757 1734
1758 if (!capable(CAP_SYS_ADMIN))
1759 return -EPERM;
1760
1761 if (!check_mnt(mnt)) 1735 if (!check_mnt(mnt))
1762 return -EINVAL; 1736 return -EINVAL;
1763 1737
@@ -1771,6 +1745,8 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1771 down_write(&sb->s_umount); 1745 down_write(&sb->s_umount);
1772 if (flags & MS_BIND) 1746 if (flags & MS_BIND)
1773 err = change_mount_flags(path->mnt, flags); 1747 err = change_mount_flags(path->mnt, flags);
1748 else if (!capable(CAP_SYS_ADMIN))
1749 err = -EPERM;
1774 else 1750 else
1775 err = do_remount_sb(sb, flags, data, 0); 1751 err = do_remount_sb(sb, flags, data, 0);
1776 if (!err) { 1752 if (!err) {
@@ -1803,9 +1779,7 @@ static int do_move_mount(struct path *path, const char *old_name)
1803 struct path old_path, parent_path; 1779 struct path old_path, parent_path;
1804 struct mount *p; 1780 struct mount *p;
1805 struct mount *old; 1781 struct mount *old;
1806 int err = 0; 1782 int err;
1807 if (!may_mount())
1808 return -EPERM;
1809 if (!old_name || !*old_name) 1783 if (!old_name || !*old_name)
1810 return -EINVAL; 1784 return -EINVAL;
1811 err = kern_path(old_name, LOOKUP_FOLLOW, &old_path); 1785 err = kern_path(old_name, LOOKUP_FOLLOW, &old_path);
@@ -1947,9 +1921,6 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
1947 if (!fstype) 1921 if (!fstype)
1948 return -EINVAL; 1922 return -EINVAL;
1949 1923
1950 if (!may_mount())
1951 return -EPERM;
1952
1953 type = get_fs_type(fstype); 1924 type = get_fs_type(fstype);
1954 if (!type) 1925 if (!type)
1955 return -ENODEV; 1926 return -ENODEV;
@@ -2263,6 +2234,9 @@ long do_mount(const char *dev_name, const char *dir_name,
2263 if (retval) 2234 if (retval)
2264 goto dput_out; 2235 goto dput_out;
2265 2236
2237 if (!may_mount())
2238 return -EPERM;
2239
2266 /* Default to relatime unless overriden */ 2240 /* Default to relatime unless overriden */
2267 if (!(flags & MS_NOATIME)) 2241 if (!(flags & MS_NOATIME))
2268 mnt_flags |= MNT_RELATIME; 2242 mnt_flags |= MNT_RELATIME;
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 4117e7b377bb..816326093656 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -593,14 +593,10 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
593 return 1; /* I'm not sure */ 593 return 1; /* I'm not sure */
594 594
595 qname.name = __name; 595 qname.name = __name;
596 qname.hash = full_name_hash(qname.name, qname.len);
597
598 if (dentry->d_op && dentry->d_op->d_hash)
599 if (dentry->d_op->d_hash(dentry, dentry->d_inode, &qname) != 0)
600 goto end_advance;
601
602 newdent = d_lookup(dentry, &qname);
603 596
597 newdent = d_hash_and_lookup(dentry, &qname);
598 if (unlikely(IS_ERR(newdent)))
599 goto end_advance;
604 if (!newdent) { 600 if (!newdent) {
605 newdent = d_alloc(dentry, &qname); 601 newdent = d_alloc(dentry, &qname);
606 if (!newdent) 602 if (!newdent)
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index e2be336d1c22..7dafd6899a62 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -538,7 +538,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
538 if (!ncp_filp) 538 if (!ncp_filp)
539 goto out; 539 goto out;
540 error = -ENOTSOCK; 540 error = -ENOTSOCK;
541 sock_inode = ncp_filp->f_path.dentry->d_inode; 541 sock_inode = file_inode(ncp_filp);
542 if (!S_ISSOCK(sock_inode->i_mode)) 542 if (!S_ISSOCK(sock_inode->i_mode))
543 goto out_fput; 543 goto out_fput;
544 sock = SOCKET_I(sock_inode); 544 sock = SOCKET_I(sock_inode);
@@ -577,7 +577,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
577 if (!server->info_filp) 577 if (!server->info_filp)
578 goto out_bdi; 578 goto out_bdi;
579 error = -ENOTSOCK; 579 error = -ENOTSOCK;
580 sock_inode = server->info_filp->f_path.dentry->d_inode; 580 sock_inode = file_inode(server->info_filp);
581 if (!S_ISSOCK(sock_inode->i_mode)) 581 if (!S_ISSOCK(sock_inode->i_mode))
582 goto out_fput2; 582 goto out_fput2;
583 info_sock = SOCKET_I(sock_inode); 583 info_sock = SOCKET_I(sock_inode);
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index d44318d27504..60426ccb3b65 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -811,7 +811,7 @@ outrel:
811 811
812long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 812long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
813{ 813{
814 struct inode *inode = filp->f_dentry->d_inode; 814 struct inode *inode = file_inode(filp);
815 struct ncp_server *server = NCP_SERVER(inode); 815 struct ncp_server *server = NCP_SERVER(inode);
816 kuid_t uid = current_uid(); 816 kuid_t uid = current_uid();
817 int need_drop_write = 0; 817 int need_drop_write = 0;
@@ -822,7 +822,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
822 case NCP_IOC_CONN_LOGGED_IN: 822 case NCP_IOC_CONN_LOGGED_IN:
823 case NCP_IOC_SETROOT: 823 case NCP_IOC_SETROOT:
824 if (!capable(CAP_SYS_ADMIN)) { 824 if (!capable(CAP_SYS_ADMIN)) {
825 ret = -EACCES; 825 ret = -EPERM;
826 goto out; 826 goto out;
827 } 827 }
828 break; 828 break;
diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c
index 63d14a99483d..ee24df5af1f9 100644
--- a/fs/ncpfs/mmap.c
+++ b/fs/ncpfs/mmap.c
@@ -105,7 +105,7 @@ static const struct vm_operations_struct ncp_file_mmap =
105/* This is used for a general mmap of a ncp file */ 105/* This is used for a general mmap of a ncp file */
106int ncp_mmap(struct file *file, struct vm_area_struct *vma) 106int ncp_mmap(struct file *file, struct vm_area_struct *vma)
107{ 107{
108 struct inode *inode = file->f_path.dentry->d_inode; 108 struct inode *inode = file_inode(file);
109 109
110 DPRINTK("ncp_mmap: called\n"); 110 DPRINTK("ncp_mmap: called\n");
111 111
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1b2d7eb93796..f23f455be42b 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -281,7 +281,7 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
281 281
282 for (i = 0; i < array->size; i++) { 282 for (i = 0; i < array->size; i++) {
283 if (array->array[i].cookie == *desc->dir_cookie) { 283 if (array->array[i].cookie == *desc->dir_cookie) {
284 struct nfs_inode *nfsi = NFS_I(desc->file->f_path.dentry->d_inode); 284 struct nfs_inode *nfsi = NFS_I(file_inode(desc->file));
285 struct nfs_open_dir_context *ctx = desc->file->private_data; 285 struct nfs_open_dir_context *ctx = desc->file->private_data;
286 286
287 new_pos = desc->current_index + i; 287 new_pos = desc->current_index + i;
@@ -629,7 +629,7 @@ out:
629static 629static
630int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page) 630int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page)
631{ 631{
632 struct inode *inode = desc->file->f_path.dentry->d_inode; 632 struct inode *inode = file_inode(desc->file);
633 int ret; 633 int ret;
634 634
635 ret = nfs_readdir_xdr_to_array(desc, page, inode); 635 ret = nfs_readdir_xdr_to_array(desc, page, inode);
@@ -660,7 +660,7 @@ void cache_page_release(nfs_readdir_descriptor_t *desc)
660static 660static
661struct page *get_cache_page(nfs_readdir_descriptor_t *desc) 661struct page *get_cache_page(nfs_readdir_descriptor_t *desc)
662{ 662{
663 return read_cache_page(desc->file->f_path.dentry->d_inode->i_mapping, 663 return read_cache_page(file_inode(desc->file)->i_mapping,
664 desc->page_index, (filler_t *)nfs_readdir_filler, desc); 664 desc->page_index, (filler_t *)nfs_readdir_filler, desc);
665} 665}
666 666
@@ -764,7 +764,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
764{ 764{
765 struct page *page = NULL; 765 struct page *page = NULL;
766 int status; 766 int status;
767 struct inode *inode = desc->file->f_path.dentry->d_inode; 767 struct inode *inode = file_inode(desc->file);
768 struct nfs_open_dir_context *ctx = desc->file->private_data; 768 struct nfs_open_dir_context *ctx = desc->file->private_data;
769 769
770 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n", 770 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n",
@@ -1136,6 +1136,45 @@ out_error:
1136} 1136}
1137 1137
1138/* 1138/*
1139 * A weaker form of d_revalidate for revalidating just the dentry->d_inode
1140 * when we don't really care about the dentry name. This is called when a
1141 * pathwalk ends on a dentry that was not found via a normal lookup in the
1142 * parent dir (e.g.: ".", "..", procfs symlinks or mountpoint traversals).
1143 *
1144 * In this situation, we just want to verify that the inode itself is OK
1145 * since the dentry might have changed on the server.
1146 */
1147static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
1148{
1149 int error;
1150 struct inode *inode = dentry->d_inode;
1151
1152 /*
1153 * I believe we can only get a negative dentry here in the case of a
1154 * procfs-style symlink. Just assume it's correct for now, but we may
1155 * eventually need to do something more here.
1156 */
1157 if (!inode) {
1158 dfprintk(LOOKUPCACHE, "%s: %s/%s has negative inode\n",
1159 __func__, dentry->d_parent->d_name.name,
1160 dentry->d_name.name);
1161 return 1;
1162 }
1163
1164 if (is_bad_inode(inode)) {
1165 dfprintk(LOOKUPCACHE, "%s: %s/%s has dud inode\n",
1166 __func__, dentry->d_parent->d_name.name,
1167 dentry->d_name.name);
1168 return 0;
1169 }
1170
1171 error = nfs_revalidate_inode(NFS_SERVER(inode), inode);
1172 dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n",
1173 __func__, inode->i_ino, error ? "invalid" : "valid");
1174 return !error;
1175}
1176
1177/*
1139 * This is called from dput() when d_count is going to 0. 1178 * This is called from dput() when d_count is going to 0.
1140 */ 1179 */
1141static int nfs_dentry_delete(const struct dentry *dentry) 1180static int nfs_dentry_delete(const struct dentry *dentry)
@@ -1202,6 +1241,7 @@ static void nfs_d_release(struct dentry *dentry)
1202 1241
1203const struct dentry_operations nfs_dentry_operations = { 1242const struct dentry_operations nfs_dentry_operations = {
1204 .d_revalidate = nfs_lookup_revalidate, 1243 .d_revalidate = nfs_lookup_revalidate,
1244 .d_weak_revalidate = nfs_weak_revalidate,
1205 .d_delete = nfs_dentry_delete, 1245 .d_delete = nfs_dentry_delete,
1206 .d_iput = nfs_dentry_iput, 1246 .d_iput = nfs_dentry_iput,
1207 .d_automount = nfs_d_automount, 1247 .d_automount = nfs_d_automount,
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 3c2b893665ba..29f4a48a0ee6 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -292,7 +292,7 @@ static int
292nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) 292nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
293{ 293{
294 int ret; 294 int ret;
295 struct inode *inode = file->f_path.dentry->d_inode; 295 struct inode *inode = file_inode(file);
296 296
297 do { 297 do {
298 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 298 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index b9623d19d599..dc0f98dfa717 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -765,7 +765,7 @@ out:
765static ssize_t 765static ssize_t
766idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) 766idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
767{ 767{
768 struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode); 768 struct rpc_inode *rpci = RPC_I(file_inode(filp));
769 struct idmap *idmap = (struct idmap *)rpci->private; 769 struct idmap *idmap = (struct idmap *)rpci->private;
770 struct key_construction *cons; 770 struct key_construction *cons;
771 struct idmap_msg im; 771 struct idmap_msg im;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 468ba8bf0f56..b586fe9af475 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -711,7 +711,7 @@ EXPORT_SYMBOL_GPL(put_nfs_open_context);
711 */ 711 */
712void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx) 712void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
713{ 713{
714 struct inode *inode = filp->f_path.dentry->d_inode; 714 struct inode *inode = file_inode(filp);
715 struct nfs_inode *nfsi = NFS_I(inode); 715 struct nfs_inode *nfsi = NFS_I(inode);
716 716
717 filp->private_data = get_nfs_open_context(ctx); 717 filp->private_data = get_nfs_open_context(ctx);
@@ -744,7 +744,7 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c
744 744
745static void nfs_file_clear_open_context(struct file *filp) 745static void nfs_file_clear_open_context(struct file *filp)
746{ 746{
747 struct inode *inode = filp->f_path.dentry->d_inode; 747 struct inode *inode = file_inode(filp);
748 struct nfs_open_context *ctx = nfs_file_open_context(filp); 748 struct nfs_open_context *ctx = nfs_file_open_context(filp);
749 749
750 if (ctx) { 750 if (ctx) {
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 70efb63b1e42..43ea96ced28c 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -872,7 +872,7 @@ static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess
872static int 872static int
873nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) 873nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
874{ 874{
875 struct inode *inode = filp->f_path.dentry->d_inode; 875 struct inode *inode = file_inode(filp);
876 876
877 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); 877 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
878} 878}
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 08ddcccb8887..13e6bb3e3fe5 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -94,7 +94,7 @@ static int
94nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) 94nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
95{ 95{
96 int ret; 96 int ret;
97 struct inode *inode = file->f_path.dentry->d_inode; 97 struct inode *inode = file_inode(file);
98 98
99 do { 99 do {
100 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 100 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index 84d2e9e2f313..569b166cc050 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -28,7 +28,7 @@ static struct file_system_type nfs4_remote_fs_type = {
28 .name = "nfs4", 28 .name = "nfs4",
29 .mount = nfs4_remote_mount, 29 .mount = nfs4_remote_mount,
30 .kill_sb = nfs_kill_super, 30 .kill_sb = nfs_kill_super,
31 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 31 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
32}; 32};
33 33
34static struct file_system_type nfs4_remote_referral_fs_type = { 34static struct file_system_type nfs4_remote_referral_fs_type = {
@@ -36,7 +36,7 @@ static struct file_system_type nfs4_remote_referral_fs_type = {
36 .name = "nfs4", 36 .name = "nfs4",
37 .mount = nfs4_remote_referral_mount, 37 .mount = nfs4_remote_referral_mount,
38 .kill_sb = nfs_kill_super, 38 .kill_sb = nfs_kill_super,
39 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 39 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
40}; 40};
41 41
42struct file_system_type nfs4_referral_fs_type = { 42struct file_system_type nfs4_referral_fs_type = {
@@ -44,7 +44,7 @@ struct file_system_type nfs4_referral_fs_type = {
44 .name = "nfs4", 44 .name = "nfs4",
45 .mount = nfs4_referral_mount, 45 .mount = nfs4_referral_mount,
46 .kill_sb = nfs_kill_super, 46 .kill_sb = nfs_kill_super,
47 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 47 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
48}; 48};
49 49
50static const struct super_operations nfs4_sops = { 50static const struct super_operations nfs4_sops = {
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index f084dac948e1..fc8de9016acf 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -662,7 +662,7 @@ nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg)
662static int 662static int
663nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) 663nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
664{ 664{
665 struct inode *inode = filp->f_path.dentry->d_inode; 665 struct inode *inode = file_inode(filp);
666 666
667 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); 667 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
668} 668}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index befbae0cce41..a9dc5fc29955 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -291,7 +291,7 @@ struct file_system_type nfs_fs_type = {
291 .name = "nfs", 291 .name = "nfs",
292 .mount = nfs_fs_mount, 292 .mount = nfs_fs_mount,
293 .kill_sb = nfs_kill_super, 293 .kill_sb = nfs_kill_super,
294 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 294 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
295}; 295};
296EXPORT_SYMBOL_GPL(nfs_fs_type); 296EXPORT_SYMBOL_GPL(nfs_fs_type);
297 297
@@ -300,7 +300,7 @@ struct file_system_type nfs_xdev_fs_type = {
300 .name = "nfs", 300 .name = "nfs",
301 .mount = nfs_xdev_mount, 301 .mount = nfs_xdev_mount,
302 .kill_sb = nfs_kill_super, 302 .kill_sb = nfs_kill_super,
303 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 303 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
304}; 304};
305 305
306const struct super_operations nfs_sops = { 306const struct super_operations nfs_sops = {
@@ -330,7 +330,7 @@ struct file_system_type nfs4_fs_type = {
330 .name = "nfs4", 330 .name = "nfs4",
331 .mount = nfs_fs_mount, 331 .mount = nfs_fs_mount,
332 .kill_sb = nfs_kill_super, 332 .kill_sb = nfs_kill_super,
333 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 333 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
334}; 334};
335EXPORT_SYMBOL_GPL(nfs4_fs_type); 335EXPORT_SYMBOL_GPL(nfs4_fs_type);
336 336
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index e761ee95617f..497584c70366 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -101,7 +101,7 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf,
101 loff_t pos = *ppos; 101 loff_t pos = *ppos;
102 102
103 if (!pos) 103 if (!pos)
104 nfsd_inject_get(file->f_dentry->d_inode->i_private, &val); 104 nfsd_inject_get(file_inode(file)->i_private, &val);
105 size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val); 105 size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val);
106 106
107 if (pos < 0) 107 if (pos < 0)
@@ -133,10 +133,10 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
133 133
134 size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa)); 134 size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
135 if (size > 0) 135 if (size > 0)
136 nfsd_inject_set_client(file->f_dentry->d_inode->i_private, &sa, size); 136 nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);
137 else { 137 else {
138 val = simple_strtoll(write_buf, NULL, 0); 138 val = simple_strtoll(write_buf, NULL, 0);
139 nfsd_inject_set(file->f_dentry->d_inode->i_private, val); 139 nfsd_inject_set(file_inode(file)->i_private, val);
140 } 140 }
141 return len; /* on success, claim we got the whole input */ 141 return len; /* on success, claim we got the whole input */
142} 142}
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
index 9170861c804a..95d76dc6c5da 100644
--- a/fs/nfsd/nfs2acl.c
+++ b/fs/nfsd/nfs2acl.c
@@ -45,6 +45,10 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
45 RETURN_STATUS(nfserr_inval); 45 RETURN_STATUS(nfserr_inval);
46 resp->mask = argp->mask; 46 resp->mask = argp->mask;
47 47
48 nfserr = fh_getattr(fh, &resp->stat);
49 if (nfserr)
50 goto fail;
51
48 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { 52 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
49 acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS); 53 acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS);
50 if (IS_ERR(acl)) { 54 if (IS_ERR(acl)) {
@@ -115,6 +119,9 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
115 nfserr = nfserrno( nfsd_set_posix_acl( 119 nfserr = nfserrno( nfsd_set_posix_acl(
116 fh, ACL_TYPE_DEFAULT, argp->acl_default) ); 120 fh, ACL_TYPE_DEFAULT, argp->acl_default) );
117 } 121 }
122 if (!nfserr) {
123 nfserr = fh_getattr(fh, &resp->stat);
124 }
118 125
119 /* argp->acl_{access,default} may have been allocated in 126 /* argp->acl_{access,default} may have been allocated in
120 nfssvc_decode_setaclargs. */ 127 nfssvc_decode_setaclargs. */
@@ -129,10 +136,15 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
129static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp, 136static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp,
130 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp) 137 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp)
131{ 138{
139 __be32 nfserr;
132 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 140 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
133 141
134 fh_copy(&resp->fh, &argp->fh); 142 fh_copy(&resp->fh, &argp->fh);
135 return fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 143 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
144 if (nfserr)
145 return nfserr;
146 nfserr = fh_getattr(&resp->fh, &resp->stat);
147 return nfserr;
136} 148}
137 149
138/* 150/*
@@ -150,6 +162,9 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessarg
150 fh_copy(&resp->fh, &argp->fh); 162 fh_copy(&resp->fh, &argp->fh);
151 resp->access = argp->access; 163 resp->access = argp->access;
152 nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); 164 nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
165 if (nfserr)
166 return nfserr;
167 nfserr = fh_getattr(&resp->fh, &resp->stat);
153 return nfserr; 168 return nfserr;
154} 169}
155 170
@@ -243,7 +258,7 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
243 return 0; 258 return 0;
244 inode = dentry->d_inode; 259 inode = dentry->d_inode;
245 260
246 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh); 261 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
247 *p++ = htonl(resp->mask); 262 *p++ = htonl(resp->mask);
248 if (!xdr_ressize_check(rqstp, p)) 263 if (!xdr_ressize_check(rqstp, p))
249 return 0; 264 return 0;
@@ -274,7 +289,7 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
274static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p, 289static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
275 struct nfsd_attrstat *resp) 290 struct nfsd_attrstat *resp)
276{ 291{
277 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh); 292 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
278 return xdr_ressize_check(rqstp, p); 293 return xdr_ressize_check(rqstp, p);
279} 294}
280 295
@@ -282,7 +297,7 @@ static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
282static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p, 297static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
283 struct nfsd3_accessres *resp) 298 struct nfsd3_accessres *resp)
284{ 299{
285 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh); 300 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
286 *p++ = htonl(resp->access); 301 *p++ = htonl(resp->access);
287 return xdr_ressize_check(rqstp, p); 302 return xdr_ressize_check(rqstp, p);
288} 303}
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 1fc02dfdc5c4..401289913130 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -43,7 +43,6 @@ static __be32
43nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, 43nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
44 struct nfsd3_attrstat *resp) 44 struct nfsd3_attrstat *resp)
45{ 45{
46 int err;
47 __be32 nfserr; 46 __be32 nfserr;
48 47
49 dprintk("nfsd: GETATTR(3) %s\n", 48 dprintk("nfsd: GETATTR(3) %s\n",
@@ -55,9 +54,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
55 if (nfserr) 54 if (nfserr)
56 RETURN_STATUS(nfserr); 55 RETURN_STATUS(nfserr);
57 56
58 err = vfs_getattr(resp->fh.fh_export->ex_path.mnt, 57 nfserr = fh_getattr(&resp->fh, &resp->stat);
59 resp->fh.fh_dentry, &resp->stat);
60 nfserr = nfserrno(err);
61 58
62 RETURN_STATUS(nfserr); 59 RETURN_STATUS(nfserr);
63} 60}
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 925c944bc0bc..14d9ecb96cff 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -11,6 +11,7 @@
11#include "xdr3.h" 11#include "xdr3.h"
12#include "auth.h" 12#include "auth.h"
13#include "netns.h" 13#include "netns.h"
14#include "vfs.h"
14 15
15#define NFSDDBG_FACILITY NFSDDBG_XDR 16#define NFSDDBG_FACILITY NFSDDBG_XDR
16 17
@@ -206,10 +207,10 @@ encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
206{ 207{
207 struct dentry *dentry = fhp->fh_dentry; 208 struct dentry *dentry = fhp->fh_dentry;
208 if (dentry && dentry->d_inode) { 209 if (dentry && dentry->d_inode) {
209 int err; 210 __be32 err;
210 struct kstat stat; 211 struct kstat stat;
211 212
212 err = vfs_getattr(fhp->fh_export->ex_path.mnt, dentry, &stat); 213 err = fh_getattr(fhp, &stat);
213 if (!err) { 214 if (!err) {
214 *p++ = xdr_one; /* attributes follow */ 215 *p++ = xdr_one; /* attributes follow */
215 lease_get_mtime(dentry->d_inode, &stat.mtime); 216 lease_get_mtime(dentry->d_inode, &stat.mtime);
@@ -256,13 +257,12 @@ encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
256 */ 257 */
257void fill_post_wcc(struct svc_fh *fhp) 258void fill_post_wcc(struct svc_fh *fhp)
258{ 259{
259 int err; 260 __be32 err;
260 261
261 if (fhp->fh_post_saved) 262 if (fhp->fh_post_saved)
262 printk("nfsd: inode locked twice during operation.\n"); 263 printk("nfsd: inode locked twice during operation.\n");
263 264
264 err = vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry, 265 err = fh_getattr(fhp, &fhp->fh_post_attr);
265 &fhp->fh_post_attr);
266 fhp->fh_post_change = fhp->fh_dentry->d_inode->i_version; 266 fhp->fh_post_change = fhp->fh_dentry->d_inode->i_version;
267 if (err) { 267 if (err) {
268 fhp->fh_post_saved = 0; 268 fhp->fh_post_saved = 0;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2d1d06bae3a7..8ca6d17f6cf3 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2015,7 +2015,7 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat)
2015 if (path.dentry != path.mnt->mnt_root) 2015 if (path.dentry != path.mnt->mnt_root)
2016 break; 2016 break;
2017 } 2017 }
2018 err = vfs_getattr(path.mnt, path.dentry, stat); 2018 err = vfs_getattr(&path, stat);
2019 path_put(&path); 2019 path_put(&path);
2020 return err; 2020 return err;
2021} 2021}
@@ -2068,7 +2068,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
2068 goto out; 2068 goto out;
2069 } 2069 }
2070 2070
2071 err = vfs_getattr(exp->ex_path.mnt, dentry, &stat); 2071 err = vfs_getattr(&path, &stat);
2072 if (err) 2072 if (err)
2073 goto out_nfserr; 2073 goto out_nfserr;
2074 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | 2074 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 74934284d9a7..2db7021b01ae 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -85,7 +85,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
85 85
86static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos) 86static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
87{ 87{
88 ino_t ino = file->f_path.dentry->d_inode->i_ino; 88 ino_t ino = file_inode(file)->i_ino;
89 char *data; 89 char *data;
90 ssize_t rv; 90 ssize_t rv;
91 91
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index aad6d457b9e8..54c6b3d3cc79 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -26,17 +26,13 @@ static __be32
26nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp) 26nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
27{ 27{
28 if (err) return err; 28 if (err) return err;
29 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt, 29 return fh_getattr(&resp->fh, &resp->stat);
30 resp->fh.fh_dentry,
31 &resp->stat));
32} 30}
33static __be32 31static __be32
34nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp) 32nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
35{ 33{
36 if (err) return err; 34 if (err) return err;
37 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt, 35 return fh_getattr(&resp->fh, &resp->stat);
38 resp->fh.fh_dentry,
39 &resp->stat));
40} 36}
41/* 37/*
42 * Get a file's attributes 38 * Get a file's attributes
@@ -150,9 +146,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
150 &resp->count); 146 &resp->count);
151 147
152 if (nfserr) return nfserr; 148 if (nfserr) return nfserr;
153 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt, 149 return fh_getattr(&resp->fh, &resp->stat);
154 resp->fh.fh_dentry,
155 &resp->stat));
156} 150}
157 151
158/* 152/*
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 4201ede0ec91..9c769a47ac5a 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 4 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
5 */ 5 */
6 6
7#include "vfs.h"
7#include "xdr.h" 8#include "xdr.h"
8#include "auth.h" 9#include "auth.h"
9 10
@@ -196,11 +197,9 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
196} 197}
197 198
198/* Helper function for NFSv2 ACL code */ 199/* Helper function for NFSv2 ACL code */
199__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) 200__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat)
200{ 201{
201 struct kstat stat; 202 return encode_fattr(rqstp, p, fhp, stat);
202 vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &stat);
203 return encode_fattr(rqstp, p, fhp, &stat);
204} 203}
205 204
206/* 205/*
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 31ff1d642e31..2a7eb536de0b 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -979,7 +979,7 @@ static void kill_suid(struct dentry *dentry)
979 */ 979 */
980static int wait_for_concurrent_writes(struct file *file) 980static int wait_for_concurrent_writes(struct file *file)
981{ 981{
982 struct inode *inode = file->f_path.dentry->d_inode; 982 struct inode *inode = file_inode(file);
983 static ino_t last_ino; 983 static ino_t last_ino;
984 static dev_t last_dev; 984 static dev_t last_dev;
985 int err = 0; 985 int err = 0;
@@ -1070,7 +1070,7 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
1070 if (err) 1070 if (err)
1071 return err; 1071 return err;
1072 1072
1073 inode = file->f_path.dentry->d_inode; 1073 inode = file_inode(file);
1074 1074
1075 /* Get readahead parameters */ 1075 /* Get readahead parameters */
1076 ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino); 1076 ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino);
@@ -1957,7 +1957,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func,
1957 offset = *offsetp; 1957 offset = *offsetp;
1958 1958
1959 while (1) { 1959 while (1) {
1960 struct inode *dir_inode = file->f_path.dentry->d_inode; 1960 struct inode *dir_inode = file_inode(file);
1961 unsigned int reclen; 1961 unsigned int reclen;
1962 1962
1963 cdp->err = nfserr_eof; /* will be cleared on successful read */ 1963 cdp->err = nfserr_eof; /* will be cleared on successful read */
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 359594c393d2..5b5894159f22 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -6,6 +6,7 @@
6#define LINUX_NFSD_VFS_H 6#define LINUX_NFSD_VFS_H
7 7
8#include "nfsfh.h" 8#include "nfsfh.h"
9#include "nfsd.h"
9 10
10/* 11/*
11 * Flags for nfsd_permission 12 * Flags for nfsd_permission
@@ -125,4 +126,11 @@ static inline void fh_drop_write(struct svc_fh *fh)
125 } 126 }
126} 127}
127 128
129static inline __be32 fh_getattr(struct svc_fh *fh, struct kstat *stat)
130{
131 struct path p = {.mnt = fh->fh_export->ex_path.mnt,
132 .dentry = fh->fh_dentry};
133 return nfserrno(vfs_getattr(&p, stat));
134}
135
128#endif /* LINUX_NFSD_VFS_H */ 136#endif /* LINUX_NFSD_VFS_H */
diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h
index 53b1863dd8f6..4f0481d63804 100644
--- a/fs/nfsd/xdr.h
+++ b/fs/nfsd/xdr.h
@@ -167,7 +167,7 @@ int nfssvc_encode_entry(void *, const char *name,
167int nfssvc_release_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *); 167int nfssvc_release_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
168 168
169/* Helper functions for NFSv2 ACL code */ 169/* Helper functions for NFSv2 ACL code */
170__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp); 170__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat);
171__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp); 171__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
172 172
173#endif /* LINUX_NFSD_H */ 173#endif /* LINUX_NFSD_H */
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index 7df980eb0562..b6d5542a4ac8 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -136,6 +136,7 @@ struct nfsd3_accessres {
136 __be32 status; 136 __be32 status;
137 struct svc_fh fh; 137 struct svc_fh fh;
138 __u32 access; 138 __u32 access;
139 struct kstat stat;
139}; 140};
140 141
141struct nfsd3_readlinkres { 142struct nfsd3_readlinkres {
@@ -225,6 +226,7 @@ struct nfsd3_getaclres {
225 int mask; 226 int mask;
226 struct posix_acl *acl_access; 227 struct posix_acl *acl_access;
227 struct posix_acl *acl_default; 228 struct posix_acl *acl_default;
229 struct kstat stat;
228}; 230};
229 231
230/* dummy type for release */ 232/* dummy type for release */
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index df1a7fb238d1..f30b017740a7 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -259,7 +259,7 @@ static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode)
259static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 259static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
260{ 260{
261 loff_t pos = filp->f_pos; 261 loff_t pos = filp->f_pos;
262 struct inode *inode = filp->f_dentry->d_inode; 262 struct inode *inode = file_inode(filp);
263 struct super_block *sb = inode->i_sb; 263 struct super_block *sb = inode->i_sb;
264 unsigned int offset = pos & ~PAGE_CACHE_MASK; 264 unsigned int offset = pos & ~PAGE_CACHE_MASK;
265 unsigned long n = pos >> PAGE_CACHE_SHIFT; 265 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index bec4af6eab13..08fdb77852ac 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -67,7 +67,7 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
67static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 67static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
68{ 68{
69 struct page *page = vmf->page; 69 struct page *page = vmf->page;
70 struct inode *inode = vma->vm_file->f_dentry->d_inode; 70 struct inode *inode = file_inode(vma->vm_file);
71 struct nilfs_transaction_info ti; 71 struct nilfs_transaction_info ti;
72 int ret = 0; 72 int ret = 0;
73 73
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index f3859354e41a..b44bdb291b84 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -796,7 +796,7 @@ static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp,
796 796
797long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 797long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
798{ 798{
799 struct inode *inode = filp->f_dentry->d_inode; 799 struct inode *inode = file_inode(filp);
800 void __user *argp = (void __user *)arg; 800 void __user *argp = (void __user *)arg;
801 801
802 switch (cmd) { 802 switch (cmd) {
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 1d0c0b84c5a3..9de78f08989e 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -517,11 +517,11 @@ static int nilfs_encode_fh(struct inode *inode, __u32 *fh, int *lenp,
517 517
518 if (parent && *lenp < NILFS_FID_SIZE_CONNECTABLE) { 518 if (parent && *lenp < NILFS_FID_SIZE_CONNECTABLE) {
519 *lenp = NILFS_FID_SIZE_CONNECTABLE; 519 *lenp = NILFS_FID_SIZE_CONNECTABLE;
520 return 255; 520 return FILEID_INVALID;
521 } 521 }
522 if (*lenp < NILFS_FID_SIZE_NON_CONNECTABLE) { 522 if (*lenp < NILFS_FID_SIZE_NON_CONNECTABLE) {
523 *lenp = NILFS_FID_SIZE_NON_CONNECTABLE; 523 *lenp = NILFS_FID_SIZE_NON_CONNECTABLE;
524 return 255; 524 return FILEID_INVALID;
525 } 525 }
526 526
527 fid->cno = root->cno; 527 fid->cno = root->cno;
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index 08b886f119ce..2bfe6dc413a0 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -174,7 +174,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
174 struct dnotify_struct **prev; 174 struct dnotify_struct **prev;
175 struct inode *inode; 175 struct inode *inode;
176 176
177 inode = filp->f_path.dentry->d_inode; 177 inode = file_inode(filp);
178 if (!S_ISDIR(inode->i_mode)) 178 if (!S_ISDIR(inode->i_mode))
179 return; 179 return;
180 180
@@ -296,7 +296,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
296 } 296 }
297 297
298 /* dnotify only works on directories */ 298 /* dnotify only works on directories */
299 inode = filp->f_path.dentry->d_inode; 299 inode = file_inode(filp);
300 if (!S_ISDIR(inode->i_mode)) { 300 if (!S_ISDIR(inode->i_mode)) {
301 error = -ENOTDIR; 301 error = -ENOTDIR;
302 goto out_err; 302 goto out_err;
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 9ff4a5ee6e20..5d8444268a16 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -466,7 +466,7 @@ static int fanotify_find_path(int dfd, const char __user *filename,
466 466
467 ret = -ENOTDIR; 467 ret = -ENOTDIR;
468 if ((flags & FAN_MARK_ONLYDIR) && 468 if ((flags & FAN_MARK_ONLYDIR) &&
469 !(S_ISDIR(f.file->f_path.dentry->d_inode->i_mode))) { 469 !(S_ISDIR(file_inode(f.file)->i_mode))) {
470 fdput(f); 470 fdput(f);
471 goto out; 471 goto out;
472 } 472 }
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 99e36107ff60..aa411c3f20e9 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1101,7 +1101,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
1101{ 1101{
1102 s64 ia_pos, ia_start, prev_ia_pos, bmp_pos; 1102 s64 ia_pos, ia_start, prev_ia_pos, bmp_pos;
1103 loff_t fpos, i_size; 1103 loff_t fpos, i_size;
1104 struct inode *bmp_vi, *vdir = filp->f_path.dentry->d_inode; 1104 struct inode *bmp_vi, *vdir = file_inode(filp);
1105 struct super_block *sb = vdir->i_sb; 1105 struct super_block *sb = vdir->i_sb;
1106 ntfs_inode *ndir = NTFS_I(vdir); 1106 ntfs_inode *ndir = NTFS_I(vdir);
1107 ntfs_volume *vol = NTFS_SB(sb); 1107 ntfs_volume *vol = NTFS_SB(sb);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 9796330d8f04..20dfec72e903 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -569,7 +569,7 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
569 int ret, 569 int ret,
570 bool is_async) 570 bool is_async)
571{ 571{
572 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 572 struct inode *inode = file_inode(iocb->ki_filp);
573 int level; 573 int level;
574 wait_queue_head_t *wq = ocfs2_ioend_wq(inode); 574 wait_queue_head_t *wq = ocfs2_ioend_wq(inode);
575 575
@@ -593,9 +593,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
593 level = ocfs2_iocb_rw_locked_level(iocb); 593 level = ocfs2_iocb_rw_locked_level(iocb);
594 ocfs2_rw_unlock(inode, level); 594 ocfs2_rw_unlock(inode, level);
595 595
596 inode_dio_done(inode);
596 if (is_async) 597 if (is_async)
597 aio_complete(iocb, ret, 0); 598 aio_complete(iocb, ret, 0);
598 inode_dio_done(inode);
599} 599}
600 600
601/* 601/*
@@ -626,7 +626,7 @@ static ssize_t ocfs2_direct_IO(int rw,
626 unsigned long nr_segs) 626 unsigned long nr_segs)
627{ 627{
628 struct file *file = iocb->ki_filp; 628 struct file *file = iocb->ki_filp;
629 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; 629 struct inode *inode = file_inode(file)->i_mapping->host;
630 630
631 /* 631 /*
632 * Fallback to buffered I/O if we see an inode without 632 * Fallback to buffered I/O if we see an inode without
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index fc121350d8cb..f1e1aed8f638 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2014,12 +2014,12 @@ int ocfs2_dir_foreach(struct inode *inode, loff_t *f_pos, void *priv,
2014int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) 2014int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
2015{ 2015{
2016 int error = 0; 2016 int error = 0;
2017 struct inode *inode = filp->f_path.dentry->d_inode; 2017 struct inode *inode = file_inode(filp);
2018 int lock_level = 0; 2018 int lock_level = 0;
2019 2019
2020 trace_ocfs2_readdir((unsigned long long)OCFS2_I(inode)->ip_blkno); 2020 trace_ocfs2_readdir((unsigned long long)OCFS2_I(inode)->ip_blkno);
2021 2021
2022 error = ocfs2_inode_lock_atime(inode, filp->f_vfsmnt, &lock_level); 2022 error = ocfs2_inode_lock_atime(inode, filp->f_path.mnt, &lock_level);
2023 if (lock_level && error >= 0) { 2023 if (lock_level && error >= 0) {
2024 /* We release EX lock which used to update atime 2024 /* We release EX lock which used to update atime
2025 * and get PR lock again to reduce contention 2025 * and get PR lock again to reduce contention
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 005261c333b0..33ecbe0e6734 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -2020,7 +2020,7 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
2020 int ignore_higher, u8 request_from, u32 flags) 2020 int ignore_higher, u8 request_from, u32 flags)
2021{ 2021{
2022 struct dlm_work_item *item; 2022 struct dlm_work_item *item;
2023 item = kzalloc(sizeof(*item), GFP_NOFS); 2023 item = kzalloc(sizeof(*item), GFP_ATOMIC);
2024 if (!item) 2024 if (!item)
2025 return -ENOMEM; 2025 return -ENOMEM;
2026 2026
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 16b712d260d4..4c5fc8d77dc2 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -224,7 +224,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
224static unsigned int dlmfs_file_poll(struct file *file, poll_table *wait) 224static unsigned int dlmfs_file_poll(struct file *file, poll_table *wait)
225{ 225{
226 int event = 0; 226 int event = 0;
227 struct inode *inode = file->f_path.dentry->d_inode; 227 struct inode *inode = file_inode(file);
228 struct dlmfs_inode_private *ip = DLMFS_I(inode); 228 struct dlmfs_inode_private *ip = DLMFS_I(inode);
229 229
230 poll_wait(file, &ip->ip_lockres.l_event, wait); 230 poll_wait(file, &ip->ip_lockres.l_event, wait);
@@ -245,7 +245,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
245 int bytes_left; 245 int bytes_left;
246 ssize_t readlen, got; 246 ssize_t readlen, got;
247 char *lvb_buf; 247 char *lvb_buf;
248 struct inode *inode = filp->f_path.dentry->d_inode; 248 struct inode *inode = file_inode(filp);
249 249
250 mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", 250 mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
251 inode->i_ino, count, *ppos); 251 inode->i_ino, count, *ppos);
@@ -293,7 +293,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
293 int bytes_left; 293 int bytes_left;
294 ssize_t writelen; 294 ssize_t writelen;
295 char *lvb_buf; 295 char *lvb_buf;
296 struct inode *inode = filp->f_path.dentry->d_inode; 296 struct inode *inode = file_inode(filp);
297 297
298 mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", 298 mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
299 inode->i_ino, count, *ppos); 299 inode->i_ino, count, *ppos);
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 322216a5f0dd..29651167190d 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -195,11 +195,11 @@ static int ocfs2_encode_fh(struct inode *inode, u32 *fh_in, int *max_len,
195 195
196 if (parent && (len < 6)) { 196 if (parent && (len < 6)) {
197 *max_len = 6; 197 *max_len = 6;
198 type = 255; 198 type = FILEID_INVALID;
199 goto bail; 199 goto bail;
200 } else if (len < 3) { 200 } else if (len < 3) {
201 *max_len = 3; 201 *max_len = 3;
202 type = 255; 202 type = FILEID_INVALID;
203 goto bail; 203 goto bail;
204 } 204 }
205 205
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 0a2924a2d9e6..6474cb44004d 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1950,7 +1950,7 @@ out:
1950int ocfs2_change_file_space(struct file *file, unsigned int cmd, 1950int ocfs2_change_file_space(struct file *file, unsigned int cmd,
1951 struct ocfs2_space_resv *sr) 1951 struct ocfs2_space_resv *sr)
1952{ 1952{
1953 struct inode *inode = file->f_path.dentry->d_inode; 1953 struct inode *inode = file_inode(file);
1954 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1954 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1955 int ret; 1955 int ret;
1956 1956
@@ -1978,7 +1978,7 @@ int ocfs2_change_file_space(struct file *file, unsigned int cmd,
1978static long ocfs2_fallocate(struct file *file, int mode, loff_t offset, 1978static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
1979 loff_t len) 1979 loff_t len)
1980{ 1980{
1981 struct inode *inode = file->f_path.dentry->d_inode; 1981 struct inode *inode = file_inode(file);
1982 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1982 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1983 struct ocfs2_space_resv sr; 1983 struct ocfs2_space_resv sr;
1984 int change_size = 1; 1984 int change_size = 1;
@@ -2233,7 +2233,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
2233 loff_t old_size, *ppos = &iocb->ki_pos; 2233 loff_t old_size, *ppos = &iocb->ki_pos;
2234 u32 old_clusters; 2234 u32 old_clusters;
2235 struct file *file = iocb->ki_filp; 2235 struct file *file = iocb->ki_filp;
2236 struct inode *inode = file->f_path.dentry->d_inode; 2236 struct inode *inode = file_inode(file);
2237 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 2237 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2238 int full_coherency = !(osb->s_mount_opt & 2238 int full_coherency = !(osb->s_mount_opt &
2239 OCFS2_MOUNT_COHERENCY_BUFFERED); 2239 OCFS2_MOUNT_COHERENCY_BUFFERED);
@@ -2517,7 +2517,7 @@ static ssize_t ocfs2_file_splice_read(struct file *in,
2517 unsigned int flags) 2517 unsigned int flags)
2518{ 2518{
2519 int ret = 0, lock_level = 0; 2519 int ret = 0, lock_level = 0;
2520 struct inode *inode = in->f_path.dentry->d_inode; 2520 struct inode *inode = file_inode(in);
2521 2521
2522 trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry, 2522 trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry,
2523 (unsigned long long)OCFS2_I(inode)->ip_blkno, 2523 (unsigned long long)OCFS2_I(inode)->ip_blkno,
@@ -2527,7 +2527,7 @@ static ssize_t ocfs2_file_splice_read(struct file *in,
2527 /* 2527 /*
2528 * See the comment in ocfs2_file_aio_read() 2528 * See the comment in ocfs2_file_aio_read()
2529 */ 2529 */
2530 ret = ocfs2_inode_lock_atime(inode, in->f_vfsmnt, &lock_level); 2530 ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level);
2531 if (ret < 0) { 2531 if (ret < 0) {
2532 mlog_errno(ret); 2532 mlog_errno(ret);
2533 goto bail; 2533 goto bail;
@@ -2547,7 +2547,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2547{ 2547{
2548 int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0; 2548 int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0;
2549 struct file *filp = iocb->ki_filp; 2549 struct file *filp = iocb->ki_filp;
2550 struct inode *inode = filp->f_path.dentry->d_inode; 2550 struct inode *inode = file_inode(filp);
2551 2551
2552 trace_ocfs2_file_aio_read(inode, filp, filp->f_path.dentry, 2552 trace_ocfs2_file_aio_read(inode, filp, filp->f_path.dentry,
2553 (unsigned long long)OCFS2_I(inode)->ip_blkno, 2553 (unsigned long long)OCFS2_I(inode)->ip_blkno,
@@ -2590,7 +2590,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2590 * like i_size. This allows the checks down below 2590 * like i_size. This allows the checks down below
2591 * generic_file_aio_read() a chance of actually working. 2591 * generic_file_aio_read() a chance of actually working.
2592 */ 2592 */
2593 ret = ocfs2_inode_lock_atime(inode, filp->f_vfsmnt, &lock_level); 2593 ret = ocfs2_inode_lock_atime(inode, filp->f_path.mnt, &lock_level);
2594 if (ret < 0) { 2594 if (ret < 0) {
2595 mlog_errno(ret); 2595 mlog_errno(ret);
2596 goto bail; 2596 goto bail;
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index f20edcbfe700..752f0b26221d 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -881,7 +881,7 @@ bail:
881 881
882long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 882long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
883{ 883{
884 struct inode *inode = filp->f_path.dentry->d_inode; 884 struct inode *inode = file_inode(filp);
885 unsigned int flags; 885 unsigned int flags;
886 int new_clusters; 886 int new_clusters;
887 int status; 887 int status;
@@ -994,7 +994,7 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
994{ 994{
995 bool preserve; 995 bool preserve;
996 struct reflink_arguments args; 996 struct reflink_arguments args;
997 struct inode *inode = file->f_path.dentry->d_inode; 997 struct inode *inode = file_inode(file);
998 struct ocfs2_info info; 998 struct ocfs2_info info;
999 void __user *argp = (void __user *)arg; 999 void __user *argp = (void __user *)arg;
1000 1000
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 47a87dda54ce..10d66c75cecb 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -62,7 +62,7 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
62 struct page *page) 62 struct page *page)
63{ 63{
64 int ret = VM_FAULT_NOPAGE; 64 int ret = VM_FAULT_NOPAGE;
65 struct inode *inode = file->f_path.dentry->d_inode; 65 struct inode *inode = file_inode(file);
66 struct address_space *mapping = inode->i_mapping; 66 struct address_space *mapping = inode->i_mapping;
67 loff_t pos = page_offset(page); 67 loff_t pos = page_offset(page);
68 unsigned int len = PAGE_CACHE_SIZE; 68 unsigned int len = PAGE_CACHE_SIZE;
@@ -131,7 +131,7 @@ out:
131static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 131static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
132{ 132{
133 struct page *page = vmf->page; 133 struct page *page = vmf->page;
134 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 134 struct inode *inode = file_inode(vma->vm_file);
135 struct buffer_head *di_bh = NULL; 135 struct buffer_head *di_bh = NULL;
136 sigset_t oldset; 136 sigset_t oldset;
137 int ret; 137 int ret;
@@ -180,13 +180,13 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
180{ 180{
181 int ret = 0, lock_level = 0; 181 int ret = 0, lock_level = 0;
182 182
183 ret = ocfs2_inode_lock_atime(file->f_dentry->d_inode, 183 ret = ocfs2_inode_lock_atime(file_inode(file),
184 file->f_vfsmnt, &lock_level); 184 file->f_path.mnt, &lock_level);
185 if (ret < 0) { 185 if (ret < 0) {
186 mlog_errno(ret); 186 mlog_errno(ret);
187 goto out; 187 goto out;
188 } 188 }
189 ocfs2_inode_unlock(file->f_dentry->d_inode, lock_level); 189 ocfs2_inode_unlock(file_inode(file), lock_level);
190out: 190out:
191 vma->vm_ops = &ocfs2_file_vm_ops; 191 vma->vm_ops = &ocfs2_file_vm_ops;
192 return 0; 192 return 0;
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 6083432f667e..9f8dcadd9a50 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -1055,7 +1055,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
1055{ 1055{
1056 int status; 1056 int status;
1057 1057
1058 struct inode *inode = filp->f_path.dentry->d_inode; 1058 struct inode *inode = file_inode(filp);
1059 struct ocfs2_move_extents range; 1059 struct ocfs2_move_extents range;
1060 struct ocfs2_move_extents_context *context = NULL; 1060 struct ocfs2_move_extents_context *context = NULL;
1061 1061
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 934a4ac3e7fc..998b17eda09d 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2927,7 +2927,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2927 u32 new_cluster, u32 new_len) 2927 u32 new_cluster, u32 new_len)
2928{ 2928{
2929 int ret = 0, partial; 2929 int ret = 0, partial;
2930 struct inode *inode = file->f_path.dentry->d_inode; 2930 struct inode *inode = file_inode(file);
2931 struct ocfs2_caching_info *ci = INODE_CACHE(inode); 2931 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
2932 struct super_block *sb = ocfs2_metadata_cache_get_super(ci); 2932 struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
2933 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); 2933 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
@@ -3020,7 +3020,7 @@ int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
3020 u32 new_cluster, u32 new_len) 3020 u32 new_cluster, u32 new_len)
3021{ 3021{
3022 int ret = 0; 3022 int ret = 0;
3023 struct inode *inode = file->f_path.dentry->d_inode; 3023 struct inode *inode = file_inode(file);
3024 struct super_block *sb = inode->i_sb; 3024 struct super_block *sb = inode->i_sb;
3025 struct ocfs2_caching_info *ci = INODE_CACHE(inode); 3025 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
3026 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len); 3026 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index f1fbb4b552ad..66edce7ecfd7 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -57,7 +57,7 @@
57static int ocfs2_fast_symlink_readpage(struct file *unused, struct page *page) 57static int ocfs2_fast_symlink_readpage(struct file *unused, struct page *page)
58{ 58{
59 struct inode *inode = page->mapping->host; 59 struct inode *inode = page->mapping->host;
60 struct buffer_head *bh; 60 struct buffer_head *bh = NULL;
61 int status = ocfs2_read_inode_block(inode, &bh); 61 int status = ocfs2_read_inode_block(inode, &bh);
62 struct ocfs2_dinode *fe; 62 struct ocfs2_dinode *fe;
63 const char *link; 63 const char *link;
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index fb5b3ff79dc6..acbaebcad3a8 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -330,7 +330,7 @@ int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
330static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir, 330static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir,
331 u64 fsblock, int hindex) 331 u64 fsblock, int hindex)
332{ 332{
333 struct inode *dir = filp->f_dentry->d_inode; 333 struct inode *dir = file_inode(filp);
334 struct buffer_head *bh; 334 struct buffer_head *bh;
335 struct omfs_inode *oi; 335 struct omfs_inode *oi;
336 u64 self; 336 u64 self;
@@ -405,7 +405,7 @@ out:
405 405
406static int omfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 406static int omfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
407{ 407{
408 struct inode *dir = filp->f_dentry->d_inode; 408 struct inode *dir = file_inode(filp);
409 struct buffer_head *bh; 409 struct buffer_head *bh;
410 loff_t offset, res; 410 loff_t offset, res;
411 unsigned int hchain, hindex; 411 unsigned int hchain, hindex;
diff --git a/fs/open.c b/fs/open.c
index 9b33c0cbfacf..62f907e3bc36 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -228,7 +228,7 @@ SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64);
228 228
229int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 229int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
230{ 230{
231 struct inode *inode = file->f_path.dentry->d_inode; 231 struct inode *inode = file_inode(file);
232 long ret; 232 long ret;
233 233
234 if (offset < 0 || len <= 0) 234 if (offset < 0 || len <= 0)
@@ -426,7 +426,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
426 if (!f.file) 426 if (!f.file)
427 goto out; 427 goto out;
428 428
429 inode = f.file->f_path.dentry->d_inode; 429 inode = file_inode(f.file);
430 430
431 error = -ENOTDIR; 431 error = -ENOTDIR;
432 if (!S_ISDIR(inode->i_mode)) 432 if (!S_ISDIR(inode->i_mode))
@@ -689,7 +689,7 @@ static int do_dentry_open(struct file *f,
689 f->f_mode = FMODE_PATH; 689 f->f_mode = FMODE_PATH;
690 690
691 path_get(&f->f_path); 691 path_get(&f->f_path);
692 inode = f->f_path.dentry->d_inode; 692 inode = file_inode(f);
693 if (f->f_mode & FMODE_WRITE) { 693 if (f->f_mode & FMODE_WRITE) {
694 error = __get_file_write_access(inode, f->f_path.mnt); 694 error = __get_file_write_access(inode, f->f_path.mnt);
695 if (error) 695 if (error)
@@ -699,7 +699,6 @@ static int do_dentry_open(struct file *f,
699 } 699 }
700 700
701 f->f_mapping = inode->i_mapping; 701 f->f_mapping = inode->i_mapping;
702 f->f_pos = 0;
703 file_sb_list_add(f, inode->i_sb); 702 file_sb_list_add(f, inode->i_sb);
704 703
705 if (unlikely(f->f_mode & FMODE_PATH)) { 704 if (unlikely(f->f_mode & FMODE_PATH)) {
@@ -810,23 +809,22 @@ struct file *dentry_open(const struct path *path, int flags,
810 /* We must always pass in a valid mount pointer. */ 809 /* We must always pass in a valid mount pointer. */
811 BUG_ON(!path->mnt); 810 BUG_ON(!path->mnt);
812 811
813 error = -ENFILE;
814 f = get_empty_filp(); 812 f = get_empty_filp();
815 if (f == NULL) 813 if (!IS_ERR(f)) {
816 return ERR_PTR(error); 814 f->f_flags = flags;
817 815 f->f_path = *path;
818 f->f_flags = flags; 816 error = do_dentry_open(f, NULL, cred);
819 f->f_path = *path; 817 if (!error) {
820 error = do_dentry_open(f, NULL, cred); 818 /* from now on we need fput() to dispose of f */
821 if (!error) { 819 error = open_check_o_direct(f);
822 error = open_check_o_direct(f); 820 if (error) {
823 if (error) { 821 fput(f);
824 fput(f); 822 f = ERR_PTR(error);
823 }
824 } else {
825 put_filp(f);
825 f = ERR_PTR(error); 826 f = ERR_PTR(error);
826 } 827 }
827 } else {
828 put_filp(f);
829 f = ERR_PTR(error);
830 } 828 }
831 return f; 829 return f;
832} 830}
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 2ad080faca34..ae47fa7efb9d 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -262,7 +262,7 @@ found:
262 262
263static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filldir) 263static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
264{ 264{
265 struct inode *inode = filp->f_path.dentry->d_inode; 265 struct inode *inode = file_inode(filp);
266 struct op_inode_info *oi = OP_I(inode); 266 struct op_inode_info *oi = OP_I(inode);
267 struct device_node *dp = oi->u.node; 267 struct device_node *dp = oi->u.node;
268 struct device_node *child; 268 struct device_node *child;
diff --git a/fs/pipe.c b/fs/pipe.c
index bd3479db4b62..64a494cef0a0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -361,7 +361,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
361 unsigned long nr_segs, loff_t pos) 361 unsigned long nr_segs, loff_t pos)
362{ 362{
363 struct file *filp = iocb->ki_filp; 363 struct file *filp = iocb->ki_filp;
364 struct inode *inode = filp->f_path.dentry->d_inode; 364 struct inode *inode = file_inode(filp);
365 struct pipe_inode_info *pipe; 365 struct pipe_inode_info *pipe;
366 int do_wakeup; 366 int do_wakeup;
367 ssize_t ret; 367 ssize_t ret;
@@ -486,7 +486,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
486 unsigned long nr_segs, loff_t ppos) 486 unsigned long nr_segs, loff_t ppos)
487{ 487{
488 struct file *filp = iocb->ki_filp; 488 struct file *filp = iocb->ki_filp;
489 struct inode *inode = filp->f_path.dentry->d_inode; 489 struct inode *inode = file_inode(filp);
490 struct pipe_inode_info *pipe; 490 struct pipe_inode_info *pipe;
491 ssize_t ret; 491 ssize_t ret;
492 int do_wakeup; 492 int do_wakeup;
@@ -677,7 +677,7 @@ bad_pipe_w(struct file *filp, const char __user *buf, size_t count,
677 677
678static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 678static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
679{ 679{
680 struct inode *inode = filp->f_path.dentry->d_inode; 680 struct inode *inode = file_inode(filp);
681 struct pipe_inode_info *pipe; 681 struct pipe_inode_info *pipe;
682 int count, buf, nrbufs; 682 int count, buf, nrbufs;
683 683
@@ -705,7 +705,7 @@ static unsigned int
705pipe_poll(struct file *filp, poll_table *wait) 705pipe_poll(struct file *filp, poll_table *wait)
706{ 706{
707 unsigned int mask; 707 unsigned int mask;
708 struct inode *inode = filp->f_path.dentry->d_inode; 708 struct inode *inode = file_inode(filp);
709 struct pipe_inode_info *pipe = inode->i_pipe; 709 struct pipe_inode_info *pipe = inode->i_pipe;
710 int nrbufs; 710 int nrbufs;
711 711
@@ -758,7 +758,7 @@ pipe_release(struct inode *inode, int decr, int decw)
758static int 758static int
759pipe_read_fasync(int fd, struct file *filp, int on) 759pipe_read_fasync(int fd, struct file *filp, int on)
760{ 760{
761 struct inode *inode = filp->f_path.dentry->d_inode; 761 struct inode *inode = file_inode(filp);
762 int retval; 762 int retval;
763 763
764 mutex_lock(&inode->i_mutex); 764 mutex_lock(&inode->i_mutex);
@@ -772,7 +772,7 @@ pipe_read_fasync(int fd, struct file *filp, int on)
772static int 772static int
773pipe_write_fasync(int fd, struct file *filp, int on) 773pipe_write_fasync(int fd, struct file *filp, int on)
774{ 774{
775 struct inode *inode = filp->f_path.dentry->d_inode; 775 struct inode *inode = file_inode(filp);
776 int retval; 776 int retval;
777 777
778 mutex_lock(&inode->i_mutex); 778 mutex_lock(&inode->i_mutex);
@@ -786,7 +786,7 @@ pipe_write_fasync(int fd, struct file *filp, int on)
786static int 786static int
787pipe_rdwr_fasync(int fd, struct file *filp, int on) 787pipe_rdwr_fasync(int fd, struct file *filp, int on)
788{ 788{
789 struct inode *inode = filp->f_path.dentry->d_inode; 789 struct inode *inode = file_inode(filp);
790 struct pipe_inode_info *pipe = inode->i_pipe; 790 struct pipe_inode_info *pipe = inode->i_pipe;
791 int retval; 791 int retval;
792 792
@@ -1037,13 +1037,13 @@ int create_pipe_files(struct file **res, int flags)
1037 1037
1038 err = -ENFILE; 1038 err = -ENFILE;
1039 f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); 1039 f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops);
1040 if (!f) 1040 if (IS_ERR(f))
1041 goto err_dentry; 1041 goto err_dentry;
1042 1042
1043 f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)); 1043 f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
1044 1044
1045 res[0] = alloc_file(&path, FMODE_READ, &read_pipefifo_fops); 1045 res[0] = alloc_file(&path, FMODE_READ, &read_pipefifo_fops);
1046 if (!res[0]) 1046 if (IS_ERR(res[0]))
1047 goto err_file; 1047 goto err_file;
1048 1048
1049 path_get(&path); 1049 path_get(&path);
@@ -1226,7 +1226,7 @@ int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf,
1226 */ 1226 */
1227struct pipe_inode_info *get_pipe_info(struct file *file) 1227struct pipe_inode_info *get_pipe_info(struct file *file)
1228{ 1228{
1229 struct inode *i = file->f_path.dentry->d_inode; 1229 struct inode *i = file_inode(file);
1230 1230
1231 return S_ISFIFO(i->i_mode) ? i->i_pipe : NULL; 1231 return S_ISFIFO(i->i_mode) ? i->i_pipe : NULL;
1232} 1232}
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9b43ff77a51e..f3b133d79914 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -383,7 +383,7 @@ static int lstats_open(struct inode *inode, struct file *file)
383static ssize_t lstats_write(struct file *file, const char __user *buf, 383static ssize_t lstats_write(struct file *file, const char __user *buf,
384 size_t count, loff_t *offs) 384 size_t count, loff_t *offs)
385{ 385{
386 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 386 struct task_struct *task = get_proc_task(file_inode(file));
387 387
388 if (!task) 388 if (!task)
389 return -ESRCH; 389 return -ESRCH;
@@ -602,7 +602,7 @@ static const struct inode_operations proc_def_inode_operations = {
602static ssize_t proc_info_read(struct file * file, char __user * buf, 602static ssize_t proc_info_read(struct file * file, char __user * buf,
603 size_t count, loff_t *ppos) 603 size_t count, loff_t *ppos)
604{ 604{
605 struct inode * inode = file->f_path.dentry->d_inode; 605 struct inode * inode = file_inode(file);
606 unsigned long page; 606 unsigned long page;
607 ssize_t length; 607 ssize_t length;
608 struct task_struct *task = get_proc_task(inode); 608 struct task_struct *task = get_proc_task(inode);
@@ -668,7 +668,7 @@ static const struct file_operations proc_single_file_operations = {
668 668
669static int __mem_open(struct inode *inode, struct file *file, unsigned int mode) 669static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
670{ 670{
671 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 671 struct task_struct *task = get_proc_task(file_inode(file));
672 struct mm_struct *mm; 672 struct mm_struct *mm;
673 673
674 if (!task) 674 if (!task)
@@ -869,7 +869,7 @@ static const struct file_operations proc_environ_operations = {
869static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, 869static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
870 loff_t *ppos) 870 loff_t *ppos)
871{ 871{
872 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 872 struct task_struct *task = get_proc_task(file_inode(file));
873 char buffer[PROC_NUMBUF]; 873 char buffer[PROC_NUMBUF];
874 int oom_adj = OOM_ADJUST_MIN; 874 int oom_adj = OOM_ADJUST_MIN;
875 size_t len; 875 size_t len;
@@ -916,7 +916,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
916 goto out; 916 goto out;
917 } 917 }
918 918
919 task = get_proc_task(file->f_path.dentry->d_inode); 919 task = get_proc_task(file_inode(file));
920 if (!task) { 920 if (!task) {
921 err = -ESRCH; 921 err = -ESRCH;
922 goto out; 922 goto out;
@@ -976,7 +976,7 @@ static const struct file_operations proc_oom_adj_operations = {
976static ssize_t oom_score_adj_read(struct file *file, char __user *buf, 976static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
977 size_t count, loff_t *ppos) 977 size_t count, loff_t *ppos)
978{ 978{
979 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 979 struct task_struct *task = get_proc_task(file_inode(file));
980 char buffer[PROC_NUMBUF]; 980 char buffer[PROC_NUMBUF];
981 short oom_score_adj = OOM_SCORE_ADJ_MIN; 981 short oom_score_adj = OOM_SCORE_ADJ_MIN;
982 unsigned long flags; 982 unsigned long flags;
@@ -1019,7 +1019,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1019 goto out; 1019 goto out;
1020 } 1020 }
1021 1021
1022 task = get_proc_task(file->f_path.dentry->d_inode); 1022 task = get_proc_task(file_inode(file));
1023 if (!task) { 1023 if (!task) {
1024 err = -ESRCH; 1024 err = -ESRCH;
1025 goto out; 1025 goto out;
@@ -1067,7 +1067,7 @@ static const struct file_operations proc_oom_score_adj_operations = {
1067static ssize_t proc_loginuid_read(struct file * file, char __user * buf, 1067static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
1068 size_t count, loff_t *ppos) 1068 size_t count, loff_t *ppos)
1069{ 1069{
1070 struct inode * inode = file->f_path.dentry->d_inode; 1070 struct inode * inode = file_inode(file);
1071 struct task_struct *task = get_proc_task(inode); 1071 struct task_struct *task = get_proc_task(inode);
1072 ssize_t length; 1072 ssize_t length;
1073 char tmpbuf[TMPBUFLEN]; 1073 char tmpbuf[TMPBUFLEN];
@@ -1084,7 +1084,7 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
1084static ssize_t proc_loginuid_write(struct file * file, const char __user * buf, 1084static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
1085 size_t count, loff_t *ppos) 1085 size_t count, loff_t *ppos)
1086{ 1086{
1087 struct inode * inode = file->f_path.dentry->d_inode; 1087 struct inode * inode = file_inode(file);
1088 char *page, *tmp; 1088 char *page, *tmp;
1089 ssize_t length; 1089 ssize_t length;
1090 uid_t loginuid; 1090 uid_t loginuid;
@@ -1142,7 +1142,7 @@ static const struct file_operations proc_loginuid_operations = {
1142static ssize_t proc_sessionid_read(struct file * file, char __user * buf, 1142static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
1143 size_t count, loff_t *ppos) 1143 size_t count, loff_t *ppos)
1144{ 1144{
1145 struct inode * inode = file->f_path.dentry->d_inode; 1145 struct inode * inode = file_inode(file);
1146 struct task_struct *task = get_proc_task(inode); 1146 struct task_struct *task = get_proc_task(inode);
1147 ssize_t length; 1147 ssize_t length;
1148 char tmpbuf[TMPBUFLEN]; 1148 char tmpbuf[TMPBUFLEN];
@@ -1165,7 +1165,7 @@ static const struct file_operations proc_sessionid_operations = {
1165static ssize_t proc_fault_inject_read(struct file * file, char __user * buf, 1165static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
1166 size_t count, loff_t *ppos) 1166 size_t count, loff_t *ppos)
1167{ 1167{
1168 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 1168 struct task_struct *task = get_proc_task(file_inode(file));
1169 char buffer[PROC_NUMBUF]; 1169 char buffer[PROC_NUMBUF];
1170 size_t len; 1170 size_t len;
1171 int make_it_fail; 1171 int make_it_fail;
@@ -1197,7 +1197,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
1197 make_it_fail = simple_strtol(strstrip(buffer), &end, 0); 1197 make_it_fail = simple_strtol(strstrip(buffer), &end, 0);
1198 if (*end) 1198 if (*end)
1199 return -EINVAL; 1199 return -EINVAL;
1200 task = get_proc_task(file->f_dentry->d_inode); 1200 task = get_proc_task(file_inode(file));
1201 if (!task) 1201 if (!task)
1202 return -ESRCH; 1202 return -ESRCH;
1203 task->make_it_fail = make_it_fail; 1203 task->make_it_fail = make_it_fail;
@@ -1237,7 +1237,7 @@ static ssize_t
1237sched_write(struct file *file, const char __user *buf, 1237sched_write(struct file *file, const char __user *buf,
1238 size_t count, loff_t *offset) 1238 size_t count, loff_t *offset)
1239{ 1239{
1240 struct inode *inode = file->f_path.dentry->d_inode; 1240 struct inode *inode = file_inode(file);
1241 struct task_struct *p; 1241 struct task_struct *p;
1242 1242
1243 p = get_proc_task(inode); 1243 p = get_proc_task(inode);
@@ -1288,7 +1288,7 @@ static ssize_t
1288sched_autogroup_write(struct file *file, const char __user *buf, 1288sched_autogroup_write(struct file *file, const char __user *buf,
1289 size_t count, loff_t *offset) 1289 size_t count, loff_t *offset)
1290{ 1290{
1291 struct inode *inode = file->f_path.dentry->d_inode; 1291 struct inode *inode = file_inode(file);
1292 struct task_struct *p; 1292 struct task_struct *p;
1293 char buffer[PROC_NUMBUF]; 1293 char buffer[PROC_NUMBUF];
1294 int nice; 1294 int nice;
@@ -1343,7 +1343,7 @@ static const struct file_operations proc_pid_sched_autogroup_operations = {
1343static ssize_t comm_write(struct file *file, const char __user *buf, 1343static ssize_t comm_write(struct file *file, const char __user *buf,
1344 size_t count, loff_t *offset) 1344 size_t count, loff_t *offset)
1345{ 1345{
1346 struct inode *inode = file->f_path.dentry->d_inode; 1346 struct inode *inode = file_inode(file);
1347 struct task_struct *p; 1347 struct task_struct *p;
1348 char buffer[TASK_COMM_LEN]; 1348 char buffer[TASK_COMM_LEN];
1349 1349
@@ -1711,7 +1711,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)
1711 return -ECHILD; 1711 return -ECHILD;
1712 1712
1713 if (!capable(CAP_SYS_ADMIN)) { 1713 if (!capable(CAP_SYS_ADMIN)) {
1714 status = -EACCES; 1714 status = -EPERM;
1715 goto out_notask; 1715 goto out_notask;
1716 } 1716 }
1717 1717
@@ -1844,7 +1844,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
1844 struct dentry *result; 1844 struct dentry *result;
1845 struct mm_struct *mm; 1845 struct mm_struct *mm;
1846 1846
1847 result = ERR_PTR(-EACCES); 1847 result = ERR_PTR(-EPERM);
1848 if (!capable(CAP_SYS_ADMIN)) 1848 if (!capable(CAP_SYS_ADMIN))
1849 goto out; 1849 goto out;
1850 1850
@@ -1900,7 +1900,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
1900 ino_t ino; 1900 ino_t ino;
1901 int ret; 1901 int ret;
1902 1902
1903 ret = -EACCES; 1903 ret = -EPERM;
1904 if (!capable(CAP_SYS_ADMIN)) 1904 if (!capable(CAP_SYS_ADMIN))
1905 goto out; 1905 goto out;
1906 1906
@@ -2146,7 +2146,7 @@ out_no_task:
2146static ssize_t proc_pid_attr_read(struct file * file, char __user * buf, 2146static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
2147 size_t count, loff_t *ppos) 2147 size_t count, loff_t *ppos)
2148{ 2148{
2149 struct inode * inode = file->f_path.dentry->d_inode; 2149 struct inode * inode = file_inode(file);
2150 char *p = NULL; 2150 char *p = NULL;
2151 ssize_t length; 2151 ssize_t length;
2152 struct task_struct *task = get_proc_task(inode); 2152 struct task_struct *task = get_proc_task(inode);
@@ -2167,7 +2167,7 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
2167static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, 2167static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
2168 size_t count, loff_t *ppos) 2168 size_t count, loff_t *ppos)
2169{ 2169{
2170 struct inode * inode = file->f_path.dentry->d_inode; 2170 struct inode * inode = file_inode(file);
2171 char *page; 2171 char *page;
2172 ssize_t length; 2172 ssize_t length;
2173 struct task_struct *task = get_proc_task(inode); 2173 struct task_struct *task = get_proc_task(inode);
@@ -2256,7 +2256,7 @@ static const struct inode_operations proc_attr_dir_inode_operations = {
2256static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf, 2256static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
2257 size_t count, loff_t *ppos) 2257 size_t count, loff_t *ppos)
2258{ 2258{
2259 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 2259 struct task_struct *task = get_proc_task(file_inode(file));
2260 struct mm_struct *mm; 2260 struct mm_struct *mm;
2261 char buffer[PROC_NUMBUF]; 2261 char buffer[PROC_NUMBUF];
2262 size_t len; 2262 size_t len;
@@ -2308,7 +2308,7 @@ static ssize_t proc_coredump_filter_write(struct file *file,
2308 goto out_no_task; 2308 goto out_no_task;
2309 2309
2310 ret = -ESRCH; 2310 ret = -ESRCH;
2311 task = get_proc_task(file->f_dentry->d_inode); 2311 task = get_proc_task(file_inode(file));
2312 if (!task) 2312 if (!task)
2313 goto out_no_task; 2313 goto out_no_task;
2314 2314
@@ -2618,6 +2618,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
2618 2618
2619 name.name = buf; 2619 name.name = buf;
2620 name.len = snprintf(buf, sizeof(buf), "%d", pid); 2620 name.len = snprintf(buf, sizeof(buf), "%d", pid);
2621 /* no ->d_hash() rejects on procfs */
2621 dentry = d_hash_and_lookup(mnt->mnt_root, &name); 2622 dentry = d_hash_and_lookup(mnt->mnt_root, &name);
2622 if (dentry) { 2623 if (dentry) {
2623 shrink_dcache_parent(dentry); 2624 shrink_dcache_parent(dentry);
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 76ddae83daa5..2983dc52ca25 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -42,7 +42,7 @@ static ssize_t
42__proc_file_read(struct file *file, char __user *buf, size_t nbytes, 42__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
43 loff_t *ppos) 43 loff_t *ppos)
44{ 44{
45 struct inode * inode = file->f_path.dentry->d_inode; 45 struct inode * inode = file_inode(file);
46 char *page; 46 char *page;
47 ssize_t retval=0; 47 ssize_t retval=0;
48 int eof=0; 48 int eof=0;
@@ -188,7 +188,7 @@ static ssize_t
188proc_file_read(struct file *file, char __user *buf, size_t nbytes, 188proc_file_read(struct file *file, char __user *buf, size_t nbytes,
189 loff_t *ppos) 189 loff_t *ppos)
190{ 190{
191 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 191 struct proc_dir_entry *pde = PDE(file_inode(file));
192 ssize_t rv = -EIO; 192 ssize_t rv = -EIO;
193 193
194 spin_lock(&pde->pde_unload_lock); 194 spin_lock(&pde->pde_unload_lock);
@@ -209,7 +209,7 @@ static ssize_t
209proc_file_write(struct file *file, const char __user *buffer, 209proc_file_write(struct file *file, const char __user *buffer,
210 size_t count, loff_t *ppos) 210 size_t count, loff_t *ppos)
211{ 211{
212 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 212 struct proc_dir_entry *pde = PDE(file_inode(file));
213 ssize_t rv = -EIO; 213 ssize_t rv = -EIO;
214 214
215 if (pde->write_proc) { 215 if (pde->write_proc) {
@@ -412,8 +412,7 @@ static const struct dentry_operations proc_dentry_operations =
412struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, 412struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
413 struct dentry *dentry) 413 struct dentry *dentry)
414{ 414{
415 struct inode *inode = NULL; 415 struct inode *inode;
416 int error = -ENOENT;
417 416
418 spin_lock(&proc_subdir_lock); 417 spin_lock(&proc_subdir_lock);
419 for (de = de->subdir; de ; de = de->next) { 418 for (de = de->subdir; de ; de = de->next) {
@@ -422,22 +421,16 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
422 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { 421 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
423 pde_get(de); 422 pde_get(de);
424 spin_unlock(&proc_subdir_lock); 423 spin_unlock(&proc_subdir_lock);
425 error = -ENOMEM;
426 inode = proc_get_inode(dir->i_sb, de); 424 inode = proc_get_inode(dir->i_sb, de);
427 goto out_unlock; 425 if (!inode)
426 return ERR_PTR(-ENOMEM);
427 d_set_d_op(dentry, &proc_dentry_operations);
428 d_add(dentry, inode);
429 return NULL;
428 } 430 }
429 } 431 }
430 spin_unlock(&proc_subdir_lock); 432 spin_unlock(&proc_subdir_lock);
431out_unlock: 433 return ERR_PTR(-ENOENT);
432
433 if (inode) {
434 d_set_d_op(dentry, &proc_dentry_operations);
435 d_add(dentry, inode);
436 return NULL;
437 }
438 if (de)
439 pde_put(de);
440 return ERR_PTR(error);
441} 434}
442 435
443struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry, 436struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
@@ -460,7 +453,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
460{ 453{
461 unsigned int ino; 454 unsigned int ino;
462 int i; 455 int i;
463 struct inode *inode = filp->f_path.dentry->d_inode; 456 struct inode *inode = file_inode(filp);
464 int ret = 0; 457 int ret = 0;
465 458
466 ino = inode->i_ino; 459 ino = inode->i_ino;
@@ -522,7 +515,7 @@ out:
522 515
523int proc_readdir(struct file *filp, void *dirent, filldir_t filldir) 516int proc_readdir(struct file *filp, void *dirent, filldir_t filldir)
524{ 517{
525 struct inode *inode = filp->f_path.dentry->d_inode; 518 struct inode *inode = file_inode(filp);
526 519
527 return proc_readdir_de(PDE(inode), filp, dirent, filldir); 520 return proc_readdir_de(PDE(inode), filp, dirent, filldir);
528} 521}
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 439ae6886507..70322e1a4f0f 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -144,7 +144,7 @@ void pde_users_dec(struct proc_dir_entry *pde)
144 144
145static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) 145static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
146{ 146{
147 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 147 struct proc_dir_entry *pde = PDE(file_inode(file));
148 loff_t rv = -EINVAL; 148 loff_t rv = -EINVAL;
149 loff_t (*llseek)(struct file *, loff_t, int); 149 loff_t (*llseek)(struct file *, loff_t, int);
150 150
@@ -179,7 +179,7 @@ static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
179 179
180static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 180static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
181{ 181{
182 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 182 struct proc_dir_entry *pde = PDE(file_inode(file));
183 ssize_t rv = -EIO; 183 ssize_t rv = -EIO;
184 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); 184 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
185 185
@@ -201,7 +201,7 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count,
201 201
202static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 202static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
203{ 203{
204 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 204 struct proc_dir_entry *pde = PDE(file_inode(file));
205 ssize_t rv = -EIO; 205 ssize_t rv = -EIO;
206 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 206 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
207 207
@@ -223,7 +223,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t
223 223
224static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) 224static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts)
225{ 225{
226 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 226 struct proc_dir_entry *pde = PDE(file_inode(file));
227 unsigned int rv = DEFAULT_POLLMASK; 227 unsigned int rv = DEFAULT_POLLMASK;
228 unsigned int (*poll)(struct file *, struct poll_table_struct *); 228 unsigned int (*poll)(struct file *, struct poll_table_struct *);
229 229
@@ -245,7 +245,7 @@ static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *p
245 245
246static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 246static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
247{ 247{
248 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 248 struct proc_dir_entry *pde = PDE(file_inode(file));
249 long rv = -ENOTTY; 249 long rv = -ENOTTY;
250 long (*ioctl)(struct file *, unsigned int, unsigned long); 250 long (*ioctl)(struct file *, unsigned int, unsigned long);
251 251
@@ -268,7 +268,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
268#ifdef CONFIG_COMPAT 268#ifdef CONFIG_COMPAT
269static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 269static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
270{ 270{
271 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 271 struct proc_dir_entry *pde = PDE(file_inode(file));
272 long rv = -ENOTTY; 272 long rv = -ENOTTY;
273 long (*compat_ioctl)(struct file *, unsigned int, unsigned long); 273 long (*compat_ioctl)(struct file *, unsigned int, unsigned long);
274 274
@@ -291,7 +291,7 @@ static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned
291 291
292static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) 292static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma)
293{ 293{
294 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 294 struct proc_dir_entry *pde = PDE(file_inode(file));
295 int rv = -EIO; 295 int rv = -EIO;
296 int (*mmap)(struct file *, struct vm_area_struct *); 296 int (*mmap)(struct file *, struct vm_area_struct *);
297 297
@@ -445,12 +445,9 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
445 445
446struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) 446struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
447{ 447{
448 struct inode * inode; 448 struct inode *inode = iget_locked(sb, de->low_ino);
449 449
450 inode = iget_locked(sb, de->low_ino); 450 if (inode && (inode->i_state & I_NEW)) {
451 if (!inode)
452 return NULL;
453 if (inode->i_state & I_NEW) {
454 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 451 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
455 PROC_I(inode)->pde = de; 452 PROC_I(inode)->pde = de;
456 453
@@ -482,10 +479,12 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
482 } else 479 } else
483 pde_put(de); 480 pde_put(de);
484 return inode; 481 return inode;
485} 482}
486 483
487int proc_fill_super(struct super_block *s) 484int proc_fill_super(struct super_block *s)
488{ 485{
486 struct inode *root_inode;
487
489 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC; 488 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC;
490 s->s_blocksize = 1024; 489 s->s_blocksize = 1024;
491 s->s_blocksize_bits = 10; 490 s->s_blocksize_bits = 10;
@@ -494,11 +493,17 @@ int proc_fill_super(struct super_block *s)
494 s->s_time_gran = 1; 493 s->s_time_gran = 1;
495 494
496 pde_get(&proc_root); 495 pde_get(&proc_root);
497 s->s_root = d_make_root(proc_get_inode(s, &proc_root)); 496 root_inode = proc_get_inode(s, &proc_root);
498 if (s->s_root) 497 if (!root_inode) {
499 return 0; 498 printk(KERN_ERR "proc_fill_super: get root inode failed\n");
499 return -ENOMEM;
500 }
500 501
501 printk("proc_read_super: get root inode failed\n"); 502 s->s_root = d_make_root(root_inode);
502 pde_put(&proc_root); 503 if (!s->s_root) {
503 return -ENOMEM; 504 printk(KERN_ERR "proc_fill_super: allocate dentry failed\n");
505 return -ENOMEM;
506 }
507
508 return 0;
504} 509}
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dde55c2..ccfd99bd1c5a 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -45,7 +45,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
45 file = region->vm_file; 45 file = region->vm_file;
46 46
47 if (file) { 47 if (file) {
48 struct inode *inode = region->vm_file->f_path.dentry->d_inode; 48 struct inode *inode = file_inode(region->vm_file);
49 dev = inode->i_sb->s_dev; 49 dev = inode->i_sb->s_dev;
50 ino = inode->i_ino; 50 ino = inode->i_ino;
51 } 51 }
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 3131a03d7d37..b4ac6572474f 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -163,7 +163,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent,
163 struct net *net; 163 struct net *net;
164 164
165 ret = -EINVAL; 165 ret = -EINVAL;
166 net = get_proc_task_net(filp->f_path.dentry->d_inode); 166 net = get_proc_task_net(file_inode(filp));
167 if (net != NULL) { 167 if (net != NULL) {
168 ret = proc_readdir_de(net->proc_net, filp, dirent, filldir); 168 ret = proc_readdir_de(net->proc_net, filp, dirent, filldir);
169 put_net(net); 169 put_net(net);
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 1827d88ad58b..612df79cc6a1 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -478,7 +478,7 @@ out:
478static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, 478static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
479 size_t count, loff_t *ppos, int write) 479 size_t count, loff_t *ppos, int write)
480{ 480{
481 struct inode *inode = filp->f_path.dentry->d_inode; 481 struct inode *inode = file_inode(filp);
482 struct ctl_table_header *head = grab_header(inode); 482 struct ctl_table_header *head = grab_header(inode);
483 struct ctl_table *table = PROC_I(inode)->sysctl_entry; 483 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
484 ssize_t error; 484 ssize_t error;
@@ -542,7 +542,7 @@ static int proc_sys_open(struct inode *inode, struct file *filp)
542 542
543static unsigned int proc_sys_poll(struct file *filp, poll_table *wait) 543static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
544{ 544{
545 struct inode *inode = filp->f_path.dentry->d_inode; 545 struct inode *inode = file_inode(filp);
546 struct ctl_table_header *head = grab_header(inode); 546 struct ctl_table_header *head = grab_header(inode);
547 struct ctl_table *table = PROC_I(inode)->sysctl_entry; 547 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
548 unsigned int ret = DEFAULT_POLLMASK; 548 unsigned int ret = DEFAULT_POLLMASK;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index ca5ce7f9f800..3e636d864d56 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -271,7 +271,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
271 const char *name = NULL; 271 const char *name = NULL;
272 272
273 if (file) { 273 if (file) {
274 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 274 struct inode *inode = file_inode(vma->vm_file);
275 dev = inode->i_sb->s_dev; 275 dev = inode->i_sb->s_dev;
276 ino = inode->i_ino; 276 ino = inode->i_ino;
277 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; 277 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
@@ -743,7 +743,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
743 return rv; 743 return rv;
744 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED) 744 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
745 return -EINVAL; 745 return -EINVAL;
746 task = get_proc_task(file->f_path.dentry->d_inode); 746 task = get_proc_task(file_inode(file));
747 if (!task) 747 if (!task)
748 return -ESRCH; 748 return -ESRCH;
749 mm = get_task_mm(task); 749 mm = get_task_mm(task);
@@ -1015,7 +1015,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
1015static ssize_t pagemap_read(struct file *file, char __user *buf, 1015static ssize_t pagemap_read(struct file *file, char __user *buf,
1016 size_t count, loff_t *ppos) 1016 size_t count, loff_t *ppos)
1017{ 1017{
1018 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 1018 struct task_struct *task = get_proc_task(file_inode(file));
1019 struct mm_struct *mm; 1019 struct mm_struct *mm;
1020 struct pagemapread pm; 1020 struct pagemapread pm;
1021 int ret = -ESRCH; 1021 int ret = -ESRCH;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 1ccfa537f5f5..56123a6f462e 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -149,7 +149,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
149 file = vma->vm_file; 149 file = vma->vm_file;
150 150
151 if (file) { 151 if (file) {
152 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 152 struct inode *inode = file_inode(vma->vm_file);
153 dev = inode->i_sb->s_dev; 153 dev = inode->i_sb->s_dev;
154 ino = inode->i_ino; 154 ino = inode->i_ino;
155 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; 155 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
index 7b0329468a5d..28ce014b3cef 100644
--- a/fs/qnx4/dir.c
+++ b/fs/qnx4/dir.c
@@ -16,7 +16,7 @@
16 16
17static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir) 17static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
18{ 18{
19 struct inode *inode = filp->f_path.dentry->d_inode; 19 struct inode *inode = file_inode(filp);
20 unsigned int offset; 20 unsigned int offset;
21 struct buffer_head *bh; 21 struct buffer_head *bh;
22 struct qnx4_inode_entry *de; 22 struct qnx4_inode_entry *de;
diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c
index dc597353db3b..8798d065e400 100644
--- a/fs/qnx6/dir.c
+++ b/fs/qnx6/dir.c
@@ -117,7 +117,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
117 117
118static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) 118static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir)
119{ 119{
120 struct inode *inode = filp->f_path.dentry->d_inode; 120 struct inode *inode = file_inode(filp);
121 struct super_block *s = inode->i_sb; 121 struct super_block *s = inode->i_sb;
122 struct qnx6_sb_info *sbi = QNX6_SB(s); 122 struct qnx6_sb_info *sbi = QNX6_SB(s);
123 loff_t pos = filp->f_pos & (QNX6_DIR_ENTRY_SIZE - 1); 123 loff_t pos = filp->f_pos & (QNX6_DIR_ENTRY_SIZE - 1);
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index d5378d028589..8d5b438cc188 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -202,7 +202,7 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
202 unsigned long pgoff, unsigned long flags) 202 unsigned long pgoff, unsigned long flags)
203{ 203{
204 unsigned long maxpages, lpages, nr, loop, ret; 204 unsigned long maxpages, lpages, nr, loop, ret;
205 struct inode *inode = file->f_path.dentry->d_inode; 205 struct inode *inode = file_inode(file);
206 struct page **pages = NULL, **ptr, *page; 206 struct page **pages = NULL, **ptr, *page;
207 loff_t isize; 207 loff_t isize;
208 208
diff --git a/fs/read_write.c b/fs/read_write.c
index bb34af315280..3ae6dbe828bf 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -163,7 +163,7 @@ EXPORT_SYMBOL(no_llseek);
163 163
164loff_t default_llseek(struct file *file, loff_t offset, int whence) 164loff_t default_llseek(struct file *file, loff_t offset, int whence)
165{ 165{
166 struct inode *inode = file->f_path.dentry->d_inode; 166 struct inode *inode = file_inode(file);
167 loff_t retval; 167 loff_t retval;
168 168
169 mutex_lock(&inode->i_mutex); 169 mutex_lock(&inode->i_mutex);
@@ -290,7 +290,7 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count
290 loff_t pos; 290 loff_t pos;
291 int retval = -EINVAL; 291 int retval = -EINVAL;
292 292
293 inode = file->f_path.dentry->d_inode; 293 inode = file_inode(file);
294 if (unlikely((ssize_t) count < 0)) 294 if (unlikely((ssize_t) count < 0))
295 return retval; 295 return retval;
296 pos = *ppos; 296 pos = *ppos;
@@ -901,8 +901,8 @@ ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count,
901 if (!(out.file->f_mode & FMODE_WRITE)) 901 if (!(out.file->f_mode & FMODE_WRITE))
902 goto fput_out; 902 goto fput_out;
903 retval = -EINVAL; 903 retval = -EINVAL;
904 in_inode = in.file->f_path.dentry->d_inode; 904 in_inode = file_inode(in.file);
905 out_inode = out.file->f_path.dentry->d_inode; 905 out_inode = file_inode(out.file);
906 retval = rw_verify_area(WRITE, out.file, &out.file->f_pos, count); 906 retval = rw_verify_area(WRITE, out.file, &out.file->f_pos, count);
907 if (retval < 0) 907 if (retval < 0)
908 goto fput_out; 908 goto fput_out;
diff --git a/fs/readdir.c b/fs/readdir.c
index 5e69ef533b77..fee38e04fae4 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -22,7 +22,7 @@
22 22
23int vfs_readdir(struct file *file, filldir_t filler, void *buf) 23int vfs_readdir(struct file *file, filldir_t filler, void *buf)
24{ 24{
25 struct inode *inode = file->f_path.dentry->d_inode; 25 struct inode *inode = file_inode(file);
26 int res = -ENOTDIR; 26 int res = -ENOTDIR;
27 if (!file->f_op || !file->f_op->readdir) 27 if (!file->f_op || !file->f_op->readdir)
28 goto out; 28 goto out;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 50302d6f8895..6165bd4784f6 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -268,7 +268,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
268 * new current position before returning. */ 268 * new current position before returning. */
269 ) 269 )
270{ 270{
271 struct inode *inode = file->f_path.dentry->d_inode; // Inode of the file that we are writing to. 271 struct inode *inode = file_inode(file); // Inode of the file that we are writing to.
272 /* To simplify coding at this time, we store 272 /* To simplify coding at this time, we store
273 locked pages in array for now */ 273 locked pages in array for now */
274 struct reiserfs_transaction_handle th; 274 struct reiserfs_transaction_handle th;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 95d7680ead47..ea5061fd4f3e 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1603,10 +1603,10 @@ int reiserfs_encode_fh(struct inode *inode, __u32 * data, int *lenp,
1603 1603
1604 if (parent && (maxlen < 5)) { 1604 if (parent && (maxlen < 5)) {
1605 *lenp = 5; 1605 *lenp = 5;
1606 return 255; 1606 return FILEID_INVALID;
1607 } else if (maxlen < 3) { 1607 } else if (maxlen < 3) {
1608 *lenp = 3; 1608 *lenp = 3;
1609 return 255; 1609 return FILEID_INVALID;
1610 } 1610 }
1611 1611
1612 data[0] = inode->i_ino; 1612 data[0] = inode->i_ino;
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 0c2185042d5f..15cb5fe6b425 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -21,7 +21,7 @@
21 */ 21 */
22long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 22long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
23{ 23{
24 struct inode *inode = filp->f_path.dentry->d_inode; 24 struct inode *inode = file_inode(filp);
25 unsigned int flags; 25 unsigned int flags;
26 int err = 0; 26 int err = 0;
27 27
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index e60e87035bb3..9cc0740adffa 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -281,7 +281,7 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
281 } 281 }
282#if defined( REISERFS_USE_OIDMAPF ) 282#if defined( REISERFS_USE_OIDMAPF )
283 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) { 283 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
284 loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size; 284 loff_t size = file_inode(sb_info->oidmap.mapf)->i_size;
285 total_used += size / sizeof(reiserfs_oidinterval_d_t); 285 total_used += size / sizeof(reiserfs_oidinterval_d_t);
286 } 286 }
287#endif 287#endif
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index fd7c5f60b46b..7e8d3a80bdab 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -147,7 +147,7 @@ static const struct address_space_operations romfs_aops = {
147 */ 147 */
148static int romfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 148static int romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
149{ 149{
150 struct inode *i = filp->f_dentry->d_inode; 150 struct inode *i = file_inode(filp);
151 struct romfs_inode ri; 151 struct romfs_inode ri;
152 unsigned long offset, maxoff; 152 unsigned long offset, maxoff;
153 int j, ino, nextfh; 153 int j, ino, nextfh;
diff --git a/fs/splice.c b/fs/splice.c
index 6909d89d0da5..718bd0056384 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -569,7 +569,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
569 return res; 569 return res;
570} 570}
571 571
572static ssize_t kernel_write(struct file *file, const char *buf, size_t count, 572ssize_t kernel_write(struct file *file, const char *buf, size_t count,
573 loff_t pos) 573 loff_t pos)
574{ 574{
575 mm_segment_t old_fs; 575 mm_segment_t old_fs;
@@ -578,11 +578,12 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
578 old_fs = get_fs(); 578 old_fs = get_fs();
579 set_fs(get_ds()); 579 set_fs(get_ds());
580 /* The cast to a user pointer is valid due to the set_fs() */ 580 /* The cast to a user pointer is valid due to the set_fs() */
581 res = vfs_write(file, (const char __user *)buf, count, &pos); 581 res = vfs_write(file, (__force const char __user *)buf, count, &pos);
582 set_fs(old_fs); 582 set_fs(old_fs);
583 583
584 return res; 584 return res;
585} 585}
586EXPORT_SYMBOL(kernel_write);
586 587
587ssize_t default_file_splice_read(struct file *in, loff_t *ppos, 588ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
588 struct pipe_inode_info *pipe, size_t len, 589 struct pipe_inode_info *pipe, size_t len,
@@ -1170,7 +1171,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
1170 * randomly drop data for eg socket -> socket splicing. Use the 1171 * randomly drop data for eg socket -> socket splicing. Use the
1171 * piped splicing for that! 1172 * piped splicing for that!
1172 */ 1173 */
1173 i_mode = in->f_path.dentry->d_inode->i_mode; 1174 i_mode = file_inode(in)->i_mode;
1174 if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode))) 1175 if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
1175 return -EINVAL; 1176 return -EINVAL;
1176 1177
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c
index b381305c9a47..57dc70ebbb19 100644
--- a/fs/squashfs/dir.c
+++ b/fs/squashfs/dir.c
@@ -102,7 +102,7 @@ static int get_dir_index_using_offset(struct super_block *sb,
102 102
103static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir) 103static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
104{ 104{
105 struct inode *inode = file->f_dentry->d_inode; 105 struct inode *inode = file_inode(file);
106 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 106 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
107 u64 block = squashfs_i(inode)->start + msblk->directory_table; 107 u64 block = squashfs_i(inode)->start + msblk->directory_table;
108 int offset = squashfs_i(inode)->offset, length, dir_count, size, 108 int offset = squashfs_i(inode)->offset, length, dir_count, size,
diff --git a/fs/stat.c b/fs/stat.c
index 14f45459c83d..04ce1ac20d20 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -37,17 +37,17 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
37 37
38EXPORT_SYMBOL(generic_fillattr); 38EXPORT_SYMBOL(generic_fillattr);
39 39
40int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 40int vfs_getattr(struct path *path, struct kstat *stat)
41{ 41{
42 struct inode *inode = dentry->d_inode; 42 struct inode *inode = path->dentry->d_inode;
43 int retval; 43 int retval;
44 44
45 retval = security_inode_getattr(mnt, dentry); 45 retval = security_inode_getattr(path->mnt, path->dentry);
46 if (retval) 46 if (retval)
47 return retval; 47 return retval;
48 48
49 if (inode->i_op->getattr) 49 if (inode->i_op->getattr)
50 return inode->i_op->getattr(mnt, dentry, stat); 50 return inode->i_op->getattr(path->mnt, path->dentry, stat);
51 51
52 generic_fillattr(inode, stat); 52 generic_fillattr(inode, stat);
53 return 0; 53 return 0;
@@ -61,8 +61,7 @@ int vfs_fstat(unsigned int fd, struct kstat *stat)
61 int error = -EBADF; 61 int error = -EBADF;
62 62
63 if (f.file) { 63 if (f.file) {
64 error = vfs_getattr(f.file->f_path.mnt, f.file->f_path.dentry, 64 error = vfs_getattr(&f.file->f_path, stat);
65 stat);
66 fdput(f); 65 fdput(f);
67 } 66 }
68 return error; 67 return error;
@@ -89,7 +88,7 @@ retry:
89 if (error) 88 if (error)
90 goto out; 89 goto out;
91 90
92 error = vfs_getattr(path.mnt, path.dentry, stat); 91 error = vfs_getattr(&path, stat);
93 path_put(&path); 92 path_put(&path);
94 if (retry_estale(error, lookup_flags)) { 93 if (retry_estale(error, lookup_flags)) {
95 lookup_flags |= LOOKUP_REVAL; 94 lookup_flags |= LOOKUP_REVAL;
diff --git a/fs/sync.c b/fs/sync.c
index 14eefeb44636..2c5d6639a66a 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -332,7 +332,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
332 if (!f.file) 332 if (!f.file)
333 goto out; 333 goto out;
334 334
335 i_mode = f.file->f_path.dentry->d_inode->i_mode; 335 i_mode = file_inode(f.file)->i_mode;
336 ret = -ESPIPE; 336 ret = -ESPIPE;
337 if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) && 337 if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) &&
338 !S_ISLNK(i_mode)) 338 !S_ISLNK(i_mode))
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 614b2b544880..2ce9a5db6ab5 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -70,7 +70,7 @@ static ssize_t
70read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) 70read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off)
71{ 71{
72 struct bin_buffer *bb = file->private_data; 72 struct bin_buffer *bb = file->private_data;
73 int size = file->f_path.dentry->d_inode->i_size; 73 int size = file_inode(file)->i_size;
74 loff_t offs = *off; 74 loff_t offs = *off;
75 int count = min_t(size_t, bytes, PAGE_SIZE); 75 int count = min_t(size_t, bytes, PAGE_SIZE);
76 char *temp; 76 char *temp;
@@ -140,7 +140,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
140 size_t bytes, loff_t *off) 140 size_t bytes, loff_t *off)
141{ 141{
142 struct bin_buffer *bb = file->private_data; 142 struct bin_buffer *bb = file->private_data;
143 int size = file->f_path.dentry->d_inode->i_size; 143 int size = file_inode(file)->i_size;
144 loff_t offs = *off; 144 loff_t offs = *off;
145 int count = min_t(size_t, bytes, PAGE_SIZE); 145 int count = min_t(size_t, bytes, PAGE_SIZE);
146 char *temp; 146 char *temp;
@@ -469,7 +469,7 @@ void unmap_bin_file(struct sysfs_dirent *attr_sd)
469 mutex_lock(&sysfs_bin_lock); 469 mutex_lock(&sysfs_bin_lock);
470 470
471 hlist_for_each_entry(bb, tmp, &attr_sd->s_bin_attr.buffers, list) { 471 hlist_for_each_entry(bb, tmp, &attr_sd->s_bin_attr.buffers, list) {
472 struct inode *inode = bb->file->f_path.dentry->d_inode; 472 struct inode *inode = file_inode(bb->file);
473 473
474 unmap_mapping_range(inode->i_mapping, 0, 0, 1); 474 unmap_mapping_range(inode->i_mapping, 0, 0, 1);
475 } 475 }
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index a77c42157620..3799e8dac3eb 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -68,7 +68,7 @@ static struct page * dir_get_page(struct inode *dir, unsigned long n)
68static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir) 68static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir)
69{ 69{
70 unsigned long pos = filp->f_pos; 70 unsigned long pos = filp->f_pos;
71 struct inode *inode = filp->f_path.dentry->d_inode; 71 struct inode *inode = file_inode(filp);
72 struct super_block *sb = inode->i_sb; 72 struct super_block *sb = inode->i_sb;
73 unsigned offset = pos & ~PAGE_CACHE_MASK; 73 unsigned offset = pos & ~PAGE_CACHE_MASK;
74 unsigned long n = pos >> PAGE_CACHE_SHIFT; 74 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 8a574776a493..de08c92f2e23 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -352,7 +352,7 @@ static int ubifs_readdir(struct file *file, void *dirent, filldir_t filldir)
352 struct qstr nm; 352 struct qstr nm;
353 union ubifs_key key; 353 union ubifs_key key;
354 struct ubifs_dent_node *dent; 354 struct ubifs_dent_node *dent;
355 struct inode *dir = file->f_path.dentry->d_inode; 355 struct inode *dir = file_inode(file);
356 struct ubifs_info *c = dir->i_sb->s_fs_info; 356 struct ubifs_info *c = dir->i_sb->s_fs_info;
357 357
358 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos); 358 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 4f6493c130e0..f12189d2db1d 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1444,7 +1444,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct *vma,
1444 struct vm_fault *vmf) 1444 struct vm_fault *vmf)
1445{ 1445{
1446 struct page *page = vmf->page; 1446 struct page *page = vmf->page;
1447 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 1447 struct inode *inode = file_inode(vma->vm_file);
1448 struct ubifs_info *c = inode->i_sb->s_fs_info; 1448 struct ubifs_info *c = inode->i_sb->s_fs_info;
1449 struct timespec now = ubifs_current_time(inode); 1449 struct timespec now = ubifs_current_time(inode);
1450 struct ubifs_budget_req req = { .new_page = 1 }; 1450 struct ubifs_budget_req req = { .new_page = 1 };
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 1a7e2d8bdbe9..648b143606cc 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -147,7 +147,7 @@ out_unlock:
147long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 147long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
148{ 148{
149 int flags, err; 149 int flags, err;
150 struct inode *inode = file->f_path.dentry->d_inode; 150 struct inode *inode = file_inode(file);
151 151
152 switch (cmd) { 152 switch (cmd) {
153 case FS_IOC_GETFLAGS: 153 case FS_IOC_GETFLAGS:
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index eb8bfe2b89a5..b3e93f5e17c3 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -186,7 +186,7 @@ out:
186 186
187static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) 187static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
188{ 188{
189 struct inode *dir = filp->f_path.dentry->d_inode; 189 struct inode *dir = file_inode(filp);
190 int result; 190 int result;
191 191
192 if (filp->f_pos == 0) { 192 if (filp->f_pos == 0) {
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 77b5953eaac8..29569dd08168 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -139,7 +139,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
139{ 139{
140 ssize_t retval; 140 ssize_t retval;
141 struct file *file = iocb->ki_filp; 141 struct file *file = iocb->ki_filp;
142 struct inode *inode = file->f_path.dentry->d_inode; 142 struct inode *inode = file_inode(file);
143 int err, pos; 143 int err, pos;
144 size_t count = iocb->ki_left; 144 size_t count = iocb->ki_left;
145 struct udf_inode_info *iinfo = UDF_I(inode); 145 struct udf_inode_info *iinfo = UDF_I(inode);
@@ -178,7 +178,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
178 178
179long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 179long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
180{ 180{
181 struct inode *inode = filp->f_dentry->d_inode; 181 struct inode *inode = file_inode(filp);
182 long old_block, new_block; 182 long old_block, new_block;
183 int result = -EINVAL; 183 int result = -EINVAL;
184 184
@@ -204,7 +204,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
204 goto out; 204 goto out;
205 case UDF_RELOCATE_BLOCKS: 205 case UDF_RELOCATE_BLOCKS:
206 if (!capable(CAP_SYS_ADMIN)) { 206 if (!capable(CAP_SYS_ADMIN)) {
207 result = -EACCES; 207 result = -EPERM;
208 goto out; 208 goto out;
209 } 209 }
210 if (get_user(old_block, (long __user *)arg)) { 210 if (get_user(old_block, (long __user *)arg)) {
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 95fee278ab9d..102c072c6bbf 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1270,10 +1270,10 @@ static int udf_encode_fh(struct inode *inode, __u32 *fh, int *lenp,
1270 1270
1271 if (parent && (len < 5)) { 1271 if (parent && (len < 5)) {
1272 *lenp = 5; 1272 *lenp = 5;
1273 return 255; 1273 return FILEID_INVALID;
1274 } else if (len < 3) { 1274 } else if (len < 3) {
1275 *lenp = 3; 1275 *lenp = 3;
1276 return 255; 1276 return FILEID_INVALID;
1277 } 1277 }
1278 1278
1279 *lenp = 3; 1279 *lenp = 3;
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index dbc90994715a..3a75ca09c506 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -433,7 +433,7 @@ static int
433ufs_readdir(struct file *filp, void *dirent, filldir_t filldir) 433ufs_readdir(struct file *filp, void *dirent, filldir_t filldir)
434{ 434{
435 loff_t pos = filp->f_pos; 435 loff_t pos = filp->f_pos;
436 struct inode *inode = filp->f_path.dentry->d_inode; 436 struct inode *inode = file_inode(filp);
437 struct super_block *sb = inode->i_sb; 437 struct super_block *sb = inode->i_sb;
438 unsigned int offset = pos & ~PAGE_CACHE_MASK; 438 unsigned int offset = pos & ~PAGE_CACHE_MASK;
439 unsigned long n = pos >> PAGE_CACHE_SHIFT; 439 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index a8bd26b82ecb..f852b082a084 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -78,14 +78,14 @@ xfs_swapext(
78 goto out_put_tmp_file; 78 goto out_put_tmp_file;
79 } 79 }
80 80
81 if (IS_SWAPFILE(f.file->f_path.dentry->d_inode) || 81 if (IS_SWAPFILE(file_inode(f.file)) ||
82 IS_SWAPFILE(tmp.file->f_path.dentry->d_inode)) { 82 IS_SWAPFILE(file_inode(tmp.file))) {
83 error = XFS_ERROR(EINVAL); 83 error = XFS_ERROR(EINVAL);
84 goto out_put_tmp_file; 84 goto out_put_tmp_file;
85 } 85 }
86 86
87 ip = XFS_I(f.file->f_path.dentry->d_inode); 87 ip = XFS_I(file_inode(f.file));
88 tip = XFS_I(tmp.file->f_path.dentry->d_inode); 88 tip = XFS_I(file_inode(tmp.file));
89 89
90 if (ip->i_mount != tip->i_mount) { 90 if (ip->i_mount != tip->i_mount) {
91 error = XFS_ERROR(EINVAL); 91 error = XFS_ERROR(EINVAL);
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
index a83611849cee..c585bc646395 100644
--- a/fs/xfs/xfs_export.c
+++ b/fs/xfs/xfs_export.c
@@ -48,7 +48,7 @@ static int xfs_fileid_length(int fileid_type)
48 case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: 48 case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG:
49 return 6; 49 return 6;
50 } 50 }
51 return 255; /* invalid */ 51 return FILEID_INVALID;
52} 52}
53 53
54STATIC int 54STATIC int
@@ -90,7 +90,7 @@ xfs_fs_encode_fh(
90 len = xfs_fileid_length(fileid_type); 90 len = xfs_fileid_length(fileid_type);
91 if (*max_len < len) { 91 if (*max_len < len) {
92 *max_len = len; 92 *max_len = len;
93 return 255; 93 return FILEID_INVALID;
94 } 94 }
95 *max_len = len; 95 *max_len = len;
96 96
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 67284edb84d7..f03bf1a456fb 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -811,7 +811,7 @@ xfs_file_fallocate(
811 loff_t offset, 811 loff_t offset,
812 loff_t len) 812 loff_t len)
813{ 813{
814 struct inode *inode = file->f_path.dentry->d_inode; 814 struct inode *inode = file_inode(file);
815 long error; 815 long error;
816 loff_t new_size = 0; 816 loff_t new_size = 0;
817 xfs_flock64_t bf; 817 xfs_flock64_t bf;
@@ -912,7 +912,7 @@ xfs_file_readdir(
912 void *dirent, 912 void *dirent,
913 filldir_t filldir) 913 filldir_t filldir)
914{ 914{
915 struct inode *inode = filp->f_path.dentry->d_inode; 915 struct inode *inode = file_inode(filp);
916 xfs_inode_t *ip = XFS_I(inode); 916 xfs_inode_t *ip = XFS_I(inode);
917 int error; 917 int error;
918 size_t bufsize; 918 size_t bufsize;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index c1c3ef88a260..d681e34c2950 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -80,7 +80,7 @@ xfs_find_handle(
80 f = fdget(hreq->fd); 80 f = fdget(hreq->fd);
81 if (!f.file) 81 if (!f.file)
82 return -EBADF; 82 return -EBADF;
83 inode = f.file->f_path.dentry->d_inode; 83 inode = file_inode(f.file);
84 } else { 84 } else {
85 error = user_lpath((const char __user *)hreq->path, &path); 85 error = user_lpath((const char __user *)hreq->path, &path);
86 if (error) 86 if (error)
@@ -168,7 +168,7 @@ xfs_handle_to_dentry(
168 /* 168 /*
169 * Only allow handle opens under a directory. 169 * Only allow handle opens under a directory.
170 */ 170 */
171 if (!S_ISDIR(parfilp->f_path.dentry->d_inode->i_mode)) 171 if (!S_ISDIR(file_inode(parfilp)->i_mode))
172 return ERR_PTR(-ENOTDIR); 172 return ERR_PTR(-ENOTDIR);
173 173
174 if (hlen != sizeof(xfs_handle_t)) 174 if (hlen != sizeof(xfs_handle_t))
@@ -1334,7 +1334,7 @@ xfs_file_ioctl(
1334 unsigned int cmd, 1334 unsigned int cmd,
1335 unsigned long p) 1335 unsigned long p)
1336{ 1336{
1337 struct inode *inode = filp->f_path.dentry->d_inode; 1337 struct inode *inode = file_inode(filp);
1338 struct xfs_inode *ip = XFS_I(inode); 1338 struct xfs_inode *ip = XFS_I(inode);
1339 struct xfs_mount *mp = ip->i_mount; 1339 struct xfs_mount *mp = ip->i_mount;
1340 void __user *arg = (void __user *)p; 1340 void __user *arg = (void __user *)p;
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 1244274a5674..63b8fc432151 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -530,7 +530,7 @@ xfs_file_compat_ioctl(
530 unsigned cmd, 530 unsigned cmd,
531 unsigned long p) 531 unsigned long p)
532{ 532{
533 struct inode *inode = filp->f_path.dentry->d_inode; 533 struct inode *inode = file_inode(filp);
534 struct xfs_inode *ip = XFS_I(inode); 534 struct xfs_inode *ip = XFS_I(inode);
535 struct xfs_mount *mp = ip->i_mount; 535 struct xfs_mount *mp = ip->i_mount;
536 void __user *arg = (void __user *)p; 536 void __user *arg = (void __user *)p;