Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
...

+803 -572
+23
Documentation/filesystems/caching/backend-api.txt
··· 676 676 as possible. 677 677 678 678 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 + 679 702 (*) Get and release references on a retrieval record: 680 703 681 704 void fscache_get_retrieval(struct fscache_retrieval *op);
+6 -1
Documentation/filesystems/caching/fscache.txt
··· 284 284 enq=N Number of times async ops queued for processing 285 285 can=N Number of async ops cancelled 286 286 rej=N Number of async ops rejected due to object lookup/create failure 287 + ini=N Number of async ops initialised 287 288 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) 289 290 gc=N Number of deferred-release async ops garbage collected 290 291 CacheOp alo=N Number of in-progress alloc_object() cache ops 291 292 luo=N Number of in-progress lookup_object() cache ops ··· 304 303 wrp=N Number of in-progress write_page() cache ops 305 304 ucp=N Number of in-progress uncache_page() cache ops 306 305 dsp=N Number of in-progress dissociate_pages() cache ops 306 + CacheEv nsp=N Number of object lookups/creations rejected due to lack of space 307 + stl=N Number of stale objects deleted 308 + rtr=N Number of objects retired when relinquished 309 + cul=N Number of objects culled 307 310 308 311 309 312 (*) /proc/fs/fscache/histogram
+4 -2
Documentation/filesystems/dax.txt
··· 18 18 ----- 19 19 20 20 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. 23 25 24 26 25 27 Implementation Tips for Block Driver Writers
+4
Documentation/filesystems/porting
··· 500 500 dentry, it does not get nameidata at all and it gets called only when cookie 501 501 is non-NULL. Note that link body isn't available anymore, so if you need it, 502 502 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.
+3 -7
arch/arc/kernel/troubleshoot.c
··· 71 71 mmput(mm); 72 72 73 73 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); 76 75 fput(exe_file); 77 - path_nm = d_path(&path, buf, 255); 78 - path_put(&path); 79 76 } 80 77 81 78 done: 82 - pr_info("Path: %s\n", path_nm); 79 + pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?"); 83 80 } 84 81 85 82 static void show_faulting_vma(unsigned long address, char *buf) ··· 100 103 if (vma && (vma->vm_start <= address)) { 101 104 struct file *file = vma->vm_file; 102 105 if (file) { 103 - struct path *path = &file->f_path; 104 - nm = d_path(path, buf, PAGE_SIZE - 1); 106 + nm = file_path(file, buf, PAGE_SIZE - 1); 105 107 inode = file_inode(vma->vm_file); 106 108 dev = inode->i_sb->s_dev; 107 109 ino = inode->i_ino;
+1 -1
arch/blackfin/kernel/trace.c
··· 136 136 struct file *file = vma->vm_file; 137 137 138 138 if (file) { 139 - char *d_name = d_path(&file->f_path, _tmpbuf, 139 + char *d_name = file_path(file, _tmpbuf, 140 140 sizeof(_tmpbuf)); 141 141 if (!IS_ERR(d_name)) 142 142 name = d_name;
+1 -1
arch/powerpc/platforms/cell/spufs/inode.c
··· 166 166 mutex_lock(&d_inode(dir)->i_mutex); 167 167 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) { 168 168 spin_lock(&dentry->d_lock); 169 - if (!(d_unhashed(dentry)) && d_really_is_positive(dentry)) { 169 + if (simple_positive(dentry)) { 170 170 dget_dlock(dentry); 171 171 __d_drop(dentry); 172 172 spin_unlock(&dentry->d_lock);
+1 -6
arch/s390/hypfs/inode.c
··· 62 62 hypfs_last_dentry = dentry; 63 63 } 64 64 65 - static inline int hypfs_positive(struct dentry *dentry) 66 - { 67 - return d_really_is_positive(dentry) && !d_unhashed(dentry); 68 - } 69 - 70 65 static void hypfs_remove(struct dentry *dentry) 71 66 { 72 67 struct dentry *parent; 73 68 74 69 parent = dentry->d_parent; 75 70 mutex_lock(&d_inode(parent)->i_mutex); 76 - if (hypfs_positive(dentry)) { 71 + if (simple_positive(dentry)) { 77 72 if (d_is_dir(dentry)) 78 73 simple_rmdir(d_inode(parent), dentry); 79 74 else
+1 -1
arch/tile/kernel/stack.c
··· 332 332 } 333 333 334 334 if (vma->vm_file) { 335 - p = d_path(&vma->vm_file->f_path, buf, bufsize); 335 + p = file_path(vma->vm_file, buf, bufsize); 336 336 if (IS_ERR(p)) 337 337 p = "?"; 338 338 name = kbasename(p);
+1 -1
arch/tile/mm/elf.c
··· 56 56 if (exe_file == NULL) 57 57 goto done_free; 58 58 59 - path = d_path(&exe_file->f_path, buf, PAGE_SIZE); 59 + path = file_path(exe_file, buf, PAGE_SIZE); 60 60 if (IS_ERR(path)) 61 61 goto done_put; 62 62
+1 -9
drivers/block/drbd/drbd_debugfs.c
··· 419 419 return 0; 420 420 } 421 421 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 - 430 422 /* make sure at *open* time that the respective object won't go away. */ 431 423 static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, void *), 432 424 void *data, struct kref *kref, ··· 436 444 /* serialize with d_delete() */ 437 445 mutex_lock(&d_inode(parent)->i_mutex); 438 446 /* Make sure the object is still alive */ 439 - if (debugfs_positive(file->f_path.dentry) 447 + if (simple_positive(file->f_path.dentry) 440 448 && kref_get_unless_zero(kref)) 441 449 ret = 0; 442 450 mutex_unlock(&d_inode(parent)->i_mutex);
+1 -1
drivers/block/loop.c
··· 588 588 589 589 spin_lock_irq(&lo->lo_lock); 590 590 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); 592 592 spin_unlock_irq(&lo->lo_lock); 593 593 594 594 if (IS_ERR_OR_NULL(p))
+1 -1
drivers/infiniband/hw/ipath/ipath_fs.c
··· 277 277 } 278 278 279 279 spin_lock(&tmp->d_lock); 280 - if (!d_unhashed(tmp) && d_really_is_positive(tmp)) { 280 + if (simple_positive(tmp)) { 281 281 dget_dlock(tmp); 282 282 __d_drop(tmp); 283 283 spin_unlock(&tmp->d_lock);
+1 -1
drivers/infiniband/hw/qib/qib_fs.c
··· 455 455 } 456 456 457 457 spin_lock(&tmp->d_lock); 458 - if (!d_unhashed(tmp) && d_really_is_positive(tmp)) { 458 + if (simple_positive(tmp)) { 459 459 __d_drop(tmp); 460 460 spin_unlock(&tmp->d_lock); 461 461 simple_unlink(d_inode(parent), tmp);
+2 -2
drivers/md/bitmap.c
··· 839 839 if (bitmap->storage.file) { 840 840 path = kmalloc(PAGE_SIZE, GFP_KERNEL); 841 841 if (path) 842 - ptr = d_path(&bitmap->storage.file->f_path, 842 + ptr = file_path(bitmap->storage.file, 843 843 path, PAGE_SIZE); 844 844 845 845 printk(KERN_ALERT ··· 1927 1927 chunk_kb ? "KB" : "B"); 1928 1928 if (bitmap->storage.file) { 1929 1929 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"); 1931 1931 } 1932 1932 1933 1933 seq_printf(seq, "\n");
+1 -1
drivers/md/md.c
··· 5766 5766 /* bitmap disabled, zero the first byte and copy out */ 5767 5767 if (!mddev->bitmap_info.file) 5768 5768 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, 5770 5770 file->pathname, sizeof(file->pathname))), 5771 5771 IS_ERR(ptr)) 5772 5772 err = PTR_ERR(ptr);
+1 -1
drivers/usb/gadget/function/f_mass_storage.c
··· 2936 2936 if (fsg_lun_is_open(lun)) { 2937 2937 p = "(error)"; 2938 2938 if (pathbuf) { 2939 - p = d_path(&lun->filp->f_path, pathbuf, PATH_MAX); 2939 + p = file_path(lun->filp, pathbuf, PATH_MAX); 2940 2940 if (IS_ERR(p)) 2941 2941 p = "(error)"; 2942 2942 }
+1 -1
drivers/usb/gadget/function/storage_common.c
··· 341 341 342 342 down_read(filesem); 343 343 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); 345 345 if (IS_ERR(p)) 346 346 rc = PTR_ERR(p); 347 347 else {
+1 -1
fs/affs/affs.h
··· 64 64 /* short cut to get to the affs specific inode data */ 65 65 static inline struct affs_inode_info *AFFS_I(struct inode *inode) 66 66 { 67 - return list_entry(inode, struct affs_inode_info, vfs_inode); 67 + return container_of(inode, struct affs_inode_info, vfs_inode); 68 68 } 69 69 70 70 /*
-5
fs/autofs4/autofs_i.h
··· 238 238 return d_inode(sbi->sb->s_root)->i_ino; 239 239 } 240 240 241 - static inline int simple_positive(struct dentry *dentry) 242 - { 243 - return d_really_is_positive(dentry) && !d_unhashed(dentry); 244 - } 245 - 246 241 static inline void __autofs4_add_expiring(struct dentry *dentry) 247 242 { 248 243 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+1 -1
fs/befs/befs.h
··· 112 112 static inline struct befs_inode_info * 113 113 BEFS_I(const struct inode *inode) 114 114 { 115 - return list_entry(inode, struct befs_inode_info, vfs_inode); 115 + return container_of(inode, struct befs_inode_info, vfs_inode); 116 116 } 117 117 118 118 static inline befs_blocknr_t
+2 -2
fs/binfmt_elf.c
··· 1530 1530 file = vma->vm_file; 1531 1531 if (!file) 1532 1532 continue; 1533 - filename = d_path(&file->f_path, name_curpos, remaining); 1533 + filename = file_path(file, name_curpos, remaining); 1534 1534 if (IS_ERR(filename)) { 1535 1535 if (PTR_ERR(filename) == -ENAMETOOLONG) { 1536 1536 vfree(data); ··· 1540 1540 continue; 1541 1541 } 1542 1542 1543 - /* d_path() fills at the end, move name down */ 1543 + /* file_path() fills at the end, move name down */ 1544 1544 /* n = strlen(filename) + 1: */ 1545 1545 n = (name_curpos + remaining) - filename; 1546 1546 remaining = filename - name_curpos;
+10
fs/block_dev.c
··· 152 152 struct file *file = iocb->ki_filp; 153 153 struct inode *inode = file->f_mapping->host; 154 154 155 + if (IS_DAX(inode)) 156 + return dax_do_io(iocb, inode, iter, offset, blkdev_get_block, 157 + NULL, DIO_SKIP_DIO_COUNT); 155 158 return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter, offset, 156 159 blkdev_get_block, NULL, NULL, 157 160 DIO_SKIP_DIO_COUNT); ··· 445 442 { 446 443 long avail; 447 444 const struct block_device_operations *ops = bdev->bd_disk->fops; 445 + 446 + /* 447 + * The device driver is allowed to sleep, in order to make the 448 + * memory directly accessible. 449 + */ 450 + might_sleep(); 448 451 449 452 if (size < 0) 450 453 return size; ··· 1179 1170 bdev->bd_disk = disk; 1180 1171 bdev->bd_queue = disk->queue; 1181 1172 bdev->bd_contains = bdev; 1173 + bdev->bd_inode->i_flags = disk->fops->direct_access ? S_DAX : 0; 1182 1174 if (!partno) { 1183 1175 ret = -ENXIO; 1184 1176 bdev->bd_part = disk_get_part(disk, partno);
+1 -1
fs/btrfs/file.c
··· 1748 1748 } 1749 1749 1750 1750 current->backing_dev_info = inode_to_bdi(inode); 1751 - err = file_remove_suid(file); 1751 + err = file_remove_privs(file); 1752 1752 if (err) { 1753 1753 mutex_unlock(&inode->i_mutex); 1754 1754 goto out;
-1
fs/cachefiles/internal.h
··· 43 43 loff_t i_size; /* object size */ 44 44 unsigned long flags; 45 45 #define CACHEFILES_OBJECT_ACTIVE 0 /* T if marked active */ 46 - #define CACHEFILES_OBJECT_BURIED 1 /* T if preemptively buried */ 47 46 atomic_t usage; /* object usage count */ 48 47 uint8_t type; /* object type */ 49 48 uint8_t new; /* T if object new */
+21 -12
fs/cachefiles/namei.c
··· 97 97 * call vfs_unlink(), vfs_rmdir() or vfs_rename() 98 98 */ 99 99 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) 101 102 { 102 103 struct cachefiles_object *object; 103 104 struct rb_node *p; ··· 133 132 pr_err("\n"); 134 133 pr_err("Error: Can't preemptively bury live object\n"); 135 134 cachefiles_printk_object(object, NULL); 136 - } else if (test_and_set_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { 137 - pr_err("Error: Object already preemptively buried\n"); 135 + } else { 136 + if (why != FSCACHE_OBJECT_IS_STALE) 137 + fscache_object_mark_killed(&object->fscache, why); 138 138 } 139 139 140 140 write_unlock(&cache->active_lock); ··· 267 265 static int cachefiles_bury_object(struct cachefiles_cache *cache, 268 266 struct dentry *dir, 269 267 struct dentry *rep, 270 - bool preemptive) 268 + bool preemptive, 269 + enum fscache_why_object_killed why) 271 270 { 272 271 struct dentry *grave, *trap; 273 272 struct path path, path_to_graveyard; ··· 292 289 ret = vfs_unlink(d_inode(dir), rep, NULL); 293 290 294 291 if (preemptive) 295 - cachefiles_mark_object_buried(cache, rep); 292 + cachefiles_mark_object_buried(cache, rep, why); 296 293 } 297 294 298 295 mutex_unlock(&d_inode(dir)->i_mutex); ··· 397 394 "Rename failed with error %d", ret); 398 395 399 396 if (preemptive) 400 - cachefiles_mark_object_buried(cache, rep); 397 + cachefiles_mark_object_buried(cache, rep, why); 401 398 } 402 399 403 400 unlock_rename(cache->graveyard, dir); ··· 425 422 426 423 mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT); 427 424 428 - if (test_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { 425 + if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) { 429 426 /* object allocation for the same key preemptively deleted this 430 427 * object's file so that it could create its own file */ 431 428 _debug("object preemptively buried"); ··· 436 433 * may have been renamed */ 437 434 if (dir == object->dentry->d_parent) { 438 435 ret = cachefiles_bury_object(cache, dir, 439 - object->dentry, false); 436 + object->dentry, false, 437 + FSCACHE_OBJECT_WAS_RETIRED); 440 438 } else { 441 439 /* it got moved, presumably by cachefilesd culling it, 442 440 * so it's no longer in the key path and we can ignore ··· 526 522 if (d_is_negative(next)) { 527 523 ret = cachefiles_has_space(cache, 1, 0); 528 524 if (ret < 0) 529 - goto create_error; 525 + goto no_space_error; 530 526 531 527 path.dentry = dir; 532 528 ret = security_path_mkdir(&path, next, 0); ··· 555 551 if (d_is_negative(next)) { 556 552 ret = cachefiles_has_space(cache, 1, 0); 557 553 if (ret < 0) 558 - goto create_error; 554 + goto no_space_error; 559 555 560 556 path.dentry = dir; 561 557 ret = security_path_mknod(&path, next, S_IFREG, 0); ··· 606 602 * mutex) */ 607 603 object->dentry = NULL; 608 604 609 - ret = cachefiles_bury_object(cache, dir, next, true); 605 + ret = cachefiles_bury_object(cache, dir, next, true, 606 + FSCACHE_OBJECT_IS_STALE); 610 607 dput(next); 611 608 next = NULL; 612 609 ··· 615 610 goto delete_error; 616 611 617 612 _debug("redo lookup"); 613 + fscache_object_retrying_stale(&object->fscache); 618 614 goto lookup_again; 619 615 } 620 616 } ··· 668 662 _leave(" = 0 [%lu]", d_backing_inode(object->dentry)->i_ino); 669 663 return 0; 670 664 665 + no_space_error: 666 + fscache_object_mark_killed(&object->fscache, FSCACHE_OBJECT_NO_SPACE); 671 667 create_error: 672 668 _debug("create error %d", ret); 673 669 if (ret == -EIO) ··· 935 927 /* actually remove the victim (drops the dir mutex) */ 936 928 _debug("bury"); 937 929 938 - ret = cachefiles_bury_object(cache, dir, victim, false); 930 + ret = cachefiles_bury_object(cache, dir, victim, false, 931 + FSCACHE_OBJECT_WAS_CULLED); 939 932 if (ret < 0) 940 933 goto error; 941 934
+1 -1
fs/ceph/file.c
··· 962 962 963 963 pos = iocb->ki_pos; 964 964 count = iov_iter_count(from); 965 - err = file_remove_suid(file); 965 + err = file_remove_privs(file); 966 966 if (err) 967 967 goto out; 968 968
+1 -1
fs/coda/coda_linux.h
··· 79 79 80 80 static inline struct coda_inode_info *ITOC(struct inode *inode) 81 81 { 82 - return list_entry(inode, struct coda_inode_info, vfs_inode); 82 + return container_of(inode, struct coda_inode_info, vfs_inode); 83 83 } 84 84 85 85 static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
+1 -1
fs/configfs/inode.c
··· 236 236 237 237 if (dentry) { 238 238 spin_lock(&dentry->d_lock); 239 - if (!d_unhashed(dentry) && d_really_is_positive(dentry)) { 239 + if (simple_positive(dentry)) { 240 240 dget_dlock(dentry); 241 241 __d_drop(dentry); 242 242 spin_unlock(&dentry->d_lock);
+1 -1
fs/coredump.c
··· 140 140 goto put_exe_file; 141 141 } 142 142 143 - path = d_path(&exe_file->f_path, pathbuf, PATH_MAX); 143 + path = file_path(exe_file, pathbuf, PATH_MAX); 144 144 if (IS_ERR(path)) { 145 145 ret = PTR_ERR(path); 146 146 goto free_buf;
+5 -3
fs/dax.c
··· 155 155 } 156 156 157 157 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); 159 159 else if (!hole) 160 160 len = copy_to_iter(addr, max - pos, iter); 161 161 else ··· 209 209 } 210 210 211 211 /* Protects against truncate */ 212 - inode_dio_begin(inode); 212 + if (!(flags & DIO_SKIP_DIO_COUNT)) 213 + inode_dio_begin(inode); 213 214 214 215 retval = dax_io(inode, iter, pos, end, get_block, &bh); 215 216 ··· 220 219 if ((retval > 0) && end_io) 221 220 end_io(iocb, pos, retval, bh.b_private); 222 221 223 - inode_dio_end(inode); 222 + if (!(flags & DIO_SKIP_DIO_COUNT)) 223 + inode_dio_end(inode); 224 224 out: 225 225 return retval; 226 226 }
+4 -1
fs/dcache.c
··· 1673 1673 DCACHE_OP_COMPARE | 1674 1674 DCACHE_OP_REVALIDATE | 1675 1675 DCACHE_OP_WEAK_REVALIDATE | 1676 - DCACHE_OP_DELETE )); 1676 + DCACHE_OP_DELETE | 1677 + DCACHE_OP_SELECT_INODE)); 1677 1678 dentry->d_op = op; 1678 1679 if (!op) 1679 1680 return; ··· 1690 1689 dentry->d_flags |= DCACHE_OP_DELETE; 1691 1690 if (op->d_prune) 1692 1691 dentry->d_flags |= DCACHE_OP_PRUNE; 1692 + if (op->d_select_inode) 1693 + dentry->d_flags |= DCACHE_OP_SELECT_INODE; 1693 1694 1694 1695 } 1695 1696 EXPORT_SYMBOL(d_set_d_op);
+3 -8
fs/debugfs/inode.c
··· 44 44 return inode; 45 45 } 46 46 47 - static inline int debugfs_positive(struct dentry *dentry) 48 - { 49 - return d_really_is_positive(dentry) && !d_unhashed(dentry); 50 - } 51 - 52 47 struct debugfs_mount_opts { 53 48 kuid_t uid; 54 49 kgid_t gid; ··· 517 522 { 518 523 int ret = 0; 519 524 520 - if (debugfs_positive(dentry)) { 525 + if (simple_positive(dentry)) { 521 526 dget(dentry); 522 527 if (d_is_dir(dentry)) 523 528 ret = simple_rmdir(d_inode(parent), dentry); ··· 597 602 */ 598 603 spin_lock(&parent->d_lock); 599 604 list_for_each_entry(child, &parent->d_subdirs, d_child) { 600 - if (!debugfs_positive(child)) 605 + if (!simple_positive(child)) 601 606 continue; 602 607 603 608 /* perhaps simple_empty(child) makes more sense */ ··· 618 623 * from d_subdirs. When releasing the parent->d_lock we can 619 624 * no longer trust that the next pointer is valid. 620 625 * Restart the loop. We'll skip this one with the 621 - * debugfs_positive() check. 626 + * simple_positive() check. 622 627 */ 623 628 goto loop; 624 629 }
-6
fs/exofs/dir.c
··· 44 44 page_cache_release(page); 45 45 } 46 46 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 - 53 47 static unsigned exofs_last_byte(struct inode *inode, unsigned long page_nr) 54 48 { 55 49 loff_t last_byte = inode->i_size;
-5
fs/ext2/dir.c
··· 70 70 page_cache_release(page); 71 71 } 72 72 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 - 78 73 /* 79 74 * Return the offset into page `page_nr' of the last valid 80 75 * byte in that page, plus one.
+1 -1
fs/ext4/super.c
··· 452 452 es = EXT4_SB(inode->i_sb)->s_es; 453 453 es->s_last_error_ino = cpu_to_le32(inode->i_ino); 454 454 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)); 456 456 if (IS_ERR(path)) 457 457 path = "(unknown)"; 458 458 va_start(args, fmt);
+56 -21
fs/file.c
··· 147 147 148 148 spin_unlock(&files->file_lock); 149 149 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 + 150 157 spin_lock(&files->file_lock); 151 158 if (!new_fdt) 152 159 return -ENOMEM; ··· 165 158 __free_fdtable(new_fdt); 166 159 return -EMFILE; 167 160 } 168 - /* 169 - * Check again since another task may have expanded the fd table while 170 - * we dropped the lock 171 - */ 172 161 cur_fdt = files_fdtable(files); 173 - if (nr >= cur_fdt->max_fds) { 174 - /* Continue as planned */ 175 - copy_fdtable(new_fdt, cur_fdt); 176 - rcu_assign_pointer(files->fdt, new_fdt); 177 - if (cur_fdt != &files->fdtab) 178 - call_rcu(&cur_fdt->rcu, free_fdtable_rcu); 179 - } else { 180 - /* Somebody else expanded, so undo our attempt */ 181 - __free_fdtable(new_fdt); 182 - } 162 + BUG_ON(nr < cur_fdt->max_fds); 163 + copy_fdtable(new_fdt, cur_fdt); 164 + rcu_assign_pointer(files->fdt, new_fdt); 165 + if (cur_fdt != &files->fdtab) 166 + call_rcu(&cur_fdt->rcu, free_fdtable_rcu); 167 + /* coupled with smp_rmb() in __fd_install() */ 168 + smp_wmb(); 183 169 return 1; 184 170 } 185 171 ··· 185 185 * The files->file_lock should be held on entry, and will be held on exit. 186 186 */ 187 187 static int expand_files(struct files_struct *files, int nr) 188 + __releases(files->file_lock) 189 + __acquires(files->file_lock) 188 190 { 189 191 struct fdtable *fdt; 192 + int expanded = 0; 190 193 194 + repeat: 191 195 fdt = files_fdtable(files); 192 196 193 197 /* Do we need to expand? */ 194 198 if (nr < fdt->max_fds) 195 - return 0; 199 + return expanded; 196 200 197 201 /* Can we expand? */ 198 202 if (nr >= sysctl_nr_open) 199 203 return -EMFILE; 200 204 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 + 201 213 /* 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; 203 220 } 204 221 205 222 static inline void __set_close_on_exec(int fd, struct fdtable *fdt) ··· 273 256 atomic_set(&newf->count, 1); 274 257 275 258 spin_lock_init(&newf->file_lock); 259 + newf->resize_in_progress = false; 260 + init_waitqueue_head(&newf->resize_wait); 276 261 newf->next_fd = 0; 277 262 new_fdt = &newf->fdtab; 278 263 new_fdt->max_fds = NR_OPEN_DEFAULT; ··· 572 553 struct file *file) 573 554 { 574 555 struct fdtable *fdt; 575 - spin_lock(&files->file_lock); 576 - fdt = files_fdtable(files); 556 + 557 + might_sleep(); 558 + rcu_read_lock_sched(); 559 + 560 + while (unlikely(files->resize_in_progress)) { 561 + rcu_read_unlock_sched(); 562 + wait_event(files->resize_wait, !files->resize_in_progress); 563 + rcu_read_lock_sched(); 564 + } 565 + /* coupled with smp_wmb() in expand_fdtable() */ 566 + smp_rmb(); 567 + fdt = rcu_dereference_sched(files->fdt); 577 568 BUG_ON(fdt->fd[fd] != NULL); 578 569 rcu_assign_pointer(fdt->fd[fd], file); 579 - spin_unlock(&files->file_lock); 570 + rcu_read_unlock_sched(); 580 571 } 581 572 582 573 void fd_install(unsigned int fd, struct file *file) ··· 664 635 struct file *file; 665 636 666 637 rcu_read_lock(); 638 + loop: 667 639 file = fcheck_files(files, fd); 668 640 if (file) { 669 - /* File object ref couldn't be taken */ 670 - if ((file->f_mode & mask) || !get_file_rcu(file)) 641 + /* File object ref couldn't be taken. 642 + * dup2() atomicity guarantee is the reason 643 + * we loop to catch the new file (or NULL pointer) 644 + */ 645 + if (file->f_mode & mask) 671 646 file = NULL; 647 + else if (!get_file_rcu(file)) 648 + goto loop; 672 649 } 673 650 rcu_read_unlock(); 674 651
-1
fs/file_table.c
··· 20 20 #include <linux/cdev.h> 21 21 #include <linux/fsnotify.h> 22 22 #include <linux/sysctl.h> 23 - #include <linux/lglock.h> 24 23 #include <linux/percpu_counter.h> 25 24 #include <linux/percpu.h> 26 25 #include <linux/hardirq.h>
-7
fs/freevxfs/vxfs_lookup.c
··· 61 61 .iterate = vxfs_readdir, 62 62 }; 63 63 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 - 71 64 static inline u_long 72 65 dir_blocks(struct inode *ip) 73 66 {
+4 -4
fs/fscache/cookie.c
··· 327 327 328 328 object_already_extant: 329 329 ret = -ENOBUFS; 330 - if (fscache_object_is_dead(object)) { 330 + if (fscache_object_is_dying(object) || 331 + fscache_cache_is_broken(object)) { 331 332 spin_unlock(&cookie->lock); 332 333 goto error; 333 334 } ··· 672 671 if (!op) 673 672 return -ENOMEM; 674 673 675 - fscache_operation_init(op, NULL, NULL); 674 + fscache_operation_init(op, NULL, NULL, NULL); 676 675 op->flags = FSCACHE_OP_MYTHREAD | 677 676 (1 << FSCACHE_OP_WAITING) | 678 677 (1 << FSCACHE_OP_UNUSE_COOKIE); ··· 696 695 /* the work queue now carries its own ref on the object */ 697 696 spin_unlock(&cookie->lock); 698 697 699 - ret = fscache_wait_for_operation_activation(object, op, 700 - NULL, NULL, NULL); 698 + ret = fscache_wait_for_operation_activation(object, op, NULL, NULL); 701 699 if (ret == 0) { 702 700 /* ask the cache to honour the operation */ 703 701 ret = object->cache->ops->check_consistency(op);
+8 -4
fs/fscache/internal.h
··· 124 124 struct fscache_operation *); 125 125 extern int fscache_submit_op(struct fscache_object *, 126 126 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); 129 128 extern void fscache_cancel_all_ops(struct fscache_object *); 130 129 extern void fscache_abort_object(struct fscache_object *); 131 130 extern void fscache_start_operations(struct fscache_object *); ··· 137 138 extern int fscache_wait_for_operation_activation(struct fscache_object *, 138 139 struct fscache_operation *, 139 140 atomic_t *, 140 - atomic_t *, 141 - void (*)(struct fscache_operation *)); 141 + atomic_t *); 142 142 extern void fscache_invalidate_writes(struct fscache_cookie *); 143 143 144 144 /* ··· 162 164 extern atomic_t fscache_n_op_run; 163 165 extern atomic_t fscache_n_op_enqueue; 164 166 extern atomic_t fscache_n_op_deferred_release; 167 + extern atomic_t fscache_n_op_initialised; 165 168 extern atomic_t fscache_n_op_release; 166 169 extern atomic_t fscache_n_op_gc; 167 170 extern atomic_t fscache_n_op_cancelled; ··· 269 270 extern atomic_t fscache_n_cop_write_page; 270 271 extern atomic_t fscache_n_cop_uncache_page; 271 272 extern atomic_t fscache_n_cop_dissociate_pages; 273 + 274 + extern atomic_t fscache_n_cache_no_space_reject; 275 + extern atomic_t fscache_n_cache_stale_objects; 276 + extern atomic_t fscache_n_cache_retired_objects; 277 + extern atomic_t fscache_n_cache_culled_objects; 272 278 273 279 static inline void fscache_stat(atomic_t *stat) 274 280 {
+65 -4
fs/fscache/object.c
··· 328 328 EXPORT_SYMBOL(fscache_object_init); 329 329 330 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 + 341 + /* 331 342 * Abort object initialisation before we start it. 332 343 */ 333 344 static const struct fscache_state *fscache_abort_initialisation(struct fscache_object *object, ··· 621 610 object->cache->ops->lookup_complete(object); 622 611 fscache_stat_d(&fscache_n_cop_lookup_complete); 623 612 613 + set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags); 614 + 624 615 cookie = object->cookie; 625 616 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags); 626 617 if (test_and_clear_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags)) ··· 642 629 _enter("{OBJ%x,%d,%d},%d", 643 630 object->debug_id, object->n_ops, object->n_children, event); 644 631 645 - clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags); 632 + fscache_mark_object_dead(object); 646 633 object->oob_event_mask = 0; 647 634 648 635 if (list_empty(&object->dependents) && ··· 961 948 if (!op) 962 949 goto nomem; 963 950 964 - fscache_operation_init(op, object->cache->ops->invalidate_object, NULL); 951 + fscache_operation_init(op, object->cache->ops->invalidate_object, 952 + NULL, NULL); 965 953 op->flags = FSCACHE_OP_ASYNC | 966 954 (1 << FSCACHE_OP_EXCLUSIVE) | 967 955 (1 << FSCACHE_OP_UNUSE_COOKIE); ··· 988 974 return transit_to(UPDATE_OBJECT); 989 975 990 976 nomem: 991 - clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags); 977 + fscache_mark_object_dead(object); 992 978 fscache_unuse_cookie(object); 993 979 _leave(" [ENOMEM]"); 994 980 return transit_to(KILL_OBJECT); 995 981 996 982 submit_op_failed: 997 - clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags); 983 + fscache_mark_object_dead(object); 998 984 spin_unlock(&cookie->lock); 999 985 fscache_unuse_cookie(object); 1000 986 kfree(op); ··· 1030 1016 _leave(""); 1031 1017 return transit_to(WAIT_FOR_CMD); 1032 1018 } 1019 + 1020 + /** 1021 + * fscache_object_retrying_stale - Note retrying stale object 1022 + * @object: The object that will be retried 1023 + * 1024 + * Note that an object lookup found an on-disk object that was adjudged to be 1025 + * stale and has been deleted. The lookup will be retried. 1026 + */ 1027 + void fscache_object_retrying_stale(struct fscache_object *object) 1028 + { 1029 + fscache_stat(&fscache_n_cache_no_space_reject); 1030 + } 1031 + EXPORT_SYMBOL(fscache_object_retrying_stale); 1032 + 1033 + /** 1034 + * fscache_object_mark_killed - Note that an object was killed 1035 + * @object: The object that was culled 1036 + * @why: The reason the object was killed. 1037 + * 1038 + * Note that an object was killed. Returns true if the object was 1039 + * already marked killed, false if it wasn't. 1040 + */ 1041 + void fscache_object_mark_killed(struct fscache_object *object, 1042 + enum fscache_why_object_killed why) 1043 + { 1044 + if (test_and_set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags)) { 1045 + pr_err("Error: Object already killed by cache [%s]\n", 1046 + object->cache->identifier); 1047 + return; 1048 + } 1049 + 1050 + switch (why) { 1051 + case FSCACHE_OBJECT_NO_SPACE: 1052 + fscache_stat(&fscache_n_cache_no_space_reject); 1053 + break; 1054 + case FSCACHE_OBJECT_IS_STALE: 1055 + fscache_stat(&fscache_n_cache_stale_objects); 1056 + break; 1057 + case FSCACHE_OBJECT_WAS_RETIRED: 1058 + fscache_stat(&fscache_n_cache_retired_objects); 1059 + break; 1060 + case FSCACHE_OBJECT_WAS_CULLED: 1061 + fscache_stat(&fscache_n_cache_culled_objects); 1062 + break; 1063 + } 1064 + } 1065 + EXPORT_SYMBOL(fscache_object_mark_killed);
+187 -105
fs/fscache/operation.c
··· 20 20 atomic_t fscache_op_debug_id; 21 21 EXPORT_SYMBOL(fscache_op_debug_id); 22 22 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 + 23 52 /** 24 53 * fscache_enqueue_operation - Enqueue an operation for processing 25 54 * @op: The operation to enqueue ··· 105 76 } 106 77 107 78 /* 108 - * submit an exclusive operation for an object 109 - * - other ops are excluded from running simultaneously with this one 110 - * - this gets any extra refs it needs on an op 111 - */ 112 - int fscache_submit_exclusive_op(struct fscache_object *object, 113 - struct fscache_operation *op) 114 - { 115 - int ret; 116 - 117 - _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id); 118 - 119 - ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); 120 - ASSERTCMP(atomic_read(&op->usage), >, 0); 121 - 122 - spin_lock(&object->lock); 123 - ASSERTCMP(object->n_ops, >=, object->n_in_progress); 124 - ASSERTCMP(object->n_ops, >=, object->n_exclusive); 125 - ASSERT(list_empty(&op->pend_link)); 126 - 127 - op->state = FSCACHE_OP_ST_PENDING; 128 - if (fscache_object_is_active(object)) { 129 - op->object = object; 130 - object->n_ops++; 131 - object->n_exclusive++; /* reads and writes must wait */ 132 - 133 - if (object->n_in_progress > 0) { 134 - atomic_inc(&op->usage); 135 - list_add_tail(&op->pend_link, &object->pending_ops); 136 - fscache_stat(&fscache_n_op_pend); 137 - } else if (!list_empty(&object->pending_ops)) { 138 - atomic_inc(&op->usage); 139 - list_add_tail(&op->pend_link, &object->pending_ops); 140 - fscache_stat(&fscache_n_op_pend); 141 - fscache_start_operations(object); 142 - } else { 143 - ASSERTCMP(object->n_in_progress, ==, 0); 144 - fscache_run_op(object, op); 145 - } 146 - 147 - /* need to issue a new write op after this */ 148 - clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); 149 - ret = 0; 150 - } else if (test_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { 151 - op->object = object; 152 - object->n_ops++; 153 - object->n_exclusive++; /* reads and writes must wait */ 154 - atomic_inc(&op->usage); 155 - list_add_tail(&op->pend_link, &object->pending_ops); 156 - fscache_stat(&fscache_n_op_pend); 157 - ret = 0; 158 - } else { 159 - /* If we're in any other state, there must have been an I/O 160 - * error of some nature. 161 - */ 162 - ASSERT(test_bit(FSCACHE_IOERROR, &object->cache->flags)); 163 - ret = -EIO; 164 - } 165 - 166 - spin_unlock(&object->lock); 167 - return ret; 168 - } 169 - 170 - /* 171 79 * report an unexpected submission 172 80 */ 173 81 static void fscache_report_unexpected_submission(struct fscache_object *object, ··· 142 176 } 143 177 144 178 /* 179 + * submit an exclusive operation for an object 180 + * - other ops are excluded from running simultaneously with this one 181 + * - this gets any extra refs it needs on an op 182 + */ 183 + int fscache_submit_exclusive_op(struct fscache_object *object, 184 + struct fscache_operation *op) 185 + { 186 + const struct fscache_state *ostate; 187 + unsigned long flags; 188 + int ret; 189 + 190 + _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id); 191 + 192 + ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); 193 + ASSERTCMP(atomic_read(&op->usage), >, 0); 194 + 195 + spin_lock(&object->lock); 196 + ASSERTCMP(object->n_ops, >=, object->n_in_progress); 197 + ASSERTCMP(object->n_ops, >=, object->n_exclusive); 198 + ASSERT(list_empty(&op->pend_link)); 199 + 200 + ostate = object->state; 201 + smp_rmb(); 202 + 203 + op->state = FSCACHE_OP_ST_PENDING; 204 + flags = READ_ONCE(object->flags); 205 + if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) { 206 + fscache_stat(&fscache_n_op_rejected); 207 + op->cancel(op); 208 + op->state = FSCACHE_OP_ST_CANCELLED; 209 + ret = -ENOBUFS; 210 + } else if (unlikely(fscache_cache_is_broken(object))) { 211 + op->cancel(op); 212 + op->state = FSCACHE_OP_ST_CANCELLED; 213 + ret = -EIO; 214 + } else if (flags & BIT(FSCACHE_OBJECT_IS_AVAILABLE)) { 215 + op->object = object; 216 + object->n_ops++; 217 + object->n_exclusive++; /* reads and writes must wait */ 218 + 219 + if (object->n_in_progress > 0) { 220 + atomic_inc(&op->usage); 221 + list_add_tail(&op->pend_link, &object->pending_ops); 222 + fscache_stat(&fscache_n_op_pend); 223 + } else if (!list_empty(&object->pending_ops)) { 224 + atomic_inc(&op->usage); 225 + list_add_tail(&op->pend_link, &object->pending_ops); 226 + fscache_stat(&fscache_n_op_pend); 227 + fscache_start_operations(object); 228 + } else { 229 + ASSERTCMP(object->n_in_progress, ==, 0); 230 + fscache_run_op(object, op); 231 + } 232 + 233 + /* need to issue a new write op after this */ 234 + clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); 235 + ret = 0; 236 + } else if (flags & BIT(FSCACHE_OBJECT_IS_LOOKED_UP)) { 237 + op->object = object; 238 + object->n_ops++; 239 + object->n_exclusive++; /* reads and writes must wait */ 240 + atomic_inc(&op->usage); 241 + list_add_tail(&op->pend_link, &object->pending_ops); 242 + fscache_stat(&fscache_n_op_pend); 243 + ret = 0; 244 + } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) { 245 + op->cancel(op); 246 + op->state = FSCACHE_OP_ST_CANCELLED; 247 + ret = -ENOBUFS; 248 + } else { 249 + fscache_report_unexpected_submission(object, op, ostate); 250 + op->cancel(op); 251 + op->state = FSCACHE_OP_ST_CANCELLED; 252 + ret = -ENOBUFS; 253 + } 254 + 255 + spin_unlock(&object->lock); 256 + return ret; 257 + } 258 + 259 + /* 145 260 * submit an operation for an object 146 261 * - objects may be submitted only in the following states: 147 262 * - during object creation (write ops may be submitted) ··· 234 187 struct fscache_operation *op) 235 188 { 236 189 const struct fscache_state *ostate; 190 + unsigned long flags; 237 191 int ret; 238 192 239 193 _enter("{OBJ%x OP%x},{%u}", ··· 252 204 smp_rmb(); 253 205 254 206 op->state = FSCACHE_OP_ST_PENDING; 255 - if (fscache_object_is_active(object)) { 207 + flags = READ_ONCE(object->flags); 208 + if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) { 209 + fscache_stat(&fscache_n_op_rejected); 210 + op->cancel(op); 211 + op->state = FSCACHE_OP_ST_CANCELLED; 212 + ret = -ENOBUFS; 213 + } else if (unlikely(fscache_cache_is_broken(object))) { 214 + op->cancel(op); 215 + op->state = FSCACHE_OP_ST_CANCELLED; 216 + ret = -EIO; 217 + } else if (flags & BIT(FSCACHE_OBJECT_IS_AVAILABLE)) { 256 218 op->object = object; 257 219 object->n_ops++; 258 220 ··· 280 222 fscache_run_op(object, op); 281 223 } 282 224 ret = 0; 283 - } else if (test_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { 225 + } else if (flags & BIT(FSCACHE_OBJECT_IS_LOOKED_UP)) { 284 226 op->object = object; 285 227 object->n_ops++; 286 228 atomic_inc(&op->usage); 287 229 list_add_tail(&op->pend_link, &object->pending_ops); 288 230 fscache_stat(&fscache_n_op_pend); 289 231 ret = 0; 290 - } else if (fscache_object_is_dying(object)) { 291 - fscache_stat(&fscache_n_op_rejected); 292 - op->state = FSCACHE_OP_ST_CANCELLED; 293 - ret = -ENOBUFS; 294 - } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) { 295 - fscache_report_unexpected_submission(object, op, ostate); 296 - ASSERT(!fscache_object_is_active(object)); 232 + } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) { 233 + op->cancel(op); 297 234 op->state = FSCACHE_OP_ST_CANCELLED; 298 235 ret = -ENOBUFS; 299 236 } else { 237 + fscache_report_unexpected_submission(object, op, ostate); 238 + ASSERT(!fscache_object_is_active(object)); 239 + op->cancel(op); 300 240 op->state = FSCACHE_OP_ST_CANCELLED; 301 241 ret = -ENOBUFS; 302 242 } ··· 349 293 * cancel an operation that's pending on an object 350 294 */ 351 295 int fscache_cancel_op(struct fscache_operation *op, 352 - void (*do_cancel)(struct fscache_operation *)) 296 + bool cancel_in_progress_op) 353 297 { 354 298 struct fscache_object *object = op->object; 299 + bool put = false; 355 300 int ret; 356 301 357 302 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id); ··· 366 309 ret = -EBUSY; 367 310 if (op->state == FSCACHE_OP_ST_PENDING) { 368 311 ASSERT(!list_empty(&op->pend_link)); 369 - fscache_stat(&fscache_n_op_cancelled); 370 312 list_del_init(&op->pend_link); 371 - if (do_cancel) 372 - do_cancel(op); 313 + put = true; 314 + 315 + fscache_stat(&fscache_n_op_cancelled); 316 + op->cancel(op); 373 317 op->state = FSCACHE_OP_ST_CANCELLED; 374 318 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) 375 319 object->n_exclusive--; 376 320 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) 377 321 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); 378 - fscache_put_operation(op); 322 + ret = 0; 323 + } else if (op->state == FSCACHE_OP_ST_IN_PROGRESS && cancel_in_progress_op) { 324 + ASSERTCMP(object->n_in_progress, >, 0); 325 + if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) 326 + object->n_exclusive--; 327 + object->n_in_progress--; 328 + if (object->n_in_progress == 0) 329 + fscache_start_operations(object); 330 + 331 + fscache_stat(&fscache_n_op_cancelled); 332 + op->cancel(op); 333 + op->state = FSCACHE_OP_ST_CANCELLED; 334 + if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) 335 + object->n_exclusive--; 336 + if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) 337 + wake_up_bit(&op->flags, FSCACHE_OP_WAITING); 379 338 ret = 0; 380 339 } 381 340 341 + if (put) 342 + fscache_put_operation(op); 382 343 spin_unlock(&object->lock); 383 344 _leave(" = %d", ret); 384 345 return ret; ··· 420 345 list_del_init(&op->pend_link); 421 346 422 347 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING); 348 + op->cancel(op); 423 349 op->state = FSCACHE_OP_ST_CANCELLED; 424 350 425 351 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) ··· 453 377 454 378 spin_lock(&object->lock); 455 379 456 - op->state = cancelled ? 457 - FSCACHE_OP_ST_CANCELLED : FSCACHE_OP_ST_COMPLETE; 380 + if (!cancelled) { 381 + op->state = FSCACHE_OP_ST_COMPLETE; 382 + } else { 383 + op->cancel(op); 384 + op->state = FSCACHE_OP_ST_CANCELLED; 385 + } 458 386 459 387 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) 460 388 object->n_exclusive--; ··· 489 409 return; 490 410 491 411 _debug("PUT OP"); 492 - ASSERTIFCMP(op->state != FSCACHE_OP_ST_COMPLETE, 412 + ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED && 413 + op->state != FSCACHE_OP_ST_COMPLETE, 493 414 op->state, ==, FSCACHE_OP_ST_CANCELLED); 494 - op->state = FSCACHE_OP_ST_DEAD; 495 415 496 416 fscache_stat(&fscache_n_op_release); 497 417 ··· 499 419 op->release(op); 500 420 op->release = NULL; 501 421 } 422 + op->state = FSCACHE_OP_ST_DEAD; 502 423 503 424 object = op->object; 425 + if (likely(object)) { 426 + if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags)) 427 + atomic_dec(&object->n_reads); 428 + if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags)) 429 + fscache_unuse_cookie(object); 504 430 505 - if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags)) 506 - atomic_dec(&object->n_reads); 507 - if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags)) 508 - fscache_unuse_cookie(object); 431 + /* now... we may get called with the object spinlock held, so we 432 + * complete the cleanup here only if we can immediately acquire the 433 + * lock, and defer it otherwise */ 434 + if (!spin_trylock(&object->lock)) { 435 + _debug("defer put"); 436 + fscache_stat(&fscache_n_op_deferred_release); 509 437 510 - /* now... we may get called with the object spinlock held, so we 511 - * complete the cleanup here only if we can immediately acquire the 512 - * lock, and defer it otherwise */ 513 - if (!spin_trylock(&object->lock)) { 514 - _debug("defer put"); 515 - fscache_stat(&fscache_n_op_deferred_release); 438 + cache = object->cache; 439 + spin_lock(&cache->op_gc_list_lock); 440 + list_add_tail(&op->pend_link, &cache->op_gc_list); 441 + spin_unlock(&cache->op_gc_list_lock); 442 + schedule_work(&cache->op_gc); 443 + _leave(" [defer]"); 444 + return; 445 + } 516 446 517 - cache = object->cache; 518 - spin_lock(&cache->op_gc_list_lock); 519 - list_add_tail(&op->pend_link, &cache->op_gc_list); 520 - spin_unlock(&cache->op_gc_list_lock); 521 - schedule_work(&cache->op_gc); 522 - _leave(" [defer]"); 523 - return; 447 + ASSERTCMP(object->n_ops, >, 0); 448 + object->n_ops--; 449 + if (object->n_ops == 0) 450 + fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED); 451 + 452 + spin_unlock(&object->lock); 524 453 } 525 - 526 - ASSERTCMP(object->n_ops, >, 0); 527 - object->n_ops--; 528 - if (object->n_ops == 0) 529 - fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED); 530 - 531 - spin_unlock(&object->lock); 532 454 533 455 kfree(op); 534 456 _leave(" [done]");
+43 -43
fs/fscache/page.c
··· 213 213 return -ENOMEM; 214 214 } 215 215 216 - fscache_operation_init(op, fscache_attr_changed_op, NULL); 216 + fscache_operation_init(op, fscache_attr_changed_op, NULL, NULL); 217 217 op->flags = FSCACHE_OP_ASYNC | 218 218 (1 << FSCACHE_OP_EXCLUSIVE) | 219 219 (1 << FSCACHE_OP_UNUSE_COOKIE); ··· 239 239 wake_cookie = __fscache_unuse_cookie(cookie); 240 240 nobufs: 241 241 spin_unlock(&cookie->lock); 242 - kfree(op); 242 + fscache_put_operation(op); 243 243 if (wake_cookie) 244 244 __fscache_wake_unused_cookie(cookie); 245 245 fscache_stat(&fscache_n_attr_changed_nobufs); ··· 247 247 return -ENOBUFS; 248 248 } 249 249 EXPORT_SYMBOL(__fscache_attr_changed); 250 + 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 + } 250 261 251 262 /* 252 263 * release a retrieval op reference ··· 269 258 270 259 _enter("{OP%x}", op->op.debug_id); 271 260 272 - ASSERTCMP(atomic_read(&op->n_pages), ==, 0); 261 + ASSERTIFCMP(op->op.state != FSCACHE_OP_ST_INITIALISED, 262 + atomic_read(&op->n_pages), ==, 0); 273 263 274 264 fscache_hist(fscache_retrieval_histogram, op->start_time); 275 265 if (op->context) 276 - fscache_put_context(op->op.object->cookie, op->context); 266 + fscache_put_context(op->cookie, op->context); 277 267 278 268 _leave(""); 279 269 } ··· 297 285 return NULL; 298 286 } 299 287 300 - fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op); 288 + fscache_operation_init(&op->op, NULL, 289 + fscache_do_cancel_retrieval, 290 + fscache_release_retrieval_op); 301 291 op->op.flags = FSCACHE_OP_MYTHREAD | 302 292 (1UL << FSCACHE_OP_WAITING) | 303 293 (1UL << FSCACHE_OP_UNUSE_COOKIE); 294 + op->cookie = cookie; 304 295 op->mapping = mapping; 305 296 op->end_io_func = end_io_func; 306 297 op->context = context; 307 298 op->start_time = jiffies; 308 299 INIT_LIST_HEAD(&op->to_do); 300 + 301 + /* Pin the netfs read context in case we need to do the actual netfs 302 + * read because we've encountered a cache read failure. 303 + */ 304 + if (context) 305 + fscache_get_context(op->cookie, context); 309 306 return op; 310 307 } 311 308 ··· 351 330 } 352 331 353 332 /* 354 - * Handle cancellation of a pending retrieval op 355 - */ 356 - static void fscache_do_cancel_retrieval(struct fscache_operation *_op) 357 - { 358 - struct fscache_retrieval *op = 359 - container_of(_op, struct fscache_retrieval, op); 360 - 361 - atomic_set(&op->n_pages, 0); 362 - } 363 - 364 - /* 365 333 * wait for an object to become active (or dead) 366 334 */ 367 335 int fscache_wait_for_operation_activation(struct fscache_object *object, 368 336 struct fscache_operation *op, 369 337 atomic_t *stat_op_waits, 370 - atomic_t *stat_object_dead, 371 - void (*do_cancel)(struct fscache_operation *)) 338 + atomic_t *stat_object_dead) 372 339 { 373 340 int ret; 374 341 ··· 368 359 fscache_stat(stat_op_waits); 369 360 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING, 370 361 TASK_INTERRUPTIBLE) != 0) { 371 - ret = fscache_cancel_op(op, do_cancel); 362 + ret = fscache_cancel_op(op, false); 372 363 if (ret == 0) 373 364 return -ERESTARTSYS; 374 365 ··· 386 377 _leave(" = -ENOBUFS [cancelled]"); 387 378 return -ENOBUFS; 388 379 } 389 - if (unlikely(fscache_object_is_dead(object))) { 390 - pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state); 391 - fscache_cancel_op(op, do_cancel); 380 + if (unlikely(fscache_object_is_dying(object) || 381 + fscache_cache_is_broken(object))) { 382 + enum fscache_operation_state state = op->state; 383 + fscache_cancel_op(op, true); 392 384 if (stat_object_dead) 393 385 fscache_stat(stat_object_dead); 386 + _leave(" = -ENOBUFS [obj dead %d]", state); 394 387 return -ENOBUFS; 395 388 } 396 389 return 0; ··· 464 453 465 454 fscache_stat(&fscache_n_retrieval_ops); 466 455 467 - /* pin the netfs read context in case we need to do the actual netfs 468 - * read because we've encountered a cache read failure */ 469 - fscache_get_context(object->cookie, op->context); 470 - 471 456 /* we wait for the operation to become active, and then process it 472 457 * *here*, in this thread, and not in the thread pool */ 473 458 ret = fscache_wait_for_operation_activation( 474 459 object, &op->op, 475 460 __fscache_stat(&fscache_n_retrieval_op_waits), 476 - __fscache_stat(&fscache_n_retrievals_object_dead), 477 - fscache_do_cancel_retrieval); 461 + __fscache_stat(&fscache_n_retrievals_object_dead)); 478 462 if (ret < 0) 479 463 goto error; 480 464 ··· 509 503 spin_unlock(&cookie->lock); 510 504 if (wake_cookie) 511 505 __fscache_wake_unused_cookie(cookie); 512 - kfree(op); 506 + fscache_put_retrieval(op); 513 507 nobufs: 514 508 fscache_stat(&fscache_n_retrievals_nobufs); 515 509 _leave(" = -ENOBUFS"); ··· 590 584 591 585 fscache_stat(&fscache_n_retrieval_ops); 592 586 593 - /* pin the netfs read context in case we need to do the actual netfs 594 - * read because we've encountered a cache read failure */ 595 - fscache_get_context(object->cookie, op->context); 596 - 597 587 /* we wait for the operation to become active, and then process it 598 588 * *here*, in this thread, and not in the thread pool */ 599 589 ret = fscache_wait_for_operation_activation( 600 590 object, &op->op, 601 591 __fscache_stat(&fscache_n_retrieval_op_waits), 602 - __fscache_stat(&fscache_n_retrievals_object_dead), 603 - fscache_do_cancel_retrieval); 592 + __fscache_stat(&fscache_n_retrievals_object_dead)); 604 593 if (ret < 0) 605 594 goto error; 606 595 ··· 633 632 wake_cookie = __fscache_unuse_cookie(cookie); 634 633 nobufs_unlock: 635 634 spin_unlock(&cookie->lock); 636 - kfree(op); 635 + fscache_put_retrieval(op); 637 636 if (wake_cookie) 638 637 __fscache_wake_unused_cookie(cookie); 639 638 nobufs: ··· 701 700 ret = fscache_wait_for_operation_activation( 702 701 object, &op->op, 703 702 __fscache_stat(&fscache_n_alloc_op_waits), 704 - __fscache_stat(&fscache_n_allocs_object_dead), 705 - fscache_do_cancel_retrieval); 703 + __fscache_stat(&fscache_n_allocs_object_dead)); 706 704 if (ret < 0) 707 705 goto error; 708 706 ··· 726 726 wake_cookie = __fscache_unuse_cookie(cookie); 727 727 nobufs_unlock: 728 728 spin_unlock(&cookie->lock); 729 - kfree(op); 729 + fscache_put_retrieval(op); 730 730 if (wake_cookie) 731 731 __fscache_wake_unused_cookie(cookie); 732 732 nobufs: ··· 944 944 if (!op) 945 945 goto nomem; 946 946 947 - fscache_operation_init(&op->op, fscache_write_op, 947 + fscache_operation_init(&op->op, fscache_write_op, NULL, 948 948 fscache_release_write_op); 949 949 op->op.flags = FSCACHE_OP_ASYNC | 950 950 (1 << FSCACHE_OP_WAITING) | ··· 1016 1016 spin_unlock(&object->lock); 1017 1017 spin_unlock(&cookie->lock); 1018 1018 radix_tree_preload_end(); 1019 - kfree(op); 1019 + fscache_put_operation(&op->op); 1020 1020 fscache_stat(&fscache_n_stores_ok); 1021 1021 _leave(" = 0"); 1022 1022 return 0; ··· 1036 1036 nobufs: 1037 1037 spin_unlock(&cookie->lock); 1038 1038 radix_tree_preload_end(); 1039 - kfree(op); 1039 + fscache_put_operation(&op->op); 1040 1040 if (wake_cookie) 1041 1041 __fscache_wake_unused_cookie(cookie); 1042 1042 fscache_stat(&fscache_n_stores_nobufs); ··· 1044 1044 return -ENOBUFS; 1045 1045 1046 1046 nomem_free: 1047 - kfree(op); 1047 + fscache_put_operation(&op->op); 1048 1048 nomem: 1049 1049 fscache_stat(&fscache_n_stores_oom); 1050 1050 _leave(" = -ENOMEM");
+13 -1
fs/fscache/stats.c
··· 23 23 atomic_t fscache_n_op_enqueue; 24 24 atomic_t fscache_n_op_requeue; 25 25 atomic_t fscache_n_op_deferred_release; 26 + atomic_t fscache_n_op_initialised; 26 27 atomic_t fscache_n_op_release; 27 28 atomic_t fscache_n_op_gc; 28 29 atomic_t fscache_n_op_cancelled; ··· 130 129 atomic_t fscache_n_cop_write_page; 131 130 atomic_t fscache_n_cop_uncache_page; 132 131 atomic_t fscache_n_cop_dissociate_pages; 132 + 133 + atomic_t fscache_n_cache_no_space_reject; 134 + atomic_t fscache_n_cache_stale_objects; 135 + atomic_t fscache_n_cache_retired_objects; 136 + atomic_t fscache_n_cache_culled_objects; 133 137 134 138 /* 135 139 * display the general statistics ··· 252 246 atomic_read(&fscache_n_op_enqueue), 253 247 atomic_read(&fscache_n_op_cancelled), 254 248 atomic_read(&fscache_n_op_rejected)); 255 - seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n", 249 + seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n", 250 + atomic_read(&fscache_n_op_initialised), 256 251 atomic_read(&fscache_n_op_deferred_release), 257 252 atomic_read(&fscache_n_op_release), 258 253 atomic_read(&fscache_n_op_gc)); ··· 278 271 atomic_read(&fscache_n_cop_write_page), 279 272 atomic_read(&fscache_n_cop_uncache_page), 280 273 atomic_read(&fscache_n_cop_dissociate_pages)); 274 + seq_printf(m, "CacheEv: nsp=%d stl=%d rtr=%d cul=%d\n", 275 + atomic_read(&fscache_n_cache_no_space_reject), 276 + atomic_read(&fscache_n_cache_stale_objects), 277 + atomic_read(&fscache_n_cache_retired_objects), 278 + atomic_read(&fscache_n_cache_culled_objects)); 281 279 return 0; 282 280 } 283 281
+1 -1
fs/fuse/file.c
··· 1169 1169 if (err <= 0) 1170 1170 goto out; 1171 1171 1172 - err = file_remove_suid(file); 1172 + err = file_remove_privs(file); 1173 1173 if (err) 1174 1174 goto out; 1175 1175
+1 -1
fs/hfs/hfs_fs.h
··· 252 252 #define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60) 253 253 #define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60) 254 254 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)) 256 256 #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info) 257 257 258 258 #define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
+1 -1
fs/hfsplus/hfsplus_fs.h
··· 263 263 264 264 static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode) 265 265 { 266 - return list_entry(inode, struct hfsplus_inode_info, vfs_inode); 266 + return container_of(inode, struct hfsplus_inode_info, vfs_inode); 267 267 } 268 268 269 269 /*
+1 -1
fs/hpfs/hpfs_fn.h
··· 304 304 305 305 static inline struct hpfs_inode_info *hpfs_i(struct inode *inode) 306 306 { 307 - return list_entry(inode, struct hpfs_inode_info, vfs_inode); 307 + return container_of(inode, struct hpfs_inode_info, vfs_inode); 308 308 } 309 309 310 310 static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
+46 -20
fs/inode.c
··· 841 841 } 842 842 #endif 843 843 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; 845 849 put_cpu_var(last_ino); 846 850 return res; 847 851 } ··· 1678 1674 } 1679 1675 EXPORT_SYMBOL(should_remove_suid); 1680 1676 1681 - static int __remove_suid(struct dentry *dentry, int kill) 1677 + /* 1678 + * Return mask of changes for notify_change() that need to be done as a 1679 + * response to write or truncate. Return 0 if nothing has to be changed. 1680 + * Negative value on error (change should be denied). 1681 + */ 1682 + int dentry_needs_remove_privs(struct dentry *dentry) 1683 + { 1684 + struct inode *inode = d_inode(dentry); 1685 + int mask = 0; 1686 + int ret; 1687 + 1688 + if (IS_NOSEC(inode)) 1689 + return 0; 1690 + 1691 + mask = should_remove_suid(dentry); 1692 + ret = security_inode_need_killpriv(dentry); 1693 + if (ret < 0) 1694 + return ret; 1695 + if (ret) 1696 + mask |= ATTR_KILL_PRIV; 1697 + return mask; 1698 + } 1699 + EXPORT_SYMBOL(dentry_needs_remove_privs); 1700 + 1701 + static int __remove_privs(struct dentry *dentry, int kill) 1682 1702 { 1683 1703 struct iattr newattrs; 1684 1704 ··· 1714 1686 return notify_change(dentry, &newattrs, NULL); 1715 1687 } 1716 1688 1717 - int file_remove_suid(struct file *file) 1689 + /* 1690 + * Remove special file priviledges (suid, capabilities) when file is written 1691 + * to or truncated. 1692 + */ 1693 + int file_remove_privs(struct file *file) 1718 1694 { 1719 1695 struct dentry *dentry = file->f_path.dentry; 1720 1696 struct inode *inode = d_inode(dentry); 1721 - int killsuid; 1722 - int killpriv; 1697 + int kill; 1723 1698 int error = 0; 1724 1699 1725 1700 /* Fast path for nothing security related */ 1726 1701 if (IS_NOSEC(inode)) 1727 1702 return 0; 1728 1703 1729 - killsuid = should_remove_suid(dentry); 1730 - killpriv = security_inode_need_killpriv(dentry); 1731 - 1732 - if (killpriv < 0) 1733 - return killpriv; 1734 - if (killpriv) 1735 - error = security_inode_killpriv(dentry); 1736 - if (!error && killsuid) 1737 - error = __remove_suid(dentry, killsuid); 1738 - if (!error && (inode->i_sb->s_flags & MS_NOSEC)) 1739 - inode->i_flags |= S_NOSEC; 1704 + kill = file_needs_remove_privs(file); 1705 + if (kill < 0) 1706 + return kill; 1707 + if (kill) 1708 + error = __remove_privs(dentry, kill); 1709 + if (!error) 1710 + inode_has_no_xattr(inode); 1740 1711 1741 1712 return error; 1742 1713 } 1743 - EXPORT_SYMBOL(file_remove_suid); 1714 + EXPORT_SYMBOL(file_remove_privs); 1744 1715 1745 1716 /** 1746 1717 * file_update_time - update mtime and ctime time ··· 1994 1967 * inode is being instantiated). The reason for the cmpxchg() loop 1995 1968 * --- which wouldn't be necessary if all code paths which modify 1996 1969 * i_flags actually followed this rule, is that there is at least one 1997 - * code path which doesn't today --- for example, 1998 - * __generic_file_aio_write() calls file_remove_suid() without holding 1999 - * i_mutex --- so we use cmpxchg() out of an abundance of caution. 1970 + * code path which doesn't today so we use cmpxchg() out of an abundance 1971 + * of caution. 2000 1972 * 2001 1973 * In the long run, i_mutex is overkill, and we should probably look 2002 1974 * at using the i_lock spinlock to protect i_flags, and then make sure
+1
fs/internal.h
··· 107 107 extern long do_handle_open(int mountdirfd, 108 108 struct file_handle __user *ufh, int open_flag); 109 109 extern int open_check_o_direct(struct file *f); 110 + extern int vfs_open(const struct path *, struct file *, const struct cred *); 110 111 111 112 /* 112 113 * inode.c
+1 -1
fs/jffs2/os-linux.h
··· 19 19 struct kstatfs; 20 20 struct kvec; 21 21 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)) 23 23 #define OFNI_EDONI_2SFFJ(f) (&(f)->vfs_inode) 24 24 #define JFFS2_SB_INFO(sb) (sb->s_fs_info) 25 25 #define OFNI_BS_2SFFJ(c) ((struct super_block *)c->os_priv)
+1 -1
fs/jfs/jfs_incore.h
··· 206 206 207 207 static inline struct jfs_inode_info *JFS_IP(struct inode *inode) 208 208 { 209 - return list_entry(inode, struct jfs_inode_info, vfs_inode); 209 + return container_of(inode, struct jfs_inode_info, vfs_inode); 210 210 } 211 211 212 212 static inline int jfs_dirtable_inline(struct inode *inode)
-5
fs/libfs.c
··· 20 20 21 21 #include "internal.h" 22 22 23 - static inline int simple_positive(struct dentry *dentry) 24 - { 25 - return d_really_is_positive(dentry) && !d_unhashed(dentry); 26 - } 27 - 28 23 int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, 29 24 struct kstat *stat) 30 25 {
-5
fs/minix/dir.c
··· 45 45 return last_byte; 46 46 } 47 47 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 - 53 48 static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) 54 49 { 55 50 struct address_space *mapping = page->mapping;
+1 -1
fs/minix/minix.h
··· 84 84 85 85 static inline struct minix_inode_info *minix_i(struct inode *inode) 86 86 { 87 - return list_entry(inode, struct minix_inode_info, vfs_inode); 87 + return container_of(inode, struct minix_inode_info, vfs_inode); 88 88 } 89 89 90 90 static inline unsigned minix_blocks_needed(unsigned bits, unsigned blocksize)
+3 -3
fs/namei.c
··· 792 792 get_fs_root(current->fs, &nd->root); 793 793 } 794 794 795 - static unsigned set_root_rcu(struct nameidata *nd) 795 + static void set_root_rcu(struct nameidata *nd) 796 796 { 797 797 struct fs_struct *fs = current->fs; 798 798 unsigned seq; ··· 802 802 nd->root = fs->root; 803 803 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq); 804 804 } while (read_seqcount_retry(&fs->seq, seq)); 805 - return nd->root_seq; 806 805 } 807 806 808 807 static void path_put_conditional(struct path *path, struct nameidata *nd) ··· 1997 1998 if (*s == '/') { 1998 1999 if (flags & LOOKUP_RCU) { 1999 2000 rcu_read_lock(); 2000 - nd->seq = set_root_rcu(nd); 2001 + set_root_rcu(nd); 2002 + nd->seq = nd->root_seq; 2001 2003 } else { 2002 2004 set_root(nd); 2003 2005 path_get(&nd->root);
+2
fs/ncpfs/dir.c
··· 1145 1145 case 0x00: 1146 1146 ncp_dbg(1, "renamed %pd -> %pd\n", 1147 1147 old_dentry, new_dentry); 1148 + ncp_d_prune(old_dentry); 1149 + ncp_d_prune(new_dentry); 1148 1150 break; 1149 1151 case 0x9E: 1150 1152 error = -ENAMETOOLONG;
+1 -1
fs/nfs/dir.c
··· 1768 1768 1769 1769 static void nfs_dentry_handle_enoent(struct dentry *dentry) 1770 1770 { 1771 - if (d_really_is_positive(dentry) && !d_unhashed(dentry)) 1771 + if (simple_positive(dentry)) 1772 1772 d_delete(dentry); 1773 1773 } 1774 1774
-5
fs/nilfs2/dir.c
··· 61 61 page_cache_release(page); 62 62 } 63 63 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 - 69 64 /* 70 65 * Return the offset into page `page_nr' of the last valid 71 66 * byte in that page, plus one.
+2 -20
fs/nilfs2/inode.c
··· 307 307 static ssize_t 308 308 nilfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset) 309 309 { 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); 315 311 316 312 if (iov_iter_rw(iter) == WRITE) 317 313 return 0; 318 314 319 315 /* 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); 335 317 } 336 318 337 319 const struct address_space_operations nilfs_aops = {
+1 -1
fs/ntfs/file.c
··· 382 382 base_ni = ni; 383 383 if (NInoAttr(ni)) 384 384 base_ni = ni->ext.base_ntfs_ino; 385 - err = file_remove_suid(file); 385 + err = file_remove_privs(file); 386 386 if (unlikely(err)) 387 387 goto out; 388 388 /*
+1 -1
fs/ntfs/inode.h
··· 239 239 */ 240 240 static inline ntfs_inode *NTFS_I(struct inode *inode) 241 241 { 242 - return (ntfs_inode *)list_entry(inode, big_ntfs_inode, vfs_inode); 242 + return (ntfs_inode *)container_of(inode, big_ntfs_inode, vfs_inode); 243 243 } 244 244 245 245 static inline struct inode *VFS_I(ntfs_inode *ni)
+36 -25
fs/open.c
··· 51 51 newattrs.ia_valid |= ATTR_FILE; 52 52 } 53 53 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; 56 58 if (ret) 57 59 newattrs.ia_valid |= ret | ATTR_FORCE; 58 60 ··· 680 678 } 681 679 682 680 static int do_dentry_open(struct file *f, 681 + struct inode *inode, 683 682 int (*open)(struct inode *, struct file *), 684 683 const struct cred *cred) 685 684 { 686 685 static const struct file_operations empty_fops = {}; 687 - struct inode *inode; 688 686 int error; 689 687 690 688 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK | 691 689 FMODE_PREAD | FMODE_PWRITE; 692 690 693 691 path_get(&f->f_path); 694 - inode = f->f_inode = f->f_path.dentry->d_inode; 692 + f->f_inode = inode; 695 693 f->f_mapping = inode->i_mapping; 696 694 697 695 if (unlikely(f->f_flags & O_PATH)) { ··· 795 793 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ 796 794 797 795 file->f_path.dentry = dentry; 798 - error = do_dentry_open(file, open, current_cred()); 796 + error = do_dentry_open(file, d_backing_inode(dentry), open, 797 + current_cred()); 799 798 if (!error) 800 799 *opened |= FILE_OPENED; 801 800 ··· 824 821 return 1; 825 822 } 826 823 EXPORT_SYMBOL(finish_no_open); 824 + 825 + char *file_path(struct file *filp, char *buf, int buflen) 826 + { 827 + return d_path(&filp->f_path, buf, buflen); 828 + } 829 + EXPORT_SYMBOL(file_path); 830 + 831 + /** 832 + * vfs_open - open the file at the given path 833 + * @path: path to open 834 + * @file: newly allocated file with f_flag initialized 835 + * @cred: credentials to use 836 + */ 837 + int vfs_open(const struct path *path, struct file *file, 838 + const struct cred *cred) 839 + { 840 + struct dentry *dentry = path->dentry; 841 + struct inode *inode = dentry->d_inode; 842 + 843 + file->f_path = *path; 844 + if (dentry->d_flags & DCACHE_OP_SELECT_INODE) { 845 + inode = dentry->d_op->d_select_inode(dentry, file->f_flags); 846 + if (IS_ERR(inode)) 847 + return PTR_ERR(inode); 848 + } 849 + 850 + return do_dentry_open(file, inode, NULL, cred); 851 + } 827 852 828 853 struct file *dentry_open(const struct path *path, int flags, 829 854 const struct cred *cred) ··· 883 852 return f; 884 853 } 885 854 EXPORT_SYMBOL(dentry_open); 886 - 887 - /** 888 - * vfs_open - open the file at the given path 889 - * @path: path to open 890 - * @filp: newly allocated file with f_flag initialized 891 - * @cred: credentials to use 892 - */ 893 - int vfs_open(const struct path *path, struct file *filp, 894 - const struct cred *cred) 895 - { 896 - struct inode *inode = path->dentry->d_inode; 897 - 898 - if (inode->i_op->dentry_open) 899 - return inode->i_op->dentry_open(path->dentry, filp, cred); 900 - else { 901 - filp->f_path = *path; 902 - return do_dentry_open(filp, NULL, cred); 903 - } 904 - } 905 - EXPORT_SYMBOL(vfs_open); 906 855 907 856 static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op) 908 857 {
+7 -15
fs/overlayfs/inode.c
··· 337 337 return true; 338 338 } 339 339 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) 342 341 { 343 342 int err; 344 343 struct path realpath; 345 344 enum ovl_path_type type; 346 - bool want_write = false; 347 345 348 346 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)) { 351 348 err = ovl_want_write(dentry); 352 349 if (err) 353 - goto out; 350 + return ERR_PTR(err); 354 351 355 - if (file->f_flags & O_TRUNC) 352 + if (file_flags & O_TRUNC) 356 353 err = ovl_copy_up_last(dentry, NULL, true); 357 354 else 358 355 err = ovl_copy_up(dentry); 356 + ovl_drop_write(dentry); 359 357 if (err) 360 - goto out_drop_write; 358 + return ERR_PTR(err); 361 359 362 360 ovl_path_upper(dentry, &realpath); 363 361 } 364 362 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); 371 364 } 372 365 373 366 static const struct inode_operations ovl_file_inode_operations = { ··· 371 378 .getxattr = ovl_getxattr, 372 379 .listxattr = ovl_listxattr, 373 380 .removexattr = ovl_removexattr, 374 - .dentry_open = ovl_dentry_open, 375 381 }; 376 382 377 383 static const struct inode_operations ovl_symlink_inode_operations = {
+1
fs/overlayfs/overlayfs.h
··· 173 173 void *value, size_t size); 174 174 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); 175 175 int ovl_removexattr(struct dentry *dentry, const char *name); 176 + struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags); 176 177 177 178 struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, 178 179 struct ovl_entry *oe);
+1
fs/overlayfs/super.c
··· 316 316 317 317 static const struct dentry_operations ovl_dentry_operations = { 318 318 .d_release = ovl_dentry_release, 319 + .d_select_inode = ovl_d_select_inode, 319 320 }; 320 321 321 322 static const struct dentry_operations ovl_reval_dentry_operations = {
+20 -26
fs/posix_acl.c
··· 547 547 struct posix_acl **default_acl, struct posix_acl **acl) 548 548 { 549 549 struct posix_acl *p; 550 + struct posix_acl *clone; 550 551 int ret; 551 552 553 + *acl = NULL; 554 + *default_acl = NULL; 555 + 552 556 if (S_ISLNK(*mode) || !IS_POSIXACL(dir)) 553 - goto no_acl; 557 + return 0; 554 558 555 559 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; 560 563 } 564 + if (IS_ERR(p)) 565 + return PTR_ERR(p); 561 566 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) 567 569 goto no_mem; 568 570 569 - ret = posix_acl_create_masq(*acl, mode); 571 + ret = posix_acl_create_masq(clone, mode); 570 572 if (ret < 0) 571 573 goto no_mem_clone; 572 574 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; 577 579 578 - if (!S_ISDIR(*mode)) { 580 + if (!S_ISDIR(*mode)) 579 581 posix_acl_release(p); 580 - *default_acl = NULL; 581 - } else { 582 + else 582 583 *default_acl = p; 583 - } 584 - return 0; 585 584 586 - apply_umask: 587 - *mode &= ~current_umask(); 588 - no_acl: 589 - *default_acl = NULL; 590 - *acl = NULL; 591 585 return 0; 592 586 593 587 no_mem_clone: 594 - posix_acl_release(*acl); 588 + posix_acl_release(clone); 595 589 no_mem: 596 590 posix_acl_release(p); 597 591 return -ENOMEM;
+1 -1
fs/proc/nommu.c
··· 64 64 65 65 if (file) { 66 66 seq_pad(m, ' '); 67 - seq_path(m, &file->f_path, ""); 67 + seq_file_path(m, file, ""); 68 68 } 69 69 70 70 seq_putc(m, '\n');
+2 -2
fs/proc/task_mmu.c
··· 310 310 */ 311 311 if (file) { 312 312 seq_pad(m, ' '); 313 - seq_path(m, &file->f_path, "\n"); 313 + seq_file_path(m, file, "\n"); 314 314 goto done; 315 315 } 316 316 ··· 1509 1509 1510 1510 if (file) { 1511 1511 seq_puts(m, " file="); 1512 - seq_path(m, &file->f_path, "\n\t= "); 1512 + seq_file_path(m, file, "\n\t= "); 1513 1513 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1514 1514 seq_puts(m, " heap"); 1515 1515 } else {
+1 -1
fs/proc/task_nommu.c
··· 180 180 181 181 if (file) { 182 182 seq_pad(m, ' '); 183 - seq_path(m, &file->f_path, ""); 183 + seq_file_path(m, file, ""); 184 184 } else if (mm) { 185 185 pid_t tid = pid_of_stack(priv, vma, is_pid); 186 186
-5
fs/qnx6/dir.c
··· 32 32 return page; 33 33 } 34 34 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 - 40 35 static unsigned last_entry(struct inode *inode, unsigned long page_nr) 41 36 { 42 37 unsigned long last_byte = inode->i_size;
+14
fs/seq_file.c
··· 490 490 } 491 491 EXPORT_SYMBOL(seq_path); 492 492 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 + 493 507 /* 494 508 * Same as seq_path, but relative to supplied root. 495 509 */
+1 -1
fs/squashfs/squashfs_fs_i.h
··· 49 49 50 50 static inline struct squashfs_inode_info *squashfs_i(struct inode *inode) 51 51 { 52 - return list_entry(inode, struct squashfs_inode_info, vfs_inode); 52 + return container_of(inode, struct squashfs_inode_info, vfs_inode); 53 53 } 54 54 #endif
+1 -1
fs/super.c
··· 842 842 else if (error) 843 843 return -EAGAIN; 844 844 845 - if (dev == (1 << MINORBITS)) { 845 + if (dev >= (1 << MINORBITS)) { 846 846 spin_lock(&unnamed_dev_lock); 847 847 ida_remove(&unnamed_dev_ida, dev); 848 848 if (unnamed_dev_start > dev)
-5
fs/sysv/dir.c
··· 33 33 page_cache_release(page); 34 34 } 35 35 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 - 41 36 static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) 42 37 { 43 38 struct address_space *mapping = page->mapping;
+1 -1
fs/sysv/sysv.h
··· 73 73 74 74 static inline struct sysv_inode_info *SYSV_I(struct inode *inode) 75 75 { 76 - return list_entry(inode, struct sysv_inode_info, vfs_inode); 76 + return container_of(inode, struct sysv_inode_info, vfs_inode); 77 77 } 78 78 79 79 static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
+3 -8
fs/tracefs/inode.c
··· 496 496 return dentry; 497 497 } 498 498 499 - static inline int tracefs_positive(struct dentry *dentry) 500 - { 501 - return dentry->d_inode && !d_unhashed(dentry); 502 - } 503 - 504 499 static int __tracefs_remove(struct dentry *dentry, struct dentry *parent) 505 500 { 506 501 int ret = 0; 507 502 508 - if (tracefs_positive(dentry)) { 503 + if (simple_positive(dentry)) { 509 504 if (dentry->d_inode) { 510 505 dget(dentry); 511 506 switch (dentry->d_inode->i_mode & S_IFMT) { ··· 577 582 */ 578 583 spin_lock(&parent->d_lock); 579 584 list_for_each_entry(child, &parent->d_subdirs, d_child) { 580 - if (!tracefs_positive(child)) 585 + if (!simple_positive(child)) 581 586 continue; 582 587 583 588 /* perhaps simple_empty(child) makes more sense */ ··· 598 603 * from d_subdirs. When releasing the parent->d_lock we can 599 604 * no longer trust that the next pointer is valid. 600 605 * Restart the loop. We'll skip this one with the 601 - * tracefs_positive() check. 606 + * simple_positive() check. 602 607 */ 603 608 goto loop; 604 609 }
+1 -1
fs/udf/udf_i.h
··· 56 56 57 57 static inline struct udf_inode_info *UDF_I(struct inode *inode) 58 58 { 59 - return list_entry(inode, struct udf_inode_info, vfs_inode); 59 + return container_of(inode, struct udf_inode_info, vfs_inode); 60 60 } 61 61 62 62 #endif /* _UDF_I_H) */
+17 -17
fs/ufs/balloc.c
··· 51 51 52 52 if (ufs_fragnum(fragment) + count > uspi->s_fpg) 53 53 ufs_error (sb, "ufs_free_fragments", "internal error"); 54 - 55 - lock_ufs(sb); 54 + 55 + mutex_lock(&UFS_SB(sb)->s_lock); 56 56 57 57 cgno = ufs_dtog(uspi, fragment); 58 58 bit = ufs_dtogd(uspi, fragment); ··· 115 115 if (sb->s_flags & MS_SYNCHRONOUS) 116 116 ubh_sync_block(UCPI_UBH(ucpi)); 117 117 ufs_mark_sb_dirty(sb); 118 - 119 - unlock_ufs(sb); 118 + 119 + mutex_unlock(&UFS_SB(sb)->s_lock); 120 120 UFSD("EXIT\n"); 121 121 return; 122 122 123 123 failed: 124 - unlock_ufs(sb); 124 + mutex_unlock(&UFS_SB(sb)->s_lock); 125 125 UFSD("EXIT (FAILED)\n"); 126 126 return; 127 127 } ··· 151 151 goto failed; 152 152 } 153 153 154 - lock_ufs(sb); 154 + mutex_lock(&UFS_SB(sb)->s_lock); 155 155 156 156 do_more: 157 157 overflow = 0; ··· 211 211 } 212 212 213 213 ufs_mark_sb_dirty(sb); 214 - unlock_ufs(sb); 214 + mutex_unlock(&UFS_SB(sb)->s_lock); 215 215 UFSD("EXIT\n"); 216 216 return; 217 217 218 218 failed_unlock: 219 - unlock_ufs(sb); 219 + mutex_unlock(&UFS_SB(sb)->s_lock); 220 220 failed: 221 221 UFSD("EXIT (FAILED)\n"); 222 222 return; ··· 357 357 usb1 = ubh_get_usb_first(uspi); 358 358 *err = -ENOSPC; 359 359 360 - lock_ufs(sb); 360 + mutex_lock(&UFS_SB(sb)->s_lock); 361 361 tmp = ufs_data_ptr_to_cpu(sb, p); 362 362 363 363 if (count + ufs_fragnum(fragment) > uspi->s_fpb) { ··· 378 378 "fragment %llu, tmp %llu\n", 379 379 (unsigned long long)fragment, 380 380 (unsigned long long)tmp); 381 - unlock_ufs(sb); 381 + mutex_unlock(&UFS_SB(sb)->s_lock); 382 382 return INVBLOCK; 383 383 } 384 384 if (fragment < UFS_I(inode)->i_lastfrag) { 385 385 UFSD("EXIT (ALREADY ALLOCATED)\n"); 386 - unlock_ufs(sb); 386 + mutex_unlock(&UFS_SB(sb)->s_lock); 387 387 return 0; 388 388 } 389 389 } 390 390 else { 391 391 if (tmp) { 392 392 UFSD("EXIT (ALREADY ALLOCATED)\n"); 393 - unlock_ufs(sb); 393 + mutex_unlock(&UFS_SB(sb)->s_lock); 394 394 return 0; 395 395 } 396 396 } ··· 399 399 * There is not enough space for user on the device 400 400 */ 401 401 if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) { 402 - unlock_ufs(sb); 402 + mutex_unlock(&UFS_SB(sb)->s_lock); 403 403 UFSD("EXIT (FAILED)\n"); 404 404 return 0; 405 405 } ··· 424 424 ufs_clear_frags(inode, result + oldcount, 425 425 newcount - oldcount, locked_page != NULL); 426 426 } 427 - unlock_ufs(sb); 427 + mutex_unlock(&UFS_SB(sb)->s_lock); 428 428 UFSD("EXIT, result %llu\n", (unsigned long long)result); 429 429 return result; 430 430 } ··· 439 439 fragment + count); 440 440 ufs_clear_frags(inode, result + oldcount, newcount - oldcount, 441 441 locked_page != NULL); 442 - unlock_ufs(sb); 442 + mutex_unlock(&UFS_SB(sb)->s_lock); 443 443 UFSD("EXIT, result %llu\n", (unsigned long long)result); 444 444 return result; 445 445 } ··· 477 477 *err = 0; 478 478 UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, 479 479 fragment + count); 480 - unlock_ufs(sb); 480 + mutex_unlock(&UFS_SB(sb)->s_lock); 481 481 if (newcount < request) 482 482 ufs_free_fragments (inode, result + newcount, request - newcount); 483 483 ufs_free_fragments (inode, tmp, oldcount); ··· 485 485 return result; 486 486 } 487 487 488 - unlock_ufs(sb); 488 + mutex_unlock(&UFS_SB(sb)->s_lock); 489 489 UFSD("EXIT (FAILED)\n"); 490 490 return 0; 491 491 }
+8 -11
fs/ufs/dir.c
··· 65 65 page_cache_release(page); 66 66 } 67 67 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 - 73 68 ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) 74 69 { 75 70 ino_t res = 0; ··· 82 87 83 88 /* Releases the page */ 84 89 void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, 85 - struct page *page, struct inode *inode) 90 + struct page *page, struct inode *inode, 91 + bool update_times) 86 92 { 87 93 loff_t pos = page_offset(page) + 88 94 (char *) de - (char *) page_address(page); ··· 99 103 100 104 err = ufs_commit_chunk(page, pos, len); 101 105 ufs_put_page(page); 102 - dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; 106 + if (update_times) 107 + dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; 103 108 mark_inode_dirty(dir); 104 109 } 105 110 ··· 253 256 int namelen = qstr->len; 254 257 unsigned reclen = UFS_DIR_REC_LEN(namelen); 255 258 unsigned long start, n; 256 - unsigned long npages = ufs_dir_pages(dir); 259 + unsigned long npages = dir_pages(dir); 257 260 struct page *page = NULL; 258 261 struct ufs_inode_info *ui = UFS_I(dir); 259 262 struct ufs_dir_entry *de; ··· 317 320 unsigned short rec_len, name_len; 318 321 struct page *page = NULL; 319 322 struct ufs_dir_entry *de; 320 - unsigned long npages = ufs_dir_pages(dir); 323 + unsigned long npages = dir_pages(dir); 321 324 unsigned long n; 322 325 char *kaddr; 323 326 loff_t pos; ··· 434 437 struct super_block *sb = inode->i_sb; 435 438 unsigned int offset = pos & ~PAGE_CACHE_MASK; 436 439 unsigned long n = pos >> PAGE_CACHE_SHIFT; 437 - unsigned long npages = ufs_dir_pages(inode); 440 + unsigned long npages = dir_pages(inode); 438 441 unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1); 439 442 int need_revalidate = file->f_version != inode->i_version; 440 443 unsigned flags = UFS_SB(sb)->s_flags; ··· 605 608 { 606 609 struct super_block *sb = inode->i_sb; 607 610 struct page *page = NULL; 608 - unsigned long i, npages = ufs_dir_pages(inode); 611 + unsigned long i, npages = dir_pages(inode); 609 612 610 613 for (i = 0; i < npages; i++) { 611 614 char *kaddr;
+8 -8
fs/ufs/ialloc.c
··· 69 69 70 70 ino = inode->i_ino; 71 71 72 - lock_ufs(sb); 72 + mutex_lock(&UFS_SB(sb)->s_lock); 73 73 74 74 if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) { 75 75 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); 77 77 return; 78 78 } 79 79 ··· 81 81 bit = ufs_inotocgoff (ino); 82 82 ucpi = ufs_load_cylinder (sb, cg); 83 83 if (!ucpi) { 84 - unlock_ufs(sb); 84 + mutex_unlock(&UFS_SB(sb)->s_lock); 85 85 return; 86 86 } 87 87 ucg = ubh_get_ucg(UCPI_UBH(ucpi)); ··· 115 115 ubh_sync_block(UCPI_UBH(ucpi)); 116 116 117 117 ufs_mark_sb_dirty(sb); 118 - unlock_ufs(sb); 118 + mutex_unlock(&UFS_SB(sb)->s_lock); 119 119 UFSD("EXIT\n"); 120 120 } 121 121 ··· 193 193 sbi = UFS_SB(sb); 194 194 uspi = sbi->s_uspi; 195 195 196 - lock_ufs(sb); 196 + mutex_lock(&sbi->s_lock); 197 197 198 198 /* 199 199 * Try to place the inode in its parent directory ··· 331 331 sync_dirty_buffer(bh); 332 332 brelse(bh); 333 333 } 334 - unlock_ufs(sb); 334 + mutex_unlock(&sbi->s_lock); 335 335 336 336 UFSD("allocating inode %lu\n", inode->i_ino); 337 337 UFSD("EXIT\n"); 338 338 return inode; 339 339 340 340 fail_remove_inode: 341 - unlock_ufs(sb); 341 + mutex_unlock(&sbi->s_lock); 342 342 clear_nlink(inode); 343 343 unlock_new_inode(inode); 344 344 iput(inode); 345 345 UFSD("EXIT (FAILED): err %d\n", err); 346 346 return ERR_PTR(err); 347 347 failed: 348 - unlock_ufs(sb); 348 + mutex_unlock(&sbi->s_lock); 349 349 make_bad_inode(inode); 350 350 iput (inode); 351 351 UFSD("EXIT (FAILED): err %d\n", err);
+4 -1
fs/ufs/inode.c
··· 903 903 invalidate_inode_buffers(inode); 904 904 clear_inode(inode); 905 905 906 - if (want_delete) 906 + if (want_delete) { 907 + lock_ufs(inode->i_sb); 907 908 ufs_free_inode(inode); 909 + unlock_ufs(inode->i_sb); 910 + } 908 911 }
+33 -46
fs/ufs/namei.c
··· 56 56 if (dentry->d_name.len > UFS_MAXNAMLEN) 57 57 return ERR_PTR(-ENAMETOOLONG); 58 58 59 - lock_ufs(dir->i_sb); 60 59 ino = ufs_inode_by_name(dir, &dentry->d_name); 61 60 if (ino) 62 61 inode = ufs_iget(dir->i_sb, ino); 63 - unlock_ufs(dir->i_sb); 64 62 return d_splice_alias(inode, dentry); 65 63 } 66 64 ··· 74 76 bool excl) 75 77 { 76 78 struct inode *inode; 77 - int err; 78 - 79 - UFSD("BEGIN\n"); 80 79 81 80 inode = ufs_new_inode(dir, mode); 82 - err = PTR_ERR(inode); 81 + if (IS_ERR(inode)) 82 + return PTR_ERR(inode); 83 83 84 - if (!IS_ERR(inode)) { 85 - inode->i_op = &ufs_file_inode_operations; 86 - inode->i_fop = &ufs_file_operations; 87 - inode->i_mapping->a_ops = &ufs_aops; 88 - mark_inode_dirty(inode); 89 - lock_ufs(dir->i_sb); 90 - err = ufs_add_nondir(dentry, inode); 91 - unlock_ufs(dir->i_sb); 92 - } 93 - UFSD("END: err=%d\n", err); 94 - return err; 84 + inode->i_op = &ufs_file_inode_operations; 85 + inode->i_fop = &ufs_file_operations; 86 + inode->i_mapping->a_ops = &ufs_aops; 87 + mark_inode_dirty(inode); 88 + return ufs_add_nondir(dentry, inode); 95 89 } 96 90 97 91 static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) ··· 100 110 init_special_inode(inode, mode, rdev); 101 111 ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev); 102 112 mark_inode_dirty(inode); 103 - lock_ufs(dir->i_sb); 104 113 err = ufs_add_nondir(dentry, inode); 105 - unlock_ufs(dir->i_sb); 106 114 } 107 115 return err; 108 116 } ··· 109 121 const char * symname) 110 122 { 111 123 struct super_block * sb = dir->i_sb; 112 - int err = -ENAMETOOLONG; 124 + int err; 113 125 unsigned l = strlen(symname)+1; 114 126 struct inode * inode; 115 127 116 128 if (l > sb->s_blocksize) 117 - goto out_notlocked; 129 + return -ENAMETOOLONG; 118 130 119 131 inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO); 120 132 err = PTR_ERR(inode); 121 133 if (IS_ERR(inode)) 122 - goto out_notlocked; 134 + return err; 123 135 124 - lock_ufs(dir->i_sb); 125 136 if (l > UFS_SB(sb)->s_uspi->s_maxsymlinklen) { 126 137 /* slow symlink */ 127 138 inode->i_op = &ufs_symlink_inode_operations; ··· 137 150 } 138 151 mark_inode_dirty(inode); 139 152 140 - err = ufs_add_nondir(dentry, inode); 141 - out: 142 - unlock_ufs(dir->i_sb); 143 - out_notlocked: 144 - return err; 153 + return ufs_add_nondir(dentry, inode); 145 154 146 155 out_fail: 147 156 inode_dec_link_count(inode); 148 157 unlock_new_inode(inode); 149 158 iput(inode); 150 - goto out; 159 + return err; 151 160 } 152 161 153 162 static int ufs_link (struct dentry * old_dentry, struct inode * dir, ··· 152 169 struct inode *inode = d_inode(old_dentry); 153 170 int error; 154 171 155 - lock_ufs(dir->i_sb); 156 - 157 172 inode->i_ctime = CURRENT_TIME_SEC; 158 173 inode_inc_link_count(inode); 159 174 ihold(inode); 160 175 161 - error = ufs_add_nondir(dentry, inode); 162 - unlock_ufs(dir->i_sb); 176 + error = ufs_add_link(dentry, inode); 177 + if (error) { 178 + inode_dec_link_count(inode); 179 + iput(inode); 180 + } else 181 + d_instantiate(dentry, inode); 163 182 return error; 164 183 } 165 184 ··· 170 185 struct inode * inode; 171 186 int err; 172 187 188 + inode_inc_link_count(dir); 189 + 173 190 inode = ufs_new_inode(dir, S_IFDIR|mode); 191 + err = PTR_ERR(inode); 174 192 if (IS_ERR(inode)) 175 - return PTR_ERR(inode); 193 + goto out_dir; 176 194 177 195 inode->i_op = &ufs_dir_inode_operations; 178 196 inode->i_fop = &ufs_dir_operations; 179 197 inode->i_mapping->a_ops = &ufs_aops; 180 198 181 199 inode_inc_link_count(inode); 182 - 183 - lock_ufs(dir->i_sb); 184 - inode_inc_link_count(dir); 185 200 186 201 err = ufs_make_empty(inode, dir); 187 202 if (err) ··· 190 205 err = ufs_add_link(dentry, inode); 191 206 if (err) 192 207 goto out_fail; 193 - unlock_ufs(dir->i_sb); 194 208 209 + unlock_new_inode(inode); 195 210 d_instantiate(dentry, inode); 196 - out: 197 - return err; 211 + return 0; 198 212 199 213 out_fail: 200 214 inode_dec_link_count(inode); 201 215 inode_dec_link_count(inode); 202 216 unlock_new_inode(inode); 203 217 iput (inode); 218 + out_dir: 204 219 inode_dec_link_count(dir); 205 - unlock_ufs(dir->i_sb); 206 - goto out; 220 + return err; 207 221 } 208 222 209 223 static int ufs_unlink(struct inode *dir, struct dentry *dentry) ··· 232 248 struct inode * inode = d_inode(dentry); 233 249 int err= -ENOTEMPTY; 234 250 235 - lock_ufs(dir->i_sb); 236 251 if (ufs_empty_dir (inode)) { 237 252 err = ufs_unlink(dir, dentry); 238 253 if (!err) { ··· 240 257 inode_dec_link_count(dir); 241 258 } 242 259 } 243 - unlock_ufs(dir->i_sb); 244 260 return err; 245 261 } 246 262 ··· 277 295 new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); 278 296 if (!new_de) 279 297 goto out_dir; 280 - ufs_set_link(new_dir, new_de, new_page, old_inode); 298 + ufs_set_link(new_dir, new_de, new_page, old_inode, 1); 281 299 new_inode->i_ctime = CURRENT_TIME_SEC; 282 300 if (dir_de) 283 301 drop_nlink(new_inode); ··· 300 318 mark_inode_dirty(old_inode); 301 319 302 320 if (dir_de) { 303 - ufs_set_link(old_inode, dir_de, dir_page, new_dir); 321 + if (old_dir != new_dir) 322 + ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0); 323 + else { 324 + kunmap(dir_page); 325 + page_cache_release(dir_page); 326 + } 304 327 inode_dec_link_count(old_dir); 305 328 } 306 329 return 0;
+11
fs/ufs/super.c
··· 695 695 unsigned flags; 696 696 697 697 lock_ufs(sb); 698 + mutex_lock(&UFS_SB(sb)->s_lock); 698 699 699 700 UFSD("ENTER\n"); 700 701 ··· 713 712 ufs_put_cstotal(sb); 714 713 715 714 UFSD("EXIT\n"); 715 + mutex_unlock(&UFS_SB(sb)->s_lock); 716 716 unlock_ufs(sb); 717 717 718 718 return 0; ··· 802 800 UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); 803 801 804 802 mutex_init(&sbi->mutex); 803 + mutex_init(&sbi->s_lock); 805 804 spin_lock_init(&sbi->work_lock); 806 805 INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs); 807 806 /* ··· 1281 1278 1282 1279 sync_filesystem(sb); 1283 1280 lock_ufs(sb); 1281 + mutex_lock(&UFS_SB(sb)->s_lock); 1284 1282 uspi = UFS_SB(sb)->s_uspi; 1285 1283 flags = UFS_SB(sb)->s_flags; 1286 1284 usb1 = ubh_get_usb_first(uspi); ··· 1295 1291 new_mount_opt = 0; 1296 1292 ufs_set_opt (new_mount_opt, ONERROR_LOCK); 1297 1293 if (!ufs_parse_options (data, &new_mount_opt)) { 1294 + mutex_unlock(&UFS_SB(sb)->s_lock); 1298 1295 unlock_ufs(sb); 1299 1296 return -EINVAL; 1300 1297 } ··· 1303 1298 new_mount_opt |= ufstype; 1304 1299 } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { 1305 1300 pr_err("ufstype can't be changed during remount\n"); 1301 + mutex_unlock(&UFS_SB(sb)->s_lock); 1306 1302 unlock_ufs(sb); 1307 1303 return -EINVAL; 1308 1304 } 1309 1305 1310 1306 if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { 1311 1307 UFS_SB(sb)->s_mount_opt = new_mount_opt; 1308 + mutex_unlock(&UFS_SB(sb)->s_lock); 1312 1309 unlock_ufs(sb); 1313 1310 return 0; 1314 1311 } ··· 1334 1327 */ 1335 1328 #ifndef CONFIG_UFS_FS_WRITE 1336 1329 pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n"); 1330 + mutex_unlock(&UFS_SB(sb)->s_lock); 1337 1331 unlock_ufs(sb); 1338 1332 return -EINVAL; 1339 1333 #else ··· 1344 1336 ufstype != UFS_MOUNT_UFSTYPE_SUNx86 && 1345 1337 ufstype != UFS_MOUNT_UFSTYPE_UFS2) { 1346 1338 pr_err("this ufstype is read-only supported\n"); 1339 + mutex_unlock(&UFS_SB(sb)->s_lock); 1347 1340 unlock_ufs(sb); 1348 1341 return -EINVAL; 1349 1342 } 1350 1343 if (!ufs_read_cylinder_structures(sb)) { 1351 1344 pr_err("failed during remounting\n"); 1345 + mutex_unlock(&UFS_SB(sb)->s_lock); 1352 1346 unlock_ufs(sb); 1353 1347 return -EPERM; 1354 1348 } ··· 1358 1348 #endif 1359 1349 } 1360 1350 UFS_SB(sb)->s_mount_opt = new_mount_opt; 1351 + mutex_unlock(&UFS_SB(sb)->s_lock); 1361 1352 unlock_ufs(sb); 1362 1353 return 0; 1363 1354 }
+2 -1
fs/ufs/ufs.h
··· 30 30 int work_queued; /* non-zero if the delayed work is queued */ 31 31 struct delayed_work sync_work; /* FS sync delayed work */ 32 32 spinlock_t work_lock; /* protects sync_work and work_queued */ 33 + struct mutex s_lock; 33 34 }; 34 35 35 36 struct ufs_inode_info { ··· 106 105 extern int ufs_empty_dir (struct inode *); 107 106 extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); 108 107 extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, 109 - struct page *page, struct inode *inode); 108 + struct page *page, struct inode *inode, bool update_times); 110 109 111 110 /* file.c */ 112 111 extern const struct inode_operations ufs_file_inode_operations;
+10 -1
fs/xfs/xfs_file.c
··· 577 577 if (error) 578 578 return error; 579 579 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 + } 580 587 /* 581 588 * If the offset is beyond the size of the file, we need to zero any 582 589 * blocks that fall between the existing EOF and the start of this ··· 644 637 * setgid bits if the process is not being run by root. This keeps 645 638 * people from modifying setuid and setgid binaries. 646 639 */ 647 - return file_remove_suid(file); 640 + if (!IS_NOSEC(inode)) 641 + return file_remove_privs(file); 642 + return 0; 648 643 } 649 644 650 645 /*
+7
include/linux/dcache.h
··· 160 160 char *(*d_dname)(struct dentry *, char *, int); 161 161 struct vfsmount *(*d_automount)(struct path *); 162 162 int (*d_manage)(struct dentry *, bool); 163 + struct inode *(*d_select_inode)(struct dentry *, unsigned); 163 164 } ____cacheline_aligned; 164 165 165 166 /* ··· 226 225 227 226 #define DCACHE_MAY_FREE 0x00800000 228 227 #define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */ 228 + #define DCACHE_OP_SELECT_INODE 0x02000000 /* Unioned entry: dcache op selects inode */ 229 229 230 230 extern seqlock_t rename_lock; 231 231 ··· 505 503 static inline bool d_really_is_positive(const struct dentry *dentry) 506 504 { 507 505 return dentry->d_inode != NULL; 506 + } 507 + 508 + static inline int simple_positive(struct dentry *dentry) 509 + { 510 + return d_really_is_positive(dentry) && !d_unhashed(dentry); 508 511 } 509 512 510 513 extern void d_set_fallthru(struct dentry *dentry);
+3
include/linux/fdtable.h
··· 47 47 * read mostly part 48 48 */ 49 49 atomic_t count; 50 + bool resize_in_progress; 51 + wait_queue_head_t resize_wait; 52 + 50 53 struct fdtable __rcu *fdt; 51 54 struct fdtable fdtab; 52 55 /*
+8 -3
include/linux/fs.h
··· 1654 1654 int (*set_acl)(struct inode *, struct posix_acl *, int); 1655 1655 1656 1656 /* WARNING: probably going away soon, do not use! */ 1657 - int (*dentry_open)(struct dentry *, struct file *, const struct cred *); 1658 1657 } ____cacheline_aligned; 1659 1658 1660 1659 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, ··· 2212 2213 extern struct file *filp_open(const char *, int, umode_t); 2213 2214 extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2214 2215 const char *, int); 2215 - extern int vfs_open(const struct path *, struct file *, const struct cred *); 2216 2216 extern struct file * dentry_open(const struct path *, int, const struct cred *); 2217 2217 extern int filp_close(struct file *, fl_owner_t id); 2218 2218 ··· 2528 2530 extern int is_subdir(struct dentry *, struct dentry *); 2529 2531 extern int path_is_under(struct path *, struct path *); 2530 2532 2533 + extern char *file_path(struct file *, char *, int); 2534 + 2531 2535 #include <linux/err.h> 2532 2536 2533 2537 /* needed for stackable file system support */ ··· 2581 2581 extern struct inode *new_inode(struct super_block *sb); 2582 2582 extern void free_inode_nonrcu(struct inode *inode); 2583 2583 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 + } 2585 2590 2586 2591 extern void __insert_inode_hash(struct inode *, unsigned long hashval); 2587 2592 static inline void insert_inode_hash(struct inode *inode)
+27 -28
include/linux/fscache-cache.h
··· 74 74 */ 75 75 typedef void (*fscache_operation_release_t)(struct fscache_operation *op); 76 76 typedef void (*fscache_operation_processor_t)(struct fscache_operation *op); 77 + typedef void (*fscache_operation_cancel_t)(struct fscache_operation *op); 77 78 78 79 enum fscache_operation_state { 79 80 FSCACHE_OP_ST_BLANK, /* Op is not yet submitted */ ··· 110 109 * the op in a non-pool thread */ 111 110 fscache_operation_processor_t processor; 112 111 112 + /* Operation cancellation cleanup (optional) */ 113 + fscache_operation_cancel_t cancel; 114 + 113 115 /* operation releaser */ 114 116 fscache_operation_release_t release; 115 117 }; ··· 123 119 extern void fscache_enqueue_operation(struct fscache_operation *); 124 120 extern void fscache_op_complete(struct fscache_operation *, bool); 125 121 extern void fscache_put_operation(struct fscache_operation *); 126 - 127 - /** 128 - * fscache_operation_init - Do basic initialisation of an operation 129 - * @op: The operation to initialise 130 - * @release: The release function to assign 131 - * 132 - * Do basic initialisation of an operation. The caller must still set flags, 133 - * object and processor if needed. 134 - */ 135 - static inline void fscache_operation_init(struct fscache_operation *op, 136 - fscache_operation_processor_t processor, 137 - fscache_operation_release_t release) 138 - { 139 - INIT_WORK(&op->work, fscache_op_work_func); 140 - atomic_set(&op->usage, 1); 141 - op->state = FSCACHE_OP_ST_INITIALISED; 142 - op->debug_id = atomic_inc_return(&fscache_op_debug_id); 143 - op->processor = processor; 144 - op->release = release; 145 - INIT_LIST_HEAD(&op->pend_link); 146 - } 122 + extern void fscache_operation_init(struct fscache_operation *, 123 + fscache_operation_processor_t, 124 + fscache_operation_cancel_t, 125 + fscache_operation_release_t); 147 126 148 127 /* 149 128 * data read operation 150 129 */ 151 130 struct fscache_retrieval { 152 131 struct fscache_operation op; 132 + struct fscache_cookie *cookie; /* The netfs cookie */ 153 133 struct address_space *mapping; /* netfs pages */ 154 134 fscache_rw_complete_t end_io_func; /* function to call on I/O completion */ 155 135 void *context; /* netfs read context (pinned) */ ··· 359 371 #define FSCACHE_OBJECT_IS_LOOKED_UP 4 /* T if object has been looked up */ 360 372 #define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */ 361 373 #define FSCACHE_OBJECT_RETIRED 6 /* T if object was retired on relinquishment */ 374 + #define FSCACHE_OBJECT_KILLED_BY_CACHE 7 /* T if object was killed by the cache */ 362 375 363 376 struct list_head cache_link; /* link in cache->object_list */ 364 377 struct hlist_node cookie_link; /* link in cookie->backing_objects */ ··· 399 410 return test_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags); 400 411 } 401 412 413 + static inline bool fscache_cache_is_broken(struct fscache_object *object) 414 + { 415 + return test_bit(FSCACHE_IOERROR, &object->cache->flags); 416 + } 417 + 402 418 static inline bool fscache_object_is_active(struct fscache_object *object) 403 419 { 404 420 return fscache_object_is_available(object) && 405 421 fscache_object_is_live(object) && 406 - !test_bit(FSCACHE_IOERROR, &object->cache->flags); 407 - } 408 - 409 - static inline bool fscache_object_is_dead(struct fscache_object *object) 410 - { 411 - return fscache_object_is_dying(object) && 412 - test_bit(FSCACHE_IOERROR, &object->cache->flags); 422 + !fscache_cache_is_broken(object); 413 423 } 414 424 415 425 /** ··· 538 550 extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object, 539 551 const void *data, 540 552 uint16_t datalen); 553 + 554 + extern void fscache_object_retrying_stale(struct fscache_object *object); 555 + 556 + enum fscache_why_object_killed { 557 + FSCACHE_OBJECT_IS_STALE, 558 + FSCACHE_OBJECT_NO_SPACE, 559 + FSCACHE_OBJECT_WAS_RETIRED, 560 + FSCACHE_OBJECT_WAS_CULLED, 561 + }; 562 + extern void fscache_object_mark_killed(struct fscache_object *object, 563 + enum fscache_why_object_killed why); 541 564 542 565 #endif /* _LINUX_FSCACHE_CACHE_H */
+6
include/linux/pagemap.h
··· 671 671 return error; 672 672 } 673 673 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 + 674 680 #endif /* _LINUX_PAGEMAP_H */
+1
include/linux/seq_file.h
··· 123 123 __printf(2, 0) int seq_vprintf(struct seq_file *, const char *, va_list args); 124 124 125 125 int seq_path(struct seq_file *, const struct path *, const char *); 126 + int seq_file_path(struct seq_file *, struct file *, const char *); 126 127 int seq_dentry(struct seq_file *, struct dentry *, const char *); 127 128 int seq_path_root(struct seq_file *m, const struct path *path, 128 129 const struct path *root, const char *esc);
+1 -1
kernel/events/core.c
··· 5794 5794 * need to add enough zero bytes after the string to handle 5795 5795 * the 64bit alignment we do later. 5796 5796 */ 5797 - name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64)); 5797 + name = file_path(file, buf, PATH_MAX - sizeof(u64)); 5798 5798 if (IS_ERR(name)) { 5799 5799 name = "//toolong"; 5800 5800 goto cpy_name;
+1 -1
mm/filemap.c
··· 2563 2563 2564 2564 /* We can write back this queue in page reclaim */ 2565 2565 current->backing_dev_info = inode_to_bdi(inode); 2566 - err = file_remove_suid(file); 2566 + err = file_remove_privs(file); 2567 2567 if (err) 2568 2568 goto out; 2569 2569
+1 -1
mm/memory.c
··· 3726 3726 if (buf) { 3727 3727 char *p; 3728 3728 3729 - p = d_path(&f->f_path, buf, PAGE_SIZE); 3729 + p = file_path(f, buf, PAGE_SIZE); 3730 3730 if (IS_ERR(p)) 3731 3731 p = "?"; 3732 3732 printk("%s%s[%lx+%lx]", prefix, kbasename(p),
+1 -1
mm/swapfile.c
··· 2032 2032 } 2033 2033 2034 2034 file = si->swap_file; 2035 - len = seq_path(swap, &file->f_path, " \t\n\\"); 2035 + len = seq_file_path(swap, file, " \t\n\\"); 2036 2036 seq_printf(swap, "%*s%s\t%u\t%u\t%d\n", 2037 2037 len < 40 ? 40 - len : 1, " ", 2038 2038 S_ISBLK(file_inode(file)->i_mode) ?
+11 -1
net/9p/client.c
··· 843 843 if (err < 0) { 844 844 if (err == -EIO) 845 845 c->status = Disconnected; 846 - goto reterr; 846 + if (err != -ERESTARTSYS) 847 + goto reterr; 847 848 } 848 849 if (req->status == REQ_STATUS_ERROR) { 849 850 p9_debug(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err); ··· 1583 1582 p9_free_req(clnt, req); 1584 1583 break; 1585 1584 } 1585 + if (rsize < count) { 1586 + pr_err("bogus RREAD count (%d > %d)\n", count, rsize); 1587 + count = rsize; 1588 + } 1586 1589 1587 1590 p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count); 1588 1591 if (!count) { ··· 1652 1647 if (*err) { 1653 1648 trace_9p_protocol_dump(clnt, req->rc); 1654 1649 p9_free_req(clnt, req); 1650 + break; 1651 + } 1652 + if (rsize < count) { 1653 + pr_err("bogus RWRITE count (%d > %d)\n", count, rsize); 1654 + count = rsize; 1655 1655 } 1656 1656 1657 1657 p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);
+6 -13
security/inode.c
··· 25 25 static struct vfsmount *mount; 26 26 static int mount_count; 27 27 28 - static inline int positive(struct dentry *dentry) 29 - { 30 - return d_really_is_positive(dentry) && !d_unhashed(dentry); 31 - } 32 - 33 28 static int fill_super(struct super_block *sb, void *data, int silent) 34 29 { 35 30 static struct tree_descr files[] = {{""}}; ··· 196 201 return; 197 202 198 203 mutex_lock(&d_inode(parent)->i_mutex); 199 - if (positive(dentry)) { 200 - if (d_really_is_positive(dentry)) { 201 - if (d_is_dir(dentry)) 202 - simple_rmdir(d_inode(parent), dentry); 203 - else 204 - simple_unlink(d_inode(parent), dentry); 205 - dput(dentry); 206 - } 204 + if (simple_positive(dentry)) { 205 + if (d_is_dir(dentry)) 206 + simple_rmdir(d_inode(parent), dentry); 207 + else 208 + simple_unlink(d_inode(parent), dentry); 209 + dput(dentry); 207 210 } 208 211 mutex_unlock(&d_inode(parent)->i_mutex); 209 212 simple_release_fs(&mount, &mount_count);