ceph: update dentry lease for async create
authorYan, Zheng <zyan@redhat.com>
Wed, 4 Mar 2020 13:22:20 +0000 (21:22 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Mar 2020 10:42:42 +0000 (12:42 +0200)
Otherwise ceph_d_delete() may return 1 for the dentry, which makes
dput() prune the dentry and clear parent dir's complete flag.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c

index 6708072..a6c4841 100644 (file)
@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,
        if (d_in_lookup(dentry)) {
                if (!__ceph_dir_is_complete(ci))
                        goto no_async;
+               spin_lock(&dentry->d_lock);
+               di->lease_shared_gen = atomic_read(&ci->i_shared_gen);
+               spin_unlock(&dentry->d_lock);
        } else if (atomic_read(&ci->i_shared_gen) !=
                   READ_ONCE(di->lease_shared_gen)) {
                goto no_async;