Merge tag 'net-5.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / fs / ceph / inode.c
index df0c8a7..1bd2cc0 100644 (file)
@@ -1124,7 +1124,7 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry,
                return;
        }
 
-       if (di->lease_gen == session->s_cap_gen &&
+       if (di->lease_gen == atomic_read(&session->s_cap_gen) &&
            time_before(ttl, di->time))
                return;  /* we already have a newer lease. */
 
@@ -1135,7 +1135,7 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry,
 
        if (!di->lease_session)
                di->lease_session = ceph_get_mds_session(session);
-       di->lease_gen = session->s_cap_gen;
+       di->lease_gen = atomic_read(&session->s_cap_gen);
        di->lease_seq = le32_to_cpu(lease->seq);
        di->lease_renew_after = half_ttl;
        di->lease_renew_from = 0;
@@ -1154,8 +1154,7 @@ static inline void update_dentry_lease(struct inode *dir, struct dentry *dentry,
        __update_dentry_lease(dir, dentry, lease, session, from_time,
                              &old_lease_session);
        spin_unlock(&dentry->d_lock);
-       if (old_lease_session)
-               ceph_put_mds_session(old_lease_session);
+       ceph_put_mds_session(old_lease_session);
 }
 
 /*
@@ -1200,8 +1199,7 @@ static void update_dentry_lease_careful(struct dentry *dentry,
                              from_time, &old_lease_session);
 out_unlock:
        spin_unlock(&dentry->d_lock);
-       if (old_lease_session)
-               ceph_put_mds_session(old_lease_session);
+       ceph_put_mds_session(old_lease_session);
 }
 
 /*
@@ -1568,8 +1566,7 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
                        unlock_new_inode(in);
                }
 
-               /* avoid calling iput_final() in mds dispatch threads */
-               ceph_async_iput(in);
+               iput(in);
        }
 
        return err;
@@ -1766,13 +1763,11 @@ retry_lookup:
                if (ret < 0) {
                        pr_err("ceph_fill_inode badness on %p\n", in);
                        if (d_really_is_negative(dn)) {
-                               /* avoid calling iput_final() in mds
-                                * dispatch threads */
                                if (in->i_state & I_NEW) {
                                        ihold(in);
                                        discard_new_inode(in);
                                }
-                               ceph_async_iput(in);
+                               iput(in);
                        }
                        d_drop(dn);
                        err = ret;
@@ -1785,7 +1780,7 @@ retry_lookup:
                        if (ceph_security_xattr_deadlock(in)) {
                                dout(" skip splicing dn %p to inode %p"
                                     " (security xattr deadlock)\n", dn, in);
-                               ceph_async_iput(in);
+                               iput(in);
                                skipped++;
                                goto next_item;
                        }
@@ -1836,25 +1831,6 @@ bool ceph_inode_set_size(struct inode *inode, loff_t size)
        return ret;
 }
 
-/*
- * Put reference to inode, but avoid calling iput_final() in current thread.
- * iput_final() may wait for reahahead pages. The wait can cause deadlock in
- * some contexts.
- */
-void ceph_async_iput(struct inode *inode)
-{
-       if (!inode)
-               return;
-       for (;;) {
-               if (atomic_add_unless(&inode->i_count, -1, 1))
-                       break;
-               if (queue_work(ceph_inode_to_client(inode)->inode_wq,
-                              &ceph_inode(inode)->i_work))
-                       break;
-               /* queue work failed, i_count must be at least 2 */
-       }
-}
-
 void ceph_queue_inode_work(struct inode *inode, int work_bit)
 {
        struct ceph_fs_client *fsc = ceph_inode_to_client(inode);