Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbed704

Browse files
jtlaytonidryomov
authored andcommitted
ceph: wait for async create reply before sending any cap messages
If we haven't received a reply to an async create request, then we don't want to send any cap messages to the MDS for that inode yet. Just have ceph_check_caps and __kick_flushing_caps return without doing anything, and have ceph_write_inode wait for the reply if we were asked to wait on the inode writeback. URL: https://tracker.ceph.com/issues/54107 Signed-off-by: Jeff Layton <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Reviewed-by: Patrick Donnelly <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 9eaa7b7 commit fbed704

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/ceph/caps.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
19151915
ceph_get_mds_session(session);
19161916

19171917
spin_lock(&ci->i_ceph_lock);
1918+
if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) {
1919+
/* Don't send messages until we get async create reply */
1920+
spin_unlock(&ci->i_ceph_lock);
1921+
ceph_put_mds_session(session);
1922+
return;
1923+
}
1924+
19181925
if (ci->i_ceph_flags & CEPH_I_FLUSH)
19191926
flags |= CHECK_CAPS_FLUSH;
19201927
retry:
@@ -2409,6 +2416,9 @@ int ceph_write_inode(struct inode *inode, struct writeback_control *wbc)
24092416
dout("write_inode %p wait=%d\n", inode, wait);
24102417
ceph_fscache_unpin_writeback(inode, wbc);
24112418
if (wait) {
2419+
err = ceph_wait_on_async_create(inode);
2420+
if (err)
2421+
return err;
24122422
dirty = try_flush_caps(inode, &flush_tid);
24132423
if (dirty)
24142424
err = wait_event_interruptible(ci->i_cap_wq,
@@ -2439,6 +2449,10 @@ static void __kick_flushing_caps(struct ceph_mds_client *mdsc,
24392449
u64 first_tid = 0;
24402450
u64 last_snap_flush = 0;
24412451

2452+
/* Don't do anything until create reply comes in */
2453+
if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE)
2454+
return;
2455+
24422456
ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH;
24432457

24442458
list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) {

0 commit comments

Comments
 (0)