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:
autofs4: clean ->d_release() and autofs4_free_ino() up
autofs4: split autofs4_init_ino()
autofs4: mkdir and symlink always get a dentry that had passed lookup
autofs4: autofs4_get_inode() doesn't need autofs_info * argument anymore
autofs4: kill ->size in autofs_info
autofs4: pass mode to autofs4_get_inode() explicitly
autofs4: autofs4_mkroot() is not different from autofs4_init_ino()
autofs4: keep symlink body in inode->i_private
autofs4 - fix debug print in autofs4_lookup()
vfs - fix dentry ref count in do_lookup()
autofs4 - fix get_next_positive_dentry()

+66 -121
+3 -11
fs/autofs4/autofs_i.h
··· 88 88 89 89 uid_t uid; 90 90 gid_t gid; 91 - 92 - mode_t mode; 93 - size_t size; 94 - 95 - void (*free)(struct autofs_info *); 96 - union { 97 - const char *symlink; 98 - } u; 99 91 }; 100 92 101 93 #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ ··· 167 175 return 0; 168 176 } 169 177 170 - struct inode *autofs4_get_inode(struct super_block *, struct autofs_info *); 178 + struct inode *autofs4_get_inode(struct super_block *, mode_t); 171 179 void autofs4_free_ino(struct autofs_info *); 172 180 173 181 /* Expiration */ ··· 277 285 /* Initializing function */ 278 286 279 287 int autofs4_fill_super(struct super_block *, void *, int); 280 - struct autofs_info *autofs4_init_ino(struct autofs_info *, struct autofs_sb_info *sbi, mode_t mode); 288 + struct autofs_info *autofs4_new_ino(struct autofs_sb_info *); 289 + void autofs4_clean_ino(struct autofs_info *); 281 290 282 291 /* Queue management functions */ 283 292 ··· 338 345 return; 339 346 } 340 347 341 - void autofs4_dentry_release(struct dentry *); 342 348 extern void autofs4_kill_sb(struct super_block *);
+2 -2
fs/autofs4/expire.c
··· 96 96 struct dentry *p, *ret; 97 97 98 98 if (prev == NULL) 99 - return dget(prev); 99 + return dget(root); 100 100 101 101 spin_lock(&autofs4_lock); 102 102 relock: ··· 133 133 spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); 134 134 /* Negative dentry - try next */ 135 135 if (!simple_positive(ret)) { 136 - spin_unlock(&ret->d_lock); 136 + spin_unlock(&p->d_lock); 137 137 p = ret; 138 138 goto again; 139 139 }
+22 -66
fs/autofs4/inode.c
··· 22 22 #include "autofs_i.h" 23 23 #include <linux/module.h> 24 24 25 - static void ino_lnkfree(struct autofs_info *ino) 25 + struct autofs_info *autofs4_new_ino(struct autofs_sb_info *sbi) 26 26 { 27 - if (ino->u.symlink) { 28 - kfree(ino->u.symlink); 29 - ino->u.symlink = NULL; 27 + struct autofs_info *ino = kzalloc(sizeof(*ino), GFP_KERNEL); 28 + if (ino) { 29 + INIT_LIST_HEAD(&ino->active); 30 + INIT_LIST_HEAD(&ino->expiring); 31 + ino->last_used = jiffies; 32 + ino->sbi = sbi; 30 33 } 34 + return ino; 31 35 } 32 36 33 - struct autofs_info *autofs4_init_ino(struct autofs_info *ino, 34 - struct autofs_sb_info *sbi, mode_t mode) 37 + void autofs4_clean_ino(struct autofs_info *ino) 35 38 { 36 - int reinit = 1; 37 - 38 - if (ino == NULL) { 39 - reinit = 0; 40 - ino = kmalloc(sizeof(*ino), GFP_KERNEL); 41 - } 42 - 43 - if (ino == NULL) 44 - return NULL; 45 - 46 - if (!reinit) { 47 - ino->flags = 0; 48 - ino->dentry = NULL; 49 - ino->size = 0; 50 - INIT_LIST_HEAD(&ino->active); 51 - ino->active_count = 0; 52 - INIT_LIST_HEAD(&ino->expiring); 53 - atomic_set(&ino->count, 0); 54 - } 55 - 56 39 ino->uid = 0; 57 40 ino->gid = 0; 58 - ino->mode = mode; 59 41 ino->last_used = jiffies; 60 - 61 - ino->sbi = sbi; 62 - 63 - if (reinit && ino->free) 64 - (ino->free)(ino); 65 - 66 - memset(&ino->u, 0, sizeof(ino->u)); 67 - 68 - ino->free = NULL; 69 - 70 - if (S_ISLNK(mode)) 71 - ino->free = ino_lnkfree; 72 - 73 - return ino; 74 42 } 75 43 76 44 void autofs4_free_ino(struct autofs_info *ino) 77 45 { 78 - if (ino->dentry) { 79 - ino->dentry->d_fsdata = NULL; 80 - ino->dentry = NULL; 81 - } 82 - if (ino->free) 83 - (ino->free)(ino); 84 46 kfree(ino); 85 47 } 86 48 ··· 98 136 return 0; 99 137 } 100 138 139 + static void autofs4_evict_inode(struct inode *inode) 140 + { 141 + end_writeback(inode); 142 + kfree(inode->i_private); 143 + } 144 + 101 145 static const struct super_operations autofs4_sops = { 102 146 .statfs = simple_statfs, 103 147 .show_options = autofs4_show_options, 148 + .evict_inode = autofs4_evict_inode, 104 149 }; 105 150 106 151 enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto, ··· 197 228 return (*pipefd < 0); 198 229 } 199 230 200 - static struct autofs_info *autofs4_mkroot(struct autofs_sb_info *sbi) 201 - { 202 - struct autofs_info *ino; 203 - 204 - ino = autofs4_init_ino(NULL, sbi, S_IFDIR | 0755); 205 - if (!ino) 206 - return NULL; 207 - 208 - return ino; 209 - } 210 - 211 231 int autofs4_fill_super(struct super_block *s, void *data, int silent) 212 232 { 213 233 struct inode * root_inode; ··· 240 282 /* 241 283 * Get the root inode and dentry, but defer checking for errors. 242 284 */ 243 - ino = autofs4_mkroot(sbi); 285 + ino = autofs4_new_ino(sbi); 244 286 if (!ino) 245 287 goto fail_free; 246 - root_inode = autofs4_get_inode(s, ino); 288 + root_inode = autofs4_get_inode(s, S_IFDIR | 0755); 247 289 if (!root_inode) 248 290 goto fail_ino; 249 291 ··· 326 368 return -EINVAL; 327 369 } 328 370 329 - struct inode *autofs4_get_inode(struct super_block *sb, 330 - struct autofs_info *inf) 371 + struct inode *autofs4_get_inode(struct super_block *sb, mode_t mode) 331 372 { 332 373 struct inode *inode = new_inode(sb); 333 374 334 375 if (inode == NULL) 335 376 return NULL; 336 377 337 - inode->i_mode = inf->mode; 378 + inode->i_mode = mode; 338 379 if (sb->s_root) { 339 380 inode->i_uid = sb->s_root->d_inode->i_uid; 340 381 inode->i_gid = sb->s_root->d_inode->i_gid; ··· 341 384 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 342 385 inode->i_ino = get_next_ino(); 343 386 344 - if (S_ISDIR(inf->mode)) { 387 + if (S_ISDIR(mode)) { 345 388 inode->i_nlink = 2; 346 389 inode->i_op = &autofs4_dir_inode_operations; 347 390 inode->i_fop = &autofs4_dir_operations; 348 - } else if (S_ISLNK(inf->mode)) { 349 - inode->i_size = inf->size; 391 + } else if (S_ISLNK(mode)) { 350 392 inode->i_op = &autofs4_symlink_inode_operations; 351 393 } 352 394
+35 -39
fs/autofs4/root.c
··· 37 37 static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); 38 38 static struct vfsmount *autofs4_d_automount(struct path *); 39 39 static int autofs4_d_manage(struct dentry *, bool, bool); 40 + static void autofs4_dentry_release(struct dentry *); 40 41 41 42 const struct file_operations autofs4_root_operations = { 42 43 .open = dcache_dir_open, ··· 139 138 return dcache_dir_open(inode, file); 140 139 } 141 140 142 - void autofs4_dentry_release(struct dentry *de) 141 + static void autofs4_dentry_release(struct dentry *de) 143 142 { 144 - struct autofs_info *inf; 143 + struct autofs_info *ino = autofs4_dentry_ino(de); 144 + struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb); 145 145 146 146 DPRINTK("releasing %p", de); 147 147 148 - inf = autofs4_dentry_ino(de); 149 - if (inf) { 150 - struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb); 151 - if (sbi) { 152 - spin_lock(&sbi->lookup_lock); 153 - if (!list_empty(&inf->active)) 154 - list_del(&inf->active); 155 - if (!list_empty(&inf->expiring)) 156 - list_del(&inf->expiring); 157 - spin_unlock(&sbi->lookup_lock); 158 - } 159 - autofs4_free_ino(inf); 148 + if (!ino) 149 + return; 150 + 151 + if (sbi) { 152 + spin_lock(&sbi->lookup_lock); 153 + if (!list_empty(&ino->active)) 154 + list_del(&ino->active); 155 + if (!list_empty(&ino->expiring)) 156 + list_del(&ino->expiring); 157 + spin_unlock(&sbi->lookup_lock); 160 158 } 159 + 160 + autofs4_free_ino(ino); 161 161 } 162 162 163 163 static struct dentry *autofs4_lookup_active(struct dentry *dentry) ··· 490 488 sbi = autofs4_sbi(dir->i_sb); 491 489 492 490 DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", 493 - current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); 491 + current->pid, task_pgrp_nr(current), sbi->catatonic, 492 + autofs4_oz_mode(sbi)); 494 493 495 494 active = autofs4_lookup_active(dentry); 496 495 if (active) { ··· 510 507 if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent)) 511 508 __managed_dentry_set_managed(dentry); 512 509 513 - ino = autofs4_init_ino(NULL, sbi, 0555); 510 + ino = autofs4_new_ino(sbi); 514 511 if (!ino) 515 512 return ERR_PTR(-ENOMEM); 516 513 ··· 532 529 struct autofs_info *ino = autofs4_dentry_ino(dentry); 533 530 struct autofs_info *p_ino; 534 531 struct inode *inode; 532 + size_t size = strlen(symname); 535 533 char *cp; 536 534 537 535 DPRINTK("%s <- %.*s", symname, ··· 541 537 if (!autofs4_oz_mode(sbi)) 542 538 return -EACCES; 543 539 544 - ino = autofs4_init_ino(ino, sbi, S_IFLNK | 0555); 545 - if (!ino) 546 - return -ENOMEM; 540 + BUG_ON(!ino); 541 + 542 + autofs4_clean_ino(ino); 547 543 548 544 autofs4_del_active(dentry); 549 545 550 - ino->size = strlen(symname); 551 - cp = kmalloc(ino->size + 1, GFP_KERNEL); 552 - if (!cp) { 553 - if (!dentry->d_fsdata) 554 - kfree(ino); 546 + cp = kmalloc(size + 1, GFP_KERNEL); 547 + if (!cp) 555 548 return -ENOMEM; 556 - } 557 549 558 550 strcpy(cp, symname); 559 551 560 - inode = autofs4_get_inode(dir->i_sb, ino); 552 + inode = autofs4_get_inode(dir->i_sb, S_IFLNK | 0555); 561 553 if (!inode) { 562 554 kfree(cp); 563 555 if (!dentry->d_fsdata) 564 556 kfree(ino); 565 557 return -ENOMEM; 566 558 } 559 + inode->i_private = cp; 560 + inode->i_size = size; 567 561 d_add(dentry, inode); 568 562 569 - dentry->d_fsdata = ino; 570 - ino->dentry = dget(dentry); 563 + dget(dentry); 571 564 atomic_inc(&ino->count); 572 565 p_ino = autofs4_dentry_ino(dentry->d_parent); 573 566 if (p_ino && dentry->d_parent != dentry) 574 567 atomic_inc(&p_ino->count); 575 568 576 - ino->u.symlink = cp; 577 569 dir->i_mtime = CURRENT_TIME; 578 570 579 571 return 0; ··· 732 732 DPRINTK("dentry %p, creating %.*s", 733 733 dentry, dentry->d_name.len, dentry->d_name.name); 734 734 735 - ino = autofs4_init_ino(ino, sbi, S_IFDIR | 0555); 736 - if (!ino) 737 - return -ENOMEM; 735 + BUG_ON(!ino); 736 + 737 + autofs4_clean_ino(ino); 738 738 739 739 autofs4_del_active(dentry); 740 740 741 - inode = autofs4_get_inode(dir->i_sb, ino); 742 - if (!inode) { 743 - if (!dentry->d_fsdata) 744 - kfree(ino); 741 + inode = autofs4_get_inode(dir->i_sb, S_IFDIR | 0555); 742 + if (!inode) 745 743 return -ENOMEM; 746 - } 747 744 d_add(dentry, inode); 748 745 749 746 if (sbi->version < 5) 750 747 autofs_set_leaf_automount_flags(dentry); 751 748 752 - dentry->d_fsdata = ino; 753 - ino->dentry = dget(dentry); 749 + dget(dentry); 754 750 atomic_inc(&ino->count); 755 751 p_ino = autofs4_dentry_ino(dentry->d_parent); 756 752 if (p_ino && dentry->d_parent != dentry)
+1 -2
fs/autofs4/symlink.c
··· 14 14 15 15 static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) 16 16 { 17 - struct autofs_info *ino = autofs4_dentry_ino(dentry); 18 - nd_set_link(nd, (char *)ino->u.symlink); 17 + nd_set_link(nd, dentry->d_inode->i_private); 19 18 return NULL; 20 19 } 21 20
+3 -1
fs/namei.c
··· 1272 1272 path->mnt = mnt; 1273 1273 path->dentry = dentry; 1274 1274 err = follow_managed(path, nd->flags); 1275 - if (unlikely(err < 0)) 1275 + if (unlikely(err < 0)) { 1276 + path_put_conditional(path, nd); 1276 1277 return err; 1278 + } 1277 1279 *inode = path->dentry->d_inode; 1278 1280 return 0; 1279 1281