aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-03-03 16:23:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-03-03 16:23:03 -0500
commit56a79b7b021bf1b08334e63c2c14b280e2dbf47a (patch)
tree0419233e6194f4f12073c9284852885aa8984bec /fs
parent1c82315a12144cde732636e259d39e3ee81b3c5b (diff)
parentdcf787f39162ce32ca325b3e784aba2d2444619a (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more VFS bits from Al Viro: "Unfortunately, it looks like xattr series will have to wait until the next cycle ;-/ This pile contains 9p cleanups and fixes (races in v9fs_fid_add() etc), fixup for nommu breakage in shmem.c, several cleanups and a bit more file_inode() work" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: constify path_get/path_put and fs_struct.c stuff fix nommu breakage in shmem.c cache the value of file_inode() in struct file 9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry 9p: make sure ->lookup() adds fid to the right dentry 9p: untangle ->lookup() a bit 9p: double iput() in ->lookup() if d_materialise_unique() fails 9p: v9fs_fid_add() can't fail now v9fs: get rid of v9fs_dentry 9p: turn fid->dlist into hlist 9p: don't bother with private lock in ->d_fsdata; dentry->d_lock will do just fine more file_inode() open-coded instances selinux: opened file can't have NULL or negative ->f_path.dentry (In the meantime, the hlist traversal macros have changed, so this required a semantic conflict fixup for the newly hlistified fid->dlist)
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/fid.c54
-rw-r--r--fs/9p/fid.h22
-rw-r--r--fs/9p/vfs_dentry.c17
-rw-r--r--fs/9p/vfs_inode.c40
-rw-r--r--fs/9p/vfs_inode_dotl.c19
-rw-r--r--fs/ext4/indirect.c2
-rw-r--r--fs/f2fs/file.c6
-rw-r--r--fs/file_table.c2
-rw-r--r--fs/fs_struct.c6
-rw-r--r--fs/fuse/dev.c2
-rw-r--r--fs/fuse/file.c24
-rw-r--r--fs/internal.h2
-rw-r--r--fs/namei.c4
-rw-r--r--fs/open.c3
-rw-r--r--fs/seq_file.c2
15 files changed, 79 insertions, 126 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index afd4724b2d92..d51ec9fafcc8 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -41,29 +41,16 @@
41 * 41 *
42 */ 42 */
43 43
44int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 44static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
45{ 45{
46 struct v9fs_dentry *dent; 46 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
47 47}
48 p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n",
49 fid->fid, dentry->d_name.name);
50
51 dent = dentry->d_fsdata;
52 if (!dent) {
53 dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL);
54 if (!dent)
55 return -ENOMEM;
56
57 spin_lock_init(&dent->lock);
58 INIT_LIST_HEAD(&dent->fidlist);
59 dentry->d_fsdata = dent;
60 }
61
62 spin_lock(&dent->lock);
63 list_add(&fid->dlist, &dent->fidlist);
64 spin_unlock(&dent->lock);
65 48
66 return 0; 49void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
50{
51 spin_lock(&dentry->d_lock);
52 __add_fid(dentry, fid);
53 spin_unlock(&dentry->d_lock);
67} 54}
68 55
69/** 56/**
@@ -76,23 +63,23 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
76 63
77static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) 64static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
78{ 65{
79 struct v9fs_dentry *dent;
80 struct p9_fid *fid, *ret; 66 struct p9_fid *fid, *ret;
81 67
82 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", 68 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n",
83 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), 69 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid),
84 any); 70 any);
85 dent = (struct v9fs_dentry *) dentry->d_fsdata;
86 ret = NULL; 71 ret = NULL;
87 if (dent) { 72 /* we'll recheck under lock if there's anything to look in */
88 spin_lock(&dent->lock); 73 if (dentry->d_fsdata) {
89 list_for_each_entry(fid, &dent->fidlist, dlist) { 74 struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
75 spin_lock(&dentry->d_lock);
76 hlist_for_each_entry(fid, h, dlist) {
90 if (any || uid_eq(fid->uid, uid)) { 77 if (any || uid_eq(fid->uid, uid)) {
91 ret = fid; 78 ret = fid;
92 break; 79 break;
93 } 80 }
94 } 81 }
95 spin_unlock(&dent->lock); 82 spin_unlock(&dentry->d_lock);
96 } 83 }
97 84
98 return ret; 85 return ret;
@@ -215,8 +202,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
215 } 202 }
216 kfree(wnames); 203 kfree(wnames);
217fid_out: 204fid_out:
218 if (!IS_ERR(fid)) 205 if (!IS_ERR(fid)) {
219 v9fs_fid_add(dentry, fid); 206 spin_lock(&dentry->d_lock);
207 if (d_unhashed(dentry)) {
208 spin_unlock(&dentry->d_lock);
209 p9_client_clunk(fid);
210 fid = ERR_PTR(-ENOENT);
211 } else {
212 __add_fid(dentry, fid);
213 spin_unlock(&dentry->d_lock);
214 }
215 }
220err_out: 216err_out:
221 up_read(&v9ses->rename_sem); 217 up_read(&v9ses->rename_sem);
222 return fid; 218 return fid;
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index bb0b6e7f58fc..2b6787fcb626 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -23,28 +23,8 @@
23#define FS_9P_FID_H 23#define FS_9P_FID_H
24#include <linux/list.h> 24#include <linux/list.h>
25 25
26/**
27 * struct v9fs_dentry - 9p private data stored in dentry d_fsdata
28 * @lock: protects the fidlist
29 * @fidlist: list of FIDs currently associated with this dentry
30 *
31 * This structure defines the 9p private data associated with
32 * a particular dentry. In particular, this private data is used
33 * to lookup which 9P FID handle should be used for a particular VFS
34 * operation. FID handles are associated with dentries instead of
35 * inodes in order to more closely map functionality to the Plan 9
36 * expected behavior for FID reclaimation and tracking.
37 *
38 * See Also: Mapping FIDs to Linux VFS model in
39 * Design and Implementation of the Linux 9P File System documentation
40 */
41struct v9fs_dentry {
42 spinlock_t lock; /* protect fidlist */
43 struct list_head fidlist;
44};
45
46struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); 26struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);
47struct p9_fid *v9fs_fid_clone(struct dentry *dentry); 27struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
48int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 28void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
49struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); 29struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
50#endif 30#endif
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 9ad68628522c..f039b104a98e 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -83,21 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry)
83 83
84static void v9fs_dentry_release(struct dentry *dentry) 84static void v9fs_dentry_release(struct dentry *dentry)
85{ 85{
86 struct v9fs_dentry *dent; 86 struct hlist_node *p, *n;
87 struct p9_fid *temp, *current_fid;
88
89 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", 87 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n",
90 dentry->d_name.name, dentry); 88 dentry->d_name.name, dentry);
91 dent = dentry->d_fsdata; 89 hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata)
92 if (dent) { 90 p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
93 list_for_each_entry_safe(current_fid, temp, &dent->fidlist, 91 dentry->d_fsdata = NULL;
94 dlist) {
95 p9_client_clunk(current_fid);
96 }
97
98 kfree(dent);
99 dentry->d_fsdata = NULL;
100 }
101} 92}
102 93
103static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) 94static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index b5340c829de1..d86edc8d3fd0 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -692,9 +692,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
692 "inode creation failed %d\n", err); 692 "inode creation failed %d\n", err);
693 goto error; 693 goto error;
694 } 694 }
695 err = v9fs_fid_add(dentry, fid); 695 v9fs_fid_add(dentry, fid);
696 if (err < 0)
697 goto error;
698 d_instantiate(dentry, inode); 696 d_instantiate(dentry, inode);
699 } 697 }
700 return ofid; 698 return ofid;
@@ -790,7 +788,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
790 struct p9_fid *dfid, *fid; 788 struct p9_fid *dfid, *fid;
791 struct inode *inode; 789 struct inode *inode;
792 char *name; 790 char *name;
793 int result = 0;
794 791
795 p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", 792 p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n",
796 dir, dentry->d_name.name, dentry, flags); 793 dir, dentry->d_name.name, dentry, flags);
@@ -808,13 +805,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
808 name = (char *) dentry->d_name.name; 805 name = (char *) dentry->d_name.name;
809 fid = p9_client_walk(dfid, 1, &name, 1); 806 fid = p9_client_walk(dfid, 1, &name, 1);
810 if (IS_ERR(fid)) { 807 if (IS_ERR(fid)) {
811 result = PTR_ERR(fid); 808 if (fid == ERR_PTR(-ENOENT)) {
812 if (result == -ENOENT) { 809 d_add(dentry, NULL);
813 inode = NULL; 810 return NULL;
814 goto inst_out;
815 } 811 }
816 812 return ERR_CAST(fid);
817 return ERR_PTR(result);
818 } 813 }
819 /* 814 /*
820 * Make sure we don't use a wrong inode due to parallel 815 * Make sure we don't use a wrong inode due to parallel
@@ -826,14 +821,9 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
826 else 821 else
827 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 822 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
828 if (IS_ERR(inode)) { 823 if (IS_ERR(inode)) {
829 result = PTR_ERR(inode); 824 p9_client_clunk(fid);
830 inode = NULL; 825 return ERR_CAST(inode);
831 goto error;
832 } 826 }
833 result = v9fs_fid_add(dentry, fid);
834 if (result < 0)
835 goto error_iput;
836inst_out:
837 /* 827 /*
838 * If we had a rename on the server and a parallel lookup 828 * If we had a rename on the server and a parallel lookup
839 * for the new name, then make sure we instantiate with 829 * for the new name, then make sure we instantiate with
@@ -842,15 +832,13 @@ inst_out:
842 * k/b. 832 * k/b.
843 */ 833 */
844 res = d_materialise_unique(dentry, inode); 834 res = d_materialise_unique(dentry, inode);
845 if (!IS_ERR(res)) 835 if (!res)
846 return res; 836 v9fs_fid_add(dentry, fid);
847 result = PTR_ERR(res); 837 else if (!IS_ERR(res))
848error_iput: 838 v9fs_fid_add(res, fid);
849 iput(inode); 839 else
850error: 840 p9_client_clunk(fid);
851 p9_client_clunk(fid); 841 return res;
852
853 return ERR_PTR(result);
854} 842}
855 843
856static int 844static int
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 61e4fa70a6fa..53687bbf2296 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -333,9 +333,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
333 /* Now set the ACL based on the default value */ 333 /* Now set the ACL based on the default value */
334 v9fs_set_create_acl(inode, fid, dacl, pacl); 334 v9fs_set_create_acl(inode, fid, dacl, pacl);
335 335
336 err = v9fs_fid_add(dentry, fid); 336 v9fs_fid_add(dentry, fid);
337 if (err < 0)
338 goto error;
339 d_instantiate(dentry, inode); 337 d_instantiate(dentry, inode);
340 338
341 v9inode = V9FS_I(inode); 339 v9inode = V9FS_I(inode);
@@ -453,12 +451,11 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
453 err); 451 err);
454 goto error; 452 goto error;
455 } 453 }
456 err = v9fs_fid_add(dentry, fid); 454 v9fs_fid_add(dentry, fid);
457 if (err < 0)
458 goto error;
459 v9fs_set_create_acl(inode, fid, dacl, pacl); 455 v9fs_set_create_acl(inode, fid, dacl, pacl);
460 d_instantiate(dentry, inode); 456 d_instantiate(dentry, inode);
461 fid = NULL; 457 fid = NULL;
458 err = 0;
462 } else { 459 } else {
463 /* 460 /*
464 * Not in cached mode. No need to populate 461 * Not in cached mode. No need to populate
@@ -747,11 +744,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
747 err); 744 err);
748 goto error; 745 goto error;
749 } 746 }
750 err = v9fs_fid_add(dentry, fid); 747 v9fs_fid_add(dentry, fid);
751 if (err < 0)
752 goto error;
753 d_instantiate(dentry, inode); 748 d_instantiate(dentry, inode);
754 fid = NULL; 749 fid = NULL;
750 err = 0;
755 } else { 751 } else {
756 /* Not in cached mode. No need to populate inode with stat */ 752 /* Not in cached mode. No need to populate inode with stat */
757 inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); 753 inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
@@ -900,11 +896,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
900 goto error; 896 goto error;
901 } 897 }
902 v9fs_set_create_acl(inode, fid, dacl, pacl); 898 v9fs_set_create_acl(inode, fid, dacl, pacl);
903 err = v9fs_fid_add(dentry, fid); 899 v9fs_fid_add(dentry, fid);
904 if (err < 0)
905 goto error;
906 d_instantiate(dentry, inode); 900 d_instantiate(dentry, inode);
907 fid = NULL; 901 fid = NULL;
902 err = 0;
908 } else { 903 } else {
909 /* 904 /*
910 * Not in cached mode. No need to populate inode with stat. 905 * Not in cached mode. No need to populate inode with stat.
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index c541ab8b64dd..b505a145a593 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1606,7 +1606,7 @@ err:
1606 1606
1607int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length) 1607int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length)
1608{ 1608{
1609 struct inode *inode = file->f_path.dentry->d_inode; 1609 struct inode *inode = file_inode(file);
1610 struct super_block *sb = inode->i_sb; 1610 struct super_block *sb = inode->i_sb;
1611 ext4_lblk_t first_block, stop_block; 1611 ext4_lblk_t first_block, stop_block;
1612 struct address_space *mapping = inode->i_mapping; 1612 struct address_space *mapping = inode->i_mapping;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b7a053d4c6d3..958a46da19ae 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -29,7 +29,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
29 struct vm_fault *vmf) 29 struct vm_fault *vmf)
30{ 30{
31 struct page *page = vmf->page; 31 struct page *page = vmf->page;
32 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 32 struct inode *inode = file_inode(vma->vm_file);
33 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 33 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
34 block_t old_blk_addr; 34 block_t old_blk_addr;
35 struct dnode_of_data dn; 35 struct dnode_of_data dn;
@@ -544,7 +544,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
544static long f2fs_fallocate(struct file *file, int mode, 544static long f2fs_fallocate(struct file *file, int mode,
545 loff_t offset, loff_t len) 545 loff_t offset, loff_t len)
546{ 546{
547 struct inode *inode = file->f_path.dentry->d_inode; 547 struct inode *inode = file_inode(file);
548 long ret; 548 long ret;
549 549
550 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) 550 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
@@ -577,7 +577,7 @@ static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags)
577 577
578long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 578long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
579{ 579{
580 struct inode *inode = filp->f_dentry->d_inode; 580 struct inode *inode = file_inode(filp);
581 struct f2fs_inode_info *fi = F2FS_I(inode); 581 struct f2fs_inode_info *fi = F2FS_I(inode);
582 unsigned int flags; 582 unsigned int flags;
583 int ret; 583 int ret;
diff --git a/fs/file_table.c b/fs/file_table.c
index aa07d3684a2e..cd4d87a82951 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode,
176 return file; 176 return file;
177 177
178 file->f_path = *path; 178 file->f_path = *path;
179 file->f_inode = path->dentry->d_inode;
179 file->f_mapping = path->dentry->d_inode->i_mapping; 180 file->f_mapping = path->dentry->d_inode->i_mapping;
180 file->f_mode = mode; 181 file->f_mode = mode;
181 file->f_op = fop; 182 file->f_op = fop;
@@ -258,6 +259,7 @@ static void __fput(struct file *file)
258 drop_file_write_access(file); 259 drop_file_write_access(file);
259 file->f_path.dentry = NULL; 260 file->f_path.dentry = NULL;
260 file->f_path.mnt = NULL; 261 file->f_path.mnt = NULL;
262 file->f_inode = NULL;
261 file_free(file); 263 file_free(file);
262 dput(dentry); 264 dput(dentry);
263 mntput(mnt); 265 mntput(mnt);
diff --git a/fs/fs_struct.c b/fs/fs_struct.c
index fe6ca583bbc0..d8ac61d0c932 100644
--- a/fs/fs_struct.c
+++ b/fs/fs_struct.c
@@ -10,7 +10,7 @@
10 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. 10 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
11 * It can block. 11 * It can block.
12 */ 12 */
13void set_fs_root(struct fs_struct *fs, struct path *path) 13void set_fs_root(struct fs_struct *fs, const struct path *path)
14{ 14{
15 struct path old_root; 15 struct path old_root;
16 16
@@ -29,7 +29,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
29 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. 29 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
30 * It can block. 30 * It can block.
31 */ 31 */
32void set_fs_pwd(struct fs_struct *fs, struct path *path) 32void set_fs_pwd(struct fs_struct *fs, const struct path *path)
33{ 33{
34 struct path old_pwd; 34 struct path old_pwd;
35 35
@@ -53,7 +53,7 @@ static inline int replace_path(struct path *p, const struct path *old, const str
53 return 1; 53 return 1;
54} 54}
55 55
56void chroot_fs_refs(struct path *old_root, struct path *new_root) 56void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
57{ 57{
58 struct task_struct *g, *p; 58 struct task_struct *g, *p;
59 struct fs_struct *fs; 59 struct fs_struct *fs;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index e9bdec0b16d9..11dfa0c3fb46 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -532,7 +532,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc,
532 532
533void fuse_force_forget(struct file *file, u64 nodeid) 533void fuse_force_forget(struct file *file, u64 nodeid)
534{ 534{
535 struct inode *inode = file->f_path.dentry->d_inode; 535 struct inode *inode = file_inode(file);
536 struct fuse_conn *fc = get_fuse_conn(inode); 536 struct fuse_conn *fc = get_fuse_conn(inode);
537 struct fuse_req *req; 537 struct fuse_req *req;
538 struct fuse_forget_in inarg; 538 struct fuse_forget_in inarg;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c8071768b950..34b80ba95bad 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -355,7 +355,7 @@ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
355 355
356static int fuse_flush(struct file *file, fl_owner_t id) 356static int fuse_flush(struct file *file, fl_owner_t id)
357{ 357{
358 struct inode *inode = file->f_path.dentry->d_inode; 358 struct inode *inode = file_inode(file);
359 struct fuse_conn *fc = get_fuse_conn(inode); 359 struct fuse_conn *fc = get_fuse_conn(inode);
360 struct fuse_file *ff = file->private_data; 360 struct fuse_file *ff = file->private_data;
361 struct fuse_req *req; 361 struct fuse_req *req;
@@ -1215,7 +1215,7 @@ static ssize_t __fuse_direct_read(struct file *file, const struct iovec *iov,
1215 unsigned long nr_segs, loff_t *ppos) 1215 unsigned long nr_segs, loff_t *ppos)
1216{ 1216{
1217 ssize_t res; 1217 ssize_t res;
1218 struct inode *inode = file->f_path.dentry->d_inode; 1218 struct inode *inode = file_inode(file);
1219 1219
1220 if (is_bad_inode(inode)) 1220 if (is_bad_inode(inode))
1221 return -EIO; 1221 return -EIO;
@@ -1238,7 +1238,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf,
1238static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov, 1238static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov,
1239 unsigned long nr_segs, loff_t *ppos) 1239 unsigned long nr_segs, loff_t *ppos)
1240{ 1240{
1241 struct inode *inode = file->f_path.dentry->d_inode; 1241 struct inode *inode = file_inode(file);
1242 size_t count = iov_length(iov, nr_segs); 1242 size_t count = iov_length(iov, nr_segs);
1243 ssize_t res; 1243 ssize_t res;
1244 1244
@@ -1258,7 +1258,7 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
1258 size_t count, loff_t *ppos) 1258 size_t count, loff_t *ppos)
1259{ 1259{
1260 struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count }; 1260 struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count };
1261 struct inode *inode = file->f_path.dentry->d_inode; 1261 struct inode *inode = file_inode(file);
1262 ssize_t res; 1262 ssize_t res;
1263 1263
1264 if (is_bad_inode(inode)) 1264 if (is_bad_inode(inode))
@@ -1485,7 +1485,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = {
1485static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) 1485static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
1486{ 1486{
1487 if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) { 1487 if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
1488 struct inode *inode = file->f_dentry->d_inode; 1488 struct inode *inode = file_inode(file);
1489 struct fuse_conn *fc = get_fuse_conn(inode); 1489 struct fuse_conn *fc = get_fuse_conn(inode);
1490 struct fuse_inode *fi = get_fuse_inode(inode); 1490 struct fuse_inode *fi = get_fuse_inode(inode);
1491 struct fuse_file *ff = file->private_data; 1491 struct fuse_file *ff = file->private_data;
@@ -1543,7 +1543,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
1543 const struct file_lock *fl, int opcode, pid_t pid, 1543 const struct file_lock *fl, int opcode, pid_t pid,
1544 int flock) 1544 int flock)
1545{ 1545{
1546 struct inode *inode = file->f_path.dentry->d_inode; 1546 struct inode *inode = file_inode(file);
1547 struct fuse_conn *fc = get_fuse_conn(inode); 1547 struct fuse_conn *fc = get_fuse_conn(inode);
1548 struct fuse_file *ff = file->private_data; 1548 struct fuse_file *ff = file->private_data;
1549 struct fuse_lk_in *arg = &req->misc.lk_in; 1549 struct fuse_lk_in *arg = &req->misc.lk_in;
@@ -1565,7 +1565,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
1565 1565
1566static int fuse_getlk(struct file *file, struct file_lock *fl) 1566static int fuse_getlk(struct file *file, struct file_lock *fl)
1567{ 1567{
1568 struct inode *inode = file->f_path.dentry->d_inode; 1568 struct inode *inode = file_inode(file);
1569 struct fuse_conn *fc = get_fuse_conn(inode); 1569 struct fuse_conn *fc = get_fuse_conn(inode);
1570 struct fuse_req *req; 1570 struct fuse_req *req;
1571 struct fuse_lk_out outarg; 1571 struct fuse_lk_out outarg;
@@ -1590,7 +1590,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl)
1590 1590
1591static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) 1591static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
1592{ 1592{
1593 struct inode *inode = file->f_path.dentry->d_inode; 1593 struct inode *inode = file_inode(file);
1594 struct fuse_conn *fc = get_fuse_conn(inode); 1594 struct fuse_conn *fc = get_fuse_conn(inode);
1595 struct fuse_req *req; 1595 struct fuse_req *req;
1596 int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; 1596 int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK;
@@ -1622,7 +1622,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
1622 1622
1623static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) 1623static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
1624{ 1624{
1625 struct inode *inode = file->f_path.dentry->d_inode; 1625 struct inode *inode = file_inode(file);
1626 struct fuse_conn *fc = get_fuse_conn(inode); 1626 struct fuse_conn *fc = get_fuse_conn(inode);
1627 int err; 1627 int err;
1628 1628
@@ -1645,7 +1645,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
1645 1645
1646static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) 1646static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl)
1647{ 1647{
1648 struct inode *inode = file->f_path.dentry->d_inode; 1648 struct inode *inode = file_inode(file);
1649 struct fuse_conn *fc = get_fuse_conn(inode); 1649 struct fuse_conn *fc = get_fuse_conn(inode);
1650 int err; 1650 int err;
1651 1651
@@ -1702,7 +1702,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
1702static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence) 1702static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence)
1703{ 1703{
1704 loff_t retval; 1704 loff_t retval;
1705 struct inode *inode = file->f_path.dentry->d_inode; 1705 struct inode *inode = file_inode(file);
1706 1706
1707 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ 1707 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */
1708 if (whence == SEEK_CUR || whence == SEEK_SET) 1708 if (whence == SEEK_CUR || whence == SEEK_SET)
@@ -2079,7 +2079,7 @@ EXPORT_SYMBOL_GPL(fuse_do_ioctl);
2079long fuse_ioctl_common(struct file *file, unsigned int cmd, 2079long fuse_ioctl_common(struct file *file, unsigned int cmd,
2080 unsigned long arg, unsigned int flags) 2080 unsigned long arg, unsigned int flags)
2081{ 2081{
2082 struct inode *inode = file->f_dentry->d_inode; 2082 struct inode *inode = file_inode(file);
2083 struct fuse_conn *fc = get_fuse_conn(inode); 2083 struct fuse_conn *fc = get_fuse_conn(inode);
2084 2084
2085 if (!fuse_allow_current_process(fc)) 2085 if (!fuse_allow_current_process(fc))
diff --git a/fs/internal.h b/fs/internal.h
index 2f6af7f645eb..507141fceb99 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -69,7 +69,7 @@ extern void __mnt_drop_write_file(struct file *);
69/* 69/*
70 * fs_struct.c 70 * fs_struct.c
71 */ 71 */
72extern void chroot_fs_refs(struct path *, struct path *); 72extern void chroot_fs_refs(const struct path *, const struct path *);
73 73
74/* 74/*
75 * file_table.c 75 * file_table.c
diff --git a/fs/namei.c b/fs/namei.c
index dc984fee5532..961bc1268366 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -451,7 +451,7 @@ int inode_permission(struct inode *inode, int mask)
451 * 451 *
452 * Given a path increment the reference count to the dentry and the vfsmount. 452 * Given a path increment the reference count to the dentry and the vfsmount.
453 */ 453 */
454void path_get(struct path *path) 454void path_get(const struct path *path)
455{ 455{
456 mntget(path->mnt); 456 mntget(path->mnt);
457 dget(path->dentry); 457 dget(path->dentry);
@@ -464,7 +464,7 @@ EXPORT_SYMBOL(path_get);
464 * 464 *
465 * Given a path decrement the reference count to the dentry and the vfsmount. 465 * Given a path decrement the reference count to the dentry and the vfsmount.
466 */ 466 */
467void path_put(struct path *path) 467void path_put(const struct path *path)
468{ 468{
469 dput(path->dentry); 469 dput(path->dentry);
470 mntput(path->mnt); 470 mntput(path->mnt);
diff --git a/fs/open.c b/fs/open.c
index e3441f58d2e1..68354466879f 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -704,7 +704,7 @@ static int do_dentry_open(struct file *f,
704 f->f_mode = FMODE_PATH; 704 f->f_mode = FMODE_PATH;
705 705
706 path_get(&f->f_path); 706 path_get(&f->f_path);
707 inode = file_inode(f); 707 inode = f->f_inode = f->f_path.dentry->d_inode;
708 if (f->f_mode & FMODE_WRITE) { 708 if (f->f_mode & FMODE_WRITE) {
709 error = __get_file_write_access(inode, f->f_path.mnt); 709 error = __get_file_write_access(inode, f->f_path.mnt);
710 if (error) 710 if (error)
@@ -767,6 +767,7 @@ cleanup_file:
767 path_put(&f->f_path); 767 path_put(&f->f_path);
768 f->f_path.mnt = NULL; 768 f->f_path.mnt = NULL;
769 f->f_path.dentry = NULL; 769 f->f_path.dentry = NULL;
770 f->f_inode = NULL;
770 return error; 771 return error;
771} 772}
772 773
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 15c6304bab71..38bb59f3f2ad 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -339,7 +339,7 @@ EXPORT_SYMBOL(seq_lseek);
339/** 339/**
340 * seq_release - free the structures associated with sequential file. 340 * seq_release - free the structures associated with sequential file.
341 * @file: file in question 341 * @file: file in question
342 * @inode: file->f_path.dentry->d_inode 342 * @inode: its inode
343 * 343 *
344 * Frees the structures associated with sequential file; can be used 344 * Frees the structures associated with sequential file; can be used
345 * as ->f_op->release() if you don't have private data to destroy. 345 * as ->f_op->release() if you don't have private data to destroy.