History

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull more vfs updates from Al Viro: "Assorted VFS fixes and related cleanups (IMO the most interesting in that part are f_path-related things and Eric's descriptor-related stuff). UFS regression fixes (it got broken last cycle). 9P fixes. fs-cache series, DAX patches, Jan's file_remove_suid() work" [ I'd say this is much more than "fixes and related cleanups". The file_table locking rule change by Eric Dumazet is a rather big and fundamental update even if the patch isn't huge. - Linus ] * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (49 commits) 9p: cope with bogus responses from server in p9_client_{read,write} p9_client_write(): avoid double p9_free_req() 9p: forgetting to cancel request on interrupted zero-copy RPC dax: bdev_direct_access() may sleep block: Add support for DAX reads/writes to block devices dax: Use copy_from_iter_nocache dax: Add block size note to documentation fs/file.c: __fget() and dup2() atomicity rules fs/file.c: don't acquire files->file_lock in fd_install() fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation vfs: avoid creation of inode number 0 in get_next_ino namei: make set_root_rcu() return void make simple_positive() public ufs: use dir_pages instead of ufs_dir_pages() pagemap.h: move dir_pages() over there remove the pointless include of lglock.h fs: cleanup slight list_entry abuse xfs: Correctly lock inode when removing suid and file capabilities fs: Call security_ops->inode_killpriv on truncate fs: Provide function telling whether file_remove_privs() will do anything ...

Linus Torvalds committed 11 years ago

Commit 1dc51b82 parents 9b284cb 0f1db7d99 files · +784 −553Browse files

Unified · Split

99 files
  1. Documentation/filesystems/caching/backend-api.txt +23 −0
  2. Documentation/filesystems/caching/fscache.txt +6 −1
  3. Documentation/filesystems/dax.txt +4 −2
  4. Documentation/filesystems/porting +4 −0
  5. arch/arc/kernel/troubleshoot.c +3 −7
  6. arch/blackfin/kernel/trace.c +1 −1
  7. arch/powerpc/platforms/cell/spufs/inode.c +1 −1
  8. arch/s390/hypfs/inode.c +1 −6
  9. arch/tile/kernel/stack.c +1 −1
  10. arch/tile/mm/elf.c +1 −1
  11. drivers/block/drbd/drbd_debugfs.c +1 −9
  12. drivers/block/loop.c +1 −1
  13. drivers/infiniband/hw/ipath/ipath_fs.c +1 −1
  14. drivers/infiniband/hw/qib/qib_fs.c +1 −1
  15. drivers/md/bitmap.c +2 −2
  16. drivers/md/md.c +1 −1
  17. drivers/usb/gadget/function/f_mass_storage.c +1 −1
  18. drivers/usb/gadget/function/storage_common.c +1 −1
  19. fs/affs/affs.h +1 −1
  20. fs/autofs4/autofs_i.h +0 −5
  21. fs/befs/befs.h +1 −1
  22. fs/binfmt_elf.c +2 −2
  23. fs/block_dev.c +10 −0
  24. fs/btrfs/file.c +1 −1
  25. fs/cachefiles/internal.h +0 −1
  26. fs/cachefiles/namei.c +21 −12
  27. fs/ceph/file.c +1 −1
  28. fs/coda/coda_linux.h +1 −1
  29. fs/configfs/inode.c +1 −1
  30. fs/coredump.c +1 −1
  31. fs/dax.c +5 −3
  32. fs/dcache.c +4 −1
  33. fs/debugfs/inode.c +3 −8
  34. fs/exofs/dir.c +0 −6
  35. fs/ext2/dir.c +0 −5
  36. fs/ext4/super.c +1 −1
  37. fs/file.c +56 −21
  38. fs/file_table.c +0 −1
  39. fs/freevxfs/vxfs_lookup.c +0 −7
  40. fs/fscache/cookie.c +4 −4
  41. fs/fscache/internal.h +8 −4
  42. fs/fscache/object.c +65 −4
  43. fs/fscache/operation.c +168 −86
  44. fs/fscache/page.c +43 −43
  45. fs/fscache/stats.c +13 −1
  46. fs/fuse/file.c +1 −1
  47. fs/hfs/hfs_fs.h +1 −1
  48. fs/hfsplus/hfsplus_fs.h +1 −1
  49. fs/hpfs/hpfs_fn.h +1 −1
  50. fs/inode.c +46 −20
  51. fs/internal.h +1 −0
  52. fs/jffs2/os-linux.h +1 −1
  53. fs/jfs/jfs_incore.h +1 −1
  54. fs/libfs.c +0 −5
  55. fs/minix/dir.c +0 −5
  56. fs/minix/minix.h +1 −1
  57. fs/namei.c +3 −3
  58. fs/ncpfs/dir.c +2 −0
  59. fs/nfs/dir.c +1 −1
  60. fs/nilfs2/dir.c +0 −5
  61. fs/nilfs2/inode.c +2 −20
  62. fs/ntfs/file.c +1 −1
  63. fs/ntfs/inode.h +1 −1
  64. fs/open.c +36 −25
  65. fs/overlayfs/inode.c +7 −15
  66. fs/overlayfs/overlayfs.h +1 −0
  67. fs/overlayfs/super.c +1 −0
  68. fs/posix_acl.c +20 −26
  69. fs/proc/nommu.c +1 −1
  70. fs/proc/task_mmu.c +2 −2
  71. fs/proc/task_nommu.c +1 −1
  72. fs/qnx6/dir.c +0 −5
  73. fs/seq_file.c +14 −0
  74. fs/squashfs/squashfs_fs_i.h +1 −1
  75. fs/super.c +1 −1
  76. fs/sysv/dir.c +0 −5
  77. fs/sysv/sysv.h +1 −1
  78. fs/tracefs/inode.c +3 −8
  79. fs/udf/udf_i.h +1 −1
  80. fs/ufs/balloc.c +17 −17
  81. fs/ufs/dir.c +8 −11
  82. fs/ufs/ialloc.c +8 −8
  83. fs/ufs/inode.c +4 −1
  84. fs/ufs/namei.c +33 −46
  85. fs/ufs/super.c +11 −0
  86. fs/ufs/ufs.h +2 −1
  87. fs/xfs/xfs_file.c +10 −1
  88. include/linux/dcache.h +7 −0
  89. include/linux/fdtable.h +3 −0
  90. include/linux/fs.h +8 −3
  91. include/linux/fscache-cache.h +27 −28
  92. include/linux/pagemap.h +6 −0
  93. include/linux/seq_file.h +1 −0
  94. kernel/events/core.c +1 −1
  95. mm/filemap.c +1 −1
  96. mm/memory.c +1 −1
  97. mm/swapfile.c +1 −1
  98. net/9p/client.c +11 −1
  99. security/inode.c +6 −13
Documentation/filesystems/caching/backend-api.txt+23−0
@@ -676,6 +676,29 @@ FS-Cache provides some utilities that a cache backend may make use of: · 675 unmodified lines
676676 as possible.
677677
678678
679+ (*) Indicate that a stale object was found and discarded:
680+
681+ void fscache_object_retrying_stale(struct fscache_object *object);
682+
683+ This is called to indicate that the lookup procedure found an object in
684+ the cache that the netfs decided was stale. The object has been
685+ discarded from the cache and the lookup will be performed again.
686+
687+
688+ (*) Indicate that the caching backend killed an object:
689+
690+ void fscache_object_mark_killed(struct fscache_object *object,
691+ enum fscache_why_object_killed why);
692+
693+ This is called to indicate that the cache backend preemptively killed an
694+ object. The why parameter should be set to indicate the reason:
695+
696+ FSCACHE_OBJECT_IS_STALE - the object was stale and needs discarding.
697+ FSCACHE_OBJECT_NO_SPACE - there was insufficient cache space
698+ FSCACHE_OBJECT_WAS_RETIRED - the object was retired when relinquished.
699+ FSCACHE_OBJECT_WAS_CULLED - the object was culled to make space.
700+
701+
679702 (*) Get and release references on a retrieval record:
680703
681704 void fscache_get_retrieval(struct fscache_retrieval *op);
Documentation/filesystems/caching/fscache.txt+6−1
@@ -284,8 +284,9 @@ proc files. · 283 unmodified lines
284284 enq=N Number of times async ops queued for processing
285285 can=N Number of async ops cancelled
286286 rej=N Number of async ops rejected due to object lookup/create failure
287+ ini=N Number of async ops initialised
287288 dfr=N Number of async ops queued for deferred release
288− rel=N Number of async ops released
289+ rel=N Number of async ops released (should equal ini=N when idle)
289290 gc=N Number of deferred-release async ops garbage collected
290291 CacheOp alo=N Number of in-progress alloc_object() cache ops
291292 luo=N Number of in-progress lookup_object() cache ops
@@ -303,6 +304,10 @@ proc files. · 11 unmodified lines
303304 wrp=N Number of in-progress write_page() cache ops
304305 ucp=N Number of in-progress uncache_page() cache ops
305306 dsp=N Number of in-progress dissociate_pages() cache ops
307+ CacheEv nsp=N Number of object lookups/creations rejected due to lack of space
308+ stl=N Number of stale objects deleted
309+ rtr=N Number of objects retired when relinquished
310+ cul=N Number of objects culled
306311
307312
308313 (*) /proc/fs/fscache/histogram
Documentation/filesystems/dax.txt+4−2
@@ -18,8 +18,10 @@ Usage · 17 unmodified lines
1818 -----
1919
2020 If you have a block device which supports DAX, you can make a filesystem
21−on it as usual. When mounting it, use the -o dax option manually
22−or add 'dax' to the options in /etc/fstab.
21+on it as usual. The DAX code currently only supports files with a block
22+size equal to your kernel's PAGE_SIZE, so you may need to specify a block
23+size when creating the filesystem. When mounting it, use the "-o dax"
24+option on the command line or add 'dax' to the options in /etc/fstab.
2325
2426
2527 Implementation Tips for Block Driver Writers
Documentation/filesystems/porting+4−0
@@ -500,3 +500,7 @@ in your dentry operations instead. · 499 unmodified lines
500500 dentry, it does not get nameidata at all and it gets called only when cookie
501501 is non-NULL. Note that link body isn't available anymore, so if you need it,
502502 store it as cookie.
503+--
504+[mandatory]
505+ __fd_install() & fd_install() can now sleep. Callers should not
506+ hold a spinlock or other resources that do not allow a schedule.
arch/arc/kernel/troubleshoot.c+3−7
@@ -71,15 +71,12 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf) · 70 unmodified lines
7171 mmput(mm);
7272
7373 if (exe_file) {
74− path = exe_file->f_path;
75− path_get(&exe_file->f_path);
74+ path_nm = file_path(exe_file, buf, 255);
7675 fput(exe_file);
77− path_nm = d_path(&path, buf, 255);
78− path_put(&path);
7976 }
8077
8178 done:
82− pr_info("Path: %s\n", path_nm);
79+ pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
8380 }
8481
8582 static void show_faulting_vma(unsigned long address, char *buf)
@@ -103,8 +100,7 @@ static void show_faulting_vma(unsigned long address, char *buf) · 17 unmodified lines
103100 if (vma && (vma->vm_start <= address)) {
104101 struct file *file = vma->vm_file;
105102 if (file) {
106− struct path *path = &file->f_path;
107− nm = d_path(path, buf, PAGE_SIZE - 1);
103+ nm = file_path(file, buf, PAGE_SIZE - 1);
108104 inode = file_inode(vma->vm_file);
109105 dev = inode->i_sb->s_dev;
110106 ino = inode->i_ino;
arch/blackfin/kernel/trace.c+1−1
@@ -136,7 +136,7 @@ void decode_address(char *buf, unsigned long address) · 135 unmodified lines
136136 struct file *file = vma->vm_file;
137137
138138 if (file) {
139− char *d_name = d_path(&file->f_path, _tmpbuf,
139+ char *d_name = file_path(file, _tmpbuf,
140140 sizeof(_tmpbuf));
141141 if (!IS_ERR(d_name))
142142 name = d_name;
arch/powerpc/platforms/cell/spufs/inode.c+1−1
@@ -166,7 +166,7 @@ static void spufs_prune_dir(struct dentry *dir) · 165 unmodified lines
166166 mutex_lock(&d_inode(dir)->i_mutex);
167167 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
168168 spin_lock(&dentry->d_lock);
169− if (!(d_unhashed(dentry)) && d_really_is_positive(dentry)) {
169+ if (simple_positive(dentry)) {
170170 dget_dlock(dentry);
171171 __d_drop(dentry);
172172 spin_unlock(&dentry->d_lock);
arch/s390/hypfs/inode.c+1−6
@@ -62,18 +62,13 @@ static void hypfs_add_dentry(struct dentry *dentry) · 61 unmodified lines
6262 hypfs_last_dentry = dentry;
6363 }
6464
65−static inline int hypfs_positive(struct dentry *dentry)
66−{
67− return d_really_is_positive(dentry) && !d_unhashed(dentry);
68−}
69−
7065 static void hypfs_remove(struct dentry *dentry)
7166 {
7267 struct dentry *parent;
7368
7469 parent = dentry->d_parent;
7570 mutex_lock(&d_inode(parent)->i_mutex);
76− if (hypfs_positive(dentry)) {
71+ if (simple_positive(dentry)) {
7772 if (d_is_dir(dentry))
7873 simple_rmdir(d_inode(parent), dentry);
7974 else
arch/tile/kernel/stack.c+1−1
@@ -332,7 +332,7 @@ static void describe_addr(struct KBacktraceIterator *kbt, · 331 unmodified lines
332332 }
333333
334334 if (vma->vm_file) {
335− p = d_path(&vma->vm_file->f_path, buf, bufsize);
335+ p = file_path(vma->vm_file, buf, bufsize);
336336 if (IS_ERR(p))
337337 p = "?";
338338 name = kbasename(p);
arch/tile/mm/elf.c+1−1
@@ -56,7 +56,7 @@ static int notify_exec(struct mm_struct *mm) · 55 unmodified lines
5656 if (exe_file == NULL)
5757 goto done_free;
5858
59− path = d_path(&exe_file->f_path, buf, PAGE_SIZE);
59+ path = file_path(exe_file, buf, PAGE_SIZE);
6060 if (IS_ERR(path))
6161 goto done_put;
6262
drivers/block/drbd/drbd_debugfs.c+1−9
@@ -419,14 +419,6 @@ static int in_flight_summary_show(struct seq_file *m, void *pos) · 418 unmodified lines
419419 return 0;
420420 }
421421
422−/* simple_positive(file->f_path.dentry) respectively debugfs_positive(),
423− * but neither is "reachable" from here.
424− * So we have our own inline version of it above. :-( */
425−static inline int debugfs_positive(struct dentry *dentry)
426−{
427− return d_really_is_positive(dentry) && !d_unhashed(dentry);
428−}
429−
430422 /* make sure at *open* time that the respective object won't go away. */
431423 static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, void *),
432424 void *data, struct kref *kref,
@@ -444,7 +436,7 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo · 11 unmodified lines
444436 /* serialize with d_delete() */
445437 mutex_lock(&d_inode(parent)->i_mutex);
446438 /* Make sure the object is still alive */
447− if (debugfs_positive(file->f_path.dentry)
439+ if (simple_positive(file->f_path.dentry)
448440 && kref_get_unless_zero(kref))
449441 ret = 0;
450442 mutex_unlock(&d_inode(parent)->i_mutex);
drivers/block/loop.c+1−1
@@ -588,7 +588,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) · 587 unmodified lines
588588
589589 spin_lock_irq(&lo->lo_lock);
590590 if (lo->lo_backing_file)
591− p = d_path(&lo->lo_backing_file->f_path, buf, PAGE_SIZE - 1);
591+ p = file_path(lo->lo_backing_file, buf, PAGE_SIZE - 1);
592592 spin_unlock_irq(&lo->lo_lock);
593593
594594 if (IS_ERR_OR_NULL(p))
drivers/infiniband/hw/ipath/ipath_fs.c+1−1
@@ -277,7 +277,7 @@ static int remove_file(struct dentry *parent, char *name) · 276 unmodified lines
277277 }
278278
279279 spin_lock(&tmp->d_lock);
280− if (!d_unhashed(tmp) && d_really_is_positive(tmp)) {
280+ if (simple_positive(tmp)) {
281281 dget_dlock(tmp);
282282 __d_drop(tmp);
283283 spin_unlock(&tmp->d_lock);
drivers/infiniband/hw/qib/qib_fs.c+1−1
@@ -455,7 +455,7 @@ static int remove_file(struct dentry *parent, char *name) · 454 unmodified lines
455455 }
456456
457457 spin_lock(&tmp->d_lock);
458− if (!d_unhashed(tmp) && d_really_is_positive(tmp)) {
458+ if (simple_positive(tmp)) {
459459 __d_drop(tmp);
460460 spin_unlock(&tmp->d_lock);
461461 simple_unlink(d_inode(parent), tmp);
drivers/md/bitmap.c+2−2
@@ -839,7 +839,7 @@ static void bitmap_file_kick(struct bitmap *bitmap) · 838 unmodified lines
839839 if (bitmap->storage.file) {
840840 path = kmalloc(PAGE_SIZE, GFP_KERNEL);
841841 if (path)
842− ptr = d_path(&bitmap->storage.file->f_path,
842+ ptr = file_path(bitmap->storage.file,
843843 path, PAGE_SIZE);
844844
845845 printk(KERN_ALERT
@@ -1927,7 +1927,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) · 1081 unmodified lines
19271927 chunk_kb ? "KB" : "B");
19281928 if (bitmap->storage.file) {
19291929 seq_printf(seq, ", file: ");
1930− seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
1930+ seq_file_path(seq, bitmap->storage.file, " \t\n");
19311931 }
19321932
19331933 seq_printf(seq, "\n");
drivers/md/md.c+1−1
@@ -5766,7 +5766,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) · 5765 unmodified lines
57665766 /* bitmap disabled, zero the first byte and copy out */
57675767 if (!mddev->bitmap_info.file)
57685768 file->pathname[0] = '\0';
5769− else if ((ptr = d_path(&mddev->bitmap_info.file->f_path,
5769+ else if ((ptr = file_path(mddev->bitmap_info.file,
57705770 file->pathname, sizeof(file->pathname))),
57715771 IS_ERR(ptr))
57725772 err = PTR_ERR(ptr);
drivers/usb/gadget/function/f_mass_storage.c+1−1
@@ -2936,7 +2936,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, · 2935 unmodified lines
29362936 if (fsg_lun_is_open(lun)) {
29372937 p = "(error)";
29382938 if (pathbuf) {
2939− p = d_path(&lun->filp->f_path, pathbuf, PATH_MAX);
2939+ p = file_path(lun->filp, pathbuf, PATH_MAX);
29402940 if (IS_ERR(p))
29412941 p = "(error)";
29422942 }
drivers/usb/gadget/function/storage_common.c+1−1
@@ -341,7 +341,7 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, · 340 unmodified lines
341341
342342 down_read(filesem);
343343 if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */
344− p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
344+ p = file_path(curlun->filp, buf, PAGE_SIZE - 1);
345345 if (IS_ERR(p))
346346 rc = PTR_ERR(p);
347347 else {
fs/affs/affs.h+1−1
@@ -64,7 +64,7 @@ struct affs_inode_info { · 63 unmodified lines
6464 /* short cut to get to the affs specific inode data */
6565 static inline struct affs_inode_info *AFFS_I(struct inode *inode)
6666 {
67− return list_entry(inode, struct affs_inode_info, vfs_inode);
67+ return container_of(inode, struct affs_inode_info, vfs_inode);
6868 }
6969
7070 /*
fs/autofs4/autofs_i.h+0−5
@@ -238,11 +238,6 @@ static inline u64 autofs4_get_ino(struct autofs_sb_info *sbi) · 237 unmodified lines
238238 return d_inode(sbi->sb->s_root)->i_ino;
239239 }
240240
241−static inline int simple_positive(struct dentry *dentry)
242−{
243− return d_really_is_positive(dentry) && !d_unhashed(dentry);
244−}
245−
246241 static inline void __autofs4_add_expiring(struct dentry *dentry)
247242 {
248243 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
fs/befs/befs.h+1−1
@@ -112,7 +112,7 @@ BEFS_SB(const struct super_block *super) · 111 unmodified lines
112112 static inline struct befs_inode_info *
113113 BEFS_I(const struct inode *inode)
114114 {
115− return list_entry(inode, struct befs_inode_info, vfs_inode);
115+ return container_of(inode, struct befs_inode_info, vfs_inode);
116116 }
117117
118118 static inline befs_blocknr_t
fs/binfmt_elf.c+2−2
@@ -1530,7 +1530,7 @@ static int fill_files_note(struct memelfnote *note) · 1529 unmodified lines
15301530 file = vma->vm_file;
15311531 if (!file)
15321532 continue;
1533− filename = d_path(&file->f_path, name_curpos, remaining);
1533+ filename = file_path(file, name_curpos, remaining);
15341534 if (IS_ERR(filename)) {
15351535 if (PTR_ERR(filename) == -ENAMETOOLONG) {
15361536 vfree(data);
@@ -1540,7 +1540,7 @@ static int fill_files_note(struct memelfnote *note) · 3 unmodified lines
15401540 continue;
15411541 }
15421542
1543− /* d_path() fills at the end, move name down */
1543+ /* file_path() fills at the end, move name down */
15441544 /* n = strlen(filename) + 1: */
15451545 n = (name_curpos + remaining) - filename;
15461546 remaining = filename - name_curpos;
fs/block_dev.c+10−0
@@ -152,6 +152,9 @@ blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset) · 151 unmodified lines
152152 struct file *file = iocb->ki_filp;
153153 struct inode *inode = file->f_mapping->host;
154154
155+ if (IS_DAX(inode))
156+ return dax_do_io(iocb, inode, iter, offset, blkdev_get_block,
157+ NULL, DIO_SKIP_DIO_COUNT);
155158 return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter, offset,
156159 blkdev_get_block, NULL, NULL,
157160 DIO_SKIP_DIO_COUNT);
@@ -443,6 +446,12 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector, · 285 unmodified lines
443446 long avail;
444447 const struct block_device_operations *ops = bdev->bd_disk->fops;
445448
449+ /*
450+ * The device driver is allowed to sleep, in order to make the
451+ * memory directly accessible.
452+ */
453+ might_sleep();
454+
446455 if (size < 0)
447456 return size;
448457 if (!ops->direct_access)
@@ -1170,6 +1179,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · 721 unmodified lines
11701179 bdev->bd_disk = disk;
11711180 bdev->bd_queue = disk->queue;
11721181 bdev->bd_contains = bdev;
1182+ bdev->bd_inode->i_flags = disk->fops->direct_access ? S_DAX : 0;
11731183 if (!partno) {
11741184 ret = -ENXIO;
11751185 bdev->bd_part = disk_get_part(disk, partno);
fs/btrfs/file.c+1−1
@@ -1748,7 +1748,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, · 1747 unmodified lines
17481748 }
17491749
17501750 current->backing_dev_info = inode_to_bdi(inode);
1751− err = file_remove_suid(file);
1751+ err = file_remove_privs(file);
17521752 if (err) {
17531753 mutex_unlock(&inode->i_mutex);
17541754 goto out;
fs/cachefiles/internal.h+0−1
@@ -43,7 +43,6 @@ struct cachefiles_object { · 42 unmodified lines
4343 loff_t i_size; /* object size */
4444 unsigned long flags;
4545 #define CACHEFILES_OBJECT_ACTIVE 0 /* T if marked active */
46−#define CACHEFILES_OBJECT_BURIED 1 /* T if preemptively buried */
4746 atomic_t usage; /* object usage count */
4847 uint8_t type; /* object type */
4948 uint8_t new; /* T if object new */
fs/cachefiles/namei.c+21−12
@@ -97,7 +97,8 @@ static noinline void cachefiles_printk_object(struct cachefiles_object *object, · 96 unmodified lines
9797 * call vfs_unlink(), vfs_rmdir() or vfs_rename()
9898 */
9999 static void cachefiles_mark_object_buried(struct cachefiles_cache *cache,
100− struct dentry *dentry)
100+ struct dentry *dentry,
101+ enum fscache_why_object_killed why)
101102 {
102103 struct cachefiles_object *object;
103104 struct rb_node *p;
@@ -132,8 +133,9 @@ found_dentry: · 28 unmodified lines
132133 pr_err("\n");
133134 pr_err("Error: Can't preemptively bury live object\n");
134135 cachefiles_printk_object(object, NULL);
135− } else if (test_and_set_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) {
136− pr_err("Error: Object already preemptively buried\n");
136+ } else {
137+ if (why != FSCACHE_OBJECT_IS_STALE)
138+ fscache_object_mark_killed(&object->fscache, why);
137139 }
138140
139141 write_unlock(&cache->active_lock);
@@ -265,7 +267,8 @@ requeue: · 125 unmodified lines
265267 static int cachefiles_bury_object(struct cachefiles_cache *cache,
266268 struct dentry *dir,
267269 struct dentry *rep,
268− bool preemptive)
270+ bool preemptive,
271+ enum fscache_why_object_killed why)
269272 {
270273 struct dentry *grave, *trap;
271274 struct path path, path_to_graveyard;
@@ -289,7 +292,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, · 17 unmodified lines
289292 ret = vfs_unlink(d_inode(dir), rep, NULL);
290293
291294 if (preemptive)
292− cachefiles_mark_object_buried(cache, rep);
295+ cachefiles_mark_object_buried(cache, rep, why);
293296 }
294297
295298 mutex_unlock(&d_inode(dir)->i_mutex);
@@ -394,7 +397,7 @@ try_again: · 98 unmodified lines
394397 "Rename failed with error %d", ret);
395398
396399 if (preemptive)
397− cachefiles_mark_object_buried(cache, rep);
400+ cachefiles_mark_object_buried(cache, rep, why);
398401 }
399402
400403 unlock_rename(cache->graveyard, dir);
@@ -422,7 +425,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache, · 21 unmodified lines
422425
423426 mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
424427
425− if (test_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) {
428+ if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) {
426429 /* object allocation for the same key preemptively deleted this
427430 * object's file so that it could create its own file */
428431 _debug("object preemptively buried");
@@ -433,7 +436,8 @@ int cachefiles_delete_object(struct cachefiles_cache *cache, · 4 unmodified lines
433436 * may have been renamed */
434437 if (dir == object->dentry->d_parent) {
435438 ret = cachefiles_bury_object(cache, dir,
436− object->dentry, false);
439+ object->dentry, false,
440+ FSCACHE_OBJECT_WAS_RETIRED);
437441 } else {
438442 /* it got moved, presumably by cachefilesd culling it,
439443 * so it's no longer in the key path and we can ignore
@@ -522,7 +526,7 @@ lookup_again: · 82 unmodified lines
522526 if (d_is_negative(next)) {
523527 ret = cachefiles_has_space(cache, 1, 0);
524528 if (ret < 0)
525− goto create_error;
529+ goto no_space_error;
526530
527531 path.dentry = dir;
528532 ret = security_path_mkdir(&path, next, 0);
@@ -551,7 +555,7 @@ lookup_again: · 22 unmodified lines
551555 if (d_is_negative(next)) {
552556 ret = cachefiles_has_space(cache, 1, 0);
553557 if (ret < 0)
554− goto create_error;
558+ goto no_space_error;
555559
556560 path.dentry = dir;
557561 ret = security_path_mknod(&path, next, S_IFREG, 0);
@@ -602,7 +606,8 @@ lookup_again: · 44 unmodified lines
602606 * mutex) */
603607 object->dentry = NULL;
604608
605− ret = cachefiles_bury_object(cache, dir, next, true);
609+ ret = cachefiles_bury_object(cache, dir, next, true,
610+ FSCACHE_OBJECT_IS_STALE);
606611 dput(next);
607612 next = NULL;
608613
@@ -610,6 +615,7 @@ lookup_again: · 1 unmodified line
610615 goto delete_error;
611616
612617 _debug("redo lookup");
618+ fscache_object_retrying_stale(&object->fscache);
613619 goto lookup_again;
614620 }
615621 }
@@ -662,6 +668,8 @@ lookup_again: · 46 unmodified lines
662668 _leave(" = 0 [%lu]", d_backing_inode(object->dentry)->i_ino);
663669 return 0;
664670
671+no_space_error:
672+ fscache_object_mark_killed(&object->fscache, FSCACHE_OBJECT_NO_SPACE);
665673 create_error:
666674 _debug("create error %d", ret);
667675 if (ret == -EIO)
@@ -927,7 +935,8 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir, · 259 unmodified lines
927935 /* actually remove the victim (drops the dir mutex) */
928936 _debug("bury");
929937
930− ret = cachefiles_bury_object(cache, dir, victim, false);
938+ ret = cachefiles_bury_object(cache, dir, victim, false,
939+ FSCACHE_OBJECT_WAS_CULLED);
931940 if (ret < 0)
932941 goto error;
933942
fs/ceph/file.c+1−1
@@ -962,7 +962,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) · 961 unmodified lines
962962
963963 pos = iocb->ki_pos;
964964 count = iov_iter_count(from);
965− err = file_remove_suid(file);
965+ err = file_remove_privs(file);
966966 if (err)
967967 goto out;
968968
fs/coda/coda_linux.h+1−1
@@ -79,7 +79,7 @@ void coda_sysctl_clean(void); · 78 unmodified lines
7979
8080 static inline struct coda_inode_info *ITOC(struct inode *inode)
8181 {
82− return list_entry(inode, struct coda_inode_info, vfs_inode);
82+ return container_of(inode, struct coda_inode_info, vfs_inode);
8383 }
8484
8585 static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
fs/configfs/inode.c+1−1
@@ -236,7 +236,7 @@ void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent) · 235 unmodified lines
236236
237237 if (dentry) {
238238 spin_lock(&dentry->d_lock);
239− if (!d_unhashed(dentry) && d_really_is_positive(dentry)) {
239+ if (simple_positive(dentry)) {
240240 dget_dlock(dentry);
241241 __d_drop(dentry);
242242 spin_unlock(&dentry->d_lock);
fs/coredump.c+1−1
@@ -140,7 +140,7 @@ static int cn_print_exe_file(struct core_name *cn) · 139 unmodified lines
140140 goto put_exe_file;
141141 }
142142
143− path = d_path(&exe_file->f_path, pathbuf, PATH_MAX);
143+ path = file_path(exe_file, pathbuf, PATH_MAX);
144144 if (IS_ERR(path)) {
145145 ret = PTR_ERR(path);
146146 goto free_buf;
fs/dax.c+5−3
@@ -155,7 +155,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, · 154 unmodified lines
155155 }
156156
157157 if (iov_iter_rw(iter) == WRITE)
158− len = copy_from_iter(addr, max - pos, iter);
158+ len = copy_from_iter_nocache(addr, max - pos, iter);
159159 else if (!hole)
160160 len = copy_to_iter(addr, max - pos, iter);
161161 else
@@ -209,7 +209,8 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, · 47 unmodified lines
209209 }
210210
211211 /* Protects against truncate */
212− inode_dio_begin(inode);
212+ if (!(flags & DIO_SKIP_DIO_COUNT))
213+ inode_dio_begin(inode);
213214
214215 retval = dax_io(inode, iter, pos, end, get_block, &bh);
215216
@@ -219,7 +220,8 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, · 3 unmodified lines
219220 if ((retval > 0) && end_io)
220221 end_io(iocb, pos, retval, bh.b_private);
221222
222− inode_dio_end(inode);
223+ if (!(flags & DIO_SKIP_DIO_COUNT))
224+ inode_dio_end(inode);
223225 out:
224226 return retval;
225227 }
fs/dcache.c+4−1
@@ -1673,7 +1673,8 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) · 1672 unmodified lines
16731673 DCACHE_OP_COMPARE |
16741674 DCACHE_OP_REVALIDATE |
16751675 DCACHE_OP_WEAK_REVALIDATE |
1676− DCACHE_OP_DELETE ));
1676+ DCACHE_OP_DELETE |
1677+ DCACHE_OP_SELECT_INODE));
16771678 dentry->d_op = op;
16781679 if (!op)
16791680 return;
@@ -1689,6 +1690,8 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) · 9 unmodified lines
16891690 dentry->d_flags |= DCACHE_OP_DELETE;
16901691 if (op->d_prune)
16911692 dentry->d_flags |= DCACHE_OP_PRUNE;
1693+ if (op->d_select_inode)
1694+ dentry->d_flags |= DCACHE_OP_SELECT_INODE;
16921695
16931696 }
16941697 EXPORT_SYMBOL(d_set_d_op);
fs/debugfs/inode.c+3−8
@@ -44,11 +44,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb) · 43 unmodified lines
4444 return inode;
4545 }
4646
47−static inline int debugfs_positive(struct dentry *dentry)
48−{
49− return d_really_is_positive(dentry) && !d_unhashed(dentry);
50−}
51−
5247 struct debugfs_mount_opts {
5348 kuid_t uid;
5449 kgid_t gid;
@@ -522,7 +517,7 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent) · 467 unmodified lines
522517 {
523518 int ret = 0;
524519
525− if (debugfs_positive(dentry)) {
520+ if (simple_positive(dentry)) {
526521 dget(dentry);
527522 if (d_is_dir(dentry))
528523 ret = simple_rmdir(d_inode(parent), dentry);
@@ -602,7 +597,7 @@ void debugfs_remove_recursive(struct dentry *dentry) · 73 unmodified lines
602597 */
603598 spin_lock(&parent->d_lock);
604599 list_for_each_entry(child, &parent->d_subdirs, d_child) {
605− if (!debugfs_positive(child))
600+ if (!simple_positive(child))
606601 continue;
607602
608603 /* perhaps simple_empty(child) makes more sense */
@@ -623,7 +618,7 @@ void debugfs_remove_recursive(struct dentry *dentry) · 14 unmodified lines
623618 * from d_subdirs. When releasing the parent->d_lock we can
624619 * no longer trust that the next pointer is valid.
625620 * Restart the loop. We'll skip this one with the
626− * debugfs_positive() check.
621+ * simple_positive() check.
627622 */
628623 goto loop;
629624 }
fs/exofs/dir.c+0−6
@@ -44,12 +44,6 @@ static inline void exofs_put_page(struct page *page) · 43 unmodified lines
4444 page_cache_release(page);
4545 }
4646
47−/* Accesses dir's inode->i_size must be called under inode lock */
48−static inline unsigned long dir_pages(struct inode *inode)
49−{
50− return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
51−}
52−
5347 static unsigned exofs_last_byte(struct inode *inode, unsigned long page_nr)
5448 {
5549 loff_t last_byte = inode->i_size;
fs/ext2/dir.c+0−5
@@ -70,11 +70,6 @@ static inline void ext2_put_page(struct page *page) · 69 unmodified lines
7070 page_cache_release(page);
7171 }
7272
73−static inline unsigned long dir_pages(struct inode *inode)
74−{
75− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
76−}
77−
7873 /*
7974 * Return the offset into page `page_nr' of the last valid
8075 * byte in that page, plus one.
fs/ext4/super.c+1−1
@@ -452,7 +452,7 @@ void __ext4_error_file(struct file *file, const char *function, · 451 unmodified lines
452452 es = EXT4_SB(inode->i_sb)->s_es;
453453 es->s_last_error_ino = cpu_to_le32(inode->i_ino);
454454 if (ext4_error_ratelimit(inode->i_sb)) {
455− path = d_path(&(file->f_path), pathname, sizeof(pathname));
455+ path = file_path(file, pathname, sizeof(pathname));
456456 if (IS_ERR(path))
457457 path = "(unknown)";
458458 va_start(args, fmt);
fs/file.c+56−21
@@ -147,6 +147,13 @@ static int expand_fdtable(struct files_struct *files, int nr) · 146 unmodified lines
147147
148148 spin_unlock(&files->file_lock);
149149 new_fdt = alloc_fdtable(nr);
150+
151+ /* make sure all __fd_install() have seen resize_in_progress
152+ * or have finished their rcu_read_lock_sched() section.
153+ */
154+ if (atomic_read(&files->count) > 1)
155+ synchronize_sched();
156+
150157 spin_lock(&files->file_lock);
151158 if (!new_fdt)
152159 return -ENOMEM;
@@ -158,21 +165,14 @@ static int expand_fdtable(struct files_struct *files, int nr) · 5 unmodified lines
158165 __free_fdtable(new_fdt);
159166 return -EMFILE;
160167 }
161− /*
162− * Check again since another task may have expanded the fd table while
163− * we dropped the lock
164− */
165168 cur_fdt = files_fdtable(files);
166− if (nr >= cur_fdt->max_fds) {
167− /* Continue as planned */
168− copy_fdtable(new_fdt, cur_fdt);
169− rcu_assign_pointer(files->fdt, new_fdt);
170− if (cur_fdt != &files->fdtab)
171− call_rcu(&cur_fdt->rcu, free_fdtable_rcu);
172− } else {
173− /* Somebody else expanded, so undo our attempt */
174− __free_fdtable(new_fdt);
175− }
169+ BUG_ON(nr < cur_fdt->max_fds);
170+ copy_fdtable(new_fdt, cur_fdt);
171+ rcu_assign_pointer(files->fdt, new_fdt);
172+ if (cur_fdt != &files->fdtab)
173+ call_rcu(&cur_fdt->rcu, free_fdtable_rcu);
174+ /* coupled with smp_rmb() in __fd_install() */
175+ smp_wmb();
176176 return 1;
177177 }
178178
@@ -185,21 +185,38 @@ static int expand_fdtable(struct files_struct *files, int nr) · 6 unmodified lines
185185 * The files->file_lock should be held on entry, and will be held on exit.
186186 */
187187 static int expand_files(struct files_struct *files, int nr)
188+ __releases(files->file_lock)
189+ __acquires(files->file_lock)
188190 {
189191 struct fdtable *fdt;
192+ int expanded = 0;
190193
194+repeat:
191195 fdt = files_fdtable(files);
192196
193197 /* Do we need to expand? */
194198 if (nr < fdt->max_fds)
195− return 0;
199+ return expanded;
196200
197201 /* Can we expand? */
198202 if (nr >= sysctl_nr_open)
199203 return -EMFILE;
200204
205+ if (unlikely(files->resize_in_progress)) {
206+ spin_unlock(&files->file_lock);
207+ expanded = 1;
208+ wait_event(files->resize_wait, !files->resize_in_progress);
209+ spin_lock(&files->file_lock);
210+ goto repeat;
211+ }
212+
201213 /* All good, so we try */
202− return expand_fdtable(files, nr);
214+ files->resize_in_progress = true;
215+ expanded = expand_fdtable(files, nr);
216+ files->resize_in_progress = false;
217+
218+ wake_up_all(&files->resize_wait);
219+ return expanded;
203220 }
204221
205222 static inline void __set_close_on_exec(int fd, struct fdtable *fdt)
@@ -256,6 +273,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) · 50 unmodified lines
256273 atomic_set(&newf->count, 1);
257274
258275 spin_lock_init(&newf->file_lock);
276+ newf->resize_in_progress = false;
277+ init_waitqueue_head(&newf->resize_wait);
259278 newf->next_fd = 0;
260279 new_fdt = &newf->fdtab;
261280 new_fdt->max_fds = NR_OPEN_DEFAULT;
@@ -553,11 +572,21 @@ void __fd_install(struct files_struct *files, unsigned int fd, · 291 unmodified lines
553572 struct file *file)
554573 {
555574 struct fdtable *fdt;
556− spin_lock(&files->file_lock);
557− fdt = files_fdtable(files);
575+
576+ might_sleep();
577+ rcu_read_lock_sched();
578+
579+ while (unlikely(files->resize_in_progress)) {
580+ rcu_read_unlock_sched();
581+ wait_event(files->resize_wait, !files->resize_in_progress);
582+ rcu_read_lock_sched();
583+ }
584+ /* coupled with smp_wmb() in expand_fdtable() */
585+ smp_rmb();
586+ fdt = rcu_dereference_sched(files->fdt);
558587 BUG_ON(fdt->fd[fd] != NULL);
559588 rcu_assign_pointer(fdt->fd[fd], file);
560− spin_unlock(&files->file_lock);
589+ rcu_read_unlock_sched();
561590 }
562591
563592 void fd_install(unsigned int fd, struct file *file)
@@ -635,11 +664,17 @@ static struct file *__fget(unsigned int fd, fmode_t mask) · 71 unmodified lines
635664 struct file *file;
636665
637666 rcu_read_lock();
667+loop:
638668 file = fcheck_files(files, fd);
639669 if (file) {
640− /* File object ref couldn't be taken */
641− if ((file->f_mode & mask) || !get_file_rcu(file))
670+ /* File object ref couldn't be taken.
671+ * dup2() atomicity guarantee is the reason
672+ * we loop to catch the new file (or NULL pointer)
673+ */
674+ if (file->f_mode & mask)
642675 file = NULL;
676+ else if (!get_file_rcu(file))
677+ goto loop;
643678 }
644679 rcu_read_unlock();
645680
fs/file_table.c+0−1
@@ -20,7 +20,6 @@ · 19 unmodified lines
2020 #include <linux/cdev.h>
2121 #include <linux/fsnotify.h>
2222 #include <linux/sysctl.h>
23−#include <linux/lglock.h>
2423 #include <linux/percpu_counter.h>
2524 #include <linux/percpu.h>
2625 #include <linux/hardirq.h>
fs/freevxfs/vxfs_lookup.c+0−7
@@ -61,13 +61,6 @@ const struct file_operations vxfs_dir_operations = { · 60 unmodified lines
6161 .iterate = vxfs_readdir,
6262 };
6363
64−
65−static inline u_long
66−dir_pages(struct inode *inode)
67−{
68− return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
69−}
70−
7164 static inline u_long
7265 dir_blocks(struct inode *ip)
7366 {
fs/fscache/cookie.c+4−4
@@ -327,7 +327,8 @@ static int fscache_alloc_object(struct fscache_cache *cache, · 326 unmodified lines
327327
328328 object_already_extant:
329329 ret = -ENOBUFS;
330− if (fscache_object_is_dead(object)) {
330+ if (fscache_object_is_dying(object) ||
331+ fscache_cache_is_broken(object)) {
331332 spin_unlock(&cookie->lock);
332333 goto error;
333334 }
@@ -671,7 +672,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie) · 337 unmodified lines
671672 if (!op)
672673 return -ENOMEM;
673674
674− fscache_operation_init(op, NULL, NULL);
675+ fscache_operation_init(op, NULL, NULL, NULL);
675676 op->flags = FSCACHE_OP_MYTHREAD |
676677 (1 << FSCACHE_OP_WAITING) |
677678 (1 << FSCACHE_OP_UNUSE_COOKIE);
@@ -695,8 +696,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie) · 17 unmodified lines
695696 /* the work queue now carries its own ref on the object */
696697 spin_unlock(&cookie->lock);
697698
698− ret = fscache_wait_for_operation_activation(object, op,
699− NULL, NULL, NULL);
699+ ret = fscache_wait_for_operation_activation(object, op, NULL, NULL);
700700 if (ret == 0) {
701701 /* ask the cache to honour the operation */
702702 ret = object->cache->ops->check_consistency(op);
fs/fscache/internal.h+8−4
@@ -124,8 +124,7 @@ extern int fscache_submit_exclusive_op(struct fscache_object *, · 123 unmodified lines
124124 struct fscache_operation *);
125125 extern int fscache_submit_op(struct fscache_object *,
126126 struct fscache_operation *);
127−extern int fscache_cancel_op(struct fscache_operation *,
128− void (*)(struct fscache_operation *));
127+extern int fscache_cancel_op(struct fscache_operation *, bool);
129128 extern void fscache_cancel_all_ops(struct fscache_object *);
130129 extern void fscache_abort_object(struct fscache_object *);
131130 extern void fscache_start_operations(struct fscache_object *);
@@ -138,8 +137,7 @@ extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *); · 6 unmodified lines
138137 extern int fscache_wait_for_operation_activation(struct fscache_object *,
139138 struct fscache_operation *,
140139 atomic_t *,
141− atomic_t *,
142− void (*)(struct fscache_operation *));
140+ atomic_t *);
143141 extern void fscache_invalidate_writes(struct fscache_cookie *);
144142
145143 /*
@@ -164,6 +162,7 @@ extern atomic_t fscache_n_op_pend; · 18 unmodified lines
164162 extern atomic_t fscache_n_op_run;
165163 extern atomic_t fscache_n_op_enqueue;
166164 extern atomic_t fscache_n_op_deferred_release;
165+extern atomic_t fscache_n_op_initialised;
167166 extern atomic_t fscache_n_op_release;
168167 extern atomic_t fscache_n_op_gc;
169168 extern atomic_t fscache_n_op_cancelled;
@@ -271,6 +270,11 @@ extern atomic_t fscache_n_cop_write_page; · 101 unmodified lines
271270 extern atomic_t fscache_n_cop_uncache_page;
272271 extern atomic_t fscache_n_cop_dissociate_pages;
273272
273+extern atomic_t fscache_n_cache_no_space_reject;
274+extern atomic_t fscache_n_cache_stale_objects;
275+extern atomic_t fscache_n_cache_retired_objects;
276+extern atomic_t fscache_n_cache_culled_objects;
277+
274278 static inline void fscache_stat(atomic_t *stat)
275279 {
276280 atomic_inc(stat);
fs/fscache/object.c+65−4
@@ -327,6 +327,17 @@ void fscache_object_init(struct fscache_object *object, · 326 unmodified lines
327327 }
328328 EXPORT_SYMBOL(fscache_object_init);
329329
330+/*
331+ * Mark the object as no longer being live, making sure that we synchronise
332+ * against op submission.
333+ */
334+static inline void fscache_mark_object_dead(struct fscache_object *object)
335+{
336+ spin_lock(&object->lock);
337+ clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
338+ spin_unlock(&object->lock);
339+}
340+
330341 /*
331342 * Abort object initialisation before we start it.
332343 */
@@ -610,6 +621,8 @@ static const struct fscache_state *fscache_lookup_failure(struct fscache_object · 277 unmodified lines
610621 object->cache->ops->lookup_complete(object);
611622 fscache_stat_d(&fscache_n_cop_lookup_complete);
612623
624+ set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags);
625+
613626 cookie = object->cookie;
614627 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags);
615628 if (test_and_clear_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags))
@@ -629,7 +642,7 @@ static const struct fscache_state *fscache_kill_object(struct fscache_object *ob · 13 unmodified lines
629642 _enter("{OBJ%x,%d,%d},%d",
630643 object->debug_id, object->n_ops, object->n_children, event);
631644
632− clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
645+ fscache_mark_object_dead(object);
633646 object->oob_event_mask = 0;
634647
635648 if (list_empty(&object->dependents) &&
@@ -948,7 +961,8 @@ static const struct fscache_state *_fscache_invalidate_object(struct fscache_obj · 312 unmodified lines
948961 if (!op)
949962 goto nomem;
950963
951− fscache_operation_init(op, object->cache->ops->invalidate_object, NULL);
964+ fscache_operation_init(op, object->cache->ops->invalidate_object,
965+ NULL, NULL);
952966 op->flags = FSCACHE_OP_ASYNC |
953967 (1 << FSCACHE_OP_EXCLUSIVE) |
954968 (1 << FSCACHE_OP_UNUSE_COOKIE);
@@ -974,13 +988,13 @@ static const struct fscache_state *_fscache_invalidate_object(struct fscache_obj · 19 unmodified lines
974988 return transit_to(UPDATE_OBJECT);
975989
976990 nomem:
977− clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
991+ fscache_mark_object_dead(object);
978992 fscache_unuse_cookie(object);
979993 _leave(" [ENOMEM]");
980994 return transit_to(KILL_OBJECT);
981995
982996 submit_op_failed:
983− clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
997+ fscache_mark_object_dead(object);
984998 spin_unlock(&cookie->lock);
985999 fscache_unuse_cookie(object);
9861000 kfree(op);
@@ -1016,3 +1030,50 @@ static const struct fscache_state *fscache_update_object(struct fscache_object * · 29 unmodified lines
10161030 _leave("");
10171031 return transit_to(WAIT_FOR_CMD);
10181032 }
1033+
1034+/**
1035+ * fscache_object_retrying_stale - Note retrying stale object
1036+ * @object: The object that will be retried
1037+ *
1038+ * Note that an object lookup found an on-disk object that was adjudged to be
1039+ * stale and has been deleted. The lookup will be retried.
1040+ */
1041+void fscache_object_retrying_stale(struct fscache_object *object)
1042+{
1043+ fscache_stat(&fscache_n_cache_no_space_reject);
1044+}
1045+EXPORT_SYMBOL(fscache_object_retrying_stale);
1046+
1047+/**
1048+ * fscache_object_mark_killed - Note that an object was killed
1049+ * @object: The object that was culled
1050+ * @why: The reason the object was killed.
1051+ *
1052+ * Note that an object was killed. Returns true if the object was
1053+ * already marked killed, false if it wasn't.
1054+ */
1055+void fscache_object_mark_killed(struct fscache_object *object,
1056+ enum fscache_why_object_killed why)
1057+{
1058+ if (test_and_set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags)) {
1059+ pr_err("Error: Object already killed by cache [%s]\n",
1060+ object->cache->identifier);
1061+ return;
1062+ }
1063+
1064+ switch (why) {
1065+ case FSCACHE_OBJECT_NO_SPACE:
1066+ fscache_stat(&fscache_n_cache_no_space_reject);
1067+ break;
1068+ case FSCACHE_OBJECT_IS_STALE:
1069+ fscache_stat(&fscache_n_cache_stale_objects);
1070+ break;
1071+ case FSCACHE_OBJECT_WAS_RETIRED:
1072+ fscache_stat(&fscache_n_cache_retired_objects);
1073+ break;
1074+ case FSCACHE_OBJECT_WAS_CULLED:
1075+ fscache_stat(&fscache_n_cache_culled_objects);
1076+ break;
1077+ }
1078+}
1079+EXPORT_SYMBOL(fscache_object_mark_killed);
fs/fscache/operation.c+168−86
@@ -20,6 +20,35 @@ · 19 unmodified lines
2020 atomic_t fscache_op_debug_id;
2121 EXPORT_SYMBOL(fscache_op_debug_id);
2222
23+static void fscache_operation_dummy_cancel(struct fscache_operation *op)
24+{
25+}
26+
27+/**
28+ * fscache_operation_init - Do basic initialisation of an operation
29+ * @op: The operation to initialise
30+ * @release: The release function to assign
31+ *
32+ * Do basic initialisation of an operation. The caller must still set flags,
33+ * object and processor if needed.
34+ */
35+void fscache_operation_init(struct fscache_operation *op,
36+ fscache_operation_processor_t processor,
37+ fscache_operation_cancel_t cancel,
38+ fscache_operation_release_t release)
39+{
40+ INIT_WORK(&op->work, fscache_op_work_func);
41+ atomic_set(&op->usage, 1);
42+ op->state = FSCACHE_OP_ST_INITIALISED;
43+ op->debug_id = atomic_inc_return(&fscache_op_debug_id);
44+ op->processor = processor;
45+ op->cancel = cancel ?: fscache_operation_dummy_cancel;
46+ op->release = release;
47+ INIT_LIST_HEAD(&op->pend_link);
48+ fscache_stat(&fscache_n_op_initialised);
49+}
50+EXPORT_SYMBOL(fscache_operation_init);
51+
2352 /**
2453 * fscache_enqueue_operation - Enqueue an operation for processing
2554 * @op: The operation to enqueue
@@ -75,6 +104,43 @@ static void fscache_run_op(struct fscache_object *object, · 49 unmodified lines
75104 fscache_stat(&fscache_n_op_run);
76105 }
77106
107+/*
108+ * report an unexpected submission
109+ */
110+static void fscache_report_unexpected_submission(struct fscache_object *object,
111+ struct fscache_operation *op,
112+ const struct fscache_state *ostate)
113+{
114+ static bool once_only;
115+ struct fscache_operation *p;
116+ unsigned n;
117+
118+ if (once_only)
119+ return;
120+ once_only = true;
121+
122+ kdebug("unexpected submission OP%x [OBJ%x %s]",
123+ op->debug_id, object->debug_id, object->state->name);
124+ kdebug("objstate=%s [%s]", object->state->name, ostate->name);
125+ kdebug("objflags=%lx", object->flags);
126+ kdebug("objevent=%lx [%lx]", object->events, object->event_mask);
127+ kdebug("ops=%u inp=%u exc=%u",
128+ object->n_ops, object->n_in_progress, object->n_exclusive);
129+
130+ if (!list_empty(&object->pending_ops)) {
131+ n = 0;
132+ list_for_each_entry(p, &object->pending_ops, pend_link) {
133+ ASSERTCMP(p->object, ==, object);
134+ kdebug("%p %p", op->processor, op->release);
135+ n++;
136+ }
137+
138+ kdebug("n=%u", n);
139+ }
140+
141+ dump_stack();
142+}
143+
78144 /*
79145 * submit an exclusive operation for an object
80146 * - other ops are excluded from running simultaneously with this one
@@ -83,6 +149,8 @@ static void fscache_run_op(struct fscache_object *object, · 2 unmodified lines
83149 int fscache_submit_exclusive_op(struct fscache_object *object,
84150 struct fscache_operation *op)
85151 {
152+ const struct fscache_state *ostate;
153+ unsigned long flags;
86154 int ret;
87155
88156 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
@@ -95,8 +163,21 @@ int fscache_submit_exclusive_op(struct fscache_object *object, · 6 unmodified lines
95163 ASSERTCMP(object->n_ops, >=, object->n_exclusive);
96164 ASSERT(list_empty(&op->pend_link));
97165
166+ ostate = object->state;
167+ smp_rmb();
168+
98169 op->state = FSCACHE_OP_ST_PENDING;
99− if (fscache_object_is_active(object)) {
170+ flags = READ_ONCE(object->flags);
171+ if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
172+ fscache_stat(&fscache_n_op_rejected);
173+ op->cancel(op);
174+ op->state = FSCACHE_OP_ST_CANCELLED;
175+ ret = -ENOBUFS;
176+ } else if (unlikely(fscache_cache_is_broken(object))) {
177+ op->cancel(op);
178+ op->state = FSCACHE_OP_ST_CANCELLED;
179+ ret = -EIO;
180+ } else if (flags & BIT(FSCACHE_OBJECT_IS_AVAILABLE)) {
100181 op->object = object;
101182 object->n_ops++;
102183 object->n_exclusive++; /* reads and writes must wait */
@@ -118,7 +199,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object, · 15 unmodified lines
118199 /* need to issue a new write op after this */
119200 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
120201 ret = 0;
121− } else if (test_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
202+ } else if (flags & BIT(FSCACHE_OBJECT_IS_LOOKED_UP)) {
122203 op->object = object;
123204 object->n_ops++;
124205 object->n_exclusive++; /* reads and writes must wait */
@@ -126,55 +207,21 @@ int fscache_submit_exclusive_op(struct fscache_object *object, · 1 unmodified line
126207 list_add_tail(&op->pend_link, &object->pending_ops);
127208 fscache_stat(&fscache_n_op_pend);
128209 ret = 0;
210+ } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
211+ op->cancel(op);
212+ op->state = FSCACHE_OP_ST_CANCELLED;
213+ ret = -ENOBUFS;
129214 } else {
130− /* If we're in any other state, there must have been an I/O
131− * error of some nature.
132− */
133− ASSERT(test_bit(FSCACHE_IOERROR, &object->cache->flags));
134− ret = -EIO;
215+ fscache_report_unexpected_submission(object, op, ostate);
216+ op->cancel(op);
217+ op->state = FSCACHE_OP_ST_CANCELLED;
218+ ret = -ENOBUFS;
135219 }
136220
137221 spin_unlock(&object->lock);
138222 return ret;
139223 }
140224
141−/*
142− * report an unexpected submission
143− */
144−static void fscache_report_unexpected_submission(struct fscache_object *object,
145− struct fscache_operation *op,
146− const struct fscache_state *ostate)
147−{
148− static bool once_only;
149− struct fscache_operation *p;
150− unsigned n;
151−
152− if (once_only)
153− return;
154− once_only = true;
155−
156− kdebug("unexpected submission OP%x [OBJ%x %s]",
157− op->debug_id, object->debug_id, object->state->name);
158− kdebug("objstate=%s [%s]", object->state->name, ostate->name);
159− kdebug("objflags=%lx", object->flags);
160− kdebug("objevent=%lx [%lx]", object->events, object->event_mask);
161− kdebug("ops=%u inp=%u exc=%u",
162− object->n_ops, object->n_in_progress, object->n_exclusive);
163−
164− if (!list_empty(&object->pending_ops)) {
165− n = 0;
166− list_for_each_entry(p, &object->pending_ops, pend_link) {
167− ASSERTCMP(p->object, ==, object);
168− kdebug("%p %p", op->processor, op->release);
169− n++;
170− }
171−
172− kdebug("n=%u", n);
173− }
174−
175− dump_stack();
176−}
177−
178225 /*
179226 * submit an operation for an object
180227 * - objects may be submitted only in the following states:
@@ -187,6 +234,7 @@ int fscache_submit_op(struct fscache_object *object, · 6 unmodified lines
187234 struct fscache_operation *op)
188235 {
189236 const struct fscache_state *ostate;
237+ unsigned long flags;
190238 int ret;
191239
192240 _enter("{OBJ%x OP%x},{%u}",
@@ -204,7 +252,17 @@ int fscache_submit_op(struct fscache_object *object, · 11 unmodified lines
204252 smp_rmb();
205253
206254 op->state = FSCACHE_OP_ST_PENDING;
207− if (fscache_object_is_active(object)) {
255+ flags = READ_ONCE(object->flags);
256+ if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
257+ fscache_stat(&fscache_n_op_rejected);
258+ op->cancel(op);
259+ op->state = FSCACHE_OP_ST_CANCELLED;
260+ ret = -ENOBUFS;
261+ } else if (unlikely(fscache_cache_is_broken(object))) {
262+ op->cancel(op);
263+ op->state = FSCACHE_OP_ST_CANCELLED;
264+ ret = -EIO;
265+ } else if (flags & BIT(FSCACHE_OBJECT_IS_AVAILABLE)) {
208266 op->object = object;
209267 object->n_ops++;
210268
@@ -222,23 +280,21 @@ int fscache_submit_op(struct fscache_object *object, · 11 unmodified lines
222280 fscache_run_op(object, op);
223281 }
224282 ret = 0;
225− } else if (test_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
283+ } else if (flags & BIT(FSCACHE_OBJECT_IS_LOOKED_UP)) {
226284 op->object = object;
227285 object->n_ops++;
228286 atomic_inc(&op->usage);
229287 list_add_tail(&op->pend_link, &object->pending_ops);
230288 fscache_stat(&fscache_n_op_pend);
231289 ret = 0;
232− } else if (fscache_object_is_dying(object)) {
233− fscache_stat(&fscache_n_op_rejected);
290+ } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
291+ op->cancel(op);
234292 op->state = FSCACHE_OP_ST_CANCELLED;
235293 ret = -ENOBUFS;
236− } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
294+ } else {
237295 fscache_report_unexpected_submission(object, op, ostate);
238296 ASSERT(!fscache_object_is_active(object));
239− op->state = FSCACHE_OP_ST_CANCELLED;
240− ret = -ENOBUFS;
241− } else {
297+ op->cancel(op);
242298 op->state = FSCACHE_OP_ST_CANCELLED;
243299 ret = -ENOBUFS;
244300 }
@@ -293,9 +349,10 @@ void fscache_start_operations(struct fscache_object *object) · 48 unmodified lines
293349 * cancel an operation that's pending on an object
294350 */
295351 int fscache_cancel_op(struct fscache_operation *op,
296− void (*do_cancel)(struct fscache_operation *))
352+ bool cancel_in_progress_op)
297353 {
298354 struct fscache_object *object = op->object;
355+ bool put = false;
299356 int ret;
300357
301358 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);
@@ -309,19 +366,37 @@ int fscache_cancel_op(struct fscache_operation *op, · 7 unmodified lines
309366 ret = -EBUSY;
310367 if (op->state == FSCACHE_OP_ST_PENDING) {
311368 ASSERT(!list_empty(&op->pend_link));
312− fscache_stat(&fscache_n_op_cancelled);
313369 list_del_init(&op->pend_link);
314− if (do_cancel)
315− do_cancel(op);
370+ put = true;
371+
372+ fscache_stat(&fscache_n_op_cancelled);
373+ op->cancel(op);
374+ op->state = FSCACHE_OP_ST_CANCELLED;
375+ if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
376+ object->n_exclusive--;
377+ if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
378+ wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
379+ ret = 0;
380+ } else if (op->state == FSCACHE_OP_ST_IN_PROGRESS && cancel_in_progress_op) {
381+ ASSERTCMP(object->n_in_progress, >, 0);
382+ if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
383+ object->n_exclusive--;
384+ object->n_in_progress--;
385+ if (object->n_in_progress == 0)
386+ fscache_start_operations(object);
387+
388+ fscache_stat(&fscache_n_op_cancelled);
389+ op->cancel(op);
316390 op->state = FSCACHE_OP_ST_CANCELLED;
317391 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
318392 object->n_exclusive--;
319393 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
320394 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
321− fscache_put_operation(op);
322395 ret = 0;
323396 }
324397
398+ if (put)
399+ fscache_put_operation(op);
325400 spin_unlock(&object->lock);
326401 _leave(" = %d", ret);
327402 return ret;
@@ -345,6 +420,7 @@ void fscache_cancel_all_ops(struct fscache_object *object) · 17 unmodified lines
345420 list_del_init(&op->pend_link);
346421
347422 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
423+ op->cancel(op);
348424 op->state = FSCACHE_OP_ST_CANCELLED;
349425
350426 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
@@ -377,8 +453,12 @@ void fscache_op_complete(struct fscache_operation *op, bool cancelled) · 26 unmodified lines
377453
378454 spin_lock(&object->lock);
379455
380− op->state = cancelled ?
381− FSCACHE_OP_ST_CANCELLED : FSCACHE_OP_ST_COMPLETE;
456+ if (!cancelled) {
457+ op->state = FSCACHE_OP_ST_COMPLETE;
458+ } else {
459+ op->cancel(op);
460+ op->state = FSCACHE_OP_ST_CANCELLED;
461+ }
382462
383463 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
384464 object->n_exclusive--;
@@ -409,9 +489,9 @@ void fscache_put_operation(struct fscache_operation *op) · 24 unmodified lines
409489 return;
410490
411491 _debug("PUT OP");
412− ASSERTIFCMP(op->state != FSCACHE_OP_ST_COMPLETE,
492+ ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
493+ op->state != FSCACHE_OP_ST_COMPLETE,
413494 op->state, ==, FSCACHE_OP_ST_CANCELLED);
414− op->state = FSCACHE_OP_ST_DEAD;
415495
416496 fscache_stat(&fscache_n_op_release);
417497
@@ -419,37 +499,39 @@ void fscache_put_operation(struct fscache_operation *op) · 1 unmodified line
419499 op->release(op);
420500 op->release = NULL;
421501 }
502+ op->state = FSCACHE_OP_ST_DEAD;
422503
423504 object = op->object;
505+ if (likely(object)) {
506+ if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags))
507+ atomic_dec(&object->n_reads);
508+ if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags))
509+ fscache_unuse_cookie(object);
510+
511+ /* now... we may get called with the object spinlock held, so we
512+ * complete the cleanup here only if we can immediately acquire the
513+ * lock, and defer it otherwise */
514+ if (!spin_trylock(&object->lock)) {
515+ _debug("defer put");
516+ fscache_stat(&fscache_n_op_deferred_release);
517+
518+ cache = object->cache;
519+ spin_lock(&cache->op_gc_list_lock);
520+ list_add_tail(&op->pend_link, &cache->op_gc_list);
521+ spin_unlock(&cache->op_gc_list_lock);
522+ schedule_work(&cache->op_gc);
523+ _leave(" [defer]");
524+ return;
525+ }
424526
425− if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags))
426− atomic_dec(&object->n_reads);
427− if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags))
428− fscache_unuse_cookie(object);
429−
430− /* now... we may get called with the object spinlock held, so we
431− * complete the cleanup here only if we can immediately acquire the
432− * lock, and defer it otherwise */
433− if (!spin_trylock(&object->lock)) {
434− _debug("defer put");
435− fscache_stat(&fscache_n_op_deferred_release);
527+ ASSERTCMP(object->n_ops, >, 0);
528+ object->n_ops--;
529+ if (object->n_ops == 0)
530+ fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED);
436531
437− cache = object->cache;
438− spin_lock(&cache->op_gc_list_lock);
439− list_add_tail(&op->pend_link, &cache->op_gc_list);
440− spin_unlock(&cache->op_gc_list_lock);
441− schedule_work(&cache->op_gc);
442− _leave(" [defer]");
443− return;
532+ spin_unlock(&object->lock);
444533 }
445534
446− ASSERTCMP(object->n_ops, >, 0);
447− object->n_ops--;
448− if (object->n_ops == 0)
449− fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED);
450−
451− spin_unlock(&object->lock);
452−
453535 kfree(op);
454536 _leave(" [done]");
455537 }
fs/fscache/page.c+43−43
@@ -213,7 +213,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie) · 212 unmodified lines
213213 return -ENOMEM;
214214 }
215215
216− fscache_operation_init(op, fscache_attr_changed_op, NULL);
216+ fscache_operation_init(op, fscache_attr_changed_op, NULL, NULL);
217217 op->flags = FSCACHE_OP_ASYNC |
218218 (1 << FSCACHE_OP_EXCLUSIVE) |
219219 (1 << FSCACHE_OP_UNUSE_COOKIE);
@@ -239,7 +239,7 @@ nobufs_dec: · 19 unmodified lines
239239 wake_cookie = __fscache_unuse_cookie(cookie);
240240 nobufs:
241241 spin_unlock(&cookie->lock);
242− kfree(op);
242+ fscache_put_operation(op);
243243 if (wake_cookie)
244244 __fscache_wake_unused_cookie(cookie);
245245 fscache_stat(&fscache_n_attr_changed_nobufs);
@@ -248,6 +248,17 @@ nobufs: · 2 unmodified lines
248248 }
249249 EXPORT_SYMBOL(__fscache_attr_changed);
250250
251+/*
252+ * Handle cancellation of a pending retrieval op
253+ */
254+static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
255+{
256+ struct fscache_retrieval *op =
257+ container_of(_op, struct fscache_retrieval, op);
258+
259+ atomic_set(&op->n_pages, 0);
260+}
261+
251262 /*
252263 * release a retrieval op reference
253264 */
@@ -258,11 +269,12 @@ static void fscache_release_retrieval_op(struct fscache_operation *_op) · 4 unmodified lines
258269
259270 _enter("{OP%x}", op->op.debug_id);
260271
261− ASSERTCMP(atomic_read(&op->n_pages), ==, 0);
272+ ASSERTIFCMP(op->op.state != FSCACHE_OP_ST_INITIALISED,
273+ atomic_read(&op->n_pages), ==, 0);
262274
263275 fscache_hist(fscache_retrieval_histogram, op->start_time);
264276 if (op->context)
265− fscache_put_context(op->op.object->cookie, op->context);
277+ fscache_put_context(op->cookie, op->context);
266278
267279 _leave("");
268280 }
@@ -285,15 +297,24 @@ static struct fscache_retrieval *fscache_alloc_retrieval( · 16 unmodified lines
285297 return NULL;
286298 }
287299
288− fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op);
300+ fscache_operation_init(&op->op, NULL,
301+ fscache_do_cancel_retrieval,
302+ fscache_release_retrieval_op);
289303 op->op.flags = FSCACHE_OP_MYTHREAD |
290304 (1UL << FSCACHE_OP_WAITING) |
291305 (1UL << FSCACHE_OP_UNUSE_COOKIE);
306+ op->cookie = cookie;
292307 op->mapping = mapping;
293308 op->end_io_func = end_io_func;
294309 op->context = context;
295310 op->start_time = jiffies;
296311 INIT_LIST_HEAD(&op->to_do);
312+
313+ /* Pin the netfs read context in case we need to do the actual netfs
314+ * read because we've encountered a cache read failure.
315+ */
316+ if (context)
317+ fscache_get_context(op->cookie, context);
297318 return op;
298319 }
299320
@@ -329,25 +350,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie) · 29 unmodified lines
329350 return 0;
330351 }
331352
332−/*
333− * Handle cancellation of a pending retrieval op
334− */
335−static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
336−{
337− struct fscache_retrieval *op =
338− container_of(_op, struct fscache_retrieval, op);
339−
340− atomic_set(&op->n_pages, 0);
341−}
342−
343353 /*
344354 * wait for an object to become active (or dead)
345355 */
346356 int fscache_wait_for_operation_activation(struct fscache_object *object,
347357 struct fscache_operation *op,
348358 atomic_t *stat_op_waits,
349− atomic_t *stat_object_dead,
350− void (*do_cancel)(struct fscache_operation *))
359+ atomic_t *stat_object_dead)
351360 {
352361 int ret;
353362
@@ -359,7 +368,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object, · 5 unmodified lines
359368 fscache_stat(stat_op_waits);
360369 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
361370 TASK_INTERRUPTIBLE) != 0) {
362− ret = fscache_cancel_op(op, do_cancel);
371+ ret = fscache_cancel_op(op, false);
363372 if (ret == 0)
364373 return -ERESTARTSYS;
365374
@@ -377,11 +386,13 @@ check_if_dead: · 11 unmodified lines
377386 _leave(" = -ENOBUFS [cancelled]");
378387 return -ENOBUFS;
379388 }
380− if (unlikely(fscache_object_is_dead(object))) {
381− pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
382− fscache_cancel_op(op, do_cancel);
389+ if (unlikely(fscache_object_is_dying(object) ||
390+ fscache_cache_is_broken(object))) {
391+ enum fscache_operation_state state = op->state;
392+ fscache_cancel_op(op, true);
383393 if (stat_object_dead)
384394 fscache_stat(stat_object_dead);
395+ _leave(" = -ENOBUFS [obj dead %d]", state);
385396 return -ENOBUFS;
386397 }
387398 return 0;
@@ -453,17 +464,12 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie, · 65 unmodified lines
453464
454465 fscache_stat(&fscache_n_retrieval_ops);
455466
456− /* pin the netfs read context in case we need to do the actual netfs
457− * read because we've encountered a cache read failure */
458− fscache_get_context(object->cookie, op->context);
459−
460467 /* we wait for the operation to become active, and then process it
461468 * *here*, in this thread, and not in the thread pool */
462469 ret = fscache_wait_for_operation_activation(
463470 object, &op->op,
464471 __fscache_stat(&fscache_n_retrieval_op_waits),
465− __fscache_stat(&fscache_n_retrievals_object_dead),
466− fscache_do_cancel_retrieval);
472+ __fscache_stat(&fscache_n_retrievals_object_dead));
467473 if (ret < 0)
468474 goto error;
469475
@@ -503,7 +509,7 @@ nobufs_unlock: · 33 unmodified lines
503509 spin_unlock(&cookie->lock);
504510 if (wake_cookie)
505511 __fscache_wake_unused_cookie(cookie);
506− kfree(op);
512+ fscache_put_retrieval(op);
507513 nobufs:
508514 fscache_stat(&fscache_n_retrievals_nobufs);
509515 _leave(" = -ENOBUFS");
@@ -584,17 +590,12 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie, · 74 unmodified lines
584590
585591 fscache_stat(&fscache_n_retrieval_ops);
586592
587− /* pin the netfs read context in case we need to do the actual netfs
588− * read because we've encountered a cache read failure */
589− fscache_get_context(object->cookie, op->context);
590−
591593 /* we wait for the operation to become active, and then process it
592594 * *here*, in this thread, and not in the thread pool */
593595 ret = fscache_wait_for_operation_activation(
594596 object, &op->op,
595597 __fscache_stat(&fscache_n_retrieval_op_waits),
596− __fscache_stat(&fscache_n_retrievals_object_dead),
597− fscache_do_cancel_retrieval);
598+ __fscache_stat(&fscache_n_retrievals_object_dead));
598599 if (ret < 0)
599600 goto error;
600601
@@ -632,7 +633,7 @@ nobufs_unlock_dec: · 31 unmodified lines
632633 wake_cookie = __fscache_unuse_cookie(cookie);
633634 nobufs_unlock:
634635 spin_unlock(&cookie->lock);
635− kfree(op);
636+ fscache_put_retrieval(op);
636637 if (wake_cookie)
637638 __fscache_wake_unused_cookie(cookie);
638639 nobufs:
@@ -700,8 +701,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie, · 61 unmodified lines
700701 ret = fscache_wait_for_operation_activation(
701702 object, &op->op,
702703 __fscache_stat(&fscache_n_alloc_op_waits),
703− __fscache_stat(&fscache_n_allocs_object_dead),
704− fscache_do_cancel_retrieval);
704+ __fscache_stat(&fscache_n_allocs_object_dead));
705705 if (ret < 0)
706706 goto error;
707707
@@ -726,7 +726,7 @@ nobufs_unlock_dec: · 18 unmodified lines
726726 wake_cookie = __fscache_unuse_cookie(cookie);
727727 nobufs_unlock:
728728 spin_unlock(&cookie->lock);
729− kfree(op);
729+ fscache_put_retrieval(op);
730730 if (wake_cookie)
731731 __fscache_wake_unused_cookie(cookie);
732732 nobufs:
@@ -944,7 +944,7 @@ int __fscache_write_page(struct fscache_cookie *cookie, · 211 unmodified lines
944944 if (!op)
945945 goto nomem;
946946
947− fscache_operation_init(&op->op, fscache_write_op,
947+ fscache_operation_init(&op->op, fscache_write_op, NULL,
948948 fscache_release_write_op);
949949 op->op.flags = FSCACHE_OP_ASYNC |
950950 (1 << FSCACHE_OP_WAITING) |
@@ -1016,7 +1016,7 @@ already_pending: · 65 unmodified lines
10161016 spin_unlock(&object->lock);
10171017 spin_unlock(&cookie->lock);
10181018 radix_tree_preload_end();
1019− kfree(op);
1019+ fscache_put_operation(&op->op);
10201020 fscache_stat(&fscache_n_stores_ok);
10211021 _leave(" = 0");
10221022 return 0;
@@ -1036,7 +1036,7 @@ nobufs_unlock_obj: · 13 unmodified lines
10361036 nobufs:
10371037 spin_unlock(&cookie->lock);
10381038 radix_tree_preload_end();
1039− kfree(op);
1039+ fscache_put_operation(&op->op);
10401040 if (wake_cookie)
10411041 __fscache_wake_unused_cookie(cookie);
10421042 fscache_stat(&fscache_n_stores_nobufs);
@@ -1044,7 +1044,7 @@ nobufs: · 1 unmodified line
10441044 return -ENOBUFS;
10451045
10461046 nomem_free:
1047− kfree(op);
1047+ fscache_put_operation(&op->op);
10481048 nomem:
10491049 fscache_stat(&fscache_n_stores_oom);
10501050 _leave(" = -ENOMEM");
fs/fscache/stats.c+13−1
@@ -23,6 +23,7 @@ atomic_t fscache_n_op_run; · 22 unmodified lines
2323 atomic_t fscache_n_op_enqueue;
2424 atomic_t fscache_n_op_requeue;
2525 atomic_t fscache_n_op_deferred_release;
26+atomic_t fscache_n_op_initialised;
2627 atomic_t fscache_n_op_release;
2728 atomic_t fscache_n_op_gc;
2829 atomic_t fscache_n_op_cancelled;
@@ -130,6 +131,11 @@ atomic_t fscache_n_cop_write_page; · 101 unmodified lines
130131 atomic_t fscache_n_cop_uncache_page;
131132 atomic_t fscache_n_cop_dissociate_pages;
132133
134+atomic_t fscache_n_cache_no_space_reject;
135+atomic_t fscache_n_cache_stale_objects;
136+atomic_t fscache_n_cache_retired_objects;
137+atomic_t fscache_n_cache_culled_objects;
138+
133139 /*
134140 * display the general statistics
135141 */
@@ -246,7 +252,8 @@ static int fscache_stats_show(struct seq_file *m, void *v) · 110 unmodified lines
246252 atomic_read(&fscache_n_op_enqueue),
247253 atomic_read(&fscache_n_op_cancelled),
248254 atomic_read(&fscache_n_op_rejected));
249− seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
255+ seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n",
256+ atomic_read(&fscache_n_op_initialised),
250257 atomic_read(&fscache_n_op_deferred_release),
251258 atomic_read(&fscache_n_op_release),
252259 atomic_read(&fscache_n_op_gc));
@@ -271,6 +278,11 @@ static int fscache_stats_show(struct seq_file *m, void *v) · 18 unmodified lines
271278 atomic_read(&fscache_n_cop_write_page),
272279 atomic_read(&fscache_n_cop_uncache_page),
273280 atomic_read(&fscache_n_cop_dissociate_pages));
281+ seq_printf(m, "CacheEv: nsp=%d stl=%d rtr=%d cul=%d\n",
282+ atomic_read(&fscache_n_cache_no_space_reject),
283+ atomic_read(&fscache_n_cache_stale_objects),
284+ atomic_read(&fscache_n_cache_retired_objects),
285+ atomic_read(&fscache_n_cache_culled_objects));
274286 return 0;
275287 }
276288
fs/fuse/file.c+1−1
@@ -1169,7 +1169,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 1168 unmodified lines
11691169 if (err <= 0)
11701170 goto out;
11711171
1172− err = file_remove_suid(file);
1172+ err = file_remove_privs(file);
11731173 if (err)
11741174 goto out;
11751175
fs/hfs/hfs_fs.h+1−1
@@ -252,7 +252,7 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb); · 251 unmodified lines
252252 #define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
253253 #define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60)
254254
255−#define HFS_I(inode) (list_entry(inode, struct hfs_inode_info, vfs_inode))
255+#define HFS_I(inode) (container_of(inode, struct hfs_inode_info, vfs_inode))
256256 #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info)
257257
258258 #define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
fs/hfsplus/hfsplus_fs.h+1−1
@@ -263,7 +263,7 @@ struct hfsplus_inode_info { · 262 unmodified lines
263263
264264 static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
265265 {
266− return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
266+ return container_of(inode, struct hfsplus_inode_info, vfs_inode);
267267 }
268268
269269 /*
fs/hpfs/hpfs_fn.h+1−1
@@ -304,7 +304,7 @@ extern const struct address_space_operations hpfs_symlink_aops; · 303 unmodified lines
304304
305305 static inline struct hpfs_inode_info *hpfs_i(struct inode *inode)
306306 {
307− return list_entry(inode, struct hpfs_inode_info, vfs_inode);
307+ return container_of(inode, struct hpfs_inode_info, vfs_inode);
308308 }
309309
310310 static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
fs/inode.c+46−20
@@ -841,7 +841,11 @@ unsigned int get_next_ino(void) · 840 unmodified lines
841841 }
842842 #endif
843843
844− *p = ++res;
844+ res++;
845+ /* get_next_ino should not provide a 0 inode number */
846+ if (unlikely(!res))
847+ res++;
848+ *p = res;
845849 put_cpu_var(last_ino);
846850 return res;
847851 }
@@ -1674,7 +1678,31 @@ int should_remove_suid(struct dentry *dentry) · 826 unmodified lines
16741678 }
16751679 EXPORT_SYMBOL(should_remove_suid);
16761680
1677−static int __remove_suid(struct dentry *dentry, int kill)
1681+/*
1682+ * Return mask of changes for notify_change() that need to be done as a
1683+ * response to write or truncate. Return 0 if nothing has to be changed.
1684+ * Negative value on error (change should be denied).
1685+ */
1686+int dentry_needs_remove_privs(struct dentry *dentry)
1687+{
1688+ struct inode *inode = d_inode(dentry);
1689+ int mask = 0;
1690+ int ret;
1691+
1692+ if (IS_NOSEC(inode))
1693+ return 0;
1694+
1695+ mask = should_remove_suid(dentry);
1696+ ret = security_inode_need_killpriv(dentry);
1697+ if (ret < 0)
1698+ return ret;
1699+ if (ret)
1700+ mask |= ATTR_KILL_PRIV;
1701+ return mask;
1702+}
1703+EXPORT_SYMBOL(dentry_needs_remove_privs);
1704+
1705+static int __remove_privs(struct dentry *dentry, int kill)
16781706 {
16791707 struct iattr newattrs;
16801708
@@ -1686,33 +1714,32 @@ static int __remove_suid(struct dentry *dentry, int kill) · 5 unmodified lines
16861714 return notify_change(dentry, &newattrs, NULL);
16871715 }
16881716
1689−int file_remove_suid(struct file *file)
1717+/*
1718+ * Remove special file priviledges (suid, capabilities) when file is written
1719+ * to or truncated.
1720+ */
1721+int file_remove_privs(struct file *file)
16901722 {
16911723 struct dentry *dentry = file->f_path.dentry;
16921724 struct inode *inode = d_inode(dentry);
1693− int killsuid;
1694− int killpriv;
1725+ int kill;
16951726 int error = 0;
16961727
16971728 /* Fast path for nothing security related */
16981729 if (IS_NOSEC(inode))
16991730 return 0;
17001731
1701− killsuid = should_remove_suid(dentry);
1702− killpriv = security_inode_need_killpriv(dentry);
1703−
1704− if (killpriv < 0)
1705− return killpriv;
1706− if (killpriv)
1707− error = security_inode_killpriv(dentry);
1708− if (!error && killsuid)
1709− error = __remove_suid(dentry, killsuid);
1710− if (!error && (inode->i_sb->s_flags & MS_NOSEC))
1711− inode->i_flags |= S_NOSEC;
1732+ kill = file_needs_remove_privs(file);
1733+ if (kill < 0)
1734+ return kill;
1735+ if (kill)
1736+ error = __remove_privs(dentry, kill);
1737+ if (!error)
1738+ inode_has_no_xattr(inode);
17121739
17131740 return error;
17141741 }
1715−EXPORT_SYMBOL(file_remove_suid);
1742+EXPORT_SYMBOL(file_remove_privs);
17161743
17171744 /**
17181745 * file_update_time - update mtime and ctime time
@@ -1967,9 +1994,8 @@ EXPORT_SYMBOL(inode_dio_wait); · 248 unmodified lines
19671994 * inode is being instantiated). The reason for the cmpxchg() loop
19681995 * --- which wouldn't be necessary if all code paths which modify
19691996 * i_flags actually followed this rule, is that there is at least one
1970− * code path which doesn't today --- for example,
1971− * __generic_file_aio_write() calls file_remove_suid() without holding
1972− * i_mutex --- so we use cmpxchg() out of an abundance of caution.
1997+ * code path which doesn't today so we use cmpxchg() out of an abundance
1998+ * of caution.
19731999 *
19742000 * In the long run, i_mutex is overkill, and we should probably look
19752001 * at using the i_lock spinlock to protect i_flags, and then make sure
fs/internal.h+1−0
@@ -107,6 +107,7 @@ extern struct file *do_file_open_root(struct dentry *, struct vfsmount *, · 106 unmodified lines
107107 extern long do_handle_open(int mountdirfd,
108108 struct file_handle __user *ufh, int open_flag);
109109 extern int open_check_o_direct(struct file *f);
110+extern int vfs_open(const struct path *, struct file *, const struct cred *);
110111
111112 /*
112113 * inode.c
fs/jffs2/os-linux.h+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 struct kstatfs;
2020 struct kvec;
2121
22−#define JFFS2_INODE_INFO(i) (list_entry(i, struct jffs2_inode_info, vfs_inode))
22+#define JFFS2_INODE_INFO(i) (container_of(i, struct jffs2_inode_info, vfs_inode))
2323 #define OFNI_EDONI_2SFFJ(f) (&(f)->vfs_inode)
2424 #define JFFS2_SB_INFO(sb) (sb->s_fs_info)
2525 #define OFNI_BS_2SFFJ(c) ((struct super_block *)c->os_priv)
fs/jfs/jfs_incore.h+1−1
@@ -206,7 +206,7 @@ struct jfs_sb_info { · 205 unmodified lines
206206
207207 static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
208208 {
209− return list_entry(inode, struct jfs_inode_info, vfs_inode);
209+ return container_of(inode, struct jfs_inode_info, vfs_inode);
210210 }
211211
212212 static inline int jfs_dirtable_inline(struct inode *inode)
fs/libfs.c+0−5
@@ -20,11 +20,6 @@ · 19 unmodified lines
2020
2121 #include "internal.h"
2222
23−static inline int simple_positive(struct dentry *dentry)
24−{
25− return d_really_is_positive(dentry) && !d_unhashed(dentry);
26−}
27−
2823 int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
2924 struct kstat *stat)
3025 {
fs/minix/dir.c+0−5
@@ -45,11 +45,6 @@ minix_last_byte(struct inode *inode, unsigned long page_nr) · 44 unmodified lines
4545 return last_byte;
4646 }
4747
48−static inline unsigned long dir_pages(struct inode *inode)
49−{
50− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
51−}
52−
5348 static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
5449 {
5550 struct address_space *mapping = page->mapping;
fs/minix/minix.h+1−1
@@ -84,7 +84,7 @@ static inline struct minix_sb_info *minix_sb(struct super_block *sb) · 83 unmodified lines
8484
8585 static inline struct minix_inode_info *minix_i(struct inode *inode)
8686 {
87− return list_entry(inode, struct minix_inode_info, vfs_inode);
87+ return container_of(inode, struct minix_inode_info, vfs_inode);
8888 }
8989
9090 static inline unsigned minix_blocks_needed(unsigned bits, unsigned blocksize)
fs/namei.c+3−3
@@ -792,7 +792,7 @@ static void set_root(struct nameidata *nd) · 791 unmodified lines
792792 get_fs_root(current->fs, &nd->root);
793793 }
794794
795−static unsigned set_root_rcu(struct nameidata *nd)
795+static void set_root_rcu(struct nameidata *nd)
796796 {
797797 struct fs_struct *fs = current->fs;
798798 unsigned seq;
@@ -802,7 +802,6 @@ static unsigned set_root_rcu(struct nameidata *nd) · 3 unmodified lines
802802 nd->root = fs->root;
803803 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq);
804804 } while (read_seqcount_retry(&fs->seq, seq));
805− return nd->root_seq;
806805 }
807806
808807 static void path_put_conditional(struct path *path, struct nameidata *nd)
@@ -1998,7 +1997,8 @@ static const char *path_init(struct nameidata *nd, unsigned flags) · 1189 unmodified lines
19981997 if (*s == '/') {
19991998 if (flags & LOOKUP_RCU) {
20001999 rcu_read_lock();
2001− nd->seq = set_root_rcu(nd);
2000+ set_root_rcu(nd);
2001+ nd->seq = nd->root_seq;
20022002 } else {
20032003 set_root(nd);
20042004 path_get(&nd->root);
fs/ncpfs/dir.c+2−0
@@ -1145,6 +1145,8 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, · 1144 unmodified lines
11451145 case 0x00:
11461146 ncp_dbg(1, "renamed %pd -> %pd\n",
11471147 old_dentry, new_dentry);
1148+ ncp_d_prune(old_dentry);
1149+ ncp_d_prune(new_dentry);
11481150 break;
11491151 case 0x9E:
11501152 error = -ENAMETOOLONG;
fs/nfs/dir.c+1−1
@@ -1768,7 +1768,7 @@ EXPORT_SYMBOL_GPL(nfs_mkdir); · 1767 unmodified lines
17681768
17691769 static void nfs_dentry_handle_enoent(struct dentry *dentry)
17701770 {
1771− if (d_really_is_positive(dentry) && !d_unhashed(dentry))
1771+ if (simple_positive(dentry))
17721772 d_delete(dentry);
17731773 }
17741774
fs/nilfs2/dir.c+0−5
@@ -61,11 +61,6 @@ static inline void nilfs_put_page(struct page *page) · 60 unmodified lines
6161 page_cache_release(page);
6262 }
6363
64−static inline unsigned long dir_pages(struct inode *inode)
65−{
66− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
67−}
68−
6964 /*
7065 * Return the offset into page `page_nr' of the last valid
7166 * byte in that page, plus one.
fs/nilfs2/inode.c+2−20
@@ -307,31 +307,13 @@ static int nilfs_write_end(struct file *file, struct address_space *mapping, · 306 unmodified lines
307307 static ssize_t
308308 nilfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
309309 {
310− struct file *file = iocb->ki_filp;
311− struct address_space *mapping = file->f_mapping;
312− struct inode *inode = file->f_mapping->host;
313− size_t count = iov_iter_count(iter);
314− ssize_t size;
310+ struct inode *inode = file_inode(iocb->ki_filp);
315311
316312 if (iov_iter_rw(iter) == WRITE)
317313 return 0;
318314
319315 /* Needs synchronization with the cleaner */
320− size = blockdev_direct_IO(iocb, inode, iter, offset, nilfs_get_block);
321−
322− /*
323− * In case of error extending write may have instantiated a few
324− * blocks outside i_size. Trim these off again.
325− */
326− if (unlikely(iov_iter_rw(iter) == WRITE && size < 0)) {
327− loff_t isize = i_size_read(inode);
328− loff_t end = offset + count;
329−
330− if (end > isize)
331− nilfs_write_failed(mapping, end);
332− }
333−
334− return size;
316+ return blockdev_direct_IO(iocb, inode, iter, offset, nilfs_get_block);
335317 }
336318
337319 const struct address_space_operations nilfs_aops = {
fs/ntfs/file.c+1−1
@@ -382,7 +382,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb, · 381 unmodified lines
382382 base_ni = ni;
383383 if (NInoAttr(ni))
384384 base_ni = ni->ext.base_ntfs_ino;
385− err = file_remove_suid(file);
385+ err = file_remove_privs(file);
386386 if (unlikely(err))
387387 goto out;
388388 /*
fs/ntfs/inode.h+1−1
@@ -239,7 +239,7 @@ typedef struct { · 238 unmodified lines
239239 */
240240 static inline ntfs_inode *NTFS_I(struct inode *inode)
241241 {
242− return (ntfs_inode *)list_entry(inode, big_ntfs_inode, vfs_inode);
242+ return (ntfs_inode *)container_of(inode, big_ntfs_inode, vfs_inode);
243243 }
244244
245245 static inline struct inode *VFS_I(ntfs_inode *ni)
fs/open.c+36−25
@@ -51,8 +51,10 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, · 50 unmodified lines
5151 newattrs.ia_valid |= ATTR_FILE;
5252 }
5353
54− /* Remove suid/sgid on truncate too */
55− ret = should_remove_suid(dentry);
54+ /* Remove suid, sgid, and file capabilities on truncate too */
55+ ret = dentry_needs_remove_privs(dentry);
56+ if (ret < 0)
57+ return ret;
5658 if (ret)
5759 newattrs.ia_valid |= ret | ATTR_FORCE;
5860
@@ -678,18 +680,18 @@ int open_check_o_direct(struct file *f) · 619 unmodified lines
678680 }
679681
680682 static int do_dentry_open(struct file *f,
683+ struct inode *inode,
681684 int (*open)(struct inode *, struct file *),
682685 const struct cred *cred)
683686 {
684687 static const struct file_operations empty_fops = {};
685− struct inode *inode;
686688 int error;
687689
688690 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
689691 FMODE_PREAD | FMODE_PWRITE;
690692
691693 path_get(&f->f_path);
692− inode = f->f_inode = f->f_path.dentry->d_inode;
694+ f->f_inode = inode;
693695 f->f_mapping = inode->i_mapping;
694696
695697 if (unlikely(f->f_flags & O_PATH)) {
@@ -793,7 +795,8 @@ int finish_open(struct file *file, struct dentry *dentry, · 97 unmodified lines
793795 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
794796
795797 file->f_path.dentry = dentry;
796− error = do_dentry_open(file, open, current_cred());
798+ error = do_dentry_open(file, d_backing_inode(dentry), open,
799+ current_cred());
797800 if (!error)
798801 *opened |= FILE_OPENED;
799802
@@ -822,6 +825,34 @@ int finish_no_open(struct file *file, struct dentry *dentry) · 22 unmodified lines
822825 }
823826 EXPORT_SYMBOL(finish_no_open);
824827
828+char *file_path(struct file *filp, char *buf, int buflen)
829+{
830+ return d_path(&filp->f_path, buf, buflen);
831+}
832+EXPORT_SYMBOL(file_path);
833+
834+/**
835+ * vfs_open - open the file at the given path
836+ * @path: path to open
837+ * @file: newly allocated file with f_flag initialized
838+ * @cred: credentials to use
839+ */
840+int vfs_open(const struct path *path, struct file *file,
841+ const struct cred *cred)
842+{
843+ struct dentry *dentry = path->dentry;
844+ struct inode *inode = dentry->d_inode;
845+
846+ file->f_path = *path;
847+ if (dentry->d_flags & DCACHE_OP_SELECT_INODE) {
848+ inode = dentry->d_op->d_select_inode(dentry, file->f_flags);
849+ if (IS_ERR(inode))
850+ return PTR_ERR(inode);
851+ }
852+
853+ return do_dentry_open(file, inode, NULL, cred);
854+}
855+
825856 struct file *dentry_open(const struct path *path, int flags,
826857 const struct cred *cred)
827858 {
@@ -853,26 +884,6 @@ struct file *dentry_open(const struct path *path, int flags, · 25 unmodified lines
853884 }
854885 EXPORT_SYMBOL(dentry_open);
855886
856−/**
857− * vfs_open - open the file at the given path
858− * @path: path to open
859− * @filp: newly allocated file with f_flag initialized
860− * @cred: credentials to use
861− */
862−int vfs_open(const struct path *path, struct file *filp,
863− const struct cred *cred)
864−{
865− struct inode *inode = path->dentry->d_inode;
866−
867− if (inode->i_op->dentry_open)
868− return inode->i_op->dentry_open(path->dentry, filp, cred);
869− else {
870− filp->f_path = *path;
871− return do_dentry_open(filp, NULL, cred);
872− }
873−}
874−EXPORT_SYMBOL(vfs_open);
875−
876887 static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
877888 {
878889 int lookup_flags = 0;
fs/overlayfs/inode.c+7−15
@@ -337,37 +337,30 @@ static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type, · 336 unmodified lines
337337 return true;
338338 }
339339
340−static int ovl_dentry_open(struct dentry *dentry, struct file *file,
341− const struct cred *cred)
340+struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
342341 {
343342 int err;
344343 struct path realpath;
345344 enum ovl_path_type type;
346− bool want_write = false;
347345
348346 type = ovl_path_real(dentry, &realpath);
349− if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) {
350− want_write = true;
347+ if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
351348 err = ovl_want_write(dentry);
352349 if (err)
353− goto out;
350+ return ERR_PTR(err);
354351
355− if (file->f_flags & O_TRUNC)
352+ if (file_flags & O_TRUNC)
356353 err = ovl_copy_up_last(dentry, NULL, true);
357354 else
358355 err = ovl_copy_up(dentry);
356+ ovl_drop_write(dentry);
359357 if (err)
360− goto out_drop_write;
358+ return ERR_PTR(err);
361359
362360 ovl_path_upper(dentry, &realpath);
363361 }
364362
365− err = vfs_open(&realpath, file, cred);
366−out_drop_write:
367− if (want_write)
368− ovl_drop_write(dentry);
369−out:
370− return err;
363+ return d_backing_inode(realpath.dentry);
371364 }
372365
373366 static const struct inode_operations ovl_file_inode_operations = {
@@ -378,7 +371,6 @@ static const struct inode_operations ovl_file_inode_operations = { · 4 unmodified lines
378371 .getxattr = ovl_getxattr,
379372 .listxattr = ovl_listxattr,
380373 .removexattr = ovl_removexattr,
381− .dentry_open = ovl_dentry_open,
382374 };
383375
384376 static const struct inode_operations ovl_symlink_inode_operations = {
fs/overlayfs/overlayfs.h+1−0
@@ -173,6 +173,7 @@ ssize_t ovl_getxattr(struct dentry *dentry, const char *name, · 172 unmodified lines
173173 void *value, size_t size);
174174 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
175175 int ovl_removexattr(struct dentry *dentry, const char *name);
176+struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags);
176177
177178 struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
178179 struct ovl_entry *oe);
fs/overlayfs/super.c+1−0
@@ -316,6 +316,7 @@ static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags) · 315 unmodified lines
316316
317317 static const struct dentry_operations ovl_dentry_operations = {
318318 .d_release = ovl_dentry_release,
319+ .d_select_inode = ovl_d_select_inode,
319320 };
320321
321322 static const struct dentry_operations ovl_reval_dentry_operations = {
fs/posix_acl.c+20−26
@@ -547,51 +547,45 @@ posix_acl_create(struct inode *dir, umode_t *mode, · 546 unmodified lines
547547 struct posix_acl **default_acl, struct posix_acl **acl)
548548 {
549549 struct posix_acl *p;
550+ struct posix_acl *clone;
550551 int ret;
551552
553+ *acl = NULL;
554+ *default_acl = NULL;
555+
552556 if (S_ISLNK(*mode) || !IS_POSIXACL(dir))
553− goto no_acl;
557+ return 0;
554558
555559 p = get_acl(dir, ACL_TYPE_DEFAULT);
556− if (IS_ERR(p)) {
557− if (p == ERR_PTR(-EOPNOTSUPP))
558− goto apply_umask;
559− return PTR_ERR(p);
560+ if (!p || p == ERR_PTR(-EOPNOTSUPP)) {
561+ *mode &= ~current_umask();
562+ return 0;
560563 }
564+ if (IS_ERR(p))
565+ return PTR_ERR(p);
561566
562− if (!p)
563− goto apply_umask;
564−
565− *acl = posix_acl_clone(p, GFP_NOFS);
566− if (!*acl)
567+ clone = posix_acl_clone(p, GFP_NOFS);
568+ if (!clone)
567569 goto no_mem;
568570
569− ret = posix_acl_create_masq(*acl, mode);
571+ ret = posix_acl_create_masq(clone, mode);
570572 if (ret < 0)
571573 goto no_mem_clone;
572574
573− if (ret == 0) {
574− posix_acl_release(*acl);
575− *acl = NULL;
576− }
575+ if (ret == 0)
576+ posix_acl_release(clone);
577+ else
578+ *acl = clone;
577579
578− if (!S_ISDIR(*mode)) {
580+ if (!S_ISDIR(*mode))
579581 posix_acl_release(p);
580− *default_acl = NULL;
581− } else {
582+ else
582583 *default_acl = p;
583− }
584− return 0;
585584
586−apply_umask:
587− *mode &= ~current_umask();
588−no_acl:
589− *default_acl = NULL;
590− *acl = NULL;
591585 return 0;
592586
593587 no_mem_clone:
594− posix_acl_release(*acl);
588+ posix_acl_release(clone);
595589 no_mem:
596590 posix_acl_release(p);
597591 return -ENOMEM;
fs/proc/nommu.c+1−1
@@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region) · 63 unmodified lines
6464
6565 if (file) {
6666 seq_pad(m, ' ');
67− seq_path(m, &file->f_path, "");
67+ seq_file_path(m, file, "");
6868 }
6969
7070 seq_putc(m, '\n');
fs/proc/task_mmu.c+2−2
@@ -310,7 +310,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) · 309 unmodified lines
310310 */
311311 if (file) {
312312 seq_pad(m, ' ');
313− seq_path(m, &file->f_path, "\n");
313+ seq_file_path(m, file, "\n");
314314 goto done;
315315 }
316316
@@ -1509,7 +1509,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) · 1192 unmodified lines
15091509
15101510 if (file) {
15111511 seq_puts(m, " file=");
1512− seq_path(m, &file->f_path, "\n\t= ");
1512+ seq_file_path(m, file, "\n\t= ");
15131513 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
15141514 seq_puts(m, " heap");
15151515 } else {
fs/proc/task_nommu.c+1−1
@@ -180,7 +180,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, · 179 unmodified lines
180180
181181 if (file) {
182182 seq_pad(m, ' ');
183− seq_path(m, &file->f_path, "");
183+ seq_file_path(m, file, "");
184184 } else if (mm) {
185185 pid_t tid = pid_of_stack(priv, vma, is_pid);
186186
fs/qnx6/dir.c+0−5
@@ -32,11 +32,6 @@ static struct page *qnx6_get_page(struct inode *dir, unsigned long n) · 31 unmodified lines
3232 return page;
3333 }
3434
35−static inline unsigned long dir_pages(struct inode *inode)
36−{
37− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
38−}
39−
4035 static unsigned last_entry(struct inode *inode, unsigned long page_nr)
4136 {
4237 unsigned long last_byte = inode->i_size;
fs/seq_file.c+14−0
@@ -490,6 +490,20 @@ int seq_path(struct seq_file *m, const struct path *path, const char *esc) · 489 unmodified lines
490490 }
491491 EXPORT_SYMBOL(seq_path);
492492
493+/**
494+ * seq_file_path - seq_file interface to print a pathname of a file
495+ * @m: the seq_file handle
496+ * @file: the struct file to print
497+ * @esc: set of characters to escape in the output
498+ *
499+ * return the absolute path to the file.
500+ */
501+int seq_file_path(struct seq_file *m, struct file *file, const char *esc)
502+{
503+ return seq_path(m, &file->f_path, esc);
504+}
505+EXPORT_SYMBOL(seq_file_path);
506+
493507 /*
494508 * Same as seq_path, but relative to supplied root.
495509 */
fs/squashfs/squashfs_fs_i.h+1−1
@@ -49,6 +49,6 @@ struct squashfs_inode_info { · 48 unmodified lines
4949
5050 static inline struct squashfs_inode_info *squashfs_i(struct inode *inode)
5151 {
52− return list_entry(inode, struct squashfs_inode_info, vfs_inode);
52+ return container_of(inode, struct squashfs_inode_info, vfs_inode);
5353 }
5454 #endif
fs/super.c+1−1
@@ -842,7 +842,7 @@ int get_anon_bdev(dev_t *p) · 841 unmodified lines
842842 else if (error)
843843 return -EAGAIN;
844844
845− if (dev == (1 << MINORBITS)) {
845+ if (dev >= (1 << MINORBITS)) {
846846 spin_lock(&unnamed_dev_lock);
847847 ida_remove(&unnamed_dev_ida, dev);
848848 if (unnamed_dev_start > dev)
fs/sysv/dir.c+0−5
@@ -33,11 +33,6 @@ static inline void dir_put_page(struct page *page) · 32 unmodified lines
3333 page_cache_release(page);
3434 }
3535
36−static inline unsigned long dir_pages(struct inode *inode)
37−{
38− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
39−}
40−
4136 static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
4237 {
4338 struct address_space *mapping = page->mapping;
fs/sysv/sysv.h+1−1
@@ -73,7 +73,7 @@ struct sysv_inode_info { · 72 unmodified lines
7373
7474 static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
7575 {
76− return list_entry(inode, struct sysv_inode_info, vfs_inode);
76+ return container_of(inode, struct sysv_inode_info, vfs_inode);
7777 }
7878
7979 static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
fs/tracefs/inode.c+3−8
@@ -496,16 +496,11 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *pare · 495 unmodified lines
496496 return dentry;
497497 }
498498
499−static inline int tracefs_positive(struct dentry *dentry)
500−{
501− return dentry->d_inode && !d_unhashed(dentry);
502−}
503−
504499 static int __tracefs_remove(struct dentry *dentry, struct dentry *parent)
505500 {
506501 int ret = 0;
507502
508− if (tracefs_positive(dentry)) {
503+ if (simple_positive(dentry)) {
509504 if (dentry->d_inode) {
510505 dget(dentry);
511506 switch (dentry->d_inode->i_mode & S_IFMT) {
@@ -582,7 +577,7 @@ void tracefs_remove_recursive(struct dentry *dentry) · 70 unmodified lines
582577 */
583578 spin_lock(&parent->d_lock);
584579 list_for_each_entry(child, &parent->d_subdirs, d_child) {
585− if (!tracefs_positive(child))
580+ if (!simple_positive(child))
586581 continue;
587582
588583 /* perhaps simple_empty(child) makes more sense */
@@ -603,7 +598,7 @@ void tracefs_remove_recursive(struct dentry *dentry) · 14 unmodified lines
603598 * from d_subdirs. When releasing the parent->d_lock we can
604599 * no longer trust that the next pointer is valid.
605600 * Restart the loop. We'll skip this one with the
606− * tracefs_positive() check.
601+ * simple_positive() check.
607602 */
608603 goto loop;
609604 }
fs/udf/udf_i.h+1−1
@@ -56,7 +56,7 @@ struct udf_inode_info { · 55 unmodified lines
5656
5757 static inline struct udf_inode_info *UDF_I(struct inode *inode)
5858 {
59− return list_entry(inode, struct udf_inode_info, vfs_inode);
59+ return container_of(inode, struct udf_inode_info, vfs_inode);
6060 }
6161
6262 #endif /* _UDF_I_H) */
fs/ufs/balloc.c+17−17
@@ -51,8 +51,8 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) · 50 unmodified lines
5151
5252 if (ufs_fragnum(fragment) + count > uspi->s_fpg)
5353 ufs_error (sb, "ufs_free_fragments", "internal error");
54−
55− lock_ufs(sb);
54+
55+ mutex_lock(&UFS_SB(sb)->s_lock);
5656
5757 cgno = ufs_dtog(uspi, fragment);
5858 bit = ufs_dtogd(uspi, fragment);
@@ -115,13 +115,13 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) · 56 unmodified lines
115115 if (sb->s_flags & MS_SYNCHRONOUS)
116116 ubh_sync_block(UCPI_UBH(ucpi));
117117 ufs_mark_sb_dirty(sb);
118−
119− unlock_ufs(sb);
118+
119+ mutex_unlock(&UFS_SB(sb)->s_lock);
120120 UFSD("EXIT\n");
121121 return;
122122
123123 failed:
124− unlock_ufs(sb);
124+ mutex_unlock(&UFS_SB(sb)->s_lock);
125125 UFSD("EXIT (FAILED)\n");
126126 return;
127127 }
@@ -151,7 +151,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) · 23 unmodified lines
151151 goto failed;
152152 }
153153
154− lock_ufs(sb);
154+ mutex_lock(&UFS_SB(sb)->s_lock);
155155
156156 do_more:
157157 overflow = 0;
@@ -211,12 +211,12 @@ do_more: · 53 unmodified lines
211211 }
212212
213213 ufs_mark_sb_dirty(sb);
214− unlock_ufs(sb);
214+ mutex_unlock(&UFS_SB(sb)->s_lock);
215215 UFSD("EXIT\n");
216216 return;
217217
218218 failed_unlock:
219− unlock_ufs(sb);
219+ mutex_unlock(&UFS_SB(sb)->s_lock);
220220 failed:
221221 UFSD("EXIT (FAILED)\n");
222222 return;
@@ -357,7 +357,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 134 unmodified lines
357357 usb1 = ubh_get_usb_first(uspi);
358358 *err = -ENOSPC;
359359
360− lock_ufs(sb);
360+ mutex_lock(&UFS_SB(sb)->s_lock);
361361 tmp = ufs_data_ptr_to_cpu(sb, p);
362362
363363 if (count + ufs_fragnum(fragment) > uspi->s_fpb) {
@@ -378,19 +378,19 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 14 unmodified lines
378378 "fragment %llu, tmp %llu\n",
379379 (unsigned long long)fragment,
380380 (unsigned long long)tmp);
381− unlock_ufs(sb);
381+ mutex_unlock(&UFS_SB(sb)->s_lock);
382382 return INVBLOCK;
383383 }
384384 if (fragment < UFS_I(inode)->i_lastfrag) {
385385 UFSD("EXIT (ALREADY ALLOCATED)\n");
386− unlock_ufs(sb);
386+ mutex_unlock(&UFS_SB(sb)->s_lock);
387387 return 0;
388388 }
389389 }
390390 else {
391391 if (tmp) {
392392 UFSD("EXIT (ALREADY ALLOCATED)\n");
393− unlock_ufs(sb);
393+ mutex_unlock(&UFS_SB(sb)->s_lock);
394394 return 0;
395395 }
396396 }
@@ -399,7 +399,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 2 unmodified lines
399399 * There is not enough space for user on the device
400400 */
401401 if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) {
402− unlock_ufs(sb);
402+ mutex_unlock(&UFS_SB(sb)->s_lock);
403403 UFSD("EXIT (FAILED)\n");
404404 return 0;
405405 }
@@ -424,7 +424,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 18 unmodified lines
424424 ufs_clear_frags(inode, result + oldcount,
425425 newcount - oldcount, locked_page != NULL);
426426 }
427− unlock_ufs(sb);
427+ mutex_unlock(&UFS_SB(sb)->s_lock);
428428 UFSD("EXIT, result %llu\n", (unsigned long long)result);
429429 return result;
430430 }
@@ -439,7 +439,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 8 unmodified lines
439439 fragment + count);
440440 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
441441 locked_page != NULL);
442− unlock_ufs(sb);
442+ mutex_unlock(&UFS_SB(sb)->s_lock);
443443 UFSD("EXIT, result %llu\n", (unsigned long long)result);
444444 return result;
445445 }
@@ -477,7 +477,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 31 unmodified lines
477477 *err = 0;
478478 UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag,
479479 fragment + count);
480− unlock_ufs(sb);
480+ mutex_unlock(&UFS_SB(sb)->s_lock);
481481 if (newcount < request)
482482 ufs_free_fragments (inode, result + newcount, request - newcount);
483483 ufs_free_fragments (inode, tmp, oldcount);
@@ -485,7 +485,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, · 1 unmodified line
485485 return result;
486486 }
487487
488− unlock_ufs(sb);
488+ mutex_unlock(&UFS_SB(sb)->s_lock);
489489 UFSD("EXIT (FAILED)\n");
490490 return 0;
491491 }
fs/ufs/dir.c+8−11
@@ -65,11 +65,6 @@ static inline void ufs_put_page(struct page *page) · 64 unmodified lines
6565 page_cache_release(page);
6666 }
6767
68−static inline unsigned long ufs_dir_pages(struct inode *inode)
69−{
70− return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
71−}
72−
7368 ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
7469 {
7570 ino_t res = 0;
@@ -87,7 +82,8 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) · 11 unmodified lines
8782
8883 /* Releases the page */
8984 void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
90− struct page *page, struct inode *inode)
85+ struct page *page, struct inode *inode,
86+ bool update_times)
9187 {
9288 loff_t pos = page_offset(page) +
9389 (char *) de - (char *) page_address(page);
@@ -103,7 +99,8 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, · 9 unmodified lines
10399
104100 err = ufs_commit_chunk(page, pos, len);
105101 ufs_put_page(page);
106− dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
102+ if (update_times)
103+ dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
107104 mark_inode_dirty(dir);
108105 }
109106
@@ -256,7 +253,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, · 146 unmodified lines
256253 int namelen = qstr->len;
257254 unsigned reclen = UFS_DIR_REC_LEN(namelen);
258255 unsigned long start, n;
259− unsigned long npages = ufs_dir_pages(dir);
256+ unsigned long npages = dir_pages(dir);
260257 struct page *page = NULL;
261258 struct ufs_inode_info *ui = UFS_I(dir);
262259 struct ufs_dir_entry *de;
@@ -320,7 +317,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) · 57 unmodified lines
320317 unsigned short rec_len, name_len;
321318 struct page *page = NULL;
322319 struct ufs_dir_entry *de;
323− unsigned long npages = ufs_dir_pages(dir);
320+ unsigned long npages = dir_pages(dir);
324321 unsigned long n;
325322 char *kaddr;
326323 loff_t pos;
@@ -437,7 +434,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx) · 110 unmodified lines
437434 struct super_block *sb = inode->i_sb;
438435 unsigned int offset = pos & ~PAGE_CACHE_MASK;
439436 unsigned long n = pos >> PAGE_CACHE_SHIFT;
440− unsigned long npages = ufs_dir_pages(inode);
437+ unsigned long npages = dir_pages(inode);
441438 unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
442439 int need_revalidate = file->f_version != inode->i_version;
443440 unsigned flags = UFS_SB(sb)->s_flags;
@@ -608,7 +605,7 @@ int ufs_empty_dir(struct inode * inode) · 164 unmodified lines
608605 {
609606 struct super_block *sb = inode->i_sb;
610607 struct page *page = NULL;
611− unsigned long i, npages = ufs_dir_pages(inode);
608+ unsigned long i, npages = dir_pages(inode);
612609
613610 for (i = 0; i < npages; i++) {
614611 char *kaddr;
fs/ufs/ialloc.c+8−8
@@ -69,11 +69,11 @@ void ufs_free_inode (struct inode * inode) · 68 unmodified lines
6969
7070 ino = inode->i_ino;
7171
72− lock_ufs(sb);
72+ mutex_lock(&UFS_SB(sb)->s_lock);
7373
7474 if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) {
7575 ufs_warning(sb, "ufs_free_inode", "reserved inode or nonexistent inode %u\n", ino);
76− unlock_ufs(sb);
76+ mutex_unlock(&UFS_SB(sb)->s_lock);
7777 return;
7878 }
7979
@@ -81,7 +81,7 @@ void ufs_free_inode (struct inode * inode) · 1 unmodified line
8181 bit = ufs_inotocgoff (ino);
8282 ucpi = ufs_load_cylinder (sb, cg);
8383 if (!ucpi) {
84− unlock_ufs(sb);
84+ mutex_unlock(&UFS_SB(sb)->s_lock);
8585 return;
8686 }
8787 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
@@ -115,7 +115,7 @@ void ufs_free_inode (struct inode * inode) · 27 unmodified lines
115115 ubh_sync_block(UCPI_UBH(ucpi));
116116
117117 ufs_mark_sb_dirty(sb);
118− unlock_ufs(sb);
118+ mutex_unlock(&UFS_SB(sb)->s_lock);
119119 UFSD("EXIT\n");
120120 }
121121
@@ -193,7 +193,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode) · 71 unmodified lines
193193 sbi = UFS_SB(sb);
194194 uspi = sbi->s_uspi;
195195
196− lock_ufs(sb);
196+ mutex_lock(&sbi->s_lock);
197197
198198 /*
199199 * Try to place the inode in its parent directory
@@ -331,21 +331,21 @@ cg_found: · 131 unmodified lines
331331 sync_dirty_buffer(bh);
332332 brelse(bh);
333333 }
334− unlock_ufs(sb);
334+ mutex_unlock(&sbi->s_lock);
335335
336336 UFSD("allocating inode %lu\n", inode->i_ino);
337337 UFSD("EXIT\n");
338338 return inode;
339339
340340 fail_remove_inode:
341− unlock_ufs(sb);
341+ mutex_unlock(&sbi->s_lock);
342342 clear_nlink(inode);
343343 unlock_new_inode(inode);
344344 iput(inode);
345345 UFSD("EXIT (FAILED): err %d\n", err);
346346 return ERR_PTR(err);
347347 failed:
348− unlock_ufs(sb);
348+ mutex_unlock(&sbi->s_lock);
349349 make_bad_inode(inode);
350350 iput (inode);
351351 UFSD("EXIT (FAILED): err %d\n", err);
fs/ufs/inode.c+4−1
@@ -903,6 +903,9 @@ void ufs_evict_inode(struct inode * inode) · 902 unmodified lines
903903 invalidate_inode_buffers(inode);
904904 clear_inode(inode);
905905
906− if (want_delete)
906+ if (want_delete) {
907+ lock_ufs(inode->i_sb);
907908 ufs_free_inode(inode);
909+ unlock_ufs(inode->i_sb);
910+ }
908911 }
fs/ufs/namei.c+33−46
@@ -56,11 +56,9 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi · 55 unmodified lines
5656 if (dentry->d_name.len > UFS_MAXNAMLEN)
5757 return ERR_PTR(-ENAMETOOLONG);
5858
59− lock_ufs(dir->i_sb);
6059 ino = ufs_inode_by_name(dir, &dentry->d_name);
6160 if (ino)
6261 inode = ufs_iget(dir->i_sb, ino);
63− unlock_ufs(dir->i_sb);
6462 return d_splice_alias(inode, dentry);
6563 }
6664
@@ -76,24 +74,16 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, umode_t mode, · 9 unmodified lines
7674 bool excl)
7775 {
7876 struct inode *inode;
79− int err;
80−
81− UFSD("BEGIN\n");
8277
8378 inode = ufs_new_inode(dir, mode);
84− err = PTR_ERR(inode);
79+ if (IS_ERR(inode))
80+ return PTR_ERR(inode);
8581
86− if (!IS_ERR(inode)) {
87− inode->i_op = &ufs_file_inode_operations;
88− inode->i_fop = &ufs_file_operations;
89− inode->i_mapping->a_ops = &ufs_aops;
90− mark_inode_dirty(inode);
91− lock_ufs(dir->i_sb);
92− err = ufs_add_nondir(dentry, inode);
93− unlock_ufs(dir->i_sb);
94− }
95− UFSD("END: err=%d\n", err);
96− return err;
82+ inode->i_op = &ufs_file_inode_operations;
83+ inode->i_fop = &ufs_file_operations;
84+ inode->i_mapping->a_ops = &ufs_aops;
85+ mark_inode_dirty(inode);
86+ return ufs_add_nondir(dentry, inode);
9787 }
9888
9989 static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
@@ -110,9 +100,7 @@ static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev · 10 unmodified lines
110100 init_special_inode(inode, mode, rdev);
111101 ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev);
112102 mark_inode_dirty(inode);
113− lock_ufs(dir->i_sb);
114103 err = ufs_add_nondir(dentry, inode);
115− unlock_ufs(dir->i_sb);
116104 }
117105 return err;
118106 }
@@ -121,19 +109,18 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, · 2 unmodified lines
121109 const char * symname)
122110 {
123111 struct super_block * sb = dir->i_sb;
124− int err = -ENAMETOOLONG;
112+ int err;
125113 unsigned l = strlen(symname)+1;
126114 struct inode * inode;
127115
128116 if (l > sb->s_blocksize)
129− goto out_notlocked;
117+ return -ENAMETOOLONG;
130118
131119 inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
132120 err = PTR_ERR(inode);
133121 if (IS_ERR(inode))
134− goto out_notlocked;
122+ return err;
135123
136− lock_ufs(dir->i_sb);
137124 if (l > UFS_SB(sb)->s_uspi->s_maxsymlinklen) {
138125 /* slow symlink */
139126 inode->i_op = &ufs_symlink_inode_operations;
@@ -150,17 +137,13 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, · 10 unmodified lines
150137 }
151138 mark_inode_dirty(inode);
152139
153− err = ufs_add_nondir(dentry, inode);
154−out:
155− unlock_ufs(dir->i_sb);
156−out_notlocked:
157− return err;
140+ return ufs_add_nondir(dentry, inode);
158141
159142 out_fail:
160143 inode_dec_link_count(inode);
161144 unlock_new_inode(inode);
162145 iput(inode);
163− goto out;
146+ return err;
164147 }
165148
166149 static int ufs_link (struct dentry * old_dentry, struct inode * dir,
@@ -169,14 +152,16 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir, · 2 unmodified lines
169152 struct inode *inode = d_inode(old_dentry);
170153 int error;
171154
172− lock_ufs(dir->i_sb);
173−
174155 inode->i_ctime = CURRENT_TIME_SEC;
175156 inode_inc_link_count(inode);
176157 ihold(inode);
177158
178− error = ufs_add_nondir(dentry, inode);
179− unlock_ufs(dir->i_sb);
159+ error = ufs_add_link(dentry, inode);
160+ if (error) {
161+ inode_dec_link_count(inode);
162+ iput(inode);
163+ } else
164+ d_instantiate(dentry, inode);
180165 return error;
181166 }
182167
@@ -185,9 +170,12 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) · 2 unmodified lines
185170 struct inode * inode;
186171 int err;
187172
173+ inode_inc_link_count(dir);
174+
188175 inode = ufs_new_inode(dir, S_IFDIR|mode);
176+ err = PTR_ERR(inode);
189177 if (IS_ERR(inode))
190− return PTR_ERR(inode);
178+ goto out_dir;
191179
192180 inode->i_op = &ufs_dir_inode_operations;
193181 inode->i_fop = &ufs_dir_operations;
@@ -195,9 +183,6 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) · 1 unmodified line
195183
196184 inode_inc_link_count(inode);
197185
198− lock_ufs(dir->i_sb);
199− inode_inc_link_count(dir);
200−
201186 err = ufs_make_empty(inode, dir);
202187 if (err)
203188 goto out_fail;
@@ -205,20 +190,19 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) · 1 unmodified line
205190 err = ufs_add_link(dentry, inode);
206191 if (err)
207192 goto out_fail;
208− unlock_ufs(dir->i_sb);
209193
194+ unlock_new_inode(inode);
210195 d_instantiate(dentry, inode);
211−out:
212− return err;
196+ return 0;
213197
214198 out_fail:
215199 inode_dec_link_count(inode);
216200 inode_dec_link_count(inode);
217201 unlock_new_inode(inode);
218202 iput (inode);
203+out_dir:
219204 inode_dec_link_count(dir);
220− unlock_ufs(dir->i_sb);
221− goto out;
205+ return err;
222206 }
223207
224208 static int ufs_unlink(struct inode *dir, struct dentry *dentry)
@@ -248,7 +232,6 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry) · 23 unmodified lines
248232 struct inode * inode = d_inode(dentry);
249233 int err= -ENOTEMPTY;
250234
251− lock_ufs(dir->i_sb);
252235 if (ufs_empty_dir (inode)) {
253236 err = ufs_unlink(dir, dentry);
254237 if (!err) {
@@ -257,7 +240,6 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry) · 2 unmodified lines
257240 inode_dec_link_count(dir);
258241 }
259242 }
260− unlock_ufs(dir->i_sb);
261243 return err;
262244 }
263245
@@ -295,7 +277,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, · 31 unmodified lines
295277 new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page);
296278 if (!new_de)
297279 goto out_dir;
298− ufs_set_link(new_dir, new_de, new_page, old_inode);
280+ ufs_set_link(new_dir, new_de, new_page, old_inode, 1);
299281 new_inode->i_ctime = CURRENT_TIME_SEC;
300282 if (dir_de)
301283 drop_nlink(new_inode);
@@ -318,7 +300,12 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, · 16 unmodified lines
318300 mark_inode_dirty(old_inode);
319301
320302 if (dir_de) {
321− ufs_set_link(old_inode, dir_de, dir_page, new_dir);
303+ if (old_dir != new_dir)
304+ ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0);
305+ else {
306+ kunmap(dir_page);
307+ page_cache_release(dir_page);
308+ }
322309 inode_dec_link_count(old_dir);
323310 }
324311 return 0;
fs/ufs/super.c+11−0
@@ -695,6 +695,7 @@ static int ufs_sync_fs(struct super_block *sb, int wait) · 694 unmodified lines
695695 unsigned flags;
696696
697697 lock_ufs(sb);
698+ mutex_lock(&UFS_SB(sb)->s_lock);
698699
699700 UFSD("ENTER\n");
700701
@@ -712,6 +713,7 @@ static int ufs_sync_fs(struct super_block *sb, int wait) · 11 unmodified lines
712713 ufs_put_cstotal(sb);
713714
714715 UFSD("EXIT\n");
716+ mutex_unlock(&UFS_SB(sb)->s_lock);
715717 unlock_ufs(sb);
716718
717719 return 0;
@@ -800,6 +802,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) · 82 unmodified lines
800802 UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));
801803
802804 mutex_init(&sbi->mutex);
805+ mutex_init(&sbi->s_lock);
803806 spin_lock_init(&sbi->work_lock);
804807 INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
805808 /*
@@ -1278,6 +1281,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 472 unmodified lines
12781281
12791282 sync_filesystem(sb);
12801283 lock_ufs(sb);
1284+ mutex_lock(&UFS_SB(sb)->s_lock);
12811285 uspi = UFS_SB(sb)->s_uspi;
12821286 flags = UFS_SB(sb)->s_flags;
12831287 usb1 = ubh_get_usb_first(uspi);
@@ -1291,6 +1295,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 7 unmodified lines
12911295 new_mount_opt = 0;
12921296 ufs_set_opt (new_mount_opt, ONERROR_LOCK);
12931297 if (!ufs_parse_options (data, &new_mount_opt)) {
1298+ mutex_unlock(&UFS_SB(sb)->s_lock);
12941299 unlock_ufs(sb);
12951300 return -EINVAL;
12961301 }
@@ -1298,12 +1303,14 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 1 unmodified line
12981303 new_mount_opt |= ufstype;
12991304 } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) {
13001305 pr_err("ufstype can't be changed during remount\n");
1306+ mutex_unlock(&UFS_SB(sb)->s_lock);
13011307 unlock_ufs(sb);
13021308 return -EINVAL;
13031309 }
13041310
13051311 if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
13061312 UFS_SB(sb)->s_mount_opt = new_mount_opt;
1313+ mutex_unlock(&UFS_SB(sb)->s_lock);
13071314 unlock_ufs(sb);
13081315 return 0;
13091316 }
@@ -1327,6 +1334,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 17 unmodified lines
13271334 */
13281335 #ifndef CONFIG_UFS_FS_WRITE
13291336 pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n");
1337+ mutex_unlock(&UFS_SB(sb)->s_lock);
13301338 unlock_ufs(sb);
13311339 return -EINVAL;
13321340 #else
@@ -1336,11 +1344,13 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 3 unmodified lines
13361344 ufstype != UFS_MOUNT_UFSTYPE_SUNx86 &&
13371345 ufstype != UFS_MOUNT_UFSTYPE_UFS2) {
13381346 pr_err("this ufstype is read-only supported\n");
1347+ mutex_unlock(&UFS_SB(sb)->s_lock);
13391348 unlock_ufs(sb);
13401349 return -EINVAL;
13411350 }
13421351 if (!ufs_read_cylinder_structures(sb)) {
13431352 pr_err("failed during remounting\n");
1353+ mutex_unlock(&UFS_SB(sb)->s_lock);
13441354 unlock_ufs(sb);
13451355 return -EPERM;
13461356 }
@@ -1348,6 +1358,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) · 1 unmodified line
13481358 #endif
13491359 }
13501360 UFS_SB(sb)->s_mount_opt = new_mount_opt;
1361+ mutex_unlock(&UFS_SB(sb)->s_lock);
13511362 unlock_ufs(sb);
13521363 return 0;
13531364 }
fs/ufs/ufs.h+2−1
@@ -30,6 +30,7 @@ struct ufs_sb_info { · 29 unmodified lines
3030 int work_queued; /* non-zero if the delayed work is queued */
3131 struct delayed_work sync_work; /* FS sync delayed work */
3232 spinlock_t work_lock; /* protects sync_work and work_queued */
33+ struct mutex s_lock;
3334 };
3435
3536 struct ufs_inode_info {
@@ -105,7 +106,7 @@ extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page · 69 unmodified lines
105106 extern int ufs_empty_dir (struct inode *);
106107 extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **);
107108 extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
108− struct page *page, struct inode *inode);
109+ struct page *page, struct inode *inode, bool update_times);
109110
110111 /* file.c */
111112 extern const struct inode_operations ufs_file_inode_operations;
fs/xfs/xfs_file.c+10−1
@@ -577,6 +577,13 @@ restart: · 576 unmodified lines
577577 if (error)
578578 return error;
579579
580+ /* For changing security info in file_remove_privs() we need i_mutex */
581+ if (*iolock == XFS_IOLOCK_SHARED && !IS_NOSEC(inode)) {
582+ xfs_rw_iunlock(ip, *iolock);
583+ *iolock = XFS_IOLOCK_EXCL;
584+ xfs_rw_ilock(ip, *iolock);
585+ goto restart;
586+ }
580587 /*
581588 * If the offset is beyond the size of the file, we need to zero any
582589 * blocks that fall between the existing EOF and the start of this
@@ -637,7 +644,9 @@ restart: · 54 unmodified lines
637644 * setgid bits if the process is not being run by root. This keeps
638645 * people from modifying setuid and setgid binaries.
639646 */
640− return file_remove_suid(file);
647+ if (!IS_NOSEC(inode))
648+ return file_remove_privs(file);
649+ return 0;
641650 }
642651
643652 /*
include/linux/dcache.h+7−0
@@ -160,6 +160,7 @@ struct dentry_operations { · 159 unmodified lines
160160 char *(*d_dname)(struct dentry *, char *, int);
161161 struct vfsmount *(*d_automount)(struct path *);
162162 int (*d_manage)(struct dentry *, bool);
163+ struct inode *(*d_select_inode)(struct dentry *, unsigned);
163164 } ____cacheline_aligned;
164165
165166 /*
@@ -225,6 +226,7 @@ struct dentry_operations { · 59 unmodified lines
225226
226227 #define DCACHE_MAY_FREE 0x00800000
227228 #define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */
229+#define DCACHE_OP_SELECT_INODE 0x02000000 /* Unioned entry: dcache op selects inode */
228230
229231 extern seqlock_t rename_lock;
230232
@@ -505,6 +507,11 @@ static inline bool d_really_is_positive(const struct dentry *dentry) · 274 unmodified lines
505507 return dentry->d_inode != NULL;
506508 }
507509
510+static inline int simple_positive(struct dentry *dentry)
511+{
512+ return d_really_is_positive(dentry) && !d_unhashed(dentry);
513+}
514+
508515 extern void d_set_fallthru(struct dentry *dentry);
509516
510517 static inline bool d_is_fallthru(const struct dentry *dentry)
include/linux/fdtable.h+3−0
@@ -47,6 +47,9 @@ struct files_struct { · 46 unmodified lines
4747 * read mostly part
4848 */
4949 atomic_t count;
50+ bool resize_in_progress;
51+ wait_queue_head_t resize_wait;
52+
5053 struct fdtable __rcu *fdt;
5154 struct fdtable fdtab;
5255 /*
include/linux/fs.h+8−3
@@ -1654,7 +1654,6 @@ struct inode_operations { · 1653 unmodified lines
16541654 int (*set_acl)(struct inode *, struct posix_acl *, int);
16551655
16561656 /* WARNING: probably going away soon, do not use! */
1657− int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
16581657 } ____cacheline_aligned;
16591658
16601659 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
@@ -2213,7 +2212,6 @@ extern struct file *file_open_name(struct filename *, int, umode_t); · 552 unmodified lines
22132212 extern struct file *filp_open(const char *, int, umode_t);
22142213 extern struct file *file_open_root(struct dentry *, struct vfsmount *,
22152214 const char *, int);
2216−extern int vfs_open(const struct path *, struct file *, const struct cred *);
22172215 extern struct file * dentry_open(const struct path *, int, const struct cred *);
22182216 extern int filp_close(struct file *, fl_owner_t id);
22192217
@@ -2530,6 +2528,8 @@ extern struct file * open_exec(const char *); · 310 unmodified lines
25302528 extern int is_subdir(struct dentry *, struct dentry *);
25312529 extern int path_is_under(struct path *, struct path *);
25322530
2531+extern char *file_path(struct file *, char *, int);
2532+
25332533 #include <linux/err.h>
25342534
25352535 /* needed for stackable file system support */
@@ -2581,7 +2581,12 @@ extern struct inode *new_inode_pseudo(struct super_block *sb); · 45 unmodified lines
25812581 extern struct inode *new_inode(struct super_block *sb);
25822582 extern void free_inode_nonrcu(struct inode *inode);
25832583 extern int should_remove_suid(struct dentry *);
2584−extern int file_remove_suid(struct file *);
2584+extern int file_remove_privs(struct file *);
2585+extern int dentry_needs_remove_privs(struct dentry *dentry);
2586+static inline int file_needs_remove_privs(struct file *file)
2587+{
2588+ return dentry_needs_remove_privs(file->f_path.dentry);
2589+}
25852590
25862591 extern void __insert_inode_hash(struct inode *, unsigned long hashval);
25872592 static inline void insert_inode_hash(struct inode *inode)
include/linux/fscache-cache.h+27−28
@@ -74,6 +74,7 @@ extern wait_queue_head_t fscache_cache_cleared_wq; · 73 unmodified lines
7474 */
7575 typedef void (*fscache_operation_release_t)(struct fscache_operation *op);
7676 typedef void (*fscache_operation_processor_t)(struct fscache_operation *op);
77+typedef void (*fscache_operation_cancel_t)(struct fscache_operation *op);
7778
7879 enum fscache_operation_state {
7980 FSCACHE_OP_ST_BLANK, /* Op is not yet submitted */
@@ -109,6 +110,9 @@ struct fscache_operation { · 29 unmodified lines
109110 * the op in a non-pool thread */
110111 fscache_operation_processor_t processor;
111112
113+ /* Operation cancellation cleanup (optional) */
114+ fscache_operation_cancel_t cancel;
115+
112116 /* operation releaser */
113117 fscache_operation_release_t release;
114118 };
@@ -119,33 +123,17 @@ extern void fscache_op_work_func(struct work_struct *work); · 4 unmodified lines
119123 extern void fscache_enqueue_operation(struct fscache_operation *);
120124 extern void fscache_op_complete(struct fscache_operation *, bool);
121125 extern void fscache_put_operation(struct fscache_operation *);
122−
123−/**
124− * fscache_operation_init - Do basic initialisation of an operation
125− * @op: The operation to initialise
126− * @release: The release function to assign
127− *
128− * Do basic initialisation of an operation. The caller must still set flags,
129− * object and processor if needed.
130− */
131−static inline void fscache_operation_init(struct fscache_operation *op,
132− fscache_operation_processor_t processor,
133− fscache_operation_release_t release)
134−{
135− INIT_WORK(&op->work, fscache_op_work_func);
136− atomic_set(&op->usage, 1);
137− op->state = FSCACHE_OP_ST_INITIALISED;
138− op->debug_id = atomic_inc_return(&fscache_op_debug_id);
139− op->processor = processor;
140− op->release = release;
141− INIT_LIST_HEAD(&op->pend_link);
142−}
126+extern void fscache_operation_init(struct fscache_operation *,
127+ fscache_operation_processor_t,
128+ fscache_operation_cancel_t,
129+ fscache_operation_release_t);
143130
144131 /*
145132 * data read operation
146133 */
147134 struct fscache_retrieval {
148135 struct fscache_operation op;
136+ struct fscache_cookie *cookie; /* The netfs cookie */
149137 struct address_space *mapping; /* netfs pages */
150138 fscache_rw_complete_t end_io_func; /* function to call on I/O completion */
151139 void *context; /* netfs read context (pinned) */
@@ -371,6 +359,7 @@ struct fscache_object { · 219 unmodified lines
371359 #define FSCACHE_OBJECT_IS_LOOKED_UP 4 /* T if object has been looked up */
372360 #define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */
373361 #define FSCACHE_OBJECT_RETIRED 6 /* T if object was retired on relinquishment */
362+#define FSCACHE_OBJECT_KILLED_BY_CACHE 7 /* T if object was killed by the cache */
374363
375364 struct list_head cache_link; /* link in cache->object_list */
376365 struct hlist_node cookie_link; /* link in cookie->backing_objects */
@@ -410,17 +399,16 @@ static inline bool fscache_object_is_available(struct fscache_object *object) · 33 unmodified lines
410399 return test_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
411400 }
412401
413−static inline bool fscache_object_is_active(struct fscache_object *object)
402+static inline bool fscache_cache_is_broken(struct fscache_object *object)
414403 {
415− return fscache_object_is_available(object) &&
416− fscache_object_is_live(object) &&
417− !test_bit(FSCACHE_IOERROR, &object->cache->flags);
404+ return test_bit(FSCACHE_IOERROR, &object->cache->flags);
418405 }
419406
420−static inline bool fscache_object_is_dead(struct fscache_object *object)
407+static inline bool fscache_object_is_active(struct fscache_object *object)
421408 {
422− return fscache_object_is_dying(object) &&
423− test_bit(FSCACHE_IOERROR, &object->cache->flags);
409+ return fscache_object_is_available(object) &&
410+ fscache_object_is_live(object) &&
411+ !fscache_cache_is_broken(object);
424412 }
425413
426414 /**
@@ -551,4 +539,15 @@ extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object, · 124 unmodified lines
551539 const void *data,
552540 uint16_t datalen);
553541
542+extern void fscache_object_retrying_stale(struct fscache_object *object);
543+
544+enum fscache_why_object_killed {
545+ FSCACHE_OBJECT_IS_STALE,
546+ FSCACHE_OBJECT_NO_SPACE,
547+ FSCACHE_OBJECT_WAS_RETIRED,
548+ FSCACHE_OBJECT_WAS_CULLED,
549+};
550+extern void fscache_object_mark_killed(struct fscache_object *object,
551+ enum fscache_why_object_killed why);
552+
554553 #endif /* _LINUX_FSCACHE_CACHE_H */
include/linux/pagemap.h+6−0
@@ -671,4 +671,10 @@ static inline int add_to_page_cache(struct page *page, · 670 unmodified lines
671671 return error;
672672 }
673673
674+static inline unsigned long dir_pages(struct inode *inode)
675+{
676+ return (unsigned long)(inode->i_size + PAGE_CACHE_SIZE - 1) >>
677+ PAGE_CACHE_SHIFT;
678+}
679+
674680 #endif /* _LINUX_PAGEMAP_H */
include/linux/seq_file.h+1−0
@@ -123,6 +123,7 @@ __printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); · 122 unmodified lines
123123 __printf(2, 0) int seq_vprintf(struct seq_file *, const char *, va_list args);
124124
125125 int seq_path(struct seq_file *, const struct path *, const char *);
126+int seq_file_path(struct seq_file *, struct file *, const char *);
126127 int seq_dentry(struct seq_file *, struct dentry *, const char *);
127128 int seq_path_root(struct seq_file *m, const struct path *path,
128129 const struct path *root, const char *esc);
kernel/events/core.c+1−1
@@ -5794,7 +5794,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) · 5793 unmodified lines
57945794 * need to add enough zero bytes after the string to handle
57955795 * the 64bit alignment we do later.
57965796 */
5797− name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
5797+ name = file_path(file, buf, PATH_MAX - sizeof(u64));
57985798 if (IS_ERR(name)) {
57995799 name = "//toolong";
58005800 goto cpy_name;
mm/filemap.c+1−1
@@ -2563,7 +2563,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 2562 unmodified lines
25632563
25642564 /* We can write back this queue in page reclaim */
25652565 current->backing_dev_info = inode_to_bdi(inode);
2566− err = file_remove_suid(file);
2566+ err = file_remove_privs(file);
25672567 if (err)
25682568 goto out;
25692569
mm/memory.c+1−1
@@ -3726,7 +3726,7 @@ void print_vma_addr(char *prefix, unsigned long ip) · 3725 unmodified lines
37263726 if (buf) {
37273727 char *p;
37283728
3729− p = d_path(&f->f_path, buf, PAGE_SIZE);
3729+ p = file_path(f, buf, PAGE_SIZE);
37303730 if (IS_ERR(p))
37313731 p = "?";
37323732 printk("%s%s[%lx+%lx]", prefix, kbasename(p),
mm/swapfile.c+1−1
@@ -2032,7 +2032,7 @@ static int swap_show(struct seq_file *swap, void *v) · 2031 unmodified lines
20322032 }
20332033
20342034 file = si->swap_file;
2035− len = seq_path(swap, &file->f_path, " \t\n\\");
2035+ len = seq_file_path(swap, file, " \t\n\\");
20362036 seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
20372037 len < 40 ? 40 - len : 1, " ",
20382038 S_ISBLK(file_inode(file)->i_mode) ?
net/9p/client.c+11−1
@@ -843,7 +843,8 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, · 842 unmodified lines
843843 if (err < 0) {
844844 if (err == -EIO)
845845 c->status = Disconnected;
846− goto reterr;
846+ if (err != -ERESTARTSYS)
847+ goto reterr;
847848 }
848849 if (req->status == REQ_STATUS_ERROR) {
849850 p9_debug(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err);
@@ -1582,6 +1583,10 @@ p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err) · 732 unmodified lines
15821583 p9_free_req(clnt, req);
15831584 break;
15841585 }
1586+ if (rsize < count) {
1587+ pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
1588+ count = rsize;
1589+ }
15851590
15861591 p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
15871592 if (!count) {
@@ -1647,6 +1652,11 @@ p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err) · 59 unmodified lines
16471652 if (*err) {
16481653 trace_9p_protocol_dump(clnt, req->rc);
16491654 p9_free_req(clnt, req);
1655+ break;
1656+ }
1657+ if (rsize < count) {
1658+ pr_err("bogus RWRITE count (%d > %d)\n", count, rsize);
1659+ count = rsize;
16501660 }
16511661
16521662 p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);
security/inode.c+6−13
@@ -25,11 +25,6 @@ · 24 unmodified lines
2525 static struct vfsmount *mount;
2626 static int mount_count;
2727
28−static inline int positive(struct dentry *dentry)
29−{
30− return d_really_is_positive(dentry) && !d_unhashed(dentry);
31−}
32−
3328 static int fill_super(struct super_block *sb, void *data, int silent)
3429 {
3530 static struct tree_descr files[] = {{""}};
@@ -201,14 +196,12 @@ void securityfs_remove(struct dentry *dentry) · 165 unmodified lines
201196 return;
202197
203198 mutex_lock(&d_inode(parent)->i_mutex);
204− if (positive(dentry)) {
205− if (d_really_is_positive(dentry)) {
206− if (d_is_dir(dentry))
207− simple_rmdir(d_inode(parent), dentry);
208− else
209− simple_unlink(d_inode(parent), dentry);
210− dput(dentry);
211− }
199+ if (simple_positive(dentry)) {
200+ if (d_is_dir(dentry))
201+ simple_rmdir(d_inode(parent), dentry);
202+ else
203+ simple_unlink(d_inode(parent), dentry);
204+ dput(dentry);
212205 }
213206 mutex_unlock(&d_inode(parent)->i_mutex);
214207 simple_release_fs(&mount, &mount_count);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t