Skip to content

Commit 23c2c76

Browse files
jtlaytonidryomov
authored andcommitted
ceph: eliminate ceph_async_iput()
Now that we don't need to hold session->s_mutex or the snap_rwsem when calling ceph_check_caps, we can eliminate ceph_async_iput and just use normal iput calls. Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 7732fe1 commit 23c2c76

6 files changed

Lines changed: 25 additions & 69 deletions

File tree

fs/ceph/caps.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,8 +3142,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
31423142
if (complete_capsnap)
31433143
wake_up_all(&ci->i_cap_wq);
31443144
while (put-- > 0) {
3145-
/* avoid calling iput_final() in osd dispatch threads */
3146-
ceph_async_iput(inode);
3145+
iput(inode);
31473146
}
31483147
}
31493148

@@ -4131,8 +4130,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
41314130
mutex_unlock(&session->s_mutex);
41324131
done_unlocked:
41334132
ceph_put_string(extra_info.pool_ns);
4134-
/* avoid calling iput_final() in mds dispatch threads */
4135-
ceph_async_iput(inode);
4133+
iput(inode);
41364134
return;
41374135

41384136
flush_cap_releases:
@@ -4174,8 +4172,7 @@ void ceph_check_delayed_caps(struct ceph_mds_client *mdsc)
41744172
spin_unlock(&mdsc->cap_delay_lock);
41754173
dout("check_delayed_caps on %p\n", inode);
41764174
ceph_check_caps(ci, 0, NULL);
4177-
/* avoid calling iput_final() in tick thread */
4178-
ceph_async_iput(inode);
4175+
iput(inode);
41794176
spin_lock(&mdsc->cap_delay_lock);
41804177
}
41814178
}

fs/ceph/inode.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,8 +1566,7 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
15661566
unlock_new_inode(in);
15671567
}
15681568

1569-
/* avoid calling iput_final() in mds dispatch threads */
1570-
ceph_async_iput(in);
1569+
iput(in);
15711570
}
15721571

15731572
return err;
@@ -1764,13 +1763,11 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
17641763
if (ret < 0) {
17651764
pr_err("ceph_fill_inode badness on %p\n", in);
17661765
if (d_really_is_negative(dn)) {
1767-
/* avoid calling iput_final() in mds
1768-
* dispatch threads */
17691766
if (in->i_state & I_NEW) {
17701767
ihold(in);
17711768
discard_new_inode(in);
17721769
}
1773-
ceph_async_iput(in);
1770+
iput(in);
17741771
}
17751772
d_drop(dn);
17761773
err = ret;
@@ -1783,7 +1780,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
17831780
if (ceph_security_xattr_deadlock(in)) {
17841781
dout(" skip splicing dn %p to inode %p"
17851782
" (security xattr deadlock)\n", dn, in);
1786-
ceph_async_iput(in);
1783+
iput(in);
17871784
skipped++;
17881785
goto next_item;
17891786
}
@@ -1834,25 +1831,6 @@ bool ceph_inode_set_size(struct inode *inode, loff_t size)
18341831
return ret;
18351832
}
18361833

1837-
/*
1838-
* Put reference to inode, but avoid calling iput_final() in current thread.
1839-
* iput_final() may wait for reahahead pages. The wait can cause deadlock in
1840-
* some contexts.
1841-
*/
1842-
void ceph_async_iput(struct inode *inode)
1843-
{
1844-
if (!inode)
1845-
return;
1846-
for (;;) {
1847-
if (atomic_add_unless(&inode->i_count, -1, 1))
1848-
break;
1849-
if (queue_work(ceph_inode_to_client(inode)->inode_wq,
1850-
&ceph_inode(inode)->i_work))
1851-
break;
1852-
/* queue work failed, i_count must be at least 2 */
1853-
}
1854-
}
1855-
18561834
void ceph_queue_inode_work(struct inode *inode, int work_bit)
18571835
{
18581836
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);

fs/ceph/mds_client.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,13 @@ void ceph_mdsc_release_request(struct kref *kref)
824824
ceph_msg_put(req->r_reply);
825825
if (req->r_inode) {
826826
ceph_put_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
827-
/* avoid calling iput_final() in mds dispatch threads */
828-
ceph_async_iput(req->r_inode);
827+
iput(req->r_inode);
829828
}
830829
if (req->r_parent) {
831830
ceph_put_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN);
832-
ceph_async_iput(req->r_parent);
831+
iput(req->r_parent);
833832
}
834-
ceph_async_iput(req->r_target_inode);
833+
iput(req->r_target_inode);
835834
if (req->r_dentry)
836835
dput(req->r_dentry);
837836
if (req->r_old_dentry)
@@ -845,7 +844,7 @@ void ceph_mdsc_release_request(struct kref *kref)
845844
*/
846845
ceph_put_cap_refs(ceph_inode(req->r_old_dentry_dir),
847846
CEPH_CAP_PIN);
848-
ceph_async_iput(req->r_old_dentry_dir);
847+
iput(req->r_old_dentry_dir);
849848
}
850849
kfree(req->r_path1);
851850
kfree(req->r_path2);
@@ -960,8 +959,7 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
960959
}
961960

962961
if (req->r_unsafe_dir) {
963-
/* avoid calling iput_final() in mds dispatch threads */
964-
ceph_async_iput(req->r_unsafe_dir);
962+
iput(req->r_unsafe_dir);
965963
req->r_unsafe_dir = NULL;
966964
}
967965

@@ -1132,7 +1130,7 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
11321130
cap = rb_entry(rb_first(&ci->i_caps), struct ceph_cap, ci_node);
11331131
if (!cap) {
11341132
spin_unlock(&ci->i_ceph_lock);
1135-
ceph_async_iput(inode);
1133+
iput(inode);
11361134
goto random;
11371135
}
11381136
mds = cap->session->s_mds;
@@ -1141,9 +1139,7 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
11411139
cap == ci->i_auth_cap ? "auth " : "", cap);
11421140
spin_unlock(&ci->i_ceph_lock);
11431141
out:
1144-
/* avoid calling iput_final() while holding mdsc->mutex or
1145-
* in mds dispatch threads */
1146-
ceph_async_iput(inode);
1142+
iput(inode);
11471143
return mds;
11481144

11491145
random:
@@ -1546,9 +1542,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session,
15461542
spin_unlock(&session->s_cap_lock);
15471543

15481544
if (last_inode) {
1549-
/* avoid calling iput_final() while holding
1550-
* s_mutex or in mds dispatch threads */
1551-
ceph_async_iput(last_inode);
1545+
iput(last_inode);
15521546
last_inode = NULL;
15531547
}
15541548
if (old_cap) {
@@ -1582,7 +1576,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session,
15821576
session->s_cap_iterator = NULL;
15831577
spin_unlock(&session->s_cap_lock);
15841578

1585-
ceph_async_iput(last_inode);
1579+
iput(last_inode);
15861580
if (old_cap)
15871581
ceph_put_cap(session->s_mdsc, old_cap);
15881582

@@ -1722,8 +1716,7 @@ static void remove_session_caps(struct ceph_mds_session *session)
17221716
spin_unlock(&session->s_cap_lock);
17231717

17241718
inode = ceph_find_inode(sb, vino);
1725-
/* avoid calling iput_final() while holding s_mutex */
1726-
ceph_async_iput(inode);
1719+
iput(inode);
17271720

17281721
spin_lock(&session->s_cap_lock);
17291722
}
@@ -4369,8 +4362,7 @@ static void handle_lease(struct ceph_mds_client *mdsc,
43694362

43704363
out:
43714364
mutex_unlock(&session->s_mutex);
4372-
/* avoid calling iput_final() in mds dispatch threads */
4373-
ceph_async_iput(inode);
4365+
iput(inode);
43744366
return;
43754367

43764368
bad:

fs/ceph/quota.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ void ceph_handle_quota(struct ceph_mds_client *mdsc,
7474
le64_to_cpu(h->max_files));
7575
spin_unlock(&ci->i_ceph_lock);
7676

77-
/* avoid calling iput_final() in dispatch thread */
78-
ceph_async_iput(inode);
77+
iput(inode);
7978
}
8079

8180
static struct ceph_quotarealm_inode *
@@ -247,8 +246,7 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
247246

248247
ci = ceph_inode(in);
249248
has_quota = __ceph_has_any_quota(ci);
250-
/* avoid calling iput_final() while holding mdsc->snap_rwsem */
251-
ceph_async_iput(in);
249+
iput(in);
252250

253251
next = realm->parent;
254252
if (has_quota || !next)
@@ -383,8 +381,7 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
383381
pr_warn("Invalid quota check op (%d)\n", op);
384382
exceeded = true; /* Just break the loop */
385383
}
386-
/* avoid calling iput_final() while holding mdsc->snap_rwsem */
387-
ceph_async_iput(in);
384+
iput(in);
388385

389386
next = realm->parent;
390387
if (exceeded || !next)

fs/ceph/snap.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)
677677
if (!inode)
678678
continue;
679679
spin_unlock(&realm->inodes_with_caps_lock);
680-
/* avoid calling iput_final() while holding
681-
* mdsc->snap_rwsem or in mds dispatch threads */
682-
ceph_async_iput(lastinode);
680+
iput(lastinode);
683681
lastinode = inode;
684682
ceph_queue_cap_snap(ci);
685683
spin_lock(&realm->inodes_with_caps_lock);
686684
}
687685
spin_unlock(&realm->inodes_with_caps_lock);
688-
ceph_async_iput(lastinode);
686+
iput(lastinode);
689687

690688
dout("queue_realm_cap_snaps %p %llx done\n", realm, realm->ino);
691689
}
@@ -839,9 +837,7 @@ static void flush_snaps(struct ceph_mds_client *mdsc)
839837
ihold(inode);
840838
spin_unlock(&mdsc->snap_flush_lock);
841839
ceph_flush_snaps(ci, &session);
842-
/* avoid calling iput_final() while holding
843-
* session->s_mutex or in mds dispatch threads */
844-
ceph_async_iput(inode);
840+
iput(inode);
845841
spin_lock(&mdsc->snap_flush_lock);
846842
}
847843
spin_unlock(&mdsc->snap_flush_lock);
@@ -982,14 +978,12 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
982978
ceph_get_snap_realm(mdsc, realm);
983979
ceph_put_snap_realm(mdsc, oldrealm);
984980

985-
/* avoid calling iput_final() while holding
986-
* mdsc->snap_rwsem or mds in dispatch threads */
987-
ceph_async_iput(inode);
981+
iput(inode);
988982
continue;
989983

990984
skip_inode:
991985
spin_unlock(&ci->i_ceph_lock);
992-
ceph_async_iput(inode);
986+
iput(inode);
993987
}
994988

995989
/* we may have taken some of the old realm's children. */

fs/ceph/super.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,6 @@ extern int ceph_inode_holds_cap(struct inode *inode, int mask);
988988
extern bool ceph_inode_set_size(struct inode *inode, loff_t size);
989989
extern void __ceph_do_pending_vmtruncate(struct inode *inode);
990990

991-
extern void ceph_async_iput(struct inode *inode);
992-
993991
void ceph_queue_inode_work(struct inode *inode, int work_bit);
994992

995993
static inline void ceph_queue_vmtruncate(struct inode *inode)

0 commit comments

Comments
 (0)