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 tag 'pull-finish_no_open' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull finish_no_open updates from Al Viro:
"finish_no_open calling conventions change to simplify callers"

* tag 'pull-finish_no_open' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
slightly simplify nfs_atomic_open()
simplify gfs2_atomic_open()
simplify fuse_atomic_open()
simplify nfs_atomic_open_v23()
simplify vboxsf_dir_atomic_open()
simplify cifs_atomic_open()
9p: simplify v9fs_vfs_atomic_open_dotl()
9p: simplify v9fs_vfs_atomic_open()
allow finish_no_open(file, ERR_PTR(-E...))

+54 -103
+12 -22
fs/9p/vfs_inode.c
··· 768 768 struct v9fs_inode __maybe_unused *v9inode; 769 769 struct v9fs_session_info *v9ses; 770 770 struct p9_fid *fid; 771 - struct dentry *res = NULL; 772 771 struct inode *inode; 773 772 int p9_omode; 774 773 775 774 if (d_in_lookup(dentry)) { 776 - res = v9fs_vfs_lookup(dir, dentry, 0); 777 - if (IS_ERR(res)) 778 - return PTR_ERR(res); 779 - 780 - if (res) 781 - dentry = res; 775 + struct dentry *res = v9fs_vfs_lookup(dir, dentry, 0); 776 + if (res || d_really_is_positive(dentry)) 777 + return finish_no_open(file, res); 782 778 } 783 779 784 780 /* Only creates */ 785 - if (!(flags & O_CREAT) || d_really_is_positive(dentry)) 786 - return finish_no_open(file, res); 781 + if (!(flags & O_CREAT)) 782 + return finish_no_open(file, NULL); 787 783 788 784 v9ses = v9fs_inode2v9ses(dir); 789 785 perm = unixmode2p9mode(v9ses, mode); ··· 791 795 "write-only file with writeback enabled, creating w/ O_RDWR\n"); 792 796 } 793 797 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, p9_omode); 794 - if (IS_ERR(fid)) { 795 - err = PTR_ERR(fid); 796 - goto error; 797 - } 798 + if (IS_ERR(fid)) 799 + return PTR_ERR(fid); 798 800 799 801 v9fs_invalidate_inode_attr(dir); 800 802 inode = d_inode(dentry); 801 803 v9inode = V9FS_I(inode); 802 804 err = finish_open(file, dentry, generic_file_open); 803 - if (err) 804 - goto error; 805 + if (unlikely(err)) { 806 + p9_fid_put(fid); 807 + return err; 808 + } 805 809 806 810 file->private_data = fid; 807 811 #ifdef CONFIG_9P_FSCACHE ··· 814 818 v9fs_open_fid_add(inode, &fid); 815 819 816 820 file->f_mode |= FMODE_CREATED; 817 - out: 818 - dput(res); 819 - return err; 820 - 821 - error: 822 - p9_fid_put(fid); 823 - goto out; 821 + return 0; 824 822 } 825 823 826 824 /**
+5 -10
fs/9p/vfs_inode_dotl.c
··· 238 238 struct p9_fid *dfid = NULL, *ofid = NULL; 239 239 struct v9fs_session_info *v9ses; 240 240 struct posix_acl *pacl = NULL, *dacl = NULL; 241 - struct dentry *res = NULL; 242 241 243 242 if (d_in_lookup(dentry)) { 244 - res = v9fs_vfs_lookup(dir, dentry, 0); 245 - if (IS_ERR(res)) 246 - return PTR_ERR(res); 247 - 248 - if (res) 249 - dentry = res; 243 + struct dentry *res = v9fs_vfs_lookup(dir, dentry, 0); 244 + if (res || d_really_is_positive(dentry)) 245 + return finish_no_open(file, res); 250 246 } 251 247 252 248 /* Only creates */ 253 - if (!(flags & O_CREAT) || d_really_is_positive(dentry)) 254 - return finish_no_open(file, res); 249 + if (!(flags & O_CREAT)) 250 + return finish_no_open(file, NULL); 255 251 256 252 v9ses = v9fs_inode2v9ses(dir); 257 253 ··· 333 337 p9_fid_put(ofid); 334 338 p9_fid_put(fid); 335 339 v9fs_put_acl(dacl, pacl); 336 - dput(res); 337 340 return err; 338 341 } 339 342
+7 -14
fs/fuse/dir.c
··· 739 739 int err; 740 740 struct mnt_idmap *idmap = file_mnt_idmap(file); 741 741 struct fuse_conn *fc = get_fuse_conn(dir); 742 - struct dentry *res = NULL; 743 742 744 743 if (fuse_is_bad(dir)) 745 744 return -EIO; 746 745 747 746 if (d_in_lookup(entry)) { 748 - res = fuse_lookup(dir, entry, 0); 749 - if (IS_ERR(res)) 750 - return PTR_ERR(res); 751 - 752 - if (res) 753 - entry = res; 747 + struct dentry *res = fuse_lookup(dir, entry, 0); 748 + if (res || d_really_is_positive(entry)) 749 + return finish_no_open(file, res); 754 750 } 755 751 756 - if (!(flags & O_CREAT) || d_really_is_positive(entry)) 757 - goto no_open; 752 + if (!(flags & O_CREAT)) 753 + return finish_no_open(file, NULL); 758 754 759 755 /* Only creates */ 760 756 file->f_mode |= FMODE_CREATED; ··· 764 768 goto mknod; 765 769 } else if (err == -EEXIST) 766 770 fuse_invalidate_entry(entry); 767 - out_dput: 768 - dput(res); 769 771 return err; 770 772 771 773 mknod: 772 774 err = fuse_mknod(idmap, dir, entry, mode, 0); 773 775 if (err) 774 - goto out_dput; 775 - no_open: 776 - return finish_no_open(file, res); 776 + return err; 777 + return finish_no_open(file, NULL); 777 778 } 778 779 779 780 /*
+9 -17
fs/gfs2/inode.c
··· 1368 1368 struct file *file, unsigned flags, 1369 1369 umode_t mode) 1370 1370 { 1371 - struct dentry *d; 1372 1371 bool excl = !!(flags & O_EXCL); 1373 1372 1374 - if (!d_in_lookup(dentry)) 1375 - goto skip_lookup; 1376 - 1377 - d = __gfs2_lookup(dir, dentry, file); 1378 - if (IS_ERR(d)) 1379 - return PTR_ERR(d); 1380 - if (d != NULL) 1381 - dentry = d; 1382 - if (d_really_is_positive(dentry)) { 1383 - if (!(file->f_mode & FMODE_OPENED)) 1373 + if (d_in_lookup(dentry)) { 1374 + struct dentry *d = __gfs2_lookup(dir, dentry, file); 1375 + if (file->f_mode & FMODE_OPENED) { 1376 + if (IS_ERR(d)) 1377 + return PTR_ERR(d); 1378 + dput(d); 1379 + return excl && (flags & O_CREAT) ? -EEXIST : 0; 1380 + } 1381 + if (d || d_really_is_positive(dentry)) 1384 1382 return finish_no_open(file, d); 1385 - dput(d); 1386 - return excl && (flags & O_CREAT) ? -EEXIST : 0; 1387 1383 } 1388 - 1389 - BUG_ON(d != NULL); 1390 - 1391 - skip_lookup: 1392 1384 if (!(flags & O_CREAT)) 1393 1385 return -ENOENT; 1394 1386
+5 -13
fs/nfs/dir.c
··· 2198 2198 else 2199 2199 dput(dentry); 2200 2200 } 2201 - if (IS_ERR(res)) 2202 - return PTR_ERR(res); 2203 2201 return finish_no_open(file, res); 2204 2202 } 2205 2203 EXPORT_SYMBOL_GPL(nfs_atomic_open); ··· 2258 2260 struct file *file, unsigned int open_flags, 2259 2261 umode_t mode) 2260 2262 { 2261 - 2263 + struct dentry *res = NULL; 2262 2264 /* Same as look+open from lookup_open(), but with different O_TRUNC 2263 2265 * handling. 2264 2266 */ ··· 2273 2275 if (error) 2274 2276 return error; 2275 2277 return finish_open(file, dentry, NULL); 2276 - } else if (d_in_lookup(dentry)) { 2278 + } 2279 + if (d_in_lookup(dentry)) { 2277 2280 /* The only flags nfs_lookup considers are 2278 2281 * LOOKUP_EXCL and LOOKUP_RENAME_TARGET, and 2279 2282 * we want those to be zero so the lookup isn't skipped. 2280 2283 */ 2281 - struct dentry *res = nfs_lookup(dir, dentry, 0); 2282 - 2283 - d_lookup_done(dentry); 2284 - if (unlikely(res)) { 2285 - if (IS_ERR(res)) 2286 - return PTR_ERR(res); 2287 - return finish_no_open(file, res); 2288 - } 2284 + res = nfs_lookup(dir, dentry, 0); 2289 2285 } 2290 - return finish_no_open(file, NULL); 2286 + return finish_no_open(file, res); 2291 2287 2292 2288 } 2293 2289 EXPORT_SYMBOL_GPL(nfs_atomic_open_v23);
+6 -4
fs/open.c
··· 1059 1059 * finish_no_open - finish ->atomic_open() without opening the file 1060 1060 * 1061 1061 * @file: file pointer 1062 - * @dentry: dentry or NULL (as returned from ->lookup()) 1062 + * @dentry: dentry, ERR_PTR(-E...) or NULL (as returned from ->lookup()) 1063 1063 * 1064 - * This can be used to set the result of a successful lookup in ->atomic_open(). 1064 + * This can be used to set the result of a lookup in ->atomic_open(). 1065 1065 * 1066 1066 * NB: unlike finish_open() this function does consume the dentry reference and 1067 1067 * the caller need not dput() it. 1068 1068 * 1069 - * Returns "0" which must be the return value of ->atomic_open() after having 1070 - * called this function. 1069 + * Returns 0 or -E..., which must be the return value of ->atomic_open() after 1070 + * having called this function. 1071 1071 */ 1072 1072 int finish_no_open(struct file *file, struct dentry *dentry) 1073 1073 { 1074 + if (IS_ERR(dentry)) 1075 + return PTR_ERR(dentry); 1074 1076 file->f_path.dentry = dentry; 1075 1077 return 0; 1076 1078 }
+1 -7
fs/smb/client/dir.c
··· 484 484 * in network traffic in the other paths. 485 485 */ 486 486 if (!(oflags & O_CREAT)) { 487 - struct dentry *res; 488 - 489 487 /* 490 488 * Check for hashed negative dentry. We have already revalidated 491 489 * the dentry and it is fine. No need to perform another lookup. ··· 491 493 if (!d_in_lookup(direntry)) 492 494 return -ENOENT; 493 495 494 - res = cifs_lookup(inode, direntry, 0); 495 - if (IS_ERR(res)) 496 - return PTR_ERR(res); 497 - 498 - return finish_no_open(file, res); 496 + return finish_no_open(file, cifs_lookup(inode, direntry, 0)); 499 497 } 500 498 501 499 xid = get_xid();
+9 -16
fs/vboxsf/dir.c
··· 315 315 { 316 316 struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); 317 317 struct vboxsf_handle *sf_handle; 318 - struct dentry *res = NULL; 319 318 u64 handle; 320 319 int err; 321 320 322 321 if (d_in_lookup(dentry)) { 323 - res = vboxsf_dir_lookup(parent, dentry, 0); 324 - if (IS_ERR(res)) 325 - return PTR_ERR(res); 326 - 327 - if (res) 328 - dentry = res; 322 + struct dentry *res = vboxsf_dir_lookup(parent, dentry, 0); 323 + if (res || d_really_is_positive(dentry)) 324 + return finish_no_open(file, res); 329 325 } 330 326 331 327 /* Only creates */ 332 - if (!(flags & O_CREAT) || d_really_is_positive(dentry)) 333 - return finish_no_open(file, res); 328 + if (!(flags & O_CREAT)) 329 + return finish_no_open(file, NULL); 334 330 335 331 err = vboxsf_dir_create(parent, dentry, mode, false, flags & O_EXCL, &handle); 336 332 if (err) 337 - goto out; 333 + return err; 338 334 339 335 sf_handle = vboxsf_create_sf_handle(d_inode(dentry), handle, SHFL_CF_ACCESS_READWRITE); 340 336 if (IS_ERR(sf_handle)) { 341 337 vboxsf_close(sbi->root, handle); 342 - err = PTR_ERR(sf_handle); 343 - goto out; 338 + return PTR_ERR(sf_handle); 344 339 } 345 340 346 341 err = finish_open(file, dentry, generic_file_open); 347 342 if (err) { 348 343 /* This also closes the handle passed to vboxsf_create_sf_handle() */ 349 344 vboxsf_release_sf_handle(d_inode(dentry), sf_handle); 350 - goto out; 345 + return err; 351 346 } 352 347 353 348 file->private_data = sf_handle; 354 349 file->f_mode |= FMODE_CREATED; 355 - out: 356 - dput(res); 357 - return err; 350 + return 0; 358 351 } 359 352 360 353 static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)