Skip to content

Commit cfb3162

Browse files
committed
Merge tag 'ceph-for-6.2-rc1' of https://github.com/ceph/ceph-client
Pull cph update from Ilya Dryomov: "A fix to facilitate prompt cap releases on async creates from Xiubo. This should address sporadic "client isn't responding to mclientcaps (revoke) ..." warnings and potential associated MDS hangs" * tag 'ceph-for-6.2-rc1' of https://github.com/ceph/ceph-client: ceph: try to check caps immediately after async creating finishes ceph: remove useless session parameter for check_caps()
2 parents 87be949 + 68c62be commit cfb3162

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

fs/ceph/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
13671367
folio_put(folio);
13681368

13691369
if (check_cap)
1370-
ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY, NULL);
1370+
ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY);
13711371

13721372
return copied;
13731373
}

fs/ceph/caps.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,8 +1898,7 @@ bool __ceph_should_report_size(struct ceph_inode_info *ci)
18981898
* CHECK_CAPS_FLUSH - we should flush any dirty caps immediately, without
18991899
* further delay.
19001900
*/
1901-
void ceph_check_caps(struct ceph_inode_info *ci, int flags,
1902-
struct ceph_mds_session *session)
1901+
void ceph_check_caps(struct ceph_inode_info *ci, int flags)
19031902
{
19041903
struct inode *inode = &ci->netfs.inode;
19051904
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
@@ -1913,15 +1912,14 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
19131912
bool queue_invalidate = false;
19141913
bool tried_invalidate = false;
19151914
bool queue_writeback = false;
1916-
1917-
if (session)
1918-
ceph_get_mds_session(session);
1915+
struct ceph_mds_session *session = NULL;
19191916

19201917
spin_lock(&ci->i_ceph_lock);
19211918
if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) {
1919+
ci->i_ceph_flags |= CEPH_I_ASYNC_CHECK_CAPS;
1920+
19221921
/* Don't send messages until we get async create reply */
19231922
spin_unlock(&ci->i_ceph_lock);
1924-
ceph_put_mds_session(session);
19251923
return;
19261924
}
19271925

@@ -2851,7 +2849,7 @@ static void check_max_size(struct inode *inode, loff_t endoff)
28512849
check = 1;
28522850
spin_unlock(&ci->i_ceph_lock);
28532851
if (check)
2854-
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
2852+
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY);
28552853
}
28562854

28572855
static inline int get_used_fmode(int caps)
@@ -3140,7 +3138,7 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
31403138
switch (mode) {
31413139
case PUT_CAP_REFS_SYNC:
31423140
if (last)
3143-
ceph_check_caps(ci, 0, NULL);
3141+
ceph_check_caps(ci, 0);
31443142
else if (flushsnaps)
31453143
ceph_flush_snaps(ci, NULL);
31463144
break;
@@ -3255,7 +3253,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
32553253
spin_unlock(&ci->i_ceph_lock);
32563254

32573255
if (last) {
3258-
ceph_check_caps(ci, 0, NULL);
3256+
ceph_check_caps(ci, 0);
32593257
} else if (flush_snaps) {
32603258
ceph_flush_snaps(ci, NULL);
32613259
}
@@ -3604,10 +3602,9 @@ static void handle_cap_grant(struct inode *inode,
36043602

36053603
mutex_unlock(&session->s_mutex);
36063604
if (check_caps == 1)
3607-
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL,
3608-
session);
3605+
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL);
36093606
else if (check_caps == 2)
3610-
ceph_check_caps(ci, CHECK_CAPS_NOINVAL, session);
3607+
ceph_check_caps(ci, CHECK_CAPS_NOINVAL);
36113608
}
36123609

36133610
/*
@@ -4333,7 +4330,7 @@ unsigned long ceph_check_delayed_caps(struct ceph_mds_client *mdsc)
43334330
if (inode) {
43344331
spin_unlock(&mdsc->cap_delay_lock);
43354332
dout("check_delayed_caps on %p\n", inode);
4336-
ceph_check_caps(ci, 0, NULL);
4333+
ceph_check_caps(ci, 0);
43374334
iput(inode);
43384335
spin_lock(&mdsc->cap_delay_lock);
43394336
}
@@ -4362,7 +4359,7 @@ static void flush_dirty_session_caps(struct ceph_mds_session *s)
43624359
dout("flush_dirty_caps %llx.%llx\n", ceph_vinop(inode));
43634360
spin_unlock(&mdsc->cap_dirty_lock);
43644361
ceph_wait_on_async_create(inode);
4365-
ceph_check_caps(ci, CHECK_CAPS_FLUSH, NULL);
4362+
ceph_check_caps(ci, CHECK_CAPS_FLUSH);
43664363
iput(inode);
43674364
spin_lock(&mdsc->cap_dirty_lock);
43684365
}

fs/ceph/file.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ int ceph_renew_caps(struct inode *inode, int fmode)
313313
spin_unlock(&ci->i_ceph_lock);
314314
dout("renew caps %p want %s issued %s updating mds_wanted\n",
315315
inode, ceph_cap_string(wanted), ceph_cap_string(issued));
316-
ceph_check_caps(ci, 0, NULL);
316+
ceph_check_caps(ci, 0);
317317
return 0;
318318
}
319319
spin_unlock(&ci->i_ceph_lock);
@@ -408,7 +408,7 @@ int ceph_open(struct inode *inode, struct file *file)
408408
if ((issued & wanted) != wanted &&
409409
(mds_wanted & wanted) != wanted &&
410410
ceph_snap(inode) != CEPH_SNAPDIR)
411-
ceph_check_caps(ci, 0, NULL);
411+
ceph_check_caps(ci, 0);
412412

413413
return ceph_init_file(inode, file, fmode);
414414
} else if (ceph_snap(inode) != CEPH_NOSNAP &&
@@ -534,14 +534,23 @@ static void wake_async_create_waiters(struct inode *inode,
534534
struct ceph_mds_session *session)
535535
{
536536
struct ceph_inode_info *ci = ceph_inode(inode);
537+
bool check_cap = false;
537538

538539
spin_lock(&ci->i_ceph_lock);
539540
if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) {
540541
ci->i_ceph_flags &= ~CEPH_I_ASYNC_CREATE;
541542
wake_up_bit(&ci->i_ceph_flags, CEPH_ASYNC_CREATE_BIT);
543+
544+
if (ci->i_ceph_flags & CEPH_I_ASYNC_CHECK_CAPS) {
545+
ci->i_ceph_flags &= ~CEPH_I_ASYNC_CHECK_CAPS;
546+
check_cap = true;
547+
}
542548
}
543549
ceph_kick_flushing_inode_caps(session, ci);
544550
spin_unlock(&ci->i_ceph_lock);
551+
552+
if (check_cap)
553+
ceph_check_caps(ci, CHECK_CAPS_FLUSH);
545554
}
546555

547556
static void ceph_async_create_cb(struct ceph_mds_client *mdsc,
@@ -1092,7 +1101,7 @@ static void ceph_aio_complete(struct inode *inode,
10921101
loff_t endoff = aio_req->iocb->ki_pos + aio_req->total_len;
10931102
if (endoff > i_size_read(inode)) {
10941103
if (ceph_inode_set_size(inode, endoff))
1095-
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
1104+
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY);
10961105
}
10971106

10981107
spin_lock(&ci->i_ceph_lock);
@@ -1421,8 +1430,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
14211430
if (write && pos > size) {
14221431
if (ceph_inode_set_size(inode, pos))
14231432
ceph_check_caps(ceph_inode(inode),
1424-
CHECK_CAPS_AUTHONLY,
1425-
NULL);
1433+
CHECK_CAPS_AUTHONLY);
14261434
}
14271435
}
14281436

@@ -1577,8 +1585,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
15771585
check_caps = ceph_inode_set_size(inode, pos);
15781586
if (check_caps)
15791587
ceph_check_caps(ceph_inode(inode),
1580-
CHECK_CAPS_AUTHONLY,
1581-
NULL);
1588+
CHECK_CAPS_AUTHONLY);
15821589
}
15831590

15841591
}
@@ -1906,7 +1913,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
19061913
if (dirty)
19071914
__mark_inode_dirty(inode, dirty);
19081915
if (ceph_quota_is_max_bytes_approaching(inode, iocb->ki_pos))
1909-
ceph_check_caps(ci, CHECK_CAPS_FLUSH, NULL);
1916+
ceph_check_caps(ci, CHECK_CAPS_FLUSH);
19101917
}
19111918

19121919
dout("aio_write %p %llx.%llx %llu~%u dropping cap refs on %s\n",
@@ -2521,8 +2528,7 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
25212528
/* Let the MDS know about dst file size change */
25222529
if (ceph_inode_set_size(dst_inode, dst_off) ||
25232530
ceph_quota_is_max_bytes_approaching(dst_inode, dst_off))
2524-
ceph_check_caps(dst_ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_FLUSH,
2525-
NULL);
2531+
ceph_check_caps(dst_ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_FLUSH);
25262532
}
25272533
/* Mark Fw dirty */
25282534
spin_lock(&dst_ci->i_ceph_lock);

fs/ceph/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ static void ceph_do_invalidate_pages(struct inode *inode)
19091909
mutex_unlock(&ci->i_truncate_mutex);
19101910
out:
19111911
if (check)
1912-
ceph_check_caps(ci, 0, NULL);
1912+
ceph_check_caps(ci, 0);
19131913
}
19141914

19151915
/*
@@ -1969,7 +1969,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
19691969
mutex_unlock(&ci->i_truncate_mutex);
19701970

19711971
if (wrbuffer_refs == 0)
1972-
ceph_check_caps(ci, 0, NULL);
1972+
ceph_check_caps(ci, 0);
19731973

19741974
wake_up_all(&ci->i_cap_wq);
19751975
}
@@ -1991,7 +1991,7 @@ static void ceph_inode_work(struct work_struct *work)
19911991
__ceph_do_pending_vmtruncate(inode);
19921992

19931993
if (test_and_clear_bit(CEPH_I_WORK_CHECK_CAPS, &ci->i_work_mask))
1994-
ceph_check_caps(ci, 0, NULL);
1994+
ceph_check_caps(ci, 0);
19951995

19961996
if (test_and_clear_bit(CEPH_I_WORK_FLUSH_SNAPS, &ci->i_work_mask))
19971997
ceph_flush_snaps(ci, NULL);

fs/ceph/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static long ceph_ioctl_lazyio(struct file *file)
253253
spin_unlock(&ci->i_ceph_lock);
254254
dout("ioctl_layzio: file %p marked lazy\n", file);
255255

256-
ceph_check_caps(ci, 0, NULL);
256+
ceph_check_caps(ci, 0);
257257
} else {
258258
dout("ioctl_layzio: file %p already lazy\n", file);
259259
}

fs/ceph/super.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ static inline struct inode *ceph_find_inode(struct super_block *sb,
593593
#define CEPH_ASYNC_CREATE_BIT (12) /* async create in flight for this */
594594
#define CEPH_I_ASYNC_CREATE (1 << CEPH_ASYNC_CREATE_BIT)
595595
#define CEPH_I_SHUTDOWN (1 << 13) /* inode is no longer usable */
596+
#define CEPH_I_ASYNC_CHECK_CAPS (1 << 14) /* check caps immediately after async
597+
creating finishes */
596598

597599
/*
598600
* Masks of ceph inode work.
@@ -1200,8 +1202,7 @@ extern void ceph_remove_capsnap(struct inode *inode,
12001202
extern void ceph_flush_snaps(struct ceph_inode_info *ci,
12011203
struct ceph_mds_session **psession);
12021204
extern bool __ceph_should_report_size(struct ceph_inode_info *ci);
1203-
extern void ceph_check_caps(struct ceph_inode_info *ci, int flags,
1204-
struct ceph_mds_session *session);
1205+
extern void ceph_check_caps(struct ceph_inode_info *ci, int flags);
12051206
extern unsigned long ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
12061207
extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc);
12071208
extern int ceph_drop_caps_for_unlink(struct inode *inode);

0 commit comments

Comments
 (0)