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

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (36 commits)
Cache xattr security drop check for write v2
fs: block_page_mkwrite should wait for writeback to finish
mm: Wait for writeback when grabbing pages to begin a write
configfs: remove unnecessary dentry_unhash on rmdir, dir rename
fat: remove unnecessary dentry_unhash on rmdir, dir rename
hpfs: remove unnecessary dentry_unhash on rmdir, dir rename
minix: remove unnecessary dentry_unhash on rmdir, dir rename
fuse: remove unnecessary dentry_unhash on rmdir, dir rename
coda: remove unnecessary dentry_unhash on rmdir, dir rename
afs: remove unnecessary dentry_unhash on rmdir, dir rename
affs: remove unnecessary dentry_unhash on rmdir, dir rename
9p: remove unnecessary dentry_unhash on rmdir, dir rename
ncpfs: fix rename over directory with dangling references
ncpfs: document dentry_unhash usage
ecryptfs: remove unnecessary dentry_unhash on rmdir, dir rename
hostfs: remove unnecessary dentry_unhash on rmdir, dir rename
hfsplus: remove unnecessary dentry_unhash on rmdir, dir rename
hfs: remove unnecessary dentry_unhash on rmdir, dir rename
omfs: remove unnecessary dentry_unhash on rmdir, dir rneame
udf: remove unnecessary dentry_unhash from rmdir, dir rename
...

+127 -235
+2 -2
Documentation/filesystems/Locking
··· 104 104 prototypes: 105 105 struct inode *(*alloc_inode)(struct super_block *sb); 106 106 void (*destroy_inode)(struct inode *); 107 - void (*dirty_inode) (struct inode *); 107 + void (*dirty_inode) (struct inode *, int flags); 108 108 int (*write_inode) (struct inode *, struct writeback_control *wbc); 109 109 int (*drop_inode) (struct inode *); 110 110 void (*evict_inode) (struct inode *); ··· 126 126 s_umount 127 127 alloc_inode: 128 128 destroy_inode: 129 - dirty_inode: (must not sleep) 129 + dirty_inode: 130 130 write_inode: 131 131 drop_inode: !!!inode->i_lock!!! 132 132 evict_inode:
+1 -1
Documentation/filesystems/vfs.txt
··· 211 211 struct inode *(*alloc_inode)(struct super_block *sb); 212 212 void (*destroy_inode)(struct inode *); 213 213 214 - void (*dirty_inode) (struct inode *); 214 + void (*dirty_inode) (struct inode *, int flags); 215 215 int (*write_inode) (struct inode *, int); 216 216 void (*drop_inode) (struct inode *); 217 217 void (*delete_inode) (struct inode *);
-4
fs/9p/vfs_inode.c
··· 814 814 815 815 int v9fs_vfs_rmdir(struct inode *i, struct dentry *d) 816 816 { 817 - dentry_unhash(d); 818 817 return v9fs_remove(i, d, 1); 819 818 } 820 819 ··· 838 839 struct p9_fid *olddirfid; 839 840 struct p9_fid *newdirfid; 840 841 struct p9_wstat wstat; 841 - 842 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 843 - dentry_unhash(new_dentry); 844 842 845 843 P9_DPRINTK(P9_DEBUG_VFS, "\n"); 846 844 retval = 0;
-5
fs/affs/namei.c
··· 320 320 dentry->d_inode->i_ino, 321 321 (int)dentry->d_name.len, dentry->d_name.name); 322 322 323 - dentry_unhash(dentry); 324 - 325 323 return affs_remove_header(dentry); 326 324 } 327 325 ··· 416 418 struct super_block *sb = old_dir->i_sb; 417 419 struct buffer_head *bh = NULL; 418 420 int retval; 419 - 420 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 421 - dentry_unhash(new_dentry); 422 421 423 422 pr_debug("AFFS: rename(old=%u,\"%*s\" to new=%u,\"%*s\")\n", 424 423 (u32)old_dir->i_ino, (int)old_dentry->d_name.len, old_dentry->d_name.name,
-5
fs/afs/dir.c
··· 845 845 _enter("{%x:%u},{%s}", 846 846 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); 847 847 848 - dentry_unhash(dentry); 849 - 850 848 ret = -ENAMETOOLONG; 851 849 if (dentry->d_name.len >= AFSNAMEMAX) 852 850 goto error; ··· 1145 1147 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode; 1146 1148 struct key *key; 1147 1149 int ret; 1148 - 1149 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 1150 - dentry_unhash(new_dentry); 1151 1150 1152 1151 vnode = AFS_FS_I(old_dentry->d_inode); 1153 1152 orig_dvnode = AFS_FS_I(old_dir);
+7
fs/attr.c
··· 175 175 return -EPERM; 176 176 } 177 177 178 + if ((ia_valid & ATTR_MODE)) { 179 + mode_t amode = attr->ia_mode; 180 + /* Flag setting protected by i_mutex */ 181 + if (is_sxid(amode)) 182 + inode->i_flags &= ~S_NOSEC; 183 + } 184 + 178 185 now = current_fs_time(inode->i_sb); 179 186 180 187 attr->ia_ctime = now;
-3
fs/bfs/dir.c
··· 224 224 struct bfs_sb_info *info; 225 225 int error = -ENOENT; 226 226 227 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 228 - dentry_unhash(new_dentry); 229 - 230 227 old_bh = new_bh = NULL; 231 228 old_inode = old_dentry->d_inode; 232 229 if (S_ISDIR(old_inode->i_mode))
+8 -8
fs/bio.c
··· 638 638 * @offset: vec entry offset 639 639 * 640 640 * Attempt to add a page to the bio_vec maplist. This can fail for a 641 - * number of reasons, such as the bio being full or target block 642 - * device limitations. The target block device must allow bio's 643 - * smaller than PAGE_SIZE, so it is always possible to add a single 644 - * page to an empty bio. This should only be used by REQ_PC bios. 641 + * number of reasons, such as the bio being full or target block device 642 + * limitations. The target block device must allow bio's up to PAGE_SIZE, 643 + * so it is always possible to add a single page to an empty bio. 644 + * 645 + * This should only be used by REQ_PC bios. 645 646 */ 646 647 int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page *page, 647 648 unsigned int len, unsigned int offset) ··· 660 659 * @offset: vec entry offset 661 660 * 662 661 * Attempt to add a page to the bio_vec maplist. This can fail for a 663 - * number of reasons, such as the bio being full or target block 664 - * device limitations. The target block device must allow bio's 665 - * smaller than PAGE_SIZE, so it is always possible to add a single 666 - * page to an empty bio. 662 + * number of reasons, such as the bio being full or target block device 663 + * limitations. The target block device must allow bio's up to PAGE_SIZE, 664 + * so it is always possible to add a single page to an empty bio. 667 665 */ 668 666 int bio_add_page(struct bio *bio, struct page *page, unsigned int len, 669 667 unsigned int offset)
+1 -1
fs/btrfs/ctree.h
··· 2524 2524 int btrfs_readpage(struct file *file, struct page *page); 2525 2525 void btrfs_evict_inode(struct inode *inode); 2526 2526 int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); 2527 - void btrfs_dirty_inode(struct inode *inode); 2527 + void btrfs_dirty_inode(struct inode *inode, int flags); 2528 2528 struct inode *btrfs_alloc_inode(struct super_block *sb); 2529 2529 void btrfs_destroy_inode(struct inode *inode); 2530 2530 int btrfs_drop_inode(struct inode *inode);
+1 -1
fs/btrfs/inode.c
··· 4294 4294 * FIXME, needs more benchmarking...there are no reasons other than performance 4295 4295 * to keep or drop this code. 4296 4296 */ 4297 - void btrfs_dirty_inode(struct inode *inode) 4297 + void btrfs_dirty_inode(struct inode *inode, int flags) 4298 4298 { 4299 4299 struct btrfs_root *root = BTRFS_I(inode)->root; 4300 4300 struct btrfs_trans_handle *trans;
+1
fs/buffer.c
··· 2382 2382 ret = -EAGAIN; 2383 2383 goto out_unlock; 2384 2384 } 2385 + wait_on_page_writeback(page); 2385 2386 return 0; 2386 2387 out_unlock: 2387 2388 unlock_page(page);
-5
fs/coda/dir.c
··· 336 336 int len = de->d_name.len; 337 337 int error; 338 338 339 - dentry_unhash(de); 340 - 341 339 error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len); 342 340 if (!error) { 343 341 /* VFS may delete the child */ ··· 358 360 int old_length = old_dentry->d_name.len; 359 361 int new_length = new_dentry->d_name.len; 360 362 int error; 361 - 362 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 363 - dentry_unhash(new_dentry); 364 363 365 364 error = venus_rename(old_dir->i_sb, coda_i2f(old_dir), 366 365 coda_i2f(new_dir), old_length, new_length,
-2
fs/configfs/dir.c
··· 1359 1359 struct module *subsys_owner = NULL, *dead_item_owner = NULL; 1360 1360 int ret; 1361 1361 1362 - dentry_unhash(dentry); 1363 - 1364 1362 if (dentry->d_parent == configfs_sb->s_root) 1365 1363 return -EPERM; 1366 1364
-5
fs/ecryptfs/inode.c
··· 521 521 struct dentry *lower_dir_dentry; 522 522 int rc; 523 523 524 - dentry_unhash(dentry); 525 - 526 524 lower_dentry = ecryptfs_dentry_to_lower(dentry); 527 525 dget(dentry); 528 526 lower_dir_dentry = lock_parent(lower_dentry); ··· 572 574 struct dentry *lower_old_dir_dentry; 573 575 struct dentry *lower_new_dir_dentry; 574 576 struct dentry *trap = NULL; 575 - 576 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 577 - dentry_unhash(new_dentry); 578 577 579 578 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry); 580 579 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
+1 -1
fs/ext3/inode.c
··· 3392 3392 * so would cause a commit on atime updates, which we don't bother doing. 3393 3393 * We handle synchronous inodes at the highest possible level. 3394 3394 */ 3395 - void ext3_dirty_inode(struct inode *inode) 3395 + void ext3_dirty_inode(struct inode *inode, int flags) 3396 3396 { 3397 3397 handle_t *current_handle = ext3_journal_current_handle(); 3398 3398 handle_t *handle;
+1 -1
fs/ext4/ext4.h
··· 1813 1813 extern void ext4_evict_inode(struct inode *); 1814 1814 extern void ext4_clear_inode(struct inode *); 1815 1815 extern int ext4_sync_inode(handle_t *, struct inode *); 1816 - extern void ext4_dirty_inode(struct inode *); 1816 + extern void ext4_dirty_inode(struct inode *, int); 1817 1817 extern int ext4_change_inode_journal_flag(struct inode *, int); 1818 1818 extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); 1819 1819 extern int ext4_can_truncate(struct inode *inode);
+1 -1
fs/ext4/inode.c
··· 5733 5733 * so would cause a commit on atime updates, which we don't bother doing. 5734 5734 * We handle synchronous inodes at the highest possible level. 5735 5735 */ 5736 - void ext4_dirty_inode(struct inode *inode) 5736 + void ext4_dirty_inode(struct inode *inode, int flags) 5737 5737 { 5738 5738 handle_t *handle; 5739 5739
-5
fs/fat/namei_msdos.c
··· 326 326 struct fat_slot_info sinfo; 327 327 int err; 328 328 329 - dentry_unhash(dentry); 330 - 331 329 lock_super(sb); 332 330 /* 333 331 * Check whether the directory is not in use, then check ··· 456 458 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; 457 459 old_inode = old_dentry->d_inode; 458 460 new_inode = new_dentry->d_inode; 459 - 460 - if (new_inode && S_ISDIR(new_inode->i_mode)) 461 - dentry_unhash(new_dentry); 462 461 463 462 err = fat_scan(old_dir, old_name, &old_sinfo); 464 463 if (err) {
-5
fs/fat/namei_vfat.c
··· 824 824 struct fat_slot_info sinfo; 825 825 int err; 826 826 827 - dentry_unhash(dentry); 828 - 829 827 lock_super(sb); 830 828 831 829 err = fat_dir_empty(inode); ··· 930 932 loff_t dotdot_i_pos, new_i_pos; 931 933 int err, is_dir, update_dotdot, corrupt = 0; 932 934 struct super_block *sb = old_dir->i_sb; 933 - 934 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 935 - dentry_unhash(new_dentry); 936 935 937 936 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; 938 937 old_inode = old_dentry->d_inode;
+1 -4
fs/fs-writeback.c
··· 1007 1007 * In short, make sure you hash any inodes _before_ you start marking 1008 1008 * them dirty. 1009 1009 * 1010 - * This function *must* be atomic for the I_DIRTY_PAGES case - 1011 - * set_page_dirty() is called under spinlock in several places. 1012 - * 1013 1010 * Note that for blockdevs, inode->dirtied_when represents the dirtying time of 1014 1011 * the block-special inode (/dev/hda1) itself. And the ->dirtied_when field of 1015 1012 * the kernel-internal blockdev inode represents the dirtying time of the ··· 1025 1028 */ 1026 1029 if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) { 1027 1030 if (sb->s_op->dirty_inode) 1028 - sb->s_op->dirty_inode(inode); 1031 + sb->s_op->dirty_inode(inode, flags); 1029 1032 } 1030 1033 1031 1034 /*
-5
fs/fuse/dir.c
··· 667 667 if (IS_ERR(req)) 668 668 return PTR_ERR(req); 669 669 670 - dentry_unhash(entry); 671 - 672 670 req->in.h.opcode = FUSE_RMDIR; 673 671 req->in.h.nodeid = get_node_id(dir); 674 672 req->in.numargs = 1; ··· 691 693 struct fuse_rename_in inarg; 692 694 struct fuse_conn *fc = get_fuse_conn(olddir); 693 695 struct fuse_req *req = fuse_get_req(fc); 694 - 695 - if (newent->d_inode && S_ISDIR(newent->d_inode->i_mode)) 696 - dentry_unhash(newent); 697 696 698 697 if (IS_ERR(req)) 699 698 return PTR_ERR(req);
-6
fs/hfs/dir.c
··· 253 253 struct inode *inode = dentry->d_inode; 254 254 int res; 255 255 256 - if (S_ISDIR(inode->i_mode)) 257 - dentry_unhash(dentry); 258 - 259 256 if (S_ISDIR(inode->i_mode) && inode->i_size != 2) 260 257 return -ENOTEMPTY; 261 258 res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); ··· 283 286 284 287 /* Unlink destination if it already exists */ 285 288 if (new_dentry->d_inode) { 286 - if (S_ISDIR(new_dentry->d_inode->i_mode)) 287 - dentry_unhash(new_dentry); 288 - 289 289 res = hfs_remove(new_dir, new_dentry); 290 290 if (res) 291 291 return res;
+2 -6
fs/hfsplus/dir.c
··· 370 370 struct inode *inode = dentry->d_inode; 371 371 int res; 372 372 373 - dentry_unhash(dentry); 374 - 375 373 if (inode->i_size != 2) 376 374 return -ENOTEMPTY; 377 375 ··· 467 469 468 470 /* Unlink destination if it already exists */ 469 471 if (new_dentry->d_inode) { 470 - if (S_ISDIR(new_dentry->d_inode->i_mode)) { 471 - dentry_unhash(new_dentry); 472 + if (S_ISDIR(new_dentry->d_inode->i_mode)) 472 473 res = hfsplus_rmdir(new_dir, new_dentry); 473 - } else { 474 + else 474 475 res = hfsplus_unlink(new_dir, new_dentry); 475 - } 476 476 if (res) 477 477 return res; 478 478 }
-5
fs/hostfs/hostfs_kern.c
··· 683 683 char *file; 684 684 int err; 685 685 686 - dentry_unhash(dentry); 687 - 688 686 if ((file = dentry_name(dentry)) == NULL) 689 687 return -ENOMEM; 690 688 err = do_rmdir(file); ··· 735 737 { 736 738 char *from_name, *to_name; 737 739 int err; 738 - 739 - if (to->d_inode && S_ISDIR(to->d_inode->i_mode)) 740 - dentry_unhash(to); 741 740 742 741 if ((from_name = dentry_name(from)) == NULL) 743 742 return -ENOMEM;
-5
fs/hpfs/namei.c
··· 439 439 int err; 440 440 int r; 441 441 442 - dentry_unhash(dentry); 443 - 444 442 hpfs_adjust_length(name, &len); 445 443 hpfs_lock(dir->i_sb); 446 444 err = -ENOENT; ··· 532 534 struct buffer_head *bh; 533 535 struct fnode *fnode; 534 536 int err; 535 - 536 - if (new_inode && S_ISDIR(new_inode->i_mode)) 537 - dentry_unhash(new_dentry); 538 537 539 538 if ((err = hpfs_chk_name(new_name, &new_len))) return err; 540 539 err = 0;
+5 -49
fs/inode.c
··· 1 1 /* 2 - * linux/fs/inode.c 3 - * 4 2 * (C) 1997 Linus Torvalds 3 + * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation) 5 4 */ 6 - 7 5 #include <linux/fs.h> 8 6 #include <linux/mm.h> 9 7 #include <linux/dcache.h> ··· 25 27 #include <linux/prefetch.h> 26 28 #include <linux/ima.h> 27 29 #include <linux/cred.h> 30 + #include <linux/buffer_head.h> /* for inode_has_buffers */ 28 31 #include "internal.h" 29 32 30 33 /* 31 - * inode locking rules. 34 + * Inode locking rules: 32 35 * 33 36 * inode->i_lock protects: 34 37 * inode->i_state, inode->i_hash, __iget() ··· 59 60 * inode_hash_lock 60 61 */ 61 62 62 - /* 63 - * This is needed for the following functions: 64 - * - inode_has_buffers 65 - * - invalidate_bdev 66 - * 67 - * FIXME: remove all knowledge of the buffer layer from this file 68 - */ 69 - #include <linux/buffer_head.h> 70 - 71 - /* 72 - * New inode.c implementation. 73 - * 74 - * This implementation has the basic premise of trying 75 - * to be extremely low-overhead and SMP-safe, yet be 76 - * simple enough to be "obviously correct". 77 - * 78 - * Famous last words. 79 - */ 80 - 81 - /* inode dynamic allocation 1999, Andrea Arcangeli <andrea@suse.de> */ 82 - 83 - /* #define INODE_PARANOIA 1 */ 84 - /* #define INODE_DEBUG 1 */ 85 - 86 - /* 87 - * Inode lookup is no longer as critical as it used to be: 88 - * most of the lookups are going to be through the dcache. 89 - */ 90 - #define I_HASHBITS i_hash_shift 91 - #define I_HASHMASK i_hash_mask 92 - 93 63 static unsigned int i_hash_mask __read_mostly; 94 64 static unsigned int i_hash_shift __read_mostly; 95 65 static struct hlist_head *inode_hashtable __read_mostly; 96 66 static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); 97 - 98 - /* 99 - * Each inode can be on two separate lists. One is 100 - * the hash list of the inode, used for lookups. The 101 - * other linked list is the "type" list: 102 - * "in_use" - valid inode, i_count > 0, i_nlink > 0 103 - * "dirty" - as "in_use" but also dirty 104 - * "unused" - valid inode, i_count = 0 105 - * 106 - * A "dirty" list is maintained for each super block, 107 - * allowing for low-overhead inode sync() operations. 108 - */ 109 67 110 68 static LIST_HEAD(inode_lru); 111 69 static DEFINE_SPINLOCK(inode_lru_lock); ··· 380 424 381 425 tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) / 382 426 L1_CACHE_BYTES; 383 - tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> I_HASHBITS); 384 - return tmp & I_HASHMASK; 427 + tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> i_hash_shift); 428 + return tmp & i_hash_mask; 385 429 } 386 430 387 431 /**
-5
fs/jffs2/dir.c
··· 605 605 int ret; 606 606 uint32_t now = get_seconds(); 607 607 608 - dentry_unhash(dentry); 609 - 610 608 for (fd = f->dents ; fd; fd = fd->next) { 611 609 if (fd->ino) 612 610 return -ENOTEMPTY; ··· 779 781 struct jffs2_inode_info *victim_f = NULL; 780 782 uint8_t type; 781 783 uint32_t now; 782 - 783 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 784 - dentry_unhash(new_dentry); 785 784 786 785 /* The VFS will check for us and prevent trying to rename a 787 786 * file over a directory and vice versa, but if it's a directory,
+1 -1
fs/jffs2/fs.c
··· 357 357 return ERR_PTR(ret); 358 358 } 359 359 360 - void jffs2_dirty_inode(struct inode *inode) 360 + void jffs2_dirty_inode(struct inode *inode, int flags) 361 361 { 362 362 struct iattr iattr; 363 363
+1 -1
fs/jffs2/os-linux.h
··· 172 172 int jffs2_do_setattr (struct inode *, struct iattr *); 173 173 struct inode *jffs2_iget(struct super_block *, unsigned long); 174 174 void jffs2_evict_inode (struct inode *); 175 - void jffs2_dirty_inode(struct inode *inode); 175 + void jffs2_dirty_inode(struct inode *inode, int flags); 176 176 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 177 177 struct jffs2_raw_inode *ri); 178 178 int jffs2_statfs (struct dentry *, struct kstatfs *);
+1 -1
fs/jfs/inode.c
··· 173 173 dquot_drop(inode); 174 174 } 175 175 176 - void jfs_dirty_inode(struct inode *inode) 176 + void jfs_dirty_inode(struct inode *inode, int flags) 177 177 { 178 178 static int noisy = 5; 179 179
+1 -1
fs/jfs/jfs_inode.h
··· 28 28 extern int jfs_commit_inode(struct inode *, int); 29 29 extern int jfs_write_inode(struct inode *, struct writeback_control *); 30 30 extern void jfs_evict_inode(struct inode *); 31 - extern void jfs_dirty_inode(struct inode *); 31 + extern void jfs_dirty_inode(struct inode *, int); 32 32 extern void jfs_truncate(struct inode *); 33 33 extern void jfs_truncate_nolock(struct inode *, loff_t); 34 34 extern void jfs_free_zero_link(struct inode *);
-5
fs/jfs/namei.c
··· 360 360 361 361 jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); 362 362 363 - dentry_unhash(dentry); 364 - 365 363 /* Init inode for quota operations. */ 366 364 dquot_initialize(dip); 367 365 dquot_initialize(ip); ··· 1094 1096 1095 1097 jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, 1096 1098 new_dentry->d_name.name); 1097 - 1098 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 1099 - dentry_unhash(new_dentry); 1100 1099 1101 1100 dquot_initialize(old_dir); 1102 1101 dquot_initialize(new_dir);
-5
fs/logfs/dir.c
··· 273 273 { 274 274 struct inode *inode = dentry->d_inode; 275 275 276 - dentry_unhash(dentry); 277 - 278 276 if (!logfs_empty_dir(inode)) 279 277 return -ENOTEMPTY; 280 278 ··· 621 623 struct logfs_transaction *ta; 622 624 loff_t pos; 623 625 int err; 624 - 625 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 626 - dentry_unhash(new_dentry); 627 626 628 627 /* 1. locate source dd */ 629 628 err = logfs_get_dd(old_dir, old_dentry, &dd, &pos);
-5
fs/minix/namei.c
··· 168 168 struct inode * inode = dentry->d_inode; 169 169 int err = -ENOTEMPTY; 170 170 171 - dentry_unhash(dentry); 172 - 173 171 if (minix_empty_dir(inode)) { 174 172 err = minix_unlink(dir, dentry); 175 173 if (!err) { ··· 189 191 struct page * old_page; 190 192 struct minix_dir_entry * old_de; 191 193 int err = -ENOENT; 192 - 193 - if (new_inode && S_ISDIR(new_inode->i_mode)) 194 - dentry_unhash(new_dentry); 195 194 196 195 old_de = minix_find_entry(old_dentry, &old_page); 197 196 if (!old_de)
+24 -17
fs/namei.c
··· 919 919 } 920 920 921 921 /* 922 - * Skip to top of mountpoint pile in rcuwalk mode. We abort the rcu-walk if we 923 - * meet a managed dentry and we're not walking to "..". True is returned to 924 - * continue, false to abort. 922 + * Try to skip to top of mountpoint pile in rcuwalk mode. Fail if 923 + * we meet a managed dentry that would need blocking. 925 924 */ 926 925 static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, 927 - struct inode **inode, bool reverse_transit) 926 + struct inode **inode) 928 927 { 929 928 for (;;) { 930 929 struct vfsmount *mounted; ··· 932 933 * that wants to block transit. 933 934 */ 934 935 *inode = path->dentry->d_inode; 935 - if (!reverse_transit && 936 - unlikely(managed_dentry_might_block(path->dentry))) 936 + if (unlikely(managed_dentry_might_block(path->dentry))) 937 937 return false; 938 938 939 939 if (!d_mountpoint(path->dentry)) ··· 945 947 path->dentry = mounted->mnt_root; 946 948 nd->seq = read_seqcount_begin(&path->dentry->d_seq); 947 949 } 948 - 949 - if (unlikely(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT)) 950 - return reverse_transit; 951 950 return true; 951 + } 952 + 953 + static void follow_mount_rcu(struct nameidata *nd) 954 + { 955 + while (d_mountpoint(nd->path.dentry)) { 956 + struct vfsmount *mounted; 957 + mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry, 1); 958 + if (!mounted) 959 + break; 960 + nd->path.mnt = mounted; 961 + nd->path.dentry = mounted->mnt_root; 962 + nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); 963 + } 952 964 } 953 965 954 966 static int follow_dotdot_rcu(struct nameidata *nd) 955 967 { 956 - struct inode *inode = nd->inode; 957 - 958 968 set_root_rcu(nd); 959 969 960 970 while (1) { ··· 978 972 seq = read_seqcount_begin(&parent->d_seq); 979 973 if (read_seqcount_retry(&old->d_seq, nd->seq)) 980 974 goto failed; 981 - inode = parent->d_inode; 982 975 nd->path.dentry = parent; 983 976 nd->seq = seq; 984 977 break; ··· 985 980 if (!follow_up_rcu(&nd->path)) 986 981 break; 987 982 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); 988 - inode = nd->path.dentry->d_inode; 989 983 } 990 - __follow_mount_rcu(nd, &nd->path, &inode, true); 991 - nd->inode = inode; 984 + follow_mount_rcu(nd); 985 + nd->inode = nd->path.dentry->d_inode; 992 986 return 0; 993 987 994 988 failed: ··· 1161 1157 } 1162 1158 path->mnt = mnt; 1163 1159 path->dentry = dentry; 1164 - if (likely(__follow_mount_rcu(nd, path, inode, false))) 1165 - return 0; 1160 + if (unlikely(!__follow_mount_rcu(nd, path, inode))) 1161 + goto unlazy; 1162 + if (unlikely(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT)) 1163 + goto unlazy; 1164 + return 0; 1166 1165 unlazy: 1167 1166 if (unlazy_walk(nd, dentry)) 1168 1167 return -ECHILD;
+13 -2
fs/ncpfs/dir.c
··· 1033 1033 DPRINTK("ncp_rmdir: removing %s/%s\n", 1034 1034 dentry->d_parent->d_name.name, dentry->d_name.name); 1035 1035 1036 + /* 1037 + * fail with EBUSY if there are still references to this 1038 + * directory. 1039 + */ 1036 1040 dentry_unhash(dentry); 1037 - 1038 1041 error = -EBUSY; 1039 1042 if (!d_unhashed(dentry)) 1040 1043 goto out; ··· 1144 1141 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1145 1142 new_dentry->d_parent->d_name.name, new_dentry->d_name.name); 1146 1143 1147 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 1144 + if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) { 1145 + /* 1146 + * fail with EBUSY if there are still references to this 1147 + * directory. 1148 + */ 1148 1149 dentry_unhash(new_dentry); 1150 + error = -EBUSY; 1151 + if (!d_unhashed(new_dentry)) 1152 + goto out; 1153 + } 1149 1154 1150 1155 ncp_age_dentry(server, old_dentry); 1151 1156 ncp_age_dentry(server, new_dentry);
+1 -1
fs/nilfs2/inode.c
··· 917 917 * construction. This function can be called both as a single operation 918 918 * and as a part of indivisible file operations. 919 919 */ 920 - void nilfs_dirty_inode(struct inode *inode) 920 + void nilfs_dirty_inode(struct inode *inode, int flags) 921 921 { 922 922 struct nilfs_transaction_info ti; 923 923 struct nilfs_mdt_info *mdi = NILFS_MDT(inode);
-5
fs/nilfs2/namei.c
··· 334 334 struct nilfs_transaction_info ti; 335 335 int err; 336 336 337 - dentry_unhash(dentry); 338 - 339 337 err = nilfs_transaction_begin(dir->i_sb, &ti, 0); 340 338 if (err) 341 339 return err; ··· 368 370 struct nilfs_dir_entry *old_de; 369 371 struct nilfs_transaction_info ti; 370 372 int err; 371 - 372 - if (new_inode && S_ISDIR(new_inode->i_mode)) 373 - dentry_unhash(new_dentry); 374 373 375 374 err = nilfs_transaction_begin(old_dir->i_sb, &ti, 1); 376 375 if (unlikely(err))
+1 -1
fs/nilfs2/nilfs.h
··· 269 269 extern int nilfs_inode_dirty(struct inode *); 270 270 int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty); 271 271 extern int nilfs_mark_inode_dirty(struct inode *); 272 - extern void nilfs_dirty_inode(struct inode *); 272 + extern void nilfs_dirty_inode(struct inode *, int flags); 273 273 int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 274 274 __u64 start, __u64 len); 275 275
+3 -8
fs/omfs/dir.c
··· 241 241 int ret; 242 242 243 243 244 - if (S_ISDIR(inode->i_mode)) { 245 - dentry_unhash(dentry); 246 - if (!omfs_dir_is_empty(inode)) 247 - return -ENOTEMPTY; 248 - } 244 + if (S_ISDIR(inode->i_mode) && 245 + !omfs_dir_is_empty(inode)) 246 + return -ENOTEMPTY; 249 247 250 248 ret = omfs_delete_entry(dentry); 251 249 if (ret) ··· 380 382 int err; 381 383 382 384 if (new_inode) { 383 - if (S_ISDIR(new_inode->i_mode)) 384 - dentry_unhash(new_dentry); 385 - 386 385 /* overwriting existing file/dir */ 387 386 err = omfs_remove(new_dir, new_dentry); 388 387 if (err)
-5
fs/reiserfs/namei.c
··· 831 831 INITIALIZE_PATH(path); 832 832 struct reiserfs_dir_entry de; 833 833 834 - dentry_unhash(dentry); 835 - 836 834 /* we will be doing 2 balancings and update 2 stat data, we change quotas 837 835 * of the owner of the directory and of the owner of the parent directory. 838 836 * The quota structure is possibly deleted only on last iput => outside ··· 1224 1226 umode_t old_inode_mode; 1225 1227 unsigned long savelink = 1; 1226 1228 struct timespec ctime; 1227 - 1228 - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) 1229 - dentry_unhash(new_dentry); 1230 1229 1231 1230 /* three balancings: (1) old name removal, (2) new name insertion 1232 1231 and (3) maybe "save" link insertion
+1 -1
fs/reiserfs/super.c
··· 568 568 } 569 569 570 570 /* we don't mark inodes dirty, we just log them */ 571 - static void reiserfs_dirty_inode(struct inode *inode) 571 + static void reiserfs_dirty_inode(struct inode *inode, int flags) 572 572 { 573 573 struct reiserfs_transaction_handle th; 574 574
-1
fs/reiserfs/xattr.c
··· 98 98 99 99 reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, 100 100 I_MUTEX_CHILD, dir->i_sb); 101 - dentry_unhash(dentry); 102 101 error = dir->i_op->rmdir(dir, dentry); 103 102 if (!error) 104 103 dentry->d_inode->i_flags |= S_DEAD;
-5
fs/sysv/namei.c
··· 196 196 struct inode *inode = dentry->d_inode; 197 197 int err = -ENOTEMPTY; 198 198 199 - dentry_unhash(dentry); 200 - 201 199 if (sysv_empty_dir(inode)) { 202 200 err = sysv_unlink(dir, dentry); 203 201 if (!err) { ··· 221 223 struct page * old_page; 222 224 struct sysv_dir_entry * old_de; 223 225 int err = -ENOENT; 224 - 225 - if (new_inode && S_ISDIR(new_inode->i_mode)) 226 - dentry_unhash(new_dentry); 227 226 228 227 old_de = sysv_find_entry(old_dentry, &old_page); 229 228 if (!old_de)
-5
fs/ubifs/dir.c
··· 656 656 struct ubifs_inode *dir_ui = ubifs_inode(dir); 657 657 struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 }; 658 658 659 - dentry_unhash(dentry); 660 - 661 659 /* 662 660 * Budget request settings: deletion direntry, deletion inode and 663 661 * changing the parent inode. If budgeting fails, go ahead anyway ··· 975 977 struct ubifs_budget_req ino_req = { .dirtied_ino = 1, 976 978 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) }; 977 979 struct timespec time; 978 - 979 - if (new_inode && S_ISDIR(new_inode->i_mode)) 980 - dentry_unhash(new_dentry); 981 980 982 981 /* 983 982 * Budget request settings: deletion direntry, new direntry, removing
+1 -1
fs/ubifs/super.c
··· 382 382 end_writeback(inode); 383 383 } 384 384 385 - static void ubifs_dirty_inode(struct inode *inode) 385 + static void ubifs_dirty_inode(struct inode *inode, int flags) 386 386 { 387 387 struct ubifs_inode *ui = ubifs_inode(inode); 388 388
-5
fs/udf/namei.c
··· 783 783 struct fileIdentDesc *fi, cfi; 784 784 struct kernel_lb_addr tloc; 785 785 786 - dentry_unhash(dentry); 787 - 788 786 retval = -ENOENT; 789 787 fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); 790 788 if (!fi) ··· 1080 1082 int retval = -ENOENT; 1081 1083 struct kernel_lb_addr tloc; 1082 1084 struct udf_inode_info *old_iinfo = UDF_I(old_inode); 1083 - 1084 - if (new_inode && S_ISDIR(new_inode->i_mode)) 1085 - dentry_unhash(new_dentry); 1086 1085 1087 1086 ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi); 1088 1087 if (ofi) {
-5
fs/ufs/namei.c
··· 258 258 struct inode * inode = dentry->d_inode; 259 259 int err= -ENOTEMPTY; 260 260 261 - dentry_unhash(dentry); 262 - 263 261 lock_ufs(dir->i_sb); 264 262 if (ufs_empty_dir (inode)) { 265 263 err = ufs_unlink(dir, dentry); ··· 281 283 struct page *old_page; 282 284 struct ufs_dir_entry *old_de; 283 285 int err = -ENOENT; 284 - 285 - if (new_inode && S_ISDIR(new_inode->i_mode)) 286 - dentry_unhash(new_dentry); 287 286 288 287 old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page); 289 288 if (!old_de)
+15 -8
fs/xattr.c
··· 46 46 return 0; 47 47 48 48 /* 49 - * The trusted.* namespace can only be accessed by a privileged user. 49 + * The trusted.* namespace can only be accessed by privileged users. 50 50 */ 51 - if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) 52 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM); 51 + if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) { 52 + if (!capable(CAP_SYS_ADMIN)) 53 + return (mask & MAY_WRITE) ? -EPERM : -ENODATA; 54 + return 0; 55 + } 53 56 54 - /* In user.* namespace, only regular files and directories can have 57 + /* 58 + * In the user.* namespace, only regular files and directories can have 55 59 * extended attributes. For sticky directories, only the owner and 56 - * privileged user can write attributes. 60 + * privileged users can write attributes. 57 61 */ 58 62 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) { 59 63 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) 60 - return -EPERM; 64 + return (mask & MAY_WRITE) ? -EPERM : -ENODATA; 61 65 if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) && 62 66 (mask & MAY_WRITE) && !inode_owner_or_capable(inode)) 63 67 return -EPERM; ··· 91 87 { 92 88 struct inode *inode = dentry->d_inode; 93 89 int error = -EOPNOTSUPP; 90 + int issec = !strncmp(name, XATTR_SECURITY_PREFIX, 91 + XATTR_SECURITY_PREFIX_LEN); 94 92 93 + if (issec) 94 + inode->i_flags &= ~S_NOSEC; 95 95 if (inode->i_op->setxattr) { 96 96 error = inode->i_op->setxattr(dentry, name, value, size, flags); 97 97 if (!error) { ··· 103 95 security_inode_post_setxattr(dentry, name, value, 104 96 size, flags); 105 97 } 106 - } else if (!strncmp(name, XATTR_SECURITY_PREFIX, 107 - XATTR_SECURITY_PREFIX_LEN)) { 98 + } else if (issec) { 108 99 const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; 109 100 error = security_inode_setsecurity(inode, suffix, value, 110 101 size, flags);
+2 -1
fs/xfs/linux-2.6/xfs_super.c
··· 925 925 */ 926 926 STATIC void 927 927 xfs_fs_dirty_inode( 928 - struct inode *inode) 928 + struct inode *inode, 929 + int flags) 929 930 { 930 931 barrier(); 931 932 XFS_I(inode)->i_update_core = 1;
+1 -1
include/linux/ext3_fs.h
··· 909 909 extern void ext3_evict_inode (struct inode *); 910 910 extern int ext3_sync_inode (handle_t *, struct inode *); 911 911 extern void ext3_discard_reservation (struct inode *); 912 - extern void ext3_dirty_inode(struct inode *); 912 + extern void ext3_dirty_inode(struct inode *, int); 913 913 extern int ext3_change_inode_journal_flag(struct inode *, int); 914 914 extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *); 915 915 extern int ext3_can_truncate(struct inode *inode);
+14 -1
include/linux/fs.h
··· 237 237 #define S_PRIVATE 512 /* Inode is fs-internal */ 238 238 #define S_IMA 1024 /* Inode has an associated IMA struct */ 239 239 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ 240 + #define S_NOSEC 4096 /* no suid or xattr security attributes */ 240 241 241 242 /* 242 243 * Note that nosuid etc flags are inode-specific: setting some file-system ··· 274 273 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) 275 274 #define IS_IMA(inode) ((inode)->i_flags & S_IMA) 276 275 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) 276 + #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) 277 277 278 278 /* the read-only stuff doesn't really belong here, but any other place is 279 279 probably as bad and I don't want to create yet another include file. */ ··· 1620 1618 struct inode *(*alloc_inode)(struct super_block *sb); 1621 1619 void (*destroy_inode)(struct inode *); 1622 1620 1623 - void (*dirty_inode) (struct inode *); 1621 + void (*dirty_inode) (struct inode *, int flags); 1624 1622 int (*write_inode) (struct inode *, struct writeback_control *wbc); 1625 1623 int (*drop_inode) (struct inode *); 1626 1624 void (*evict_inode) (struct inode *); ··· 2583 2581 #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) 2584 2582 #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ 2585 2583 (flag & __FMODE_NONOTIFY))) 2584 + 2585 + static inline int is_sxid(mode_t mode) 2586 + { 2587 + return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP)); 2588 + } 2589 + 2590 + static inline void inode_has_no_xattr(struct inode *inode) 2591 + { 2592 + if (!is_sxid(inode->i_mode)) 2593 + inode->i_flags |= S_NOSEC; 2594 + } 2586 2595 2587 2596 #endif /* __KERNEL__ */ 2588 2597 #endif /* _LINUX_FS_H */
+15 -3
mm/filemap.c
··· 1982 1982 int file_remove_suid(struct file *file) 1983 1983 { 1984 1984 struct dentry *dentry = file->f_path.dentry; 1985 - int killsuid = should_remove_suid(dentry); 1986 - int killpriv = security_inode_need_killpriv(dentry); 1985 + struct inode *inode = dentry->d_inode; 1986 + int killsuid; 1987 + int killpriv; 1987 1988 int error = 0; 1989 + 1990 + /* Fast path for nothing security related */ 1991 + if (IS_NOSEC(inode)) 1992 + return 0; 1993 + 1994 + killsuid = should_remove_suid(dentry); 1995 + killpriv = security_inode_need_killpriv(dentry); 1988 1996 1989 1997 if (killpriv < 0) 1990 1998 return killpriv; ··· 2000 1992 error = security_inode_killpriv(dentry); 2001 1993 if (!error && killsuid) 2002 1994 error = __remove_suid(dentry, killsuid); 1995 + if (!error) 1996 + inode->i_flags |= S_NOSEC; 2003 1997 2004 1998 return error; 2005 1999 } ··· 2337 2327 repeat: 2338 2328 page = find_lock_page(mapping, index); 2339 2329 if (page) 2340 - return page; 2330 + goto found; 2341 2331 2342 2332 page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask); 2343 2333 if (!page) ··· 2350 2340 goto repeat; 2351 2341 return NULL; 2352 2342 } 2343 + found: 2344 + wait_on_page_writeback(page); 2353 2345 return page; 2354 2346 } 2355 2347 EXPORT_SYMBOL(grab_cache_page_write_begin);