aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-28 15:59:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-28 15:59:05 -0400
commit6784725ab0b9473ce44bfad91a256bd72b5cddc1 (patch)
treef31e2bfc4795c2ee490b0eb9fb752be58060568f
parent554828ee0db41618d101d9549db8808af9fd9d65 (diff)
parent47be61845c775643f1aa4d2a54343549f943c94c (diff)
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "Assorted cleanups and fixes. Probably the most interesting part long-term is ->d_init() - that will have a bunch of followups in (at least) ceph and lustre, but we'll need to sort the barrier-related rules before it can get used for really non-trivial stuff. Another fun thing is the merge of ->d_iput() callers (dentry_iput() and dentry_unlink_inode()) and a bunch of ->d_compare() ones (all except the one in __d_lookup_lru())" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits) fs/dcache.c: avoid soft-lockup in dput() vfs: new d_init method vfs: Update lookup_dcache() comment bdev: get rid of ->bd_inodes Remove last traces of ->sync_page new helper: d_same_name() dentry_cmp(): use lockless_dereference() instead of smp_read_barrier_depends() vfs: clean up documentation vfs: document ->d_real() vfs: merge .d_select_inode() into .d_real() unify dentry_iput() and dentry_unlink_inode() binfmt_misc: ->s_root is not going anywhere drop redundant ->owner initializations ufs: get rid of redundant checks orangefs: constify inode_operations missed comment updates from ->direct_IO() prototype change file_inode(f)->i_mapping is f->f_mapping trim fsnotify hooks a bit 9p: new helper - v9fs_parent_fid() debugfs: ->d_parent is never NULL or negative ...
-rw-r--r--Documentation/block/biodoc.txt3
-rw-r--r--Documentation/filesystems/Locking18
-rw-r--r--Documentation/filesystems/vfs.txt51
-rw-r--r--drivers/block/drbd/drbd_debugfs.c4
-rw-r--r--drivers/gpu/drm/armada/armada_gem.c4
-rw-r--r--drivers/gpu/drm/drm_gem.c2
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gem.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c10
-rw-r--r--drivers/gpu/drm/omapdrm/omap_gem.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c4
-rw-r--r--fs/9p/fid.h4
-rw-r--r--fs/9p/vfs_addr.c1
-rw-r--r--fs/9p/vfs_inode.c10
-rw-r--r--fs/9p/vfs_inode_dotl.c16
-rw-r--r--fs/binfmt_misc.c12
-rw-r--r--fs/block_dev.c16
-rw-r--r--fs/cachefiles/proc.c1
-rw-r--r--fs/cifs/cifs_debug.c7
-rw-r--r--fs/coda/pioctl.c1
-rw-r--r--fs/dcache.c208
-rw-r--r--fs/debugfs/inode.c7
-rw-r--r--fs/ext4/mballoc.c1
-rw-r--r--fs/ext4/sysfs.c1
-rw-r--r--fs/f2fs/super.c1
-rw-r--r--fs/fscache/histogram.c1
-rw-r--r--fs/fscache/object-list.c1
-rw-r--r--fs/fscache/stats.c1
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/isofs/compress.c1
-rw-r--r--fs/jfs/jfs_debug.c1
-rw-r--r--fs/jfs/jfs_logmgr.c1
-rw-r--r--fs/jfs/jfs_metapage.c1
-rw-r--r--fs/jfs/jfs_txnmgr.c2
-rw-r--r--fs/jfs/jfs_xtree.c1
-rw-r--r--fs/lockd/procfs.c1
-rw-r--r--fs/namei.c7
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/dir.c11
-rw-r--r--fs/nfs/direct.c4
-rw-r--r--fs/nfsd/nfsctl.c3
-rw-r--r--fs/nfsd/stats.c1
-rw-r--r--fs/ntfs/inode.c2
-rw-r--r--fs/ocfs2/aops.c2
-rw-r--r--fs/open.c8
-rw-r--r--fs/orangefs/inode.c2
-rw-r--r--fs/orangefs/namei.c10
-rw-r--r--fs/orangefs/orangefs-kernel.h6
-rw-r--r--fs/orangefs/symlink.c2
-rw-r--r--fs/overlayfs/inode.c31
-rw-r--r--fs/overlayfs/overlayfs.h2
-rw-r--r--fs/overlayfs/super.c20
-rw-r--r--fs/tracefs/inode.c7
-rw-r--r--fs/ufs/dir.c17
-rw-r--r--fs/xfs/xfs_stats.c1
-rw-r--r--include/linux/dcache.h41
-rw-r--r--include/linux/fs.h8
-rw-r--r--include/linux/fsnotify.h12
-rw-r--r--include/linux/fsnotify_backend.h20
-rw-r--r--mm/hugetlb.c2
-rw-r--r--security/inode.c15
61 files changed, 224 insertions, 413 deletions
diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
index 5be8a7f4cc7f..026d13362aca 100644
--- a/Documentation/block/biodoc.txt
+++ b/Documentation/block/biodoc.txt
@@ -1024,8 +1024,7 @@ could be on demand. For example wait_on_buffer sets the unplugging going
1024through sync_buffer() running blk_run_address_space(mapping). Or the caller 1024through sync_buffer() running blk_run_address_space(mapping). Or the caller
1025can do it explicity through blk_unplug(bdev). So in the read case, 1025can do it explicity through blk_unplug(bdev). So in the read case,
1026the queue gets explicitly unplugged as part of waiting for completion on that 1026the queue gets explicitly unplugged as part of waiting for completion on that
1027buffer. For page driven IO, the address space ->sync_page() takes care of 1027buffer.
1028doing the blk_run_address_space().
1029 1028
1030Aside: 1029Aside:
1031 This is kind of controversial territory, as it's not clear if plugging is 1030 This is kind of controversial territory, as it's not clear if plugging is
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index 5a7386e38e2d..ef46d3ac5774 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -15,11 +15,14 @@ prototypes:
15 int (*d_compare)(const struct dentry *, const struct dentry *, 15 int (*d_compare)(const struct dentry *, const struct dentry *,
16 unsigned int, const char *, const struct qstr *); 16 unsigned int, const char *, const struct qstr *);
17 int (*d_delete)(struct dentry *); 17 int (*d_delete)(struct dentry *);
18 int (*d_init)(struct dentry *);
18 void (*d_release)(struct dentry *); 19 void (*d_release)(struct dentry *);
19 void (*d_iput)(struct dentry *, struct inode *); 20 void (*d_iput)(struct dentry *, struct inode *);
20 char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); 21 char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen);
21 struct vfsmount *(*d_automount)(struct path *path); 22 struct vfsmount *(*d_automount)(struct path *path);
22 int (*d_manage)(struct dentry *, bool); 23 int (*d_manage)(struct dentry *, bool);
24 struct dentry *(*d_real)(struct dentry *, const struct inode *,
25 unsigned int);
23 26
24locking rules: 27locking rules:
25 rename_lock ->d_lock may block rcu-walk 28 rename_lock ->d_lock may block rcu-walk
@@ -28,12 +31,14 @@ d_weak_revalidate:no no yes no
28d_hash no no no maybe 31d_hash no no no maybe
29d_compare: yes no no maybe 32d_compare: yes no no maybe
30d_delete: no yes no no 33d_delete: no yes no no
34d_init: no no yes no
31d_release: no no yes no 35d_release: no no yes no
32d_prune: no yes no no 36d_prune: no yes no no
33d_iput: no no yes no 37d_iput: no no yes no
34d_dname: no no no no 38d_dname: no no no no
35d_automount: no no yes no 39d_automount: no no yes no
36d_manage: no no yes (ref-walk) maybe 40d_manage: no no yes (ref-walk) maybe
41d_real no no yes no
37 42
38--------------------------- inode_operations --------------------------- 43--------------------------- inode_operations ---------------------------
39prototypes: 44prototypes:
@@ -66,7 +71,6 @@ prototypes:
66 struct file *, unsigned open_flag, 71 struct file *, unsigned open_flag,
67 umode_t create_mode, int *opened); 72 umode_t create_mode, int *opened);
68 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 73 int (*tmpfile) (struct inode *, struct dentry *, umode_t);
69 int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
70 74
71locking rules: 75locking rules:
72 all may block 76 all may block
@@ -95,7 +99,6 @@ fiemap: no
95update_time: no 99update_time: no
96atomic_open: yes 100atomic_open: yes
97tmpfile: no 101tmpfile: no
98dentry_open: no
99 102
100 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on 103 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
101victim. 104victim.
@@ -179,7 +182,6 @@ unlocks and drops the reference.
179prototypes: 182prototypes:
180 int (*writepage)(struct page *page, struct writeback_control *wbc); 183 int (*writepage)(struct page *page, struct writeback_control *wbc);
181 int (*readpage)(struct file *, struct page *); 184 int (*readpage)(struct file *, struct page *);
182 int (*sync_page)(struct page *);
183 int (*writepages)(struct address_space *, struct writeback_control *); 185 int (*writepages)(struct address_space *, struct writeback_control *);
184 int (*set_page_dirty)(struct page *page); 186 int (*set_page_dirty)(struct page *page);
185 int (*readpages)(struct file *filp, struct address_space *mapping, 187 int (*readpages)(struct file *filp, struct address_space *mapping,
@@ -210,7 +212,6 @@ locking rules:
210 PageLocked(page) i_mutex 212 PageLocked(page) i_mutex
211writepage: yes, unlocks (see below) 213writepage: yes, unlocks (see below)
212readpage: yes, unlocks 214readpage: yes, unlocks
213sync_page: maybe
214writepages: 215writepages:
215set_page_dirty no 216set_page_dirty no
216readpages: 217readpages:
@@ -230,8 +231,8 @@ error_remove_page: yes
230swap_activate: no 231swap_activate: no
231swap_deactivate: no 232swap_deactivate: no
232 233
233 ->write_begin(), ->write_end(), ->sync_page() and ->readpage() 234 ->write_begin(), ->write_end() and ->readpage() may be called from
234may be called from the request handler (/dev/loop). 235the request handler (/dev/loop).
235 236
236 ->readpage() unlocks the page, either synchronously or via I/O 237 ->readpage() unlocks the page, either synchronously or via I/O
237completion. 238completion.
@@ -287,11 +288,6 @@ will leave the page itself marked clean but it will be tagged as dirty in the
287radix tree. This incoherency can lead to all sorts of hard-to-debug problems 288radix tree. This incoherency can lead to all sorts of hard-to-debug problems
288in the filesystem like having dirty inodes at umount and losing written data. 289in the filesystem like having dirty inodes at umount and losing written data.
289 290
290 ->sync_page() locking rules are not well-defined - usually it is called
291with lock on page, but that is not guaranteed. Considering the currently
292existing instances of this method ->sync_page() itself doesn't look
293well-defined...
294
295 ->writepages() is used for periodic writeback and for syscall-initiated 291 ->writepages() is used for periodic writeback and for syscall-initiated
296sync operations. The address_space should start I/O against at least 292sync operations. The address_space should start I/O against at least
297*nr_to_write pages. *nr_to_write must be decremented for each page which is 293*nr_to_write pages. *nr_to_write must be decremented for each page which is
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 900360cbcdae..8a196851f01d 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -364,7 +364,6 @@ struct inode_operations {
364 int (*atomic_open)(struct inode *, struct dentry *, struct file *, 364 int (*atomic_open)(struct inode *, struct dentry *, struct file *,
365 unsigned open_flag, umode_t create_mode, int *opened); 365 unsigned open_flag, umode_t create_mode, int *opened);
366 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 366 int (*tmpfile) (struct inode *, struct dentry *, umode_t);
367 int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
368}; 367};
369 368
370Again, all methods are called without any locks being held, unless 369Again, all methods are called without any locks being held, unless
@@ -534,9 +533,7 @@ __sync_single_inode) to check if ->writepages has been successful in
534writing out the whole address_space. 533writing out the whole address_space.
535 534
536The Writeback tag is used by filemap*wait* and sync_page* functions, 535The Writeback tag is used by filemap*wait* and sync_page* functions,
537via filemap_fdatawait_range, to wait for all writeback to 536via filemap_fdatawait_range, to wait for all writeback to complete.
538complete. While waiting ->sync_page (if defined) will be called on
539each page that is found to require writeback.
540 537
541An address_space handler may attach extra information to a page, 538An address_space handler may attach extra information to a page,
542typically using the 'private' field in the 'struct page'. If such 539typically using the 'private' field in the 'struct page'. If such
@@ -554,8 +551,8 @@ address_space has finer control of write sizes.
554 551
555The read process essentially only requires 'readpage'. The write 552The read process essentially only requires 'readpage'. The write
556process is more complicated and uses write_begin/write_end or 553process is more complicated and uses write_begin/write_end or
557set_page_dirty to write data into the address_space, and writepage, 554set_page_dirty to write data into the address_space, and writepage
558sync_page, and writepages to writeback data to storage. 555and writepages to writeback data to storage.
559 556
560Adding and removing pages to/from an address_space is protected by the 557Adding and removing pages to/from an address_space is protected by the
561inode's i_mutex. 558inode's i_mutex.
@@ -701,13 +698,6 @@ struct address_space_operations {
701 but instead uses bmap to find out where the blocks in the file 698 but instead uses bmap to find out where the blocks in the file
702 are and uses those addresses directly. 699 are and uses those addresses directly.
703 700
704 dentry_open: *WARNING: probably going away soon, do not use!* This is an
705 alternative to f_op->open(), the difference is that this method may open
706 a file not necessarily originating from the same filesystem as the one
707 i_op->open() was called on. It may be useful for stacking filesystems
708 which want to allow native I/O directly on underlying files.
709
710
711 invalidatepage: If a page has PagePrivate set, then invalidatepage 701 invalidatepage: If a page has PagePrivate set, then invalidatepage
712 will be called when part or all of the page is to be removed 702 will be called when part or all of the page is to be removed
713 from the address space. This generally corresponds to either a 703 from the address space. This generally corresponds to either a
@@ -944,11 +934,14 @@ struct dentry_operations {
944 int (*d_compare)(const struct dentry *, const struct dentry *, 934 int (*d_compare)(const struct dentry *, const struct dentry *,
945 unsigned int, const char *, const struct qstr *); 935 unsigned int, const char *, const struct qstr *);
946 int (*d_delete)(const struct dentry *); 936 int (*d_delete)(const struct dentry *);
937 int (*d_init)(struct dentry *);
947 void (*d_release)(struct dentry *); 938 void (*d_release)(struct dentry *);
948 void (*d_iput)(struct dentry *, struct inode *); 939 void (*d_iput)(struct dentry *, struct inode *);
949 char *(*d_dname)(struct dentry *, char *, int); 940 char *(*d_dname)(struct dentry *, char *, int);
950 struct vfsmount *(*d_automount)(struct path *); 941 struct vfsmount *(*d_automount)(struct path *);
951 int (*d_manage)(struct dentry *, bool); 942 int (*d_manage)(struct dentry *, bool);
943 struct dentry *(*d_real)(struct dentry *, const struct inode *,
944 unsigned int);
952}; 945};
953 946
954 d_revalidate: called when the VFS needs to revalidate a dentry. This 947 d_revalidate: called when the VFS needs to revalidate a dentry. This
@@ -1014,6 +1007,8 @@ struct dentry_operations {
1014 always cache a reachable dentry. d_delete must be constant and 1007 always cache a reachable dentry. d_delete must be constant and
1015 idempotent. 1008 idempotent.
1016 1009
1010 d_init: called when a dentry is allocated
1011
1017 d_release: called when a dentry is really deallocated 1012 d_release: called when a dentry is really deallocated
1018 1013
1019 d_iput: called when a dentry loses its inode (just prior to its 1014 d_iput: called when a dentry loses its inode (just prior to its
@@ -1033,6 +1028,14 @@ struct dentry_operations {
1033 at the end of the buffer, and returns a pointer to the first char. 1028 at the end of the buffer, and returns a pointer to the first char.
1034 dynamic_dname() helper function is provided to take care of this. 1029 dynamic_dname() helper function is provided to take care of this.
1035 1030
1031 Example :
1032
1033 static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen)
1034 {
1035 return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]",
1036 dentry->d_inode->i_ino);
1037 }
1038
1036 d_automount: called when an automount dentry is to be traversed (optional). 1039 d_automount: called when an automount dentry is to be traversed (optional).
1037 This should create a new VFS mount record and return the record to the 1040 This should create a new VFS mount record and return the record to the
1038 caller. The caller is supplied with a path parameter giving the 1041 caller. The caller is supplied with a path parameter giving the
@@ -1071,13 +1074,23 @@ struct dentry_operations {
1071 This function is only used if DCACHE_MANAGE_TRANSIT is set on the 1074 This function is only used if DCACHE_MANAGE_TRANSIT is set on the
1072 dentry being transited from. 1075 dentry being transited from.
1073 1076
1074Example : 1077 d_real: overlay/union type filesystems implement this method to return one of
1078 the underlying dentries hidden by the overlay. It is used in three
1079 different modes:
1075 1080
1076static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen) 1081 Called from open it may need to copy-up the file depending on the
1077{ 1082 supplied open flags. This mode is selected with a non-zero flags
1078 return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]", 1083 argument. In this mode the d_real method can return an error.
1079 dentry->d_inode->i_ino); 1084
1080} 1085 Called from file_dentry() it returns the real dentry matching the inode
1086 argument. The real dentry may be from a lower layer already copied up,
1087 but still referenced from the file. This mode is selected with a
1088 non-NULL inode argument. This will always succeed.
1089
1090 With NULL inode and zero flags the topmost real underlying dentry is
1091 returned. This will always succeed.
1092
1093 This method is never called with both non-NULL inode and non-zero flags.
1081 1094
1082Each dentry has a pointer to its parent dentry, as well as a hash list 1095Each dentry has a pointer to its parent dentry, as well as a hash list
1083of child dentries. Child dentries are basically like files in a 1096of child dentries. Child dentries are basically like files in a
diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c
index be91a8d7c22a..de5c3ee8a790 100644
--- a/drivers/block/drbd/drbd_debugfs.c
+++ b/drivers/block/drbd/drbd_debugfs.c
@@ -425,9 +425,6 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
425 /* Are we still linked, 425 /* Are we still linked,
426 * or has debugfs_remove() already been called? */ 426 * or has debugfs_remove() already been called? */
427 parent = file->f_path.dentry->d_parent; 427 parent = file->f_path.dentry->d_parent;
428 /* not sure if this can happen: */
429 if (!parent || d_really_is_negative(parent))
430 goto out;
431 /* serialize with d_delete() */ 428 /* serialize with d_delete() */
432 inode_lock(d_inode(parent)); 429 inode_lock(d_inode(parent));
433 /* Make sure the object is still alive */ 430 /* Make sure the object is still alive */
@@ -440,7 +437,6 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
440 if (ret) 437 if (ret)
441 kref_put(kref, release); 438 kref_put(kref, release);
442 } 439 }
443out:
444 return ret; 440 return ret;
445} 441}
446 442
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c
index 88e7fc797721..cb8f0347b934 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -231,7 +231,7 @@ struct armada_gem_object *armada_gem_alloc_object(struct drm_device *dev,
231 231
232 obj->dev_addr = DMA_ERROR_CODE; 232 obj->dev_addr = DMA_ERROR_CODE;
233 233
234 mapping = file_inode(obj->obj.filp)->i_mapping; 234 mapping = obj->obj.filp->f_mapping;
235 mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE); 235 mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE);
236 236
237 DRM_DEBUG_DRIVER("alloc obj %p size %zu\n", obj, size); 237 DRM_DEBUG_DRIVER("alloc obj %p size %zu\n", obj, size);
@@ -441,7 +441,7 @@ armada_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
441 if (sg_alloc_table(sgt, count, GFP_KERNEL)) 441 if (sg_alloc_table(sgt, count, GFP_KERNEL))
442 goto free_sgt; 442 goto free_sgt;
443 443
444 mapping = file_inode(dobj->obj.filp)->i_mapping; 444 mapping = dobj->obj.filp->f_mapping;
445 445
446 for_each_sg(sgt->sgl, sg, count, i) { 446 for_each_sg(sgt->sgl, sg, count, i) {
447 struct page *page; 447 struct page *page;
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 32156060b9c9..ad89db36ca25 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -511,7 +511,7 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
511 int i, npages; 511 int i, npages;
512 512
513 /* This is the shared memory object that backs the GEM resource */ 513 /* This is the shared memory object that backs the GEM resource */
514 mapping = file_inode(obj->filp)->i_mapping; 514 mapping = obj->filp->f_mapping;
515 515
516 /* We already BUG_ON() for non-page-aligned sizes in 516 /* We already BUG_ON() for non-page-aligned sizes in
517 * drm_gem_object_init(), so we should never hit this unless 517 * drm_gem_object_init(), so we should never hit this unless
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index df9bcbab922f..8c6f750634af 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -660,7 +660,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
660 * why this is required _and_ expected if you're 660 * why this is required _and_ expected if you're
661 * going to pin these pages. 661 * going to pin these pages.
662 */ 662 */
663 mapping = file_inode(obj->filp)->i_mapping; 663 mapping = obj->filp->f_mapping;
664 mapping_set_gfp_mask(mapping, GFP_HIGHUSER); 664 mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
665 } 665 }
666 666
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index aad26851cee3..ed6117a0ee84 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -151,7 +151,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
151static int 151static int
152i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj) 152i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
153{ 153{
154 struct address_space *mapping = file_inode(obj->base.filp)->i_mapping; 154 struct address_space *mapping = obj->base.filp->f_mapping;
155 char *vaddr = obj->phys_handle->vaddr; 155 char *vaddr = obj->phys_handle->vaddr;
156 struct sg_table *st; 156 struct sg_table *st;
157 struct scatterlist *sg; 157 struct scatterlist *sg;
@@ -218,7 +218,7 @@ i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj)
218 obj->dirty = 0; 218 obj->dirty = 0;
219 219
220 if (obj->dirty) { 220 if (obj->dirty) {
221 struct address_space *mapping = file_inode(obj->base.filp)->i_mapping; 221 struct address_space *mapping = obj->base.filp->f_mapping;
222 char *vaddr = obj->phys_handle->vaddr; 222 char *vaddr = obj->phys_handle->vaddr;
223 int i; 223 int i;
224 224
@@ -2155,7 +2155,7 @@ i915_gem_object_invalidate(struct drm_i915_gem_object *obj)
2155 if (obj->base.filp == NULL) 2155 if (obj->base.filp == NULL)
2156 return; 2156 return;
2157 2157
2158 mapping = file_inode(obj->base.filp)->i_mapping, 2158 mapping = obj->base.filp->f_mapping,
2159 invalidate_mapping_pages(mapping, 0, (loff_t)-1); 2159 invalidate_mapping_pages(mapping, 0, (loff_t)-1);
2160} 2160}
2161 2161
@@ -2271,7 +2271,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
2271 * 2271 *
2272 * Fail silently without starting the shrinker 2272 * Fail silently without starting the shrinker
2273 */ 2273 */
2274 mapping = file_inode(obj->base.filp)->i_mapping; 2274 mapping = obj->base.filp->f_mapping;
2275 gfp = mapping_gfp_constraint(mapping, ~(__GFP_IO | __GFP_RECLAIM)); 2275 gfp = mapping_gfp_constraint(mapping, ~(__GFP_IO | __GFP_RECLAIM));
2276 gfp |= __GFP_NORETRY | __GFP_NOWARN; 2276 gfp |= __GFP_NORETRY | __GFP_NOWARN;
2277 sg = st->sgl; 2277 sg = st->sgl;
@@ -4522,7 +4522,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
4522 mask |= __GFP_DMA32; 4522 mask |= __GFP_DMA32;
4523 } 4523 }
4524 4524
4525 mapping = file_inode(obj->base.filp)->i_mapping; 4525 mapping = obj->base.filp->f_mapping;
4526 mapping_set_gfp_mask(mapping, mask); 4526 mapping_set_gfp_mask(mapping, mask);
4527 4527
4528 i915_gem_object_init(obj, &i915_gem_object_ops); 4528 i915_gem_object_init(obj, &i915_gem_object_ops);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 03698b6c806c..0dbd0f03f9bd 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1407,7 +1407,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
1407 if (ret) 1407 if (ret)
1408 goto err_free; 1408 goto err_free;
1409 1409
1410 mapping = file_inode(obj->filp)->i_mapping; 1410 mapping = obj->filp->f_mapping;
1411 mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32); 1411 mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
1412 } 1412 }
1413 1413
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 077ae9b2865d..97542c35d6ef 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -298,7 +298,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
298 swap_storage = ttm->swap_storage; 298 swap_storage = ttm->swap_storage;
299 BUG_ON(swap_storage == NULL); 299 BUG_ON(swap_storage == NULL);
300 300
301 swap_space = file_inode(swap_storage)->i_mapping; 301 swap_space = swap_storage->f_mapping;
302 302
303 for (i = 0; i < ttm->num_pages; ++i) { 303 for (i = 0; i < ttm->num_pages; ++i) {
304 from_page = shmem_read_mapping_page(swap_space, i); 304 from_page = shmem_read_mapping_page(swap_space, i);
@@ -347,7 +347,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
347 } else 347 } else
348 swap_storage = persistent_swap_storage; 348 swap_storage = persistent_swap_storage;
349 349
350 swap_space = file_inode(swap_storage)->i_mapping; 350 swap_space = swap_storage->f_mapping;
351 351
352 for (i = 0; i < ttm->num_pages; ++i) { 352 for (i = 0; i < ttm->num_pages; ++i) {
353 from_page = ttm->pages[i]; 353 from_page = ttm->pages[i];
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 2b6787fcb626..12700df0bb51 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -24,6 +24,10 @@
24#include <linux/list.h> 24#include <linux/list.h>
25 25
26struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); 26struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);
27static inline struct p9_fid *v9fs_parent_fid(struct dentry *dentry)
28{
29 return v9fs_fid_lookup(dentry->d_parent);
30}
27struct p9_fid *v9fs_fid_clone(struct dentry *dentry); 31struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
28void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 32void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
29struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); 33struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index c37fb9c08970..6181ad79e1a5 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -231,7 +231,6 @@ static int v9fs_launder_page(struct page *page)
231/** 231/**
232 * v9fs_direct_IO - 9P address space operation for direct I/O 232 * v9fs_direct_IO - 9P address space operation for direct I/O
233 * @iocb: target I/O control block 233 * @iocb: target I/O control block
234 * @pos: offset in file to begin the operation
235 * 234 *
236 * The presence of v9fs_direct_IO() in the address space ops vector 235 * The presence of v9fs_direct_IO() in the address space ops vector
237 * allowes open() O_DIRECT flags which would have failed otherwise. 236 * allowes open() O_DIRECT flags which would have failed otherwise.
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index e2e7c749925a..7da9a8354fad 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -595,7 +595,7 @@ static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags)
595 595
596 v9ses = v9fs_inode2v9ses(dir); 596 v9ses = v9fs_inode2v9ses(dir);
597 inode = d_inode(dentry); 597 inode = d_inode(dentry);
598 dfid = v9fs_fid_lookup(dentry->d_parent); 598 dfid = v9fs_parent_fid(dentry);
599 if (IS_ERR(dfid)) { 599 if (IS_ERR(dfid)) {
600 retval = PTR_ERR(dfid); 600 retval = PTR_ERR(dfid);
601 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", retval); 601 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", retval);
@@ -653,7 +653,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
653 ofid = NULL; 653 ofid = NULL;
654 fid = NULL; 654 fid = NULL;
655 name = (char *) dentry->d_name.name; 655 name = (char *) dentry->d_name.name;
656 dfid = v9fs_fid_lookup(dentry->d_parent); 656 dfid = v9fs_parent_fid(dentry);
657 if (IS_ERR(dfid)) { 657 if (IS_ERR(dfid)) {
658 err = PTR_ERR(dfid); 658 err = PTR_ERR(dfid);
659 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 659 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
@@ -798,7 +798,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
798 798
799 v9ses = v9fs_inode2v9ses(dir); 799 v9ses = v9fs_inode2v9ses(dir);
800 /* We can walk d_parent because we hold the dir->i_mutex */ 800 /* We can walk d_parent because we hold the dir->i_mutex */
801 dfid = v9fs_fid_lookup(dentry->d_parent); 801 dfid = v9fs_parent_fid(dentry);
802 if (IS_ERR(dfid)) 802 if (IS_ERR(dfid))
803 return ERR_CAST(dfid); 803 return ERR_CAST(dfid);
804 804
@@ -975,13 +975,13 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
975 if (IS_ERR(oldfid)) 975 if (IS_ERR(oldfid))
976 return PTR_ERR(oldfid); 976 return PTR_ERR(oldfid);
977 977
978 olddirfid = v9fs_fid_clone(old_dentry->d_parent); 978 olddirfid = v9fs_parent_fid(old_dentry);
979 if (IS_ERR(olddirfid)) { 979 if (IS_ERR(olddirfid)) {
980 retval = PTR_ERR(olddirfid); 980 retval = PTR_ERR(olddirfid);
981 goto done; 981 goto done;
982 } 982 }
983 983
984 newdirfid = v9fs_fid_clone(new_dentry->d_parent); 984 newdirfid = v9fs_parent_fid(new_dentry);
985 if (IS_ERR(newdirfid)) { 985 if (IS_ERR(newdirfid)) {
986 retval = PTR_ERR(newdirfid); 986 retval = PTR_ERR(newdirfid);
987 goto clunk_olddir; 987 goto clunk_olddir;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 1b51eaa5e2dd..2ed04c2fe7af 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -273,7 +273,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
273 p9_debug(P9_DEBUG_VFS, "name:%s flags:0x%x mode:0x%hx\n", 273 p9_debug(P9_DEBUG_VFS, "name:%s flags:0x%x mode:0x%hx\n",
274 name, flags, omode); 274 name, flags, omode);
275 275
276 dfid = v9fs_fid_lookup(dentry->d_parent); 276 dfid = v9fs_parent_fid(dentry);
277 if (IS_ERR(dfid)) { 277 if (IS_ERR(dfid)) {
278 err = PTR_ERR(dfid); 278 err = PTR_ERR(dfid);
279 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 279 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
@@ -389,7 +389,6 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
389 umode_t mode; 389 umode_t mode;
390 struct inode *inode; 390 struct inode *inode;
391 struct p9_qid qid; 391 struct p9_qid qid;
392 struct dentry *dir_dentry;
393 struct posix_acl *dacl = NULL, *pacl = NULL; 392 struct posix_acl *dacl = NULL, *pacl = NULL;
394 393
395 p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry); 394 p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry);
@@ -400,8 +399,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
400 if (dir->i_mode & S_ISGID) 399 if (dir->i_mode & S_ISGID)
401 omode |= S_ISGID; 400 omode |= S_ISGID;
402 401
403 dir_dentry = dentry->d_parent; 402 dfid = v9fs_parent_fid(dentry);
404 dfid = v9fs_fid_lookup(dir_dentry);
405 if (IS_ERR(dfid)) { 403 if (IS_ERR(dfid)) {
406 err = PTR_ERR(dfid); 404 err = PTR_ERR(dfid);
407 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 405 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
@@ -691,7 +689,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
691 p9_debug(P9_DEBUG_VFS, "%lu,%s,%s\n", dir->i_ino, name, symname); 689 p9_debug(P9_DEBUG_VFS, "%lu,%s,%s\n", dir->i_ino, name, symname);
692 v9ses = v9fs_inode2v9ses(dir); 690 v9ses = v9fs_inode2v9ses(dir);
693 691
694 dfid = v9fs_fid_lookup(dentry->d_parent); 692 dfid = v9fs_parent_fid(dentry);
695 if (IS_ERR(dfid)) { 693 if (IS_ERR(dfid)) {
696 err = PTR_ERR(dfid); 694 err = PTR_ERR(dfid);
697 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 695 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
@@ -762,7 +760,6 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
762 struct dentry *dentry) 760 struct dentry *dentry)
763{ 761{
764 int err; 762 int err;
765 struct dentry *dir_dentry;
766 struct p9_fid *dfid, *oldfid; 763 struct p9_fid *dfid, *oldfid;
767 struct v9fs_session_info *v9ses; 764 struct v9fs_session_info *v9ses;
768 765
@@ -770,8 +767,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
770 dir->i_ino, old_dentry, dentry); 767 dir->i_ino, old_dentry, dentry);
771 768
772 v9ses = v9fs_inode2v9ses(dir); 769 v9ses = v9fs_inode2v9ses(dir);
773 dir_dentry = dentry->d_parent; 770 dfid = v9fs_parent_fid(dentry);
774 dfid = v9fs_fid_lookup(dir_dentry);
775 if (IS_ERR(dfid)) 771 if (IS_ERR(dfid))
776 return PTR_ERR(dfid); 772 return PTR_ERR(dfid);
777 773
@@ -822,7 +818,6 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
822 struct p9_fid *fid = NULL, *dfid = NULL; 818 struct p9_fid *fid = NULL, *dfid = NULL;
823 struct inode *inode; 819 struct inode *inode;
824 struct p9_qid qid; 820 struct p9_qid qid;
825 struct dentry *dir_dentry;
826 struct posix_acl *dacl = NULL, *pacl = NULL; 821 struct posix_acl *dacl = NULL, *pacl = NULL;
827 822
828 p9_debug(P9_DEBUG_VFS, " %lu,%pd mode: %hx MAJOR: %u MINOR: %u\n", 823 p9_debug(P9_DEBUG_VFS, " %lu,%pd mode: %hx MAJOR: %u MINOR: %u\n",
@@ -830,8 +825,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
830 MAJOR(rdev), MINOR(rdev)); 825 MAJOR(rdev), MINOR(rdev));
831 826
832 v9ses = v9fs_inode2v9ses(dir); 827 v9ses = v9fs_inode2v9ses(dir);
833 dir_dentry = dentry->d_parent; 828 dfid = v9fs_parent_fid(dentry);
834 dfid = v9fs_fid_lookup(dir_dentry);
835 if (IS_ERR(dfid)) { 829 if (IS_ERR(dfid)) {
836 err = PTR_ERR(dfid); 830 err = PTR_ERR(dfid);
837 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 831 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 3a3ced779fc7..5417516f6e59 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -637,13 +637,12 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
637 break; 637 break;
638 case 3: 638 case 3:
639 /* Delete this handler. */ 639 /* Delete this handler. */
640 root = dget(file->f_path.dentry->d_sb->s_root); 640 root = file_inode(file)->i_sb->s_root;
641 inode_lock(d_inode(root)); 641 inode_lock(d_inode(root));
642 642
643 kill_node(e); 643 kill_node(e);
644 644
645 inode_unlock(d_inode(root)); 645 inode_unlock(d_inode(root));
646 dput(root);
647 break; 646 break;
648 default: 647 default:
649 return res; 648 return res;
@@ -665,8 +664,8 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
665{ 664{
666 Node *e; 665 Node *e;
667 struct inode *inode; 666 struct inode *inode;
668 struct dentry *root, *dentry; 667 struct super_block *sb = file_inode(file)->i_sb;
669 struct super_block *sb = file->f_path.dentry->d_sb; 668 struct dentry *root = sb->s_root, *dentry;
670 int err = 0; 669 int err = 0;
671 670
672 e = create_entry(buffer, count); 671 e = create_entry(buffer, count);
@@ -674,7 +673,6 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
674 if (IS_ERR(e)) 673 if (IS_ERR(e))
675 return PTR_ERR(e); 674 return PTR_ERR(e);
676 675
677 root = dget(sb->s_root);
678 inode_lock(d_inode(root)); 676 inode_lock(d_inode(root));
679 dentry = lookup_one_len(e->name, root, strlen(e->name)); 677 dentry = lookup_one_len(e->name, root, strlen(e->name));
680 err = PTR_ERR(dentry); 678 err = PTR_ERR(dentry);
@@ -712,7 +710,6 @@ out2:
712 dput(dentry); 710 dput(dentry);
713out: 711out:
714 inode_unlock(d_inode(root)); 712 inode_unlock(d_inode(root));
715 dput(root);
716 713
717 if (err) { 714 if (err) {
718 kfree(e); 715 kfree(e);
@@ -753,14 +750,13 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
753 break; 750 break;
754 case 3: 751 case 3:
755 /* Delete all handlers. */ 752 /* Delete all handlers. */
756 root = dget(file->f_path.dentry->d_sb->s_root); 753 root = file_inode(file)->i_sb->s_root;
757 inode_lock(d_inode(root)); 754 inode_lock(d_inode(root));
758 755
759 while (!list_empty(&entries)) 756 while (!list_empty(&entries))
760 kill_node(list_entry(entries.next, Node, list)); 757 kill_node(list_entry(entries.next, Node, list));
761 758
762 inode_unlock(d_inode(root)); 759 inode_unlock(d_inode(root));
763 dput(root);
764 break; 760 break;
765 default: 761 default:
766 return res; 762 return res;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index d012be4ab977..5cbd5391667e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -614,7 +614,6 @@ static void init_once(void *foo)
614 614
615 memset(bdev, 0, sizeof(*bdev)); 615 memset(bdev, 0, sizeof(*bdev));
616 mutex_init(&bdev->bd_mutex); 616 mutex_init(&bdev->bd_mutex);
617 INIT_LIST_HEAD(&bdev->bd_inodes);
618 INIT_LIST_HEAD(&bdev->bd_list); 617 INIT_LIST_HEAD(&bdev->bd_list);
619#ifdef CONFIG_SYSFS 618#ifdef CONFIG_SYSFS
620 INIT_LIST_HEAD(&bdev->bd_holder_disks); 619 INIT_LIST_HEAD(&bdev->bd_holder_disks);
@@ -624,24 +623,13 @@ static void init_once(void *foo)
624 mutex_init(&bdev->bd_fsfreeze_mutex); 623 mutex_init(&bdev->bd_fsfreeze_mutex);
625} 624}
626 625
627static inline void __bd_forget(struct inode *inode)
628{
629 list_del_init(&inode->i_devices);
630 inode->i_bdev = NULL;
631 inode->i_mapping = &inode->i_data;
632}
633
634static void bdev_evict_inode(struct inode *inode) 626static void bdev_evict_inode(struct inode *inode)
635{ 627{
636 struct block_device *bdev = &BDEV_I(inode)->bdev; 628 struct block_device *bdev = &BDEV_I(inode)->bdev;
637 struct list_head *p;
638 truncate_inode_pages_final(&inode->i_data); 629 truncate_inode_pages_final(&inode->i_data);
639 invalidate_inode_buffers(inode); /* is it needed here? */ 630 invalidate_inode_buffers(inode); /* is it needed here? */
640 clear_inode(inode); 631 clear_inode(inode);
641 spin_lock(&bdev_lock); 632 spin_lock(&bdev_lock);
642 while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
643 __bd_forget(list_entry(p, struct inode, i_devices));
644 }
645 list_del_init(&bdev->bd_list); 633 list_del_init(&bdev->bd_list);
646 spin_unlock(&bdev_lock); 634 spin_unlock(&bdev_lock);
647} 635}
@@ -805,7 +793,6 @@ static struct block_device *bd_acquire(struct inode *inode)
805 bdgrab(bdev); 793 bdgrab(bdev);
806 inode->i_bdev = bdev; 794 inode->i_bdev = bdev;
807 inode->i_mapping = bdev->bd_inode->i_mapping; 795 inode->i_mapping = bdev->bd_inode->i_mapping;
808 list_add(&inode->i_devices, &bdev->bd_inodes);
809 } 796 }
810 spin_unlock(&bdev_lock); 797 spin_unlock(&bdev_lock);
811 } 798 }
@@ -821,7 +808,8 @@ void bd_forget(struct inode *inode)
821 spin_lock(&bdev_lock); 808 spin_lock(&bdev_lock);
822 if (!sb_is_blkdev_sb(inode->i_sb)) 809 if (!sb_is_blkdev_sb(inode->i_sb))
823 bdev = inode->i_bdev; 810 bdev = inode->i_bdev;
824 __bd_forget(inode); 811 inode->i_bdev = NULL;
812 inode->i_mapping = &inode->i_data;
825 spin_unlock(&bdev_lock); 813 spin_unlock(&bdev_lock);
826 814
827 if (bdev) 815 if (bdev)
diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
index eccd33941199..125b90f6c796 100644
--- a/fs/cachefiles/proc.c
+++ b/fs/cachefiles/proc.c
@@ -93,7 +93,6 @@ static int cachefiles_histogram_open(struct inode *inode, struct file *file)
93} 93}
94 94
95static const struct file_operations cachefiles_histogram_fops = { 95static const struct file_operations cachefiles_histogram_fops = {
96 .owner = THIS_MODULE,
97 .open = cachefiles_histogram_open, 96 .open = cachefiles_histogram_open,
98 .read = seq_read, 97 .read = seq_read,
99 .llseek = seq_lseek, 98 .llseek = seq_lseek,
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 788e19195991..6c58e13fed2f 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -244,7 +244,6 @@ static int cifs_debug_data_proc_open(struct inode *inode, struct file *file)
244} 244}
245 245
246static const struct file_operations cifs_debug_data_proc_fops = { 246static const struct file_operations cifs_debug_data_proc_fops = {
247 .owner = THIS_MODULE,
248 .open = cifs_debug_data_proc_open, 247 .open = cifs_debug_data_proc_open,
249 .read = seq_read, 248 .read = seq_read,
250 .llseek = seq_lseek, 249 .llseek = seq_lseek,
@@ -361,7 +360,6 @@ static int cifs_stats_proc_open(struct inode *inode, struct file *file)
361} 360}
362 361
363static const struct file_operations cifs_stats_proc_fops = { 362static const struct file_operations cifs_stats_proc_fops = {
364 .owner = THIS_MODULE,
365 .open = cifs_stats_proc_open, 363 .open = cifs_stats_proc_open,
366 .read = seq_read, 364 .read = seq_read,
367 .llseek = seq_lseek, 365 .llseek = seq_lseek,
@@ -447,7 +445,6 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
447} 445}
448 446
449static const struct file_operations cifsFYI_proc_fops = { 447static const struct file_operations cifsFYI_proc_fops = {
450 .owner = THIS_MODULE,
451 .open = cifsFYI_proc_open, 448 .open = cifsFYI_proc_open,
452 .read = seq_read, 449 .read = seq_read,
453 .llseek = seq_lseek, 450 .llseek = seq_lseek,
@@ -479,7 +476,6 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file,
479} 476}
480 477
481static const struct file_operations cifs_linux_ext_proc_fops = { 478static const struct file_operations cifs_linux_ext_proc_fops = {
482 .owner = THIS_MODULE,
483 .open = cifs_linux_ext_proc_open, 479 .open = cifs_linux_ext_proc_open,
484 .read = seq_read, 480 .read = seq_read,
485 .llseek = seq_lseek, 481 .llseek = seq_lseek,
@@ -511,7 +507,6 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file,
511} 507}
512 508
513static const struct file_operations cifs_lookup_cache_proc_fops = { 509static const struct file_operations cifs_lookup_cache_proc_fops = {
514 .owner = THIS_MODULE,
515 .open = cifs_lookup_cache_proc_open, 510 .open = cifs_lookup_cache_proc_open,
516 .read = seq_read, 511 .read = seq_read,
517 .llseek = seq_lseek, 512 .llseek = seq_lseek,
@@ -543,7 +538,6 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
543} 538}
544 539
545static const struct file_operations traceSMB_proc_fops = { 540static const struct file_operations traceSMB_proc_fops = {
546 .owner = THIS_MODULE,
547 .open = traceSMB_proc_open, 541 .open = traceSMB_proc_open,
548 .read = seq_read, 542 .read = seq_read,
549 .llseek = seq_lseek, 543 .llseek = seq_lseek,
@@ -655,7 +649,6 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
655} 649}
656 650
657static const struct file_operations cifs_security_flags_proc_fops = { 651static const struct file_operations cifs_security_flags_proc_fops = {
658 .owner = THIS_MODULE,
659 .open = cifs_security_flags_proc_open, 652 .open = cifs_security_flags_proc_open,
660 .read = seq_read, 653 .read = seq_read,
661 .llseek = seq_lseek, 654 .llseek = seq_lseek,
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index f36a4040afb8..b0b9cda41928 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -35,7 +35,6 @@ const struct inode_operations coda_ioctl_inode_operations = {
35}; 35};
36 36
37const struct file_operations coda_ioctl_operations = { 37const struct file_operations coda_ioctl_operations = {
38 .owner = THIS_MODULE,
39 .unlocked_ioctl = coda_pioctl, 38 .unlocked_ioctl = coda_pioctl,
40 .llseek = noop_llseek, 39 .llseek = noop_llseek,
41}; 40};
diff --git a/fs/dcache.c b/fs/dcache.c
index 24bf27d66f6e..b90cf8e09d5b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -224,10 +224,9 @@ static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char
224 224
225static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount) 225static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount)
226{ 226{
227 const unsigned char *cs;
228 /* 227 /*
229 * Be careful about RCU walk racing with rename: 228 * Be careful about RCU walk racing with rename:
230 * use ACCESS_ONCE to fetch the name pointer. 229 * use 'lockless_dereference' to fetch the name pointer.
231 * 230 *
232 * NOTE! Even if a rename will mean that the length 231 * NOTE! Even if a rename will mean that the length
233 * was not loaded atomically, we don't care. The 232 * was not loaded atomically, we don't care. The
@@ -241,8 +240,8 @@ static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *c
241 * early because the data cannot match (there can 240 * early because the data cannot match (there can
242 * be no NUL in the ct/tcount data) 241 * be no NUL in the ct/tcount data)
243 */ 242 */
244 cs = ACCESS_ONCE(dentry->d_name.name); 243 const unsigned char *cs = lockless_dereference(dentry->d_name.name);
245 smp_read_barrier_depends(); 244
246 return dentry_string_cmp(cs, ct, tcount); 245 return dentry_string_cmp(cs, ct, tcount);
247} 246}
248 247
@@ -333,44 +332,21 @@ static inline void dentry_rcuwalk_invalidate(struct dentry *dentry)
333 332
334/* 333/*
335 * Release the dentry's inode, using the filesystem 334 * Release the dentry's inode, using the filesystem
336 * d_iput() operation if defined. Dentry has no refcount 335 * d_iput() operation if defined.
337 * and is unhashed.
338 */
339static void dentry_iput(struct dentry * dentry)
340 __releases(dentry->d_lock)
341 __releases(dentry->d_inode->i_lock)
342{
343 struct inode *inode = dentry->d_inode;
344 if (inode) {
345 __d_clear_type_and_inode(dentry);
346 hlist_del_init(&dentry->d_u.d_alias);
347 spin_unlock(&dentry->d_lock);
348 spin_unlock(&inode->i_lock);
349 if (!inode->i_nlink)
350 fsnotify_inoderemove(inode);
351 if (dentry->d_op && dentry->d_op->d_iput)
352 dentry->d_op->d_iput(dentry, inode);
353 else
354 iput(inode);
355 } else {
356 spin_unlock(&dentry->d_lock);
357 }
358}
359
360/*
361 * Release the dentry's inode, using the filesystem
362 * d_iput() operation if defined. dentry remains in-use.
363 */ 336 */
364static void dentry_unlink_inode(struct dentry * dentry) 337static void dentry_unlink_inode(struct dentry * dentry)
365 __releases(dentry->d_lock) 338 __releases(dentry->d_lock)
366 __releases(dentry->d_inode->i_lock) 339 __releases(dentry->d_inode->i_lock)
367{ 340{
368 struct inode *inode = dentry->d_inode; 341 struct inode *inode = dentry->d_inode;
342 bool hashed = !d_unhashed(dentry);
369 343
370 raw_write_seqcount_begin(&dentry->d_seq); 344 if (hashed)
345 raw_write_seqcount_begin(&dentry->d_seq);
371 __d_clear_type_and_inode(dentry); 346 __d_clear_type_and_inode(dentry);
372 hlist_del_init(&dentry->d_u.d_alias); 347 hlist_del_init(&dentry->d_u.d_alias);
373 raw_write_seqcount_end(&dentry->d_seq); 348 if (hashed)
349 raw_write_seqcount_end(&dentry->d_seq);
374 spin_unlock(&dentry->d_lock); 350 spin_unlock(&dentry->d_lock);
375 spin_unlock(&inode->i_lock); 351 spin_unlock(&inode->i_lock);
376 if (!inode->i_nlink) 352 if (!inode->i_nlink)
@@ -571,12 +547,10 @@ static void __dentry_kill(struct dentry *dentry)
571 dentry_unlist(dentry, parent); 547 dentry_unlist(dentry, parent);
572 if (parent) 548 if (parent)
573 spin_unlock(&parent->d_lock); 549 spin_unlock(&parent->d_lock);
574 dentry_iput(dentry); 550 if (dentry->d_inode)
575 /* 551 dentry_unlink_inode(dentry);
576 * dentry_iput drops the locks, at which point nobody (except 552 else
577 * transient RCU lookups) can reach this dentry. 553 spin_unlock(&dentry->d_lock);
578 */
579 BUG_ON(dentry->d_lockref.count > 0);
580 this_cpu_dec(nr_dentry); 554 this_cpu_dec(nr_dentry);
581 if (dentry->d_op && dentry->d_op->d_release) 555 if (dentry->d_op && dentry->d_op->d_release)
582 dentry->d_op->d_release(dentry); 556 dentry->d_op->d_release(dentry);
@@ -620,7 +594,6 @@ static struct dentry *dentry_kill(struct dentry *dentry)
620 594
621failed: 595failed:
622 spin_unlock(&dentry->d_lock); 596 spin_unlock(&dentry->d_lock);
623 cpu_relax();
624 return dentry; /* try again with same dentry */ 597 return dentry; /* try again with same dentry */
625} 598}
626 599
@@ -794,6 +767,8 @@ void dput(struct dentry *dentry)
794 return; 767 return;
795 768
796repeat: 769repeat:
770 might_sleep();
771
797 rcu_read_lock(); 772 rcu_read_lock();
798 if (likely(fast_dput(dentry))) { 773 if (likely(fast_dput(dentry))) {
799 rcu_read_unlock(); 774 rcu_read_unlock();
@@ -827,8 +802,10 @@ repeat:
827 802
828kill_it: 803kill_it:
829 dentry = dentry_kill(dentry); 804 dentry = dentry_kill(dentry);
830 if (dentry) 805 if (dentry) {
806 cond_resched();
831 goto repeat; 807 goto repeat;
808 }
832} 809}
833EXPORT_SYMBOL(dput); 810EXPORT_SYMBOL(dput);
834 811
@@ -1593,6 +1570,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
1593{ 1570{
1594 struct dentry *dentry; 1571 struct dentry *dentry;
1595 char *dname; 1572 char *dname;
1573 int err;
1596 1574
1597 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL); 1575 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
1598 if (!dentry) 1576 if (!dentry)
@@ -1651,6 +1629,16 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
1651 INIT_LIST_HEAD(&dentry->d_child); 1629 INIT_LIST_HEAD(&dentry->d_child);
1652 d_set_d_op(dentry, dentry->d_sb->s_d_op); 1630 d_set_d_op(dentry, dentry->d_sb->s_d_op);
1653 1631
1632 if (dentry->d_op && dentry->d_op->d_init) {
1633 err = dentry->d_op->d_init(dentry);
1634 if (err) {
1635 if (dname_external(dentry))
1636 kfree(external_name(dentry));
1637 kmem_cache_free(dentry_cache, dentry);
1638 return NULL;
1639 }
1640 }
1641
1654 this_cpu_inc(nr_dentry); 1642 this_cpu_inc(nr_dentry);
1655 1643
1656 return dentry; 1644 return dentry;
@@ -1727,7 +1715,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
1727 DCACHE_OP_REVALIDATE | 1715 DCACHE_OP_REVALIDATE |
1728 DCACHE_OP_WEAK_REVALIDATE | 1716 DCACHE_OP_WEAK_REVALIDATE |
1729 DCACHE_OP_DELETE | 1717 DCACHE_OP_DELETE |
1730 DCACHE_OP_SELECT_INODE |
1731 DCACHE_OP_REAL)); 1718 DCACHE_OP_REAL));
1732 dentry->d_op = op; 1719 dentry->d_op = op;
1733 if (!op) 1720 if (!op)
@@ -1744,8 +1731,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
1744 dentry->d_flags |= DCACHE_OP_DELETE; 1731 dentry->d_flags |= DCACHE_OP_DELETE;
1745 if (op->d_prune) 1732 if (op->d_prune)
1746 dentry->d_flags |= DCACHE_OP_PRUNE; 1733 dentry->d_flags |= DCACHE_OP_PRUNE;
1747 if (op->d_select_inode)
1748 dentry->d_flags |= DCACHE_OP_SELECT_INODE;
1749 if (op->d_real) 1734 if (op->d_real)
1750 dentry->d_flags |= DCACHE_OP_REAL; 1735 dentry->d_flags |= DCACHE_OP_REAL;
1751 1736
@@ -1813,7 +1798,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
1813 raw_write_seqcount_begin(&dentry->d_seq); 1798 raw_write_seqcount_begin(&dentry->d_seq);
1814 __d_set_inode_and_type(dentry, inode, add_flags); 1799 __d_set_inode_and_type(dentry, inode, add_flags);
1815 raw_write_seqcount_end(&dentry->d_seq); 1800 raw_write_seqcount_end(&dentry->d_seq);
1816 __fsnotify_d_instantiate(dentry); 1801 fsnotify_update_flags(dentry);
1817 spin_unlock(&dentry->d_lock); 1802 spin_unlock(&dentry->d_lock);
1818} 1803}
1819 1804
@@ -2065,42 +2050,19 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
2065} 2050}
2066EXPORT_SYMBOL(d_add_ci); 2051EXPORT_SYMBOL(d_add_ci);
2067 2052
2068/*
2069 * Do the slow-case of the dentry name compare.
2070 *
2071 * Unlike the dentry_cmp() function, we need to atomically
2072 * load the name and length information, so that the
2073 * filesystem can rely on them, and can use the 'name' and
2074 * 'len' information without worrying about walking off the
2075 * end of memory etc.
2076 *
2077 * Thus the read_seqcount_retry() and the "duplicate" info
2078 * in arguments (the low-level filesystem should not look
2079 * at the dentry inode or name contents directly, since
2080 * rename can change them while we're in RCU mode).
2081 */
2082enum slow_d_compare {
2083 D_COMP_OK,
2084 D_COMP_NOMATCH,
2085 D_COMP_SEQRETRY,
2086};
2087 2053
2088static noinline enum slow_d_compare slow_dentry_cmp( 2054static inline bool d_same_name(const struct dentry *dentry,
2089 const struct dentry *parent, 2055 const struct dentry *parent,
2090 struct dentry *dentry, 2056 const struct qstr *name)
2091 unsigned int seq,
2092 const struct qstr *name)
2093{ 2057{
2094 int tlen = dentry->d_name.len; 2058 if (likely(!(parent->d_flags & DCACHE_OP_COMPARE))) {
2095 const char *tname = dentry->d_name.name; 2059 if (dentry->d_name.len != name->len)
2096 2060 return false;
2097 if (read_seqcount_retry(&dentry->d_seq, seq)) { 2061 return dentry_cmp(dentry, name->name, name->len) == 0;
2098 cpu_relax();
2099 return D_COMP_SEQRETRY;
2100 } 2062 }
2101 if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) 2063 return parent->d_op->d_compare(parent, dentry,
2102 return D_COMP_NOMATCH; 2064 dentry->d_name.len, dentry->d_name.name,
2103 return D_COMP_OK; 2065 name) == 0;
2104} 2066}
2105 2067
2106/** 2068/**
@@ -2179,6 +2141,9 @@ seqretry:
2179 * dentry compare, we will do seqretries until it is stable, 2141 * dentry compare, we will do seqretries until it is stable,
2180 * and if we end up with a successful lookup, we actually 2142 * and if we end up with a successful lookup, we actually
2181 * want to exit RCU lookup anyway. 2143 * want to exit RCU lookup anyway.
2144 *
2145 * Note that raw_seqcount_begin still *does* smp_rmb(), so
2146 * we are still guaranteed NUL-termination of ->d_name.name.
2182 */ 2147 */
2183 seq = raw_seqcount_begin(&dentry->d_seq); 2148 seq = raw_seqcount_begin(&dentry->d_seq);
2184 if (dentry->d_parent != parent) 2149 if (dentry->d_parent != parent)
@@ -2187,24 +2152,28 @@ seqretry:
2187 continue; 2152 continue;
2188 2153
2189 if (unlikely(parent->d_flags & DCACHE_OP_COMPARE)) { 2154 if (unlikely(parent->d_flags & DCACHE_OP_COMPARE)) {
2155 int tlen;
2156 const char *tname;
2190 if (dentry->d_name.hash != hashlen_hash(hashlen)) 2157 if (dentry->d_name.hash != hashlen_hash(hashlen))
2191 continue; 2158 continue;
2192 *seqp = seq; 2159 tlen = dentry->d_name.len;
2193 switch (slow_dentry_cmp(parent, dentry, seq, name)) { 2160 tname = dentry->d_name.name;
2194 case D_COMP_OK: 2161 /* we want a consistent (name,len) pair */
2195 return dentry; 2162 if (read_seqcount_retry(&dentry->d_seq, seq)) {
2196 case D_COMP_NOMATCH: 2163 cpu_relax();
2197 continue;
2198 default:
2199 goto seqretry; 2164 goto seqretry;
2200 } 2165 }
2166 if (parent->d_op->d_compare(parent, dentry,
2167 tlen, tname, name) != 0)
2168 continue;
2169 } else {
2170 if (dentry->d_name.hash_len != hashlen)
2171 continue;
2172 if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0)
2173 continue;
2201 } 2174 }
2202
2203 if (dentry->d_name.hash_len != hashlen)
2204 continue;
2205 *seqp = seq; 2175 *seqp = seq;
2206 if (!dentry_cmp(dentry, str, hashlen_len(hashlen))) 2176 return dentry;
2207 return dentry;
2208 } 2177 }
2209 return NULL; 2178 return NULL;
2210} 2179}
@@ -2252,9 +2221,7 @@ EXPORT_SYMBOL(d_lookup);
2252 */ 2221 */
2253struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) 2222struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
2254{ 2223{
2255 unsigned int len = name->len;
2256 unsigned int hash = name->hash; 2224 unsigned int hash = name->hash;
2257 const unsigned char *str = name->name;
2258 struct hlist_bl_head *b = d_hash(hash); 2225 struct hlist_bl_head *b = d_hash(hash);
2259 struct hlist_bl_node *node; 2226 struct hlist_bl_node *node;
2260 struct dentry *found = NULL; 2227 struct dentry *found = NULL;
@@ -2293,21 +2260,8 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
2293 if (d_unhashed(dentry)) 2260 if (d_unhashed(dentry))
2294 goto next; 2261 goto next;
2295 2262
2296 /* 2263 if (!d_same_name(dentry, parent, name))
2297 * It is safe to compare names since d_move() cannot 2264 goto next;
2298 * change the qstr (protected by d_lock).
2299 */
2300 if (parent->d_flags & DCACHE_OP_COMPARE) {
2301 int tlen = dentry->d_name.len;
2302 const char *tname = dentry->d_name.name;
2303 if (parent->d_op->d_compare(parent, dentry, tlen, tname, name))
2304 goto next;
2305 } else {
2306 if (dentry->d_name.len != len)
2307 goto next;
2308 if (dentry_cmp(dentry, str, len))
2309 goto next;
2310 }
2311 2265
2312 dentry->d_lockref.count++; 2266 dentry->d_lockref.count++;
2313 found = dentry; 2267 found = dentry;
@@ -2460,9 +2414,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
2460 const struct qstr *name, 2414 const struct qstr *name,
2461 wait_queue_head_t *wq) 2415 wait_queue_head_t *wq)
2462{ 2416{
2463 unsigned int len = name->len;
2464 unsigned int hash = name->hash; 2417 unsigned int hash = name->hash;
2465 const unsigned char *str = name->name;
2466 struct hlist_bl_head *b = in_lookup_hash(parent, hash); 2418 struct hlist_bl_head *b = in_lookup_hash(parent, hash);
2467 struct hlist_bl_node *node; 2419 struct hlist_bl_node *node;
2468 struct dentry *new = d_alloc(parent, name); 2420 struct dentry *new = d_alloc(parent, name);
@@ -2513,17 +2465,8 @@ retry:
2513 continue; 2465 continue;
2514 if (dentry->d_parent != parent) 2466 if (dentry->d_parent != parent)
2515 continue; 2467 continue;
2516 if (parent->d_flags & DCACHE_OP_COMPARE) { 2468 if (!d_same_name(dentry, parent, name))
2517 int tlen = dentry->d_name.len; 2469 continue;
2518 const char *tname = dentry->d_name.name;
2519 if (parent->d_op->d_compare(parent, dentry, tlen, tname, name))
2520 continue;
2521 } else {
2522 if (dentry->d_name.len != len)
2523 continue;
2524 if (dentry_cmp(dentry, str, len))
2525 continue;
2526 }
2527 hlist_bl_unlock(b); 2470 hlist_bl_unlock(b);
2528 /* now we can try to grab a reference */ 2471 /* now we can try to grab a reference */
2529 if (!lockref_get_not_dead(&dentry->d_lockref)) { 2472 if (!lockref_get_not_dead(&dentry->d_lockref)) {
@@ -2550,17 +2493,8 @@ retry:
2550 goto mismatch; 2493 goto mismatch;
2551 if (unlikely(d_unhashed(dentry))) 2494 if (unlikely(d_unhashed(dentry)))
2552 goto mismatch; 2495 goto mismatch;
2553 if (parent->d_flags & DCACHE_OP_COMPARE) { 2496 if (unlikely(!d_same_name(dentry, parent, name)))
2554 int tlen = dentry->d_name.len; 2497 goto mismatch;
2555 const char *tname = dentry->d_name.name;
2556 if (parent->d_op->d_compare(parent, dentry, tlen, tname, name))
2557 goto mismatch;
2558 } else {
2559 if (unlikely(dentry->d_name.len != len))
2560 goto mismatch;
2561 if (unlikely(dentry_cmp(dentry, str, len)))
2562 goto mismatch;
2563 }
2564 /* OK, it *is* a hashed match; return it */ 2498 /* OK, it *is* a hashed match; return it */
2565 spin_unlock(&dentry->d_lock); 2499 spin_unlock(&dentry->d_lock);
2566 dput(new); 2500 dput(new);
@@ -2613,7 +2547,7 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode)
2613 raw_write_seqcount_begin(&dentry->d_seq); 2547 raw_write_seqcount_begin(&dentry->d_seq);
2614 __d_set_inode_and_type(dentry, inode, add_flags); 2548 __d_set_inode_and_type(dentry, inode, add_flags);
2615 raw_write_seqcount_end(&dentry->d_seq); 2549 raw_write_seqcount_end(&dentry->d_seq);
2616 __fsnotify_d_instantiate(dentry); 2550 fsnotify_update_flags(dentry);
2617 } 2551 }
2618 _d_rehash(dentry); 2552 _d_rehash(dentry);
2619 if (dir) 2553 if (dir)
@@ -2656,8 +2590,6 @@ EXPORT_SYMBOL(d_add);
2656struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode) 2590struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode)
2657{ 2591{
2658 struct dentry *alias; 2592 struct dentry *alias;
2659 int len = entry->d_name.len;
2660 const char *name = entry->d_name.name;
2661 unsigned int hash = entry->d_name.hash; 2593 unsigned int hash = entry->d_name.hash;
2662 2594
2663 spin_lock(&inode->i_lock); 2595 spin_lock(&inode->i_lock);
@@ -2671,9 +2603,7 @@ struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode)
2671 continue; 2603 continue;
2672 if (alias->d_parent != entry->d_parent) 2604 if (alias->d_parent != entry->d_parent)
2673 continue; 2605 continue;
2674 if (alias->d_name.len != len) 2606 if (!d_same_name(alias, entry->d_parent, &entry->d_name))
2675 continue;
2676 if (dentry_cmp(alias, name, len))
2677 continue; 2607 continue;
2678 spin_lock(&alias->d_lock); 2608 spin_lock(&alias->d_lock);
2679 if (!d_unhashed(alias)) { 2609 if (!d_unhashed(alias)) {
@@ -2903,8 +2833,8 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
2903 list_move(&target->d_child, &target->d_parent->d_subdirs); 2833 list_move(&target->d_child, &target->d_parent->d_subdirs);
2904 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs); 2834 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs);
2905 if (exchange) 2835 if (exchange)
2906 fsnotify_d_move(target); 2836 fsnotify_update_flags(target);
2907 fsnotify_d_move(dentry); 2837 fsnotify_update_flags(dentry);
2908 } 2838 }
2909 2839
2910 write_seqcount_end(&target->d_seq); 2840 write_seqcount_end(&target->d_seq);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4bc1f68243c1..72361baf9da7 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -621,9 +621,6 @@ void debugfs_remove(struct dentry *dentry)
621 return; 621 return;
622 622
623 parent = dentry->d_parent; 623 parent = dentry->d_parent;
624 if (!parent || d_really_is_negative(parent))
625 return;
626
627 inode_lock(d_inode(parent)); 624 inode_lock(d_inode(parent));
628 ret = __debugfs_remove(dentry, parent); 625 ret = __debugfs_remove(dentry, parent);
629 inode_unlock(d_inode(parent)); 626 inode_unlock(d_inode(parent));
@@ -654,10 +651,6 @@ void debugfs_remove_recursive(struct dentry *dentry)
654 if (IS_ERR_OR_NULL(dentry)) 651 if (IS_ERR_OR_NULL(dentry))
655 return; 652 return;
656 653
657 parent = dentry->d_parent;
658 if (!parent || d_really_is_negative(parent))
659 return;
660
661 parent = dentry; 654 parent = dentry;
662 down: 655 down:
663 inode_lock(d_inode(parent)); 656 inode_lock(d_inode(parent));
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 11562161e24a..f418f55c2bbe 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2350,7 +2350,6 @@ static int ext4_mb_seq_groups_open(struct inode *inode, struct file *file)
2350} 2350}
2351 2351
2352const struct file_operations ext4_seq_mb_groups_fops = { 2352const struct file_operations ext4_seq_mb_groups_fops = {
2353 .owner = THIS_MODULE,
2354 .open = ext4_mb_seq_groups_open, 2353 .open = ext4_mb_seq_groups_open,
2355 .read = seq_read, 2354 .read = seq_read,
2356 .llseek = seq_lseek, 2355 .llseek = seq_lseek,
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 1420a3c614af..73bcfd41f5f2 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -359,7 +359,6 @@ static int name##_open(struct inode *inode, struct file *file) \
359} \ 359} \
360\ 360\
361static const struct file_operations ext4_seq_##name##_fops = { \ 361static const struct file_operations ext4_seq_##name##_fops = { \
362 .owner = THIS_MODULE, \
363 .open = name##_open, \ 362 .open = name##_open, \
364 .read = seq_read, \ 363 .read = seq_read, \
365 .llseek = seq_lseek, \ 364 .llseek = seq_lseek, \
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b97c065cbe74..1b86d3f638ef 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -961,7 +961,6 @@ static int _name##_open_fs(struct inode *inode, struct file *file) \
961} \ 961} \
962 \ 962 \
963static const struct file_operations f2fs_seq_##_name##_fops = { \ 963static const struct file_operations f2fs_seq_##_name##_fops = { \
964 .owner = THIS_MODULE, \
965 .open = _name##_open_fs, \ 964 .open = _name##_open_fs, \
966 .read = seq_read, \ 965 .read = seq_read, \
967 .llseek = seq_lseek, \ 966 .llseek = seq_lseek, \
diff --git a/fs/fscache/histogram.c b/fs/fscache/histogram.c
index 7d637e2335fd..15a3d042247e 100644
--- a/fs/fscache/histogram.c
+++ b/fs/fscache/histogram.c
@@ -99,7 +99,6 @@ static int fscache_histogram_open(struct inode *inode, struct file *file)
99} 99}
100 100
101const struct file_operations fscache_histogram_fops = { 101const struct file_operations fscache_histogram_fops = {
102 .owner = THIS_MODULE,
103 .open = fscache_histogram_open, 102 .open = fscache_histogram_open,
104 .read = seq_read, 103 .read = seq_read,
105 .llseek = seq_lseek, 104 .llseek = seq_lseek,
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index 6b028b7c4250..5d5ddaa84b21 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -404,7 +404,6 @@ static int fscache_objlist_release(struct inode *inode, struct file *file)
404} 404}
405 405
406const struct file_operations fscache_objlist_fops = { 406const struct file_operations fscache_objlist_fops = {
407 .owner = THIS_MODULE,
408 .open = fscache_objlist_open, 407 .open = fscache_objlist_open,
409 .read = seq_read, 408 .read = seq_read,
410 .llseek = seq_lseek, 409 .llseek = seq_lseek,
diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
index 7cfa0aacdf6d..7ac6e839b065 100644
--- a/fs/fscache/stats.c
+++ b/fs/fscache/stats.c
@@ -295,7 +295,6 @@ static int fscache_stats_open(struct inode *inode, struct file *file)
295} 295}
296 296
297const struct file_operations fscache_stats_fops = { 297const struct file_operations fscache_stats_fops = {
298 .owner = THIS_MODULE,
299 .open = fscache_stats_open, 298 .open = fscache_stats_open,
300 .read = seq_read, 299 .read = seq_read,
301 .llseek = seq_lseek, 300 .llseek = seq_lseek,
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 8eed66af5b82..02a3845363f7 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -128,7 +128,7 @@ static ssize_t hfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
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_inode(file)->i_mapping->host; 131 struct inode *inode = mapping->host;
132 size_t count = iov_iter_count(iter); 132 size_t count = iov_iter_count(iter);
133 ssize_t ret; 133 ssize_t ret;
134 134
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index ef9fefe364a6..19462d773fe2 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -126,7 +126,7 @@ static ssize_t hfsplus_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
126{ 126{
127 struct file *file = iocb->ki_filp; 127 struct file *file = iocb->ki_filp;
128 struct address_space *mapping = file->f_mapping; 128 struct address_space *mapping = file->f_mapping;
129 struct inode *inode = file_inode(file)->i_mapping->host; 129 struct inode *inode = mapping->host;
130 size_t count = iov_iter_count(iter); 130 size_t count = iov_iter_count(iter);
131 ssize_t ret; 131 ssize_t ret;
132 132
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index 2ce5b75ee9a5..44af14b2e916 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -361,7 +361,6 @@ static int zisofs_readpage(struct file *file, struct page *page)
361 361
362const struct address_space_operations zisofs_aops = { 362const struct address_space_operations zisofs_aops = {
363 .readpage = zisofs_readpage, 363 .readpage = zisofs_readpage,
364 /* No sync_page operation supported? */
365 /* No bmap operation supported */ 364 /* No bmap operation supported */
366}; 365};
367 366
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index dd824d9b0b1a..a37eb5f8cbc0 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -58,7 +58,6 @@ static ssize_t jfs_loglevel_proc_write(struct file *file,
58} 58}
59 59
60static const struct file_operations jfs_loglevel_proc_fops = { 60static const struct file_operations jfs_loglevel_proc_fops = {
61 .owner = THIS_MODULE,
62 .open = jfs_loglevel_proc_open, 61 .open = jfs_loglevel_proc_open,
63 .read = seq_read, 62 .read = seq_read,
64 .llseek = seq_lseek, 63 .llseek = seq_lseek,
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index a74752146ec9..a21ea8b3e5fa 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -2517,7 +2517,6 @@ static int jfs_lmstats_proc_open(struct inode *inode, struct file *file)
2517} 2517}
2518 2518
2519const struct file_operations jfs_lmstats_proc_fops = { 2519const struct file_operations jfs_lmstats_proc_fops = {
2520 .owner = THIS_MODULE,
2521 .open = jfs_lmstats_proc_open, 2520 .open = jfs_lmstats_proc_open,
2522 .read = seq_read, 2521 .read = seq_read,
2523 .llseek = seq_lseek, 2522 .llseek = seq_lseek,
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index e7fa9e513040..489aaa1403e5 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -830,7 +830,6 @@ static int jfs_mpstat_proc_open(struct inode *inode, struct file *file)
830} 830}
831 831
832const struct file_operations jfs_mpstat_proc_fops = { 832const struct file_operations jfs_mpstat_proc_fops = {
833 .owner = THIS_MODULE,
834 .open = jfs_mpstat_proc_open, 833 .open = jfs_mpstat_proc_open,
835 .read = seq_read, 834 .read = seq_read,
836 .llseek = seq_lseek, 835 .llseek = seq_lseek,
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index eddf2b6eda85..2e58978d6f45 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -3040,7 +3040,6 @@ static int jfs_txanchor_proc_open(struct inode *inode, struct file *file)
3040} 3040}
3041 3041
3042const struct file_operations jfs_txanchor_proc_fops = { 3042const struct file_operations jfs_txanchor_proc_fops = {
3043 .owner = THIS_MODULE,
3044 .open = jfs_txanchor_proc_open, 3043 .open = jfs_txanchor_proc_open,
3045 .read = seq_read, 3044 .read = seq_read,
3046 .llseek = seq_lseek, 3045 .llseek = seq_lseek,
@@ -3081,7 +3080,6 @@ static int jfs_txstats_proc_open(struct inode *inode, struct file *file)
3081} 3080}
3082 3081
3083const struct file_operations jfs_txstats_proc_fops = { 3082const struct file_operations jfs_txstats_proc_fops = {
3084 .owner = THIS_MODULE,
3085 .open = jfs_txstats_proc_open, 3083 .open = jfs_txstats_proc_open,
3086 .read = seq_read, 3084 .read = seq_read,
3087 .llseek = seq_lseek, 3085 .llseek = seq_lseek,
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 5ad7748860ce..5cde6d2fcfca 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -3894,7 +3894,6 @@ static int jfs_xtstat_proc_open(struct inode *inode, struct file *file)
3894} 3894}
3895 3895
3896const struct file_operations jfs_xtstat_proc_fops = { 3896const struct file_operations jfs_xtstat_proc_fops = {
3897 .owner = THIS_MODULE,
3898 .open = jfs_xtstat_proc_open, 3897 .open = jfs_xtstat_proc_open,
3899 .read = seq_read, 3898 .read = seq_read,
3900 .llseek = seq_lseek, 3899 .llseek = seq_lseek,
diff --git a/fs/lockd/procfs.c b/fs/lockd/procfs.c
index 2a0a98480e39..8f72cb237ef3 100644
--- a/fs/lockd/procfs.c
+++ b/fs/lockd/procfs.c
@@ -64,7 +64,6 @@ static const struct file_operations lockd_end_grace_operations = {
64 .read = nlm_end_grace_read, 64 .read = nlm_end_grace_read,
65 .llseek = default_llseek, 65 .llseek = default_llseek,
66 .release = simple_transaction_release, 66 .release = simple_transaction_release,
67 .owner = THIS_MODULE,
68}; 67};
69 68
70int __init 69int __init
diff --git a/fs/namei.c b/fs/namei.c
index 7cb9be3e200a..ecb0b439747e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1449,9 +1449,8 @@ static int follow_dotdot(struct nameidata *nd)
1449} 1449}
1450 1450
1451/* 1451/*
1452 * This looks up the name in dcache, possibly revalidates the old dentry and 1452 * This looks up the name in dcache and possibly revalidates the found dentry.
1453 * allocates a new one if not found or not valid. In the need_lookup argument 1453 * NULL is returned if the dentry does not exist in the cache.
1454 * returns whether i_op->lookup is necessary.
1455 */ 1454 */
1456static struct dentry *lookup_dcache(const struct qstr *name, 1455static struct dentry *lookup_dcache(const struct qstr *name,
1457 struct dentry *dir, 1456 struct dentry *dir,
@@ -4336,7 +4335,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4336 * Check source == target. 4335 * Check source == target.
4337 * On overlayfs need to look at underlying inodes. 4336 * On overlayfs need to look at underlying inodes.
4338 */ 4337 */
4339 if (vfs_select_inode(old_dentry, 0) == vfs_select_inode(new_dentry, 0)) 4338 if (d_real_inode(old_dentry) == d_real_inode(new_dentry))
4340 return 0; 4339 return 0;
4341 4340
4342 error = may_delete(old_dir, old_dentry, is_dir); 4341 error = may_delete(old_dir, old_dentry, is_dir);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 0c96528db94a..487c5607d52f 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1102,7 +1102,6 @@ static const struct file_operations nfs_server_list_fops = {
1102 .read = seq_read, 1102 .read = seq_read,
1103 .llseek = seq_lseek, 1103 .llseek = seq_lseek,
1104 .release = seq_release_net, 1104 .release = seq_release_net,
1105 .owner = THIS_MODULE,
1106}; 1105};
1107 1106
1108static int nfs_volume_list_open(struct inode *inode, struct file *file); 1107static int nfs_volume_list_open(struct inode *inode, struct file *file);
@@ -1123,7 +1122,6 @@ static const struct file_operations nfs_volume_list_fops = {
1123 .read = seq_read, 1122 .read = seq_read,
1124 .llseek = seq_lseek, 1123 .llseek = seq_lseek,
1125 .release = seq_release_net, 1124 .release = seq_release_net,
1126 .owner = THIS_MODULE,
1127}; 1125};
1128 1126
1129/* 1127/*
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 411375f3c585..baaa38859899 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -734,7 +734,7 @@ struct page *get_cache_page(nfs_readdir_descriptor_t *desc)
734 struct page *page; 734 struct page *page;
735 735
736 for (;;) { 736 for (;;) {
737 page = read_cache_page(file_inode(desc->file)->i_mapping, 737 page = read_cache_page(desc->file->f_mapping,
738 desc->page_index, (filler_t *)nfs_readdir_filler, desc); 738 desc->page_index, (filler_t *)nfs_readdir_filler, desc);
739 if (IS_ERR(page) || grab_page(page)) 739 if (IS_ERR(page) || grab_page(page))
740 break; 740 break;
@@ -1397,19 +1397,18 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
1397 if (IS_ERR(label)) 1397 if (IS_ERR(label))
1398 goto out; 1398 goto out;
1399 1399
1400 /* Protect against concurrent sillydeletes */
1401 trace_nfs_lookup_enter(dir, dentry, flags); 1400 trace_nfs_lookup_enter(dir, dentry, flags);
1402 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); 1401 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
1403 if (error == -ENOENT) 1402 if (error == -ENOENT)
1404 goto no_entry; 1403 goto no_entry;
1405 if (error < 0) { 1404 if (error < 0) {
1406 res = ERR_PTR(error); 1405 res = ERR_PTR(error);
1407 goto out_unblock_sillyrename; 1406 goto out_label;
1408 } 1407 }
1409 inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label); 1408 inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label);
1410 res = ERR_CAST(inode); 1409 res = ERR_CAST(inode);
1411 if (IS_ERR(res)) 1410 if (IS_ERR(res))
1412 goto out_unblock_sillyrename; 1411 goto out_label;
1413 1412
1414 /* Success: notify readdir to use READDIRPLUS */ 1413 /* Success: notify readdir to use READDIRPLUS */
1415 nfs_advise_use_readdirplus(dir); 1414 nfs_advise_use_readdirplus(dir);
@@ -1418,11 +1417,11 @@ no_entry:
1418 res = d_splice_alias(inode, dentry); 1417 res = d_splice_alias(inode, dentry);
1419 if (res != NULL) { 1418 if (res != NULL) {
1420 if (IS_ERR(res)) 1419 if (IS_ERR(res))
1421 goto out_unblock_sillyrename; 1420 goto out_label;
1422 dentry = res; 1421 dentry = res;
1423 } 1422 }
1424 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1423 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1425out_unblock_sillyrename: 1424out_label:
1426 trace_nfs_lookup_exit(dir, dentry, flags, error); 1425 trace_nfs_lookup_exit(dir, dentry, flags, error);
1427 nfs4_label_free(label); 1426 nfs4_label_free(label);
1428out: 1427out:
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index c7326c2af2c3..e6210ead71d0 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -244,9 +244,7 @@ static int nfs_direct_cmp_commit_data_verf(struct nfs_direct_req *dreq,
244/** 244/**
245 * nfs_direct_IO - NFS address space operation for direct I/O 245 * nfs_direct_IO - NFS address space operation for direct I/O
246 * @iocb: target I/O control block 246 * @iocb: target I/O control block
247 * @iov: array of vectors that define I/O buffer 247 * @iter: I/O buffer
248 * @pos: offset in file to begin the operation
249 * @nr_segs: size of iovec array
250 * 248 *
251 * The presence of this routine in the address space ops vector means 249 * The presence of this routine in the address space ops vector means
252 * the NFS client supports direct I/O. However, for most direct IO, we 250 * the NFS client supports direct I/O. However, for most direct IO, we
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 9690cb4dd588..e7787777620e 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -158,7 +158,6 @@ static const struct file_operations exports_proc_operations = {
158 .read = seq_read, 158 .read = seq_read,
159 .llseek = seq_lseek, 159 .llseek = seq_lseek,
160 .release = seq_release, 160 .release = seq_release,
161 .owner = THIS_MODULE,
162}; 161};
163 162
164static int exports_nfsd_open(struct inode *inode, struct file *file) 163static int exports_nfsd_open(struct inode *inode, struct file *file)
@@ -171,7 +170,6 @@ static const struct file_operations exports_nfsd_operations = {
171 .read = seq_read, 170 .read = seq_read,
172 .llseek = seq_lseek, 171 .llseek = seq_lseek,
173 .release = seq_release, 172 .release = seq_release,
174 .owner = THIS_MODULE,
175}; 173};
176 174
177static int export_features_show(struct seq_file *m, void *v) 175static int export_features_show(struct seq_file *m, void *v)
@@ -217,7 +215,6 @@ static const struct file_operations pool_stats_operations = {
217 .read = seq_read, 215 .read = seq_read,
218 .llseek = seq_lseek, 216 .llseek = seq_lseek,
219 .release = nfsd_pool_stats_release, 217 .release = nfsd_pool_stats_release,
220 .owner = THIS_MODULE,
221}; 218};
222 219
223static struct file_operations reply_cache_stats_operations = { 220static struct file_operations reply_cache_stats_operations = {
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index cd90878a76aa..d97338bb6a39 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -84,7 +84,6 @@ static int nfsd_proc_open(struct inode *inode, struct file *file)
84} 84}
85 85
86static const struct file_operations nfsd_proc_fops = { 86static const struct file_operations nfsd_proc_fops = {
87 .owner = THIS_MODULE,
88 .open = nfsd_proc_open, 87 .open = nfsd_proc_open,
89 .read = seq_read, 88 .read = seq_read,
90 .llseek = seq_lseek, 89 .llseek = seq_lseek,
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index f40972d6df90..e01287c964a8 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1854,7 +1854,7 @@ int ntfs_read_inode_mount(struct inode *vi)
1854 /* Need this to sanity check attribute list references to $MFT. */ 1854 /* Need this to sanity check attribute list references to $MFT. */
1855 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number); 1855 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number);
1856 1856
1857 /* Provides readpage() and sync_page() for map_mft_record(). */ 1857 /* Provides readpage() for map_mft_record(). */
1858 vi->i_mapping->a_ops = &ntfs_mst_aops; 1858 vi->i_mapping->a_ops = &ntfs_mst_aops;
1859 1859
1860 ctx = ntfs_attr_get_search_ctx(ni, m); 1860 ctx = ntfs_attr_get_search_ctx(ni, m);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index e97a37179614..af2adfcb0f6f 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2426,7 +2426,7 @@ static int ocfs2_dio_end_io(struct kiocb *iocb,
2426static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) 2426static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
2427{ 2427{
2428 struct file *file = iocb->ki_filp; 2428 struct file *file = iocb->ki_filp;
2429 struct inode *inode = file_inode(file)->i_mapping->host; 2429 struct inode *inode = file->f_mapping->host;
2430 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 2430 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2431 get_block_t *get_block; 2431 get_block_t *get_block;
2432 2432
diff --git a/fs/open.c b/fs/open.c
index 93ae3cdee4ab..bf66cf1a9f5c 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -840,13 +840,13 @@ EXPORT_SYMBOL(file_path);
840int vfs_open(const struct path *path, struct file *file, 840int vfs_open(const struct path *path, struct file *file,
841 const struct cred *cred) 841 const struct cred *cred)
842{ 842{
843 struct inode *inode = vfs_select_inode(path->dentry, file->f_flags); 843 struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags);
844 844
845 if (IS_ERR(inode)) 845 if (IS_ERR(dentry))
846 return PTR_ERR(inode); 846 return PTR_ERR(dentry);
847 847
848 file->f_path = *path; 848 file->f_path = *path;
849 return do_dentry_open(file, inode, NULL, cred); 849 return do_dentry_open(file, d_backing_inode(dentry), NULL, cred);
850} 850}
851 851
852struct file *dentry_open(const struct path *path, int flags, 852struct file *dentry_open(const struct path *path, int flags,
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 8f2fa94cc4f6..2e63e6d0a68e 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -291,7 +291,7 @@ int orangefs_permission(struct inode *inode, int mask)
291} 291}
292 292
293/* ORANGEDS2 implementation of VFS inode operations for files */ 293/* ORANGEDS2 implementation of VFS inode operations for files */
294struct inode_operations orangefs_file_inode_operations = { 294const struct inode_operations orangefs_file_inode_operations = {
295 .get_acl = orangefs_get_acl, 295 .get_acl = orangefs_get_acl,
296 .set_acl = orangefs_set_acl, 296 .set_acl = orangefs_set_acl,
297 .setattr = orangefs_setattr, 297 .setattr = orangefs_setattr,
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 5a60c508af4e..7e8dfa97c44a 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -405,12 +405,8 @@ static int orangefs_rename(struct inode *old_dir,
405 int ret; 405 int ret;
406 406
407 gossip_debug(GOSSIP_NAME_DEBUG, 407 gossip_debug(GOSSIP_NAME_DEBUG,
408 "orangefs_rename: called (%s/%s => %s/%s) ct=%d\n", 408 "orangefs_rename: called (%pd2 => %pd2) ct=%d\n",
409 old_dentry->d_parent->d_name.name, 409 old_dentry, new_dentry, d_count(new_dentry));
410 old_dentry->d_name.name,
411 new_dentry->d_parent->d_name.name,
412 new_dentry->d_name.name,
413 d_count(new_dentry));
414 410
415 new_op = op_alloc(ORANGEFS_VFS_OP_RENAME); 411 new_op = op_alloc(ORANGEFS_VFS_OP_RENAME);
416 if (!new_op) 412 if (!new_op)
@@ -442,7 +438,7 @@ static int orangefs_rename(struct inode *old_dir,
442} 438}
443 439
444/* ORANGEFS implementation of VFS inode operations for directories */ 440/* ORANGEFS implementation of VFS inode operations for directories */
445struct inode_operations orangefs_dir_inode_operations = { 441const struct inode_operations orangefs_dir_inode_operations = {
446 .lookup = orangefs_lookup, 442 .lookup = orangefs_lookup,
447 .get_acl = orangefs_get_acl, 443 .get_acl = orangefs_get_acl,
448 .set_acl = orangefs_set_acl, 444 .set_acl = orangefs_set_acl,
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index c1181e5529af..4b6e132d5a0f 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -557,10 +557,10 @@ extern int hash_table_size;
557 557
558extern const struct address_space_operations orangefs_address_operations; 558extern const struct address_space_operations orangefs_address_operations;
559extern struct backing_dev_info orangefs_backing_dev_info; 559extern struct backing_dev_info orangefs_backing_dev_info;
560extern struct inode_operations orangefs_file_inode_operations; 560extern const struct inode_operations orangefs_file_inode_operations;
561extern const struct file_operations orangefs_file_operations; 561extern const struct file_operations orangefs_file_operations;
562extern struct inode_operations orangefs_symlink_inode_operations; 562extern const struct inode_operations orangefs_symlink_inode_operations;
563extern struct inode_operations orangefs_dir_inode_operations; 563extern const struct inode_operations orangefs_dir_inode_operations;
564extern const struct file_operations orangefs_dir_operations; 564extern const struct file_operations orangefs_dir_operations;
565extern const struct dentry_operations orangefs_dentry_operations; 565extern const struct dentry_operations orangefs_dentry_operations;
566extern const struct file_operations orangefs_devreq_file_operations; 566extern const struct file_operations orangefs_devreq_file_operations;
diff --git a/fs/orangefs/symlink.c b/fs/orangefs/symlink.c
index 6418dd638680..8fecf823f5ba 100644
--- a/fs/orangefs/symlink.c
+++ b/fs/orangefs/symlink.c
@@ -8,7 +8,7 @@
8#include "orangefs-kernel.h" 8#include "orangefs-kernel.h"
9#include "orangefs-bufmap.h" 9#include "orangefs-bufmap.h"
10 10
11struct inode_operations orangefs_symlink_inode_operations = { 11const struct inode_operations orangefs_symlink_inode_operations = {
12 .readlink = generic_readlink, 12 .readlink = generic_readlink,
13 .get_link = simple_get_link, 13 .get_link = simple_get_link,
14 .setattr = orangefs_setattr, 14 .setattr = orangefs_setattr,
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index d1cdc60dd68f..d554e86abbe3 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -351,36 +351,25 @@ static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
351 return true; 351 return true;
352} 352}
353 353
354struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags) 354int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags)
355{ 355{
356 int err; 356 int err = 0;
357 struct path realpath; 357 struct path realpath;
358 enum ovl_path_type type; 358 enum ovl_path_type type;
359 359
360 if (d_is_dir(dentry))
361 return d_backing_inode(dentry);
362
363 type = ovl_path_real(dentry, &realpath); 360 type = ovl_path_real(dentry, &realpath);
364 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) { 361 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
365 err = ovl_want_write(dentry); 362 err = ovl_want_write(dentry);
366 if (err) 363 if (!err) {
367 return ERR_PTR(err); 364 if (file_flags & O_TRUNC)
368 365 err = ovl_copy_up_truncate(dentry);
369 if (file_flags & O_TRUNC) 366 else
370 err = ovl_copy_up_truncate(dentry); 367 err = ovl_copy_up(dentry);
371 else 368 ovl_drop_write(dentry);
372 err = ovl_copy_up(dentry); 369 }
373 ovl_drop_write(dentry);
374 if (err)
375 return ERR_PTR(err);
376
377 ovl_path_upper(dentry, &realpath);
378 } 370 }
379 371
380 if (realpath.dentry->d_flags & DCACHE_OP_SELECT_INODE) 372 return err;
381 return realpath.dentry->d_op->d_select_inode(realpath.dentry, file_flags);
382
383 return d_backing_inode(realpath.dentry);
384} 373}
385 374
386static const struct inode_operations ovl_file_inode_operations = { 375static const struct inode_operations ovl_file_inode_operations = {
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index cfbca53590d0..0d3f2ad45708 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -179,7 +179,7 @@ ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
179 const char *name, void *value, size_t size); 179 const char *name, void *value, size_t size);
180ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); 180ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
181int ovl_removexattr(struct dentry *dentry, const char *name); 181int ovl_removexattr(struct dentry *dentry, const char *name);
182struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags); 182int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags);
183 183
184struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, 184struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
185 struct ovl_entry *oe); 185 struct ovl_entry *oe);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 9a7693d5f8ff..5e254b3a8c56 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -304,7 +304,9 @@ static void ovl_dentry_release(struct dentry *dentry)
304 } 304 }
305} 305}
306 306
307static struct dentry *ovl_d_real(struct dentry *dentry, struct inode *inode) 307static struct dentry *ovl_d_real(struct dentry *dentry,
308 const struct inode *inode,
309 unsigned int open_flags)
308{ 310{
309 struct dentry *real; 311 struct dentry *real;
310 312
@@ -314,6 +316,16 @@ static struct dentry *ovl_d_real(struct dentry *dentry, struct inode *inode)
314 goto bug; 316 goto bug;
315 } 317 }
316 318
319 if (d_is_negative(dentry))
320 return dentry;
321
322 if (open_flags) {
323 int err = ovl_open_maybe_copy_up(dentry, open_flags);
324
325 if (err)
326 return ERR_PTR(err);
327 }
328
317 real = ovl_dentry_upper(dentry); 329 real = ovl_dentry_upper(dentry);
318 if (real && (!inode || inode == d_inode(real))) 330 if (real && (!inode || inode == d_inode(real)))
319 return real; 331 return real;
@@ -326,9 +338,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry, struct inode *inode)
326 return real; 338 return real;
327 339
328 /* Handle recursion */ 340 /* Handle recursion */
329 if (real->d_flags & DCACHE_OP_REAL) 341 return d_real(real, inode, open_flags);
330 return real->d_op->d_real(real, inode);
331
332bug: 342bug:
333 WARN(1, "ovl_d_real(%pd4, %s:%lu\n): real dentry not found\n", dentry, 343 WARN(1, "ovl_d_real(%pd4, %s:%lu\n): real dentry not found\n", dentry,
334 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0); 344 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
@@ -378,13 +388,11 @@ static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
378 388
379static const struct dentry_operations ovl_dentry_operations = { 389static const struct dentry_operations ovl_dentry_operations = {
380 .d_release = ovl_dentry_release, 390 .d_release = ovl_dentry_release,
381 .d_select_inode = ovl_d_select_inode,
382 .d_real = ovl_d_real, 391 .d_real = ovl_d_real,
383}; 392};
384 393
385static const struct dentry_operations ovl_reval_dentry_operations = { 394static const struct dentry_operations ovl_reval_dentry_operations = {
386 .d_release = ovl_dentry_release, 395 .d_release = ovl_dentry_release,
387 .d_select_inode = ovl_d_select_inode,
388 .d_real = ovl_d_real, 396 .d_real = ovl_d_real,
389 .d_revalidate = ovl_dentry_revalidate, 397 .d_revalidate = ovl_dentry_revalidate,
390 .d_weak_revalidate = ovl_dentry_weak_revalidate, 398 .d_weak_revalidate = ovl_dentry_weak_revalidate,
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 4a0e48f92104..ad40b64c5e2f 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -541,9 +541,6 @@ void tracefs_remove(struct dentry *dentry)
541 return; 541 return;
542 542
543 parent = dentry->d_parent; 543 parent = dentry->d_parent;
544 if (!parent || !parent->d_inode)
545 return;
546
547 inode_lock(parent->d_inode); 544 inode_lock(parent->d_inode);
548 ret = __tracefs_remove(dentry, parent); 545 ret = __tracefs_remove(dentry, parent);
549 inode_unlock(parent->d_inode); 546 inode_unlock(parent->d_inode);
@@ -566,10 +563,6 @@ void tracefs_remove_recursive(struct dentry *dentry)
566 if (IS_ERR_OR_NULL(dentry)) 563 if (IS_ERR_OR_NULL(dentry))
567 return; 564 return;
568 565
569 parent = dentry->d_parent;
570 if (!parent || !parent->d_inode)
571 return;
572
573 parent = dentry; 566 parent = dentry;
574 down: 567 down:
575 inode_lock(parent->d_inode); 568 inode_lock(parent->d_inode);
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 57dcceda17d6..fa3bda1a860f 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -279,12 +279,6 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr,
279 de = (struct ufs_dir_entry *) kaddr; 279 de = (struct ufs_dir_entry *) kaddr;
280 kaddr += ufs_last_byte(dir, n) - reclen; 280 kaddr += ufs_last_byte(dir, n) - reclen;
281 while ((char *) de <= kaddr) { 281 while ((char *) de <= kaddr) {
282 if (de->d_reclen == 0) {
283 ufs_error(dir->i_sb, __func__,
284 "zero-length directory entry");
285 ufs_put_page(page);
286 goto out;
287 }
288 if (ufs_match(sb, namelen, name, de)) 282 if (ufs_match(sb, namelen, name, de))
289 goto found; 283 goto found;
290 de = ufs_next_entry(sb, de); 284 de = ufs_next_entry(sb, de);
@@ -414,11 +408,8 @@ ufs_validate_entry(struct super_block *sb, char *base,
414{ 408{
415 struct ufs_dir_entry *de = (struct ufs_dir_entry*)(base + offset); 409 struct ufs_dir_entry *de = (struct ufs_dir_entry*)(base + offset);
416 struct ufs_dir_entry *p = (struct ufs_dir_entry*)(base + (offset&mask)); 410 struct ufs_dir_entry *p = (struct ufs_dir_entry*)(base + (offset&mask));
417 while ((char*)p < (char*)de) { 411 while ((char*)p < (char*)de)
418 if (p->d_reclen == 0)
419 break;
420 p = ufs_next_entry(sb, p); 412 p = ufs_next_entry(sb, p);
421 }
422 return (char *)p - base; 413 return (char *)p - base;
423} 414}
424 415
@@ -469,12 +460,6 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
469 de = (struct ufs_dir_entry *)(kaddr+offset); 460 de = (struct ufs_dir_entry *)(kaddr+offset);
470 limit = kaddr + ufs_last_byte(inode, n) - UFS_DIR_REC_LEN(1); 461 limit = kaddr + ufs_last_byte(inode, n) - UFS_DIR_REC_LEN(1);
471 for ( ;(char*)de <= limit; de = ufs_next_entry(sb, de)) { 462 for ( ;(char*)de <= limit; de = ufs_next_entry(sb, de)) {
472 if (de->d_reclen == 0) {
473 ufs_error(sb, __func__,
474 "zero-length directory entry");
475 ufs_put_page(page);
476 return -EIO;
477 }
478 if (de->d_ino) { 463 if (de->d_ino) {
479 unsigned char d_type = DT_UNKNOWN; 464 unsigned char d_type = DT_UNKNOWN;
480 465
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index 8686df6c7609..d266e835ecc3 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -128,7 +128,6 @@ static int xqm_proc_open(struct inode *inode, struct file *file)
128} 128}
129 129
130static const struct file_operations xqm_proc_fops = { 130static const struct file_operations xqm_proc_fops = {
131 .owner = THIS_MODULE,
132 .open = xqm_proc_open, 131 .open = xqm_proc_open,
133 .read = seq_read, 132 .read = seq_read,
134 .llseek = seq_lseek, 133 .llseek = seq_lseek,
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index f53fa055021a..98044a8d1487 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -133,14 +133,15 @@ struct dentry_operations {
133 int (*d_compare)(const struct dentry *, const struct dentry *, 133 int (*d_compare)(const struct dentry *, const struct dentry *,
134 unsigned int, const char *, const struct qstr *); 134 unsigned int, const char *, const struct qstr *);
135 int (*d_delete)(const struct dentry *); 135 int (*d_delete)(const struct dentry *);
136 int (*d_init)(struct dentry *);
136 void (*d_release)(struct dentry *); 137 void (*d_release)(struct dentry *);
137 void (*d_prune)(struct dentry *); 138 void (*d_prune)(struct dentry *);
138 void (*d_iput)(struct dentry *, struct inode *); 139 void (*d_iput)(struct dentry *, struct inode *);
139 char *(*d_dname)(struct dentry *, char *, int); 140 char *(*d_dname)(struct dentry *, char *, int);
140 struct vfsmount *(*d_automount)(struct path *); 141 struct vfsmount *(*d_automount)(struct path *);
141 int (*d_manage)(struct dentry *, bool); 142 int (*d_manage)(struct dentry *, bool);
142 struct inode *(*d_select_inode)(struct dentry *, unsigned); 143 struct dentry *(*d_real)(struct dentry *, const struct inode *,
143 struct dentry *(*d_real)(struct dentry *, struct inode *); 144 unsigned int);
144} ____cacheline_aligned; 145} ____cacheline_aligned;
145 146
146/* 147/*
@@ -206,10 +207,8 @@ struct dentry_operations {
206 207
207#define DCACHE_MAY_FREE 0x00800000 208#define DCACHE_MAY_FREE 0x00800000
208#define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */ 209#define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */
209#define DCACHE_OP_SELECT_INODE 0x02000000 /* Unioned entry: dcache op selects inode */ 210#define DCACHE_ENCRYPTED_WITH_KEY 0x02000000 /* dir is encrypted with a valid key */
210 211#define DCACHE_OP_REAL 0x04000000
211#define DCACHE_ENCRYPTED_WITH_KEY 0x04000000 /* dir is encrypted with a valid key */
212#define DCACHE_OP_REAL 0x08000000
213 212
214#define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */ 213#define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */
215#define DCACHE_DENTRY_CURSOR 0x20000000 214#define DCACHE_DENTRY_CURSOR 0x20000000
@@ -557,25 +556,27 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
557 return upper; 556 return upper;
558} 557}
559 558
560static inline struct dentry *d_real(struct dentry *dentry) 559/**
560 * d_real - Return the real dentry
561 * @dentry: the dentry to query
562 * @inode: inode to select the dentry from multiple layers (can be NULL)
563 * @flags: open flags to control copy-up behavior
564 *
565 * If dentry is on an union/overlay, then return the underlying, real dentry.
566 * Otherwise return the dentry itself.
567 *
568 * See also: Documentation/filesystems/vfs.txt
569 */
570static inline struct dentry *d_real(struct dentry *dentry,
571 const struct inode *inode,
572 unsigned int flags)
561{ 573{
562 if (unlikely(dentry->d_flags & DCACHE_OP_REAL)) 574 if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
563 return dentry->d_op->d_real(dentry, NULL); 575 return dentry->d_op->d_real(dentry, inode, flags);
564 else 576 else
565 return dentry; 577 return dentry;
566} 578}
567 579
568static inline struct inode *vfs_select_inode(struct dentry *dentry,
569 unsigned open_flags)
570{
571 struct inode *inode = d_inode(dentry);
572
573 if (inode && unlikely(dentry->d_flags & DCACHE_OP_SELECT_INODE))
574 inode = dentry->d_op->d_select_inode(dentry, open_flags);
575
576 return inode;
577}
578
579/** 580/**
580 * d_real_inode - Return the real inode 581 * d_real_inode - Return the real inode
581 * @dentry: The dentry to query 582 * @dentry: The dentry to query
@@ -585,7 +586,7 @@ static inline struct inode *vfs_select_inode(struct dentry *dentry,
585 */ 586 */
586static inline struct inode *d_real_inode(struct dentry *dentry) 587static inline struct inode *d_real_inode(struct dentry *dentry)
587{ 588{
588 return d_backing_inode(d_real(dentry)); 589 return d_backing_inode(d_real(dentry, NULL, 0));
589} 590}
590 591
591 592
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f2a69f20926f..50ccf845b56c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -457,7 +457,6 @@ struct block_device {
457 struct inode * bd_inode; /* will die */ 457 struct inode * bd_inode; /* will die */
458 struct super_block * bd_super; 458 struct super_block * bd_super;
459 struct mutex bd_mutex; /* open/close mutex */ 459 struct mutex bd_mutex; /* open/close mutex */
460 struct list_head bd_inodes;
461 void * bd_claiming; 460 void * bd_claiming;
462 void * bd_holder; 461 void * bd_holder;
463 int bd_holders; 462 int bd_holders;
@@ -1271,12 +1270,7 @@ static inline struct inode *file_inode(const struct file *f)
1271 1270
1272static inline struct dentry *file_dentry(const struct file *file) 1271static inline struct dentry *file_dentry(const struct file *file)
1273{ 1272{
1274 struct dentry *dentry = file->f_path.dentry; 1273 return d_real(file->f_path.dentry, file_inode(file), 0);
1275
1276 if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
1277 return dentry->d_op->d_real(dentry, file_inode(file));
1278 else
1279 return dentry;
1280} 1274}
1281 1275
1282static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) 1276static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 0141f257d67b..eed9e853a06f 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -52,18 +52,6 @@ static inline int fsnotify_perm(struct file *file, int mask)
52} 52}
53 53
54/* 54/*
55 * fsnotify_d_move - dentry has been moved
56 */
57static inline void fsnotify_d_move(struct dentry *dentry)
58{
59 /*
60 * On move we need to update dentry->d_flags to indicate if the new parent
61 * cares about events from this dentry.
62 */
63 __fsnotify_update_dcache_flags(dentry);
64}
65
66/*
67 * fsnotify_link_count - inode's link count changed 55 * fsnotify_link_count - inode's link count changed
68 */ 56 */
69static inline void fsnotify_link_count(struct inode *inode) 57static inline void fsnotify_link_count(struct inode *inode)
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 29f917517299..58205f33af02 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -267,10 +267,8 @@ static inline int fsnotify_inode_watches_children(struct inode *inode)
267 * Update the dentry with a flag indicating the interest of its parent to receive 267 * Update the dentry with a flag indicating the interest of its parent to receive
268 * filesystem events when those events happens to this dentry->d_inode. 268 * filesystem events when those events happens to this dentry->d_inode.
269 */ 269 */
270static inline void __fsnotify_update_dcache_flags(struct dentry *dentry) 270static inline void fsnotify_update_flags(struct dentry *dentry)
271{ 271{
272 struct dentry *parent;
273
274 assert_spin_locked(&dentry->d_lock); 272 assert_spin_locked(&dentry->d_lock);
275 273
276 /* 274 /*
@@ -280,21 +278,12 @@ static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
280 * find our entry, so it will spin until we complete here, and update 278 * find our entry, so it will spin until we complete here, and update
281 * us with the new state. 279 * us with the new state.
282 */ 280 */
283 parent = dentry->d_parent; 281 if (fsnotify_inode_watches_children(dentry->d_parent->d_inode))
284 if (parent->d_inode && fsnotify_inode_watches_children(parent->d_inode))
285 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; 282 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
286 else 283 else
287 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; 284 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
288} 285}
289 286
290/*
291 * fsnotify_d_instantiate - instantiate a dentry for inode
292 */
293static inline void __fsnotify_d_instantiate(struct dentry *dentry)
294{
295 __fsnotify_update_dcache_flags(dentry);
296}
297
298/* called from fsnotify listeners, such as fanotify or dnotify */ 287/* called from fsnotify listeners, such as fanotify or dnotify */
299 288
300/* create a new group */ 289/* create a new group */
@@ -386,10 +375,7 @@ static inline void __fsnotify_inode_delete(struct inode *inode)
386static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt) 375static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
387{} 376{}
388 377
389static inline void __fsnotify_update_dcache_flags(struct dentry *dentry) 378static inline void fsnotify_update_flags(struct dentry *dentry)
390{}
391
392static inline void __fsnotify_d_instantiate(struct dentry *dentry)
393{} 379{}
394 380
395static inline u32 fsnotify_get_cookie(void) 381static inline u32 fsnotify_get_cookie(void)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index abc1c5fb7222..51a04e5e9373 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3316,7 +3316,7 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
3316 address = address & huge_page_mask(h); 3316 address = address & huge_page_mask(h);
3317 pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + 3317 pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) +
3318 vma->vm_pgoff; 3318 vma->vm_pgoff;
3319 mapping = file_inode(vma->vm_file)->i_mapping; 3319 mapping = vma->vm_file->f_mapping;
3320 3320
3321 /* 3321 /*
3322 * Take the mapping lock for the duration of the table walk. As 3322 * Take the mapping lock for the duration of the table walk. As
diff --git a/security/inode.c b/security/inode.c
index 28414b0207ce..e3df905ab5b1 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -186,24 +186,21 @@ EXPORT_SYMBOL_GPL(securityfs_create_dir);
186 */ 186 */
187void securityfs_remove(struct dentry *dentry) 187void securityfs_remove(struct dentry *dentry)
188{ 188{
189 struct dentry *parent; 189 struct inode *dir;
190 190
191 if (!dentry || IS_ERR(dentry)) 191 if (!dentry || IS_ERR(dentry))
192 return; 192 return;
193 193
194 parent = dentry->d_parent; 194 dir = d_inode(dentry->d_parent);
195 if (!parent || d_really_is_negative(parent)) 195 inode_lock(dir);
196 return;
197
198 inode_lock(d_inode(parent));
199 if (simple_positive(dentry)) { 196 if (simple_positive(dentry)) {
200 if (d_is_dir(dentry)) 197 if (d_is_dir(dentry))
201 simple_rmdir(d_inode(parent), dentry); 198 simple_rmdir(dir, dentry);
202 else 199 else
203 simple_unlink(d_inode(parent), dentry); 200 simple_unlink(dir, dentry);
204 dput(dentry); 201 dput(dentry);
205 } 202 }
206 inode_unlock(d_inode(parent)); 203 inode_unlock(dir);
207 simple_release_fs(&mount, &mount_count); 204 simple_release_fs(&mount, &mount_count);
208} 205}
209EXPORT_SYMBOL_GPL(securityfs_remove); 206EXPORT_SYMBOL_GPL(securityfs_remove);