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

[PATCH] switch all filesystems over to d_obtain_alias

Switch all users of d_alloc_anon to d_obtain_alias.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Christoph Hellwig and committed by
Al Viro
44003728 4ea3ada2

+78 -305
+5 -5
fs/dcache.c
··· 1187 1187 * allocating a new one. 1188 1188 * 1189 1189 * On successful return, the reference to the inode has been transferred 1190 - * to the dentry. If %NULL is returned (indicating kmalloc failure), 1191 - * the reference on the inode has been released. To make it easier 1192 - * to use in export operations a NULL or IS_ERR inode may be passed in 1193 - * and will be casted to the corresponding NULL or IS_ERR dentry. 1190 + * to the dentry. In case of an error the reference on the inode is released. 1191 + * To make it easier to use in export operations a %NULL or IS_ERR inode may 1192 + * be passed in and will be the error will be propagate to the return value, 1193 + * with a %NULL @inode replaced by ERR_PTR(-ESTALE). 1194 1194 */ 1195 1195 struct dentry *d_obtain_alias(struct inode *inode) 1196 1196 { 1197 1197 struct dentry *dentry; 1198 1198 1199 1199 if (!inode) 1200 - return NULL; 1200 + return ERR_PTR(-ESTALE); 1201 1201 if (IS_ERR(inode)) 1202 1202 return ERR_CAST(inode); 1203 1203
+4 -25
fs/efs/namei.c
··· 112 112 113 113 struct dentry *efs_get_parent(struct dentry *child) 114 114 { 115 - struct dentry *parent; 116 - struct inode *inode; 115 + struct dentry *parent = ERR_PTR(-ENOENT); 117 116 efs_ino_t ino; 118 - long error; 119 117 120 118 lock_kernel(); 121 - 122 - error = -ENOENT; 123 119 ino = efs_find_entry(child->d_inode, "..", 2); 124 - if (!ino) 125 - goto fail; 126 - 127 - inode = efs_iget(child->d_inode->i_sb, ino); 128 - if (IS_ERR(inode)) { 129 - error = PTR_ERR(inode); 130 - goto fail; 131 - } 132 - 133 - error = -ENOMEM; 134 - parent = d_alloc_anon(inode); 135 - if (!parent) 136 - goto fail_iput; 137 - 120 + if (ino) 121 + parent = d_obtain_alias(efs_iget(child->d_inode->i_sb, ino)); 138 122 unlock_kernel(); 123 + 139 124 return parent; 140 - 141 - fail_iput: 142 - iput(inode); 143 - fail: 144 - unlock_kernel(); 145 - return ERR_PTR(error); 146 125 }
-4
fs/exportfs/expfs.c
··· 366 366 * Try to get any dentry for the given file handle from the filesystem. 367 367 */ 368 368 result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type); 369 - if (!result) 370 - result = ERR_PTR(-ESTALE); 371 369 if (IS_ERR(result)) 372 370 return result; 373 371 ··· 420 422 421 423 target_dir = nop->fh_to_parent(mnt->mnt_sb, fid, 422 424 fh_len, fileid_type); 423 - if (!target_dir) 424 - goto err_result; 425 425 err = PTR_ERR(target_dir); 426 426 if (IS_ERR(target_dir)) 427 427 goto err_result;
+1 -12
fs/ext2/namei.c
··· 73 73 struct dentry *ext2_get_parent(struct dentry *child) 74 74 { 75 75 unsigned long ino; 76 - struct dentry *parent; 77 - struct inode *inode; 78 76 struct dentry dotdot; 79 77 80 78 dotdot.d_name.name = ".."; ··· 81 83 ino = ext2_inode_by_name(child->d_inode, &dotdot); 82 84 if (!ino) 83 85 return ERR_PTR(-ENOENT); 84 - inode = ext2_iget(child->d_inode->i_sb, ino); 85 - 86 - if (IS_ERR(inode)) 87 - return ERR_CAST(inode); 88 - parent = d_alloc_anon(inode); 89 - if (!parent) { 90 - iput(inode); 91 - parent = ERR_PTR(-ENOMEM); 92 - } 93 - return parent; 86 + return d_obtain_alias(ext2_iget(child->d_inode->i_sb, ino)); 94 87 } 95 88 96 89 /*
+1 -13
fs/ext3/namei.c
··· 1057 1057 struct dentry *ext3_get_parent(struct dentry *child) 1058 1058 { 1059 1059 unsigned long ino; 1060 - struct dentry *parent; 1061 - struct inode *inode; 1062 1060 struct dentry dotdot; 1063 1061 struct ext3_dir_entry_2 * de; 1064 1062 struct buffer_head *bh; ··· 1066 1068 dotdot.d_parent = child; /* confusing, isn't it! */ 1067 1069 1068 1070 bh = ext3_find_entry(&dotdot, &de); 1069 - inode = NULL; 1070 1071 if (!bh) 1071 1072 return ERR_PTR(-ENOENT); 1072 1073 ino = le32_to_cpu(de->inode); ··· 1077 1080 return ERR_PTR(-EIO); 1078 1081 } 1079 1082 1080 - inode = ext3_iget(child->d_inode->i_sb, ino); 1081 - if (IS_ERR(inode)) 1082 - return ERR_CAST(inode); 1083 - 1084 - parent = d_alloc_anon(inode); 1085 - if (!parent) { 1086 - iput(inode); 1087 - parent = ERR_PTR(-ENOMEM); 1088 - } 1089 - return parent; 1083 + return d_obtain_alias(ext3_iget(child->d_inode->i_sb, ino)); 1090 1084 } 1091 1085 1092 1086 #define S_SHIFT 12
+1 -10
fs/ext4/namei.c
··· 1083 1083 return ERR_PTR(-EIO); 1084 1084 } 1085 1085 1086 - inode = ext4_iget(child->d_inode->i_sb, ino); 1087 - if (IS_ERR(inode)) 1088 - return ERR_CAST(inode); 1089 - 1090 - parent = d_alloc_anon(inode); 1091 - if (!parent) { 1092 - iput(inode); 1093 - parent = ERR_PTR(-ENOMEM); 1094 - } 1095 - return parent; 1086 + return d_obtain_alias(ext4_iget(child->d_inode->i_sb, ino)); 1096 1087 } 1097 1088 1098 1089 #define S_SHIFT 12
+18 -34
fs/fat/inode.c
··· 681 681 inode = NULL; 682 682 } 683 683 } 684 - if (!inode) { 685 - /* For now, do nothing 686 - * What we could do is: 687 - * follow the file starting at fh[4], and record 688 - * the ".." entry, and the name of the fh[2] entry. 689 - * The follow the ".." file finding the next step up. 690 - * This way we build a path to the root of 691 - * the tree. If this works, we lookup the path and so 692 - * get this inode into the cache. 693 - * Finally try the fat_iget lookup again 694 - * If that fails, then weare totally out of luck 695 - * But all that is for another day 696 - */ 697 - } 698 - if (!inode) 699 - return ERR_PTR(-ESTALE); 700 684 701 - 702 - /* now to find a dentry. 703 - * If possible, get a well-connected one 685 + /* 686 + * For now, do nothing if the inode is not found. 687 + * 688 + * What we could do is: 689 + * 690 + * - follow the file starting at fh[4], and record the ".." entry, 691 + * and the name of the fh[2] entry. 692 + * - then follow the ".." file finding the next step up. 693 + * 694 + * This way we build a path to the root of the tree. If this works, we 695 + * lookup the path and so get this inode into the cache. Finally try 696 + * the fat_iget lookup again. If that fails, then we are totally out 697 + * of luck. But all that is for another day 704 698 */ 705 - result = d_alloc_anon(inode); 706 - if (result == NULL) { 707 - iput(inode); 708 - return ERR_PTR(-ENOMEM); 709 - } 710 - result->d_op = sb->s_root->d_op; 699 + result = d_obtain_alias(inode); 700 + if (!IS_ERR(result)) 701 + result->d_op = sb->s_root->d_op; 711 702 return result; 712 703 } 713 704 ··· 745 754 } 746 755 inode = fat_build_inode(sb, de, i_pos); 747 756 brelse(bh); 748 - if (IS_ERR(inode)) { 749 - parent = ERR_CAST(inode); 750 - goto out; 751 - } 752 - parent = d_alloc_anon(inode); 753 - if (!parent) { 754 - iput(inode); 755 - parent = ERR_PTR(-ENOMEM); 756 - } 757 + 758 + parent = d_obtain_alias(inode); 757 759 out: 758 760 unlock_super(sb); 759 761
+8 -15
fs/fuse/inode.c
··· 596 596 if (inode->i_generation != handle->generation) 597 597 goto out_iput; 598 598 599 - entry = d_alloc_anon(inode); 600 - err = -ENOMEM; 601 - if (!entry) 602 - goto out_iput; 603 - 604 - if (get_node_id(inode) != FUSE_ROOT_ID) { 599 + entry = d_obtain_alias(inode); 600 + if (!IS_ERR(entry) && get_node_id(inode) != FUSE_ROOT_ID) { 605 601 entry->d_op = &fuse_dentry_operations; 606 602 fuse_invalidate_entry_cache(entry); 607 603 } ··· 692 696 name.name = ".."; 693 697 err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode), 694 698 &name, &outarg, &inode); 695 - if (err && err != -ENOENT) 699 + if (err) { 700 + if (err == -ENOENT) 701 + return ERR_PTR(-ESTALE); 696 702 return ERR_PTR(err); 697 - if (err || !inode) 698 - return ERR_PTR(-ESTALE); 699 - 700 - parent = d_alloc_anon(inode); 701 - if (!parent) { 702 - iput(inode); 703 - return ERR_PTR(-ENOMEM); 704 703 } 705 - if (get_node_id(inode) != FUSE_ROOT_ID) { 704 + 705 + parent = d_obtain_alias(inode); 706 + if (!IS_ERR(parent) && get_node_id(inode) != FUSE_ROOT_ID) { 706 707 parent->d_op = &fuse_dentry_operations; 707 708 fuse_invalidate_entry_cache(parent); 708 709 }
+9 -24
fs/gfs2/ops_export.c
··· 130 130 static struct dentry *gfs2_get_parent(struct dentry *child) 131 131 { 132 132 struct qstr dotdot; 133 - struct inode *inode; 134 133 struct dentry *dentry; 135 134 136 - gfs2_str2qstr(&dotdot, ".."); 137 - inode = gfs2_lookupi(child->d_inode, &dotdot, 1); 138 - 139 - if (!inode) 140 - return ERR_PTR(-ENOENT); 141 135 /* 142 - * In case of an error, @inode carries the error value, and we 143 - * have to return that as a(n invalid) pointer to dentry. 136 + * XXX(hch): it would be a good idea to keep this around as a 137 + * static variable. 144 138 */ 145 - if (IS_ERR(inode)) 146 - return ERR_CAST(inode); 139 + gfs2_str2qstr(&dotdot, ".."); 147 140 148 - dentry = d_alloc_anon(inode); 149 - if (!dentry) { 150 - iput(inode); 151 - return ERR_PTR(-ENOMEM); 152 - } 153 - 154 - dentry->d_op = &gfs2_dops; 141 + dentry = d_obtain_alias(gfs2_lookupi(child->d_inode, &dotdot, 1)); 142 + if (!IS_ERR(dentry)) 143 + dentry->d_op = &gfs2_dops; 155 144 return dentry; 156 145 } 157 146 ··· 222 233 gfs2_glock_dq_uninit(&i_gh); 223 234 224 235 out_inode: 225 - dentry = d_alloc_anon(inode); 226 - if (!dentry) { 227 - iput(inode); 228 - return ERR_PTR(-ENOMEM); 229 - } 230 - 231 - dentry->d_op = &gfs2_dops; 236 + dentry = d_obtain_alias(inode); 237 + if (!IS_ERR(dentry)) 238 + dentry->d_op = &gfs2_dops; 232 239 return dentry; 233 240 234 241 fail_rgd:
+5 -28
fs/isofs/export.c
··· 22 22 __u32 generation) 23 23 { 24 24 struct inode *inode; 25 - struct dentry *result; 25 + 26 26 if (block == 0) 27 27 return ERR_PTR(-ESTALE); 28 28 inode = isofs_iget(sb, block, offset); ··· 32 32 iput(inode); 33 33 return ERR_PTR(-ESTALE); 34 34 } 35 - result = d_alloc_anon(inode); 36 - if (!result) { 37 - iput(inode); 38 - return ERR_PTR(-ENOMEM); 39 - } 40 - return result; 35 + return d_obtain_alias(inode); 41 36 } 42 37 43 38 /* This function is surprisingly simple. The trick is understanding ··· 46 51 unsigned long parent_offset = 0; 47 52 struct inode *child_inode = child->d_inode; 48 53 struct iso_inode_info *e_child_inode = ISOFS_I(child_inode); 49 - struct inode *parent_inode = NULL; 50 54 struct iso_directory_record *de = NULL; 51 55 struct buffer_head * bh = NULL; 52 56 struct dentry *rv = NULL; ··· 98 104 /* Normalize */ 99 105 isofs_normalize_block_and_offset(de, &parent_block, &parent_offset); 100 106 101 - /* Get the inode. */ 102 - parent_inode = isofs_iget(child_inode->i_sb, 103 - parent_block, 104 - parent_offset); 105 - if (IS_ERR(parent_inode)) { 106 - rv = ERR_CAST(parent_inode); 107 - if (rv != ERR_PTR(-ENOMEM)) 108 - rv = ERR_PTR(-EACCES); 109 - goto out; 110 - } 111 - 112 - /* Allocate the dentry. */ 113 - rv = d_alloc_anon(parent_inode); 114 - if (rv == NULL) { 115 - rv = ERR_PTR(-ENOMEM); 116 - goto out; 117 - } 118 - 107 + rv = d_obtain_alias(isofs_iget(child_inode->i_sb, parent_block, 108 + parent_offset)); 119 109 out: 120 - if (bh) { 110 + if (bh) 121 111 brelse(bh); 122 - } 123 112 return rv; 124 113 } 125 114
+1 -14
fs/jfs/namei.c
··· 1511 1511 1512 1512 struct dentry *jfs_get_parent(struct dentry *dentry) 1513 1513 { 1514 - struct super_block *sb = dentry->d_inode->i_sb; 1515 - struct dentry *parent = ERR_PTR(-ENOENT); 1516 - struct inode *inode; 1517 1514 unsigned long parent_ino; 1518 1515 1519 1516 parent_ino = 1520 1517 le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot); 1521 - inode = jfs_iget(sb, parent_ino); 1522 - if (IS_ERR(inode)) { 1523 - parent = ERR_CAST(inode); 1524 - } else { 1525 - parent = d_alloc_anon(inode); 1526 - if (!parent) { 1527 - parent = ERR_PTR(-ENOMEM); 1528 - iput(inode); 1529 - } 1530 - } 1531 1518 1532 - return parent; 1519 + return d_obtain_alias(jfs_iget(dentry->d_inode->i_sb, parent_ino)); 1533 1520 } 1534 1521 1535 1522 const struct inode_operations jfs_dir_inode_operations = {
+6 -8
fs/nfs/getroot.c
··· 107 107 * if the dentry tree reaches them; however if the dentry already 108 108 * exists, we'll pick it up at this point and use it as the root 109 109 */ 110 - mntroot = d_alloc_anon(inode); 111 - if (!mntroot) { 112 - iput(inode); 110 + mntroot = d_obtain_alias(inode); 111 + if (IS_ERR(mntroot)) { 113 112 dprintk("nfs_get_root: get root dentry failed\n"); 114 - return ERR_PTR(-ENOMEM); 113 + return mntroot; 115 114 } 116 115 117 116 security_d_instantiate(mntroot, inode); ··· 276 277 * if the dentry tree reaches them; however if the dentry already 277 278 * exists, we'll pick it up at this point and use it as the root 278 279 */ 279 - mntroot = d_alloc_anon(inode); 280 - if (!mntroot) { 281 - iput(inode); 280 + mntroot = d_obtain_alias(inode); 281 + if (IS_ERR(mntroot)) { 282 282 dprintk("nfs_get_root: get root dentry failed\n"); 283 - return ERR_PTR(-ENOMEM); 283 + return mntroot; 284 284 } 285 285 286 286 security_d_instantiate(mntroot, inode);
+2 -20
fs/ntfs/namei.c
··· 304 304 ntfs_attr_search_ctx *ctx; 305 305 ATTR_RECORD *attr; 306 306 FILE_NAME_ATTR *fn; 307 - struct inode *parent_vi; 308 - struct dentry *parent_dent; 309 307 unsigned long parent_ino; 310 308 int err; 311 309 ··· 343 345 /* Release the search context and the mft record of the child. */ 344 346 ntfs_attr_put_search_ctx(ctx); 345 347 unmap_mft_record(ni); 346 - /* Get the inode of the parent directory. */ 347 - parent_vi = ntfs_iget(vi->i_sb, parent_ino); 348 - if (IS_ERR(parent_vi) || unlikely(is_bad_inode(parent_vi))) { 349 - if (!IS_ERR(parent_vi)) 350 - iput(parent_vi); 351 - ntfs_error(vi->i_sb, "Failed to get parent directory inode " 352 - "0x%lx of child inode 0x%lx.", parent_ino, 353 - vi->i_ino); 354 - return ERR_PTR(-EACCES); 355 - } 356 - /* Finally get a dentry for the parent directory and return it. */ 357 - parent_dent = d_alloc_anon(parent_vi); 358 - if (unlikely(!parent_dent)) { 359 - iput(parent_vi); 360 - return ERR_PTR(-ENOMEM); 361 - } 362 - ntfs_debug("Done for inode 0x%lx.", vi->i_ino); 363 - return parent_dent; 348 + 349 + return d_obtain_alias(ntfs_iget(vi->i_sb, parent_ino)); 364 350 } 365 351 366 352 static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
+6 -24
fs/ocfs2/export.c
··· 68 68 return ERR_PTR(-ESTALE); 69 69 } 70 70 71 - result = d_alloc_anon(inode); 72 - 73 - if (!result) { 74 - iput(inode); 75 - mlog_errno(-ENOMEM); 76 - return ERR_PTR(-ENOMEM); 77 - } 78 - result->d_op = &ocfs2_dentry_ops; 71 + result = d_obtain_alias(inode); 72 + if (!IS_ERR(result)) 73 + result->d_op = &ocfs2_dentry_ops; 79 74 80 75 mlog_exit_ptr(result); 81 76 return result; ··· 81 86 int status; 82 87 u64 blkno; 83 88 struct dentry *parent; 84 - struct inode *inode; 85 89 struct inode *dir = child->d_inode; 86 90 87 91 mlog_entry("(0x%p, '%.*s')\n", child, ··· 103 109 goto bail_unlock; 104 110 } 105 111 106 - inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0); 107 - if (IS_ERR(inode)) { 108 - mlog(ML_ERROR, "Unable to create inode %llu\n", 109 - (unsigned long long)blkno); 110 - parent = ERR_PTR(-EACCES); 111 - goto bail_unlock; 112 - } 113 - 114 - parent = d_alloc_anon(inode); 115 - if (!parent) { 116 - iput(inode); 117 - parent = ERR_PTR(-ENOMEM); 118 - } 119 - 120 - parent->d_op = &ocfs2_dentry_ops; 112 + parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0)); 113 + if (!IS_ERR(parent)) 114 + parent->d_op = &ocfs2_dentry_ops; 121 115 122 116 bail_unlock: 123 117 ocfs2_inode_unlock(dir, 0);
+2 -11
fs/reiserfs/inode.c
··· 1522 1522 1523 1523 { 1524 1524 struct cpu_key key; 1525 - struct dentry *result; 1526 1525 struct inode *inode; 1527 1526 1528 1527 key.on_disk_key.k_objectid = objectid; ··· 1534 1535 inode = NULL; 1535 1536 } 1536 1537 reiserfs_write_unlock(sb); 1537 - if (!inode) 1538 - inode = ERR_PTR(-ESTALE); 1539 - if (IS_ERR(inode)) 1540 - return ERR_CAST(inode); 1541 - result = d_alloc_anon(inode); 1542 - if (!result) { 1543 - iput(inode); 1544 - return ERR_PTR(-ENOMEM); 1545 - } 1546 - return result; 1538 + 1539 + return d_obtain_alias(inode); 1547 1540 } 1548 1541 1549 1542 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+1 -10
fs/reiserfs/namei.c
··· 383 383 struct inode *inode = NULL; 384 384 struct reiserfs_dir_entry de; 385 385 INITIALIZE_PATH(path_to_entry); 386 - struct dentry *parent; 387 386 struct inode *dir = child->d_inode; 388 387 389 388 if (dir->i_nlink == 0) { ··· 400 401 inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id)); 401 402 reiserfs_write_unlock(dir->i_sb); 402 403 403 - if (!inode || IS_ERR(inode)) { 404 - return ERR_PTR(-EACCES); 405 - } 406 - parent = d_alloc_anon(inode); 407 - if (!parent) { 408 - iput(inode); 409 - parent = ERR_PTR(-ENOMEM); 410 - } 411 - return parent; 404 + return d_obtain_alias(inode); 412 405 } 413 406 414 407 /* add entry to the directory (entry can be hidden).
+2 -15
fs/udf/namei.c
··· 1243 1243 1244 1244 static struct dentry *udf_get_parent(struct dentry *child) 1245 1245 { 1246 - struct dentry *parent; 1247 1246 struct inode *inode = NULL; 1248 1247 struct dentry dotdot; 1249 1248 struct fileIdentDesc cfi; ··· 1265 1266 goto out_unlock; 1266 1267 unlock_kernel(); 1267 1268 1268 - parent = d_alloc_anon(inode); 1269 - if (!parent) { 1270 - iput(inode); 1271 - parent = ERR_PTR(-ENOMEM); 1272 - } 1273 - 1274 - return parent; 1269 + return d_obtain_alias(inode); 1275 1270 out_unlock: 1276 1271 unlock_kernel(); 1277 1272 return ERR_PTR(-EACCES); ··· 1276 1283 u16 partref, __u32 generation) 1277 1284 { 1278 1285 struct inode *inode; 1279 - struct dentry *result; 1280 1286 kernel_lb_addr loc; 1281 1287 1282 1288 if (block == 0) ··· 1292 1300 iput(inode); 1293 1301 return ERR_PTR(-ESTALE); 1294 1302 } 1295 - result = d_alloc_anon(inode); 1296 - if (!result) { 1297 - iput(inode); 1298 - return ERR_PTR(-ENOMEM); 1299 - } 1300 - return result; 1303 + return d_obtain_alias(inode); 1301 1304 } 1302 1305 1303 1306 static struct dentry *udf_fh_to_dentry(struct super_block *sb,
+3 -29
fs/xfs/linux-2.6/xfs_export.c
··· 148 148 { 149 149 struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; 150 150 struct inode *inode = NULL; 151 - struct dentry *result; 152 151 153 152 if (fh_len < xfs_fileid_length(fileid_type)) 154 153 return NULL; ··· 163 164 break; 164 165 } 165 166 166 - if (!inode) 167 - return NULL; 168 - if (IS_ERR(inode)) 169 - return ERR_CAST(inode); 170 - result = d_alloc_anon(inode); 171 - if (!result) { 172 - iput(inode); 173 - return ERR_PTR(-ENOMEM); 174 - } 175 - return result; 167 + return d_obtain_alias(inode); 176 168 } 177 169 178 170 STATIC struct dentry * ··· 172 182 { 173 183 struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; 174 184 struct inode *inode = NULL; 175 - struct dentry *result; 176 185 177 186 switch (fileid_type) { 178 187 case FILEID_INO32_GEN_PARENT: ··· 184 195 break; 185 196 } 186 197 187 - if (!inode) 188 - return NULL; 189 - if (IS_ERR(inode)) 190 - return ERR_CAST(inode); 191 - result = d_alloc_anon(inode); 192 - if (!result) { 193 - iput(inode); 194 - return ERR_PTR(-ENOMEM); 195 - } 196 - return result; 198 + return d_obtain_alias(inode); 197 199 } 198 200 199 201 STATIC struct dentry * ··· 193 213 { 194 214 int error; 195 215 struct xfs_inode *cip; 196 - struct dentry *parent; 197 216 198 217 error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL); 199 218 if (unlikely(error)) 200 219 return ERR_PTR(-error); 201 220 202 - parent = d_alloc_anon(VFS_I(cip)); 203 - if (unlikely(!parent)) { 204 - iput(VFS_I(cip)); 205 - return ERR_PTR(-ENOMEM); 206 - } 207 - return parent; 221 + return d_obtain_alias(VFS_I(cip)); 208 222 } 209 223 210 224 const struct export_operations xfs_export_operations = {
+3 -4
fs/xfs/linux-2.6/xfs_ioctl.c
··· 311 311 return new_fd; 312 312 } 313 313 314 - dentry = d_alloc_anon(inode); 315 - if (dentry == NULL) { 316 - iput(inode); 314 + dentry = d_obtain_alias(inode); 315 + if (IS_ERR(dentry)) { 317 316 put_unused_fd(new_fd); 318 - return -XFS_ERROR(ENOMEM); 317 + return PTR_ERR(dentry); 319 318 } 320 319 321 320 /* Ensure umount returns EBUSY on umounts while this file is open. */