8000 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel… · bsd-unix/linux@08d27eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 08d27eb

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: posix_acl: de-union a_refcount and a_rcu nfs_atomic_open(): prevent parallel nfs_lookup() on a negative hashed Use the right predicate in ->atomic_open() instances
2 parents 92d21ac + 6d4e56c commit 08d27eb

File tree

8 files changed

+34
-14
lines changed

8 files changed

+34
-14
lines changed

fs/9p/vfs_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
853853
struct p9_fid *fid, *inode_fid;
854854
struct dentry *res = NULL;
855855

856-
if (d_unhashed(dentry)) {
856+
if (d_in_lookup(dentry)) {
857857
res = v9fs_vfs_lookup(dir, dentry, 0);
858858
if (IS_ERR(res))
859859
return PTR_ERR(res);

fs/9p/vfs_inode_dotl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
254254
struct posix_acl *pacl = NULL, *dacl = NULL;
255255
struct dentry *res = NULL;
256256

257-
if (d_unhashed(dentry)) {
257+
if (d_in_lookup(dentry)) {
258258
res = v9fs_vfs_lookup(dir, dentry, 0);
259259
if (IS_ERR(res))
260260
return PTR_ERR(res);

fs/ceph/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
394394
if ((flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
395395
err = ceph_handle_notrace_create(dir, dentry);
396396

397-
if (d_unhashed(dentry)) {
397+
if (d_in_lookup(dentry)) {
398398
dn = ceph_finish_lookup(req, dentry, err);
399399
if (IS_ERR(dn))
400400
err = PTR_ERR(dn);

fs/cifs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
445445
* Check for hashed negative dentry. We have already revalidated
446446
* the dentry and it is fine. No need to perform another lookup.
447447
*/
448-
if (!d_unhashed(direntry))
448+
if (!d_in_lookup(direntry))
449449
return -ENOENT;
450450

451451
res = cifs_lookup(inode, direntry, 0);

fs/fuse/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
480480
struct fuse_conn *fc = get_fuse_conn(dir);
481481
struct dentry *res = NULL;
482482

483-
if (d_unhashed(entry)) {
483+
if (d_in_lookup(entry)) {
484484
res = fuse_lookup(dir, entry, 0);
485485
if (IS_ERR(res))
486486
return PTR_ERR(res);

fs/gfs2/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
11891189
struct dentry *d;
11901190
bool excl = !!(flags & O_EXCL);
11911191

1192-
if (!d_unhashed(dentry))
1192+
if (!d_in_lookup(dentry))
11931193
goto skip_lookup;
11941194

11951195
d = __gfs2_lookup(dir, dentry, file, opened);

fs/nfs/dir.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,11 +1485,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
14851485
struct file *file, unsigned open_flags,
14861486
umode_t mode, int *opened)
14871487
{
1488+
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
14881489
struct nfs_open_context *ctx;
14891490
struct dentry *res;
14901491
struct iattr attr = { .ia_valid = ATTR_OPEN };
14911492
struct inode *inode;
14921493
unsigned int lookup_flags = 0;
1494+
bool switched = false;
14931495
int err;
14941496

14951497
/* Expect a negative dentry */
@@ -1504,7 +1506,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
15041506

15051507
/* NFS only supports OPEN on regular files */
15061508
if ((open_flags & O_DIRECTORY)) {
1507-
if (!d_unhashed(dentry)) {
1509+
if (!d_in_lookup(dentry)) {
15081510
/*
15091511
* Hashed negative dentry with O_DIRECTORY: dentry was
15101512
* revalidated and is fine, no need to perform lookup
@@ -1528,6 +1530,17 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
15281530
attr.ia_size = 0;
15291531
}
15301532

1533+
if (!( 9E88 open_flags & O_CREAT) && !d_in_lookup(dentry)) {
1534+
d_drop(dentry);
1535+
switched = true;
1536+
dentry = d_alloc_parallel(dentry->d_parent,
1537+
&dentry->d_name, &wq);
1538+
if (IS_ERR(dentry))
1539+
return PTR_ERR(dentry);
1540+
if (unlikely(!d_in_lookup(dentry)))
1541+
return finish_no_open(file, dentry);
1542+
}
1543+
15311544
ctx = create_nfs_open_context(dentry, open_flags);
15321545
err = PTR_ERR(ctx);
15331546
if (IS_ERR(ctx))
@@ -1563,14 +1576,23 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
15631576
trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
15641577
put_nfs_open_context(ctx);
15651578
out:
1579+
if (unlikely(switched)) {
1580+
d_lookup_done(dentry);
1581+
dput(dentry);
1582+
}
15661583
return err;
15671584

15681585
no_open:
15691586
res = nfs_lookup(dir, dentry, lookup_flags);
1570-
err = PTR_ERR(res);
1587+
if (switched) {
1588+
d_lookup_done(dentry);
1589+
if (!res)
1590+
res = dentry;
1591+
else
1592+
dput(dentry);
1593+
}
15711594
if (IS_ERR(res))
1572-
goto out;
1573-
1595+
return PTR_ERR(res);
15741596
return finish_no_open(file, res);
15751597
}
15761598
EXPORT_SYMBOL_GPL(nfs_atomic_open);

include/linux/posix_acl.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ struct posix_acl_entry {
4343
};
4444

4545
struct posix_acl {
46-
union {
47-
atomic_t a_refcount;
48-
struct rcu_head a_rcu;
49-
};
46+
atomic_t a_refcount;
47+
struct rcu_head a_rcu;
5048
unsigned int a_count;
5149
struct posix_acl_entry a_entries[0];
5250
};

0 commit comments

Comments
 (0)
0