Bug #69440
closedclient/mds: cap revoke stuck with concurrent readdir and rename operation
0%
Description
Reproducing this involves running concurrent readdir and rename operation on a directory from many clients. This results in the following cap scenario for the directory under which the operation is being performed:
"client_caps": [
{
"client_id": 123,
"pending": "pAsLsXs",
"issued": "pAsLsXs",
"wanted": "pAsLsXsFsxcral",
"last_sent": 115460
},
{
"client_id": 456,
"pending": "pAsLsXs",
"issued": "pAsLsXs",
"wanted": "pAsLsXsFsxcral",
"last_sent": 90925
},
{
"client_id": 789,
"pending": "pAsLsXs",
"issued": "pAsLsXsFs",
"wanted": "pAsLsXsFsxcral",
"last_sent": 748126
}
],
(note: client-id's have been mangled for this tracker report). The MDS sends a cap revoke for `Fs` to client.789 to satisfy the rename (or create). For some reason, the MDS hasn't heard back from the client for the cap revoke thereby causing the rename (mv) operations to block. There is a corresponding
client.XXX isn't responding to mclientcaps(revoke), ino <inode> pending pAsLsXs issued pAsLsXsFs, sent 61.575452seconds ago
warning. The scope of this tracker is to be able to run the reproducer script in sepia lab to be able to debug the issue.
VS Updated by Venky Shankar almost 2 years ago
- Priority changed from Normal to High
- Severity changed from 3 - minor to 2 - major
BH Updated by Brad Hubbard almost 2 years ago
/a/teuthology-2025-02-10_21:32:02-powercycle-squid-distro-default-smithi/8123957
2025-02-10T23:34:19.881 INFO:teuthology.orchestra.run.smithi079.stdout:2025-02-10T23:31:15.447641+0000 mds.a (mds.0) 12 : cluster [WRN] client.4566 isn't responding to mclientcaps(revoke), ino 0x10000003295 pending pAsLsXsFcb issued pAsLsXsFcrb, sent 63.354918 seconds ago
VS Updated by Venky Shankar over 1 year ago
- Project changed from CephFS to Linux kernel client
- Category changed from Testing to fs/ceph
- Assignee changed from Venky Shankar to Alex Markuze
- ceph-qa-suite kcephfs added
(Changing this to kernel client component since the bug has been identified there)
Copying from internal discussion (filenames sanitized)
I think I understand what's going on and in my opinion it's in the kernel driver. Here it is...
It all boils down to one particular client request that's of our interest:
2025-07-10T04:18:24.992+0000 7fb6ae245640 4 mds.0.server handle_client_request client_request(client.630601:55028 lookup #0x1000000000f/fileabc0 2025-07-10T04:18:24.992482+0000 caller_uid=1000750000, caller_gid=0{0,1000750000,})
i.e., a lookup request on "#0x1000000000f/fileabc0" from client.630601 with tid 55028 (the client which ends up in the MDS warning message ("not responding to cap revoke....")). This request is processed by the MDS and replied back to the client:
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.server reply to stat on client_request(client.630601:55028 lookup #0x1000000000f/fileabc0 2025-07-10T04:18:24.992482+0000 caller_uid=1000750000, caller_gid=0{0,1000750000,})
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.server respond_to_request: batch head request(client.630601:55028 nref=3 cr=0x555d8cafa300)
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 respond: responding to batch ops with result=0: [batch front=request(client.630601:55028 nref=3 cr=0x555d8cafa300)]
2025-07-10T04:18:25.045+0000 7fb6a8239640 7 mds.0.server reply_client_request 0 ((0) Success) client_request(client.630601:55028 lookup #0x1000000000f/fileabc0 2025-07-fileabc:18:24.992482+0000 caller_uid=1000750000, caller_gid=0{0,1000750000,})
And along with the reply, the MDS will encode inode/dentry/dir trace information of the parent and the looked up file (and snaprealm too, which is not of much importance for this bug):
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.server set_trace_dist snapid head
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.server set_trace_dist snaprealm snaprealm(0x1000000000c seq 1 lc 0 cr 1 cps 2 snaps {} last_modified 0.000000 change_attr 0 0x555d8c3e7440) len=144
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.cache.ino(0x1000000000f) pfile 0 pauth 0 plink 0 pxattr 0 plocal 0 mtime 2025-07-10T04:18:24.981482+0000 ctime 2025-07-10T04:18:24.981482+0000 change_attr 277039 valid=1
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.cache.ino(0x1000000000f) encode_inodestat issuing pAsLsXsFs seq 34097
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.cache.ino(0x1000000000f) encode_inodestat caps pAsLsXsFs seq 34097 mseq 0 xattrv 0
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.server set_trace_dist added diri [inode 0x1000000000f [...2,head] /volumes/csi/csi-vol-31f477b6-d431-4df3-82c7-66f844f893ee/2bcfc90d-7335-495b-9fb2-d92271296489/work/new1/ auth v1115502 ap=1 f(v0 m2025-07-10T04:18:24.981482+0000 5=5+0) n(v0 rc2025-07-10T04:18:24.981482+0000 b524288000 6=5+1)/n(v0 rc2025-07-10T04:18:24.938245+0000 b419430400 5=4+1) (isnap sync r=2) (inest lock) caps={591898=pAsLsXsFs/pAsLsXsFsxcral@39005,597609=pAsLsXsFs/pAsLsXsFsxcral@38842,630601=pAsLsXsFs/pAsLsXsFsxcral@34097} | request=0 lock=1 dirfrag=1 caps=1 dirtyrstat=1 dirty=1 waiter=0 authpin=1 0x555d8c3f4680]
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.server set_trace_dist added dir [dir 0x1000000000f /volumes/csi/csi-vol-31f477b6-d431-4df3-82c7-66f844f893ee/2bcfc90d-7335-495b-9fb2-d92271296489/work/new1/ [2,head] auth v=554329 cv=0/0 REP ap=1+6 state=1610874881|complete f(v0 m2025-07-10T04:18:24.981482+0000 5=5+0) n(v0 rc2025-07-10T04:18:24.981482+0000 b524288000 5=5+0) hs=5+5,ss=0+0 dirty=10 | child=1 dirty=1 waiter=0 authpin=1 0x555d8c3a7180]
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.locker issue_client_lease no/null lease on [dentry #0x1/volumes/csi/csi-vol-31f477b6-d431-4df3-82c7-66f844f893ee/2bcfc90d-7335-495b-9fb2-d92271296489/work/new1/fileabc0 [2,head] auth (dn sync r=1) (dversion lock w=1 last_client=630601) v=554328 ap=2 ino=0x10000000011 state=1610612736 | request=2 lock=2 inodepin=1 dirty=1 waiter=0 authpin=1 clientlease=0 0x555d8c404780]
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.cache.ino(0x10000000011) pfile 0 pauth 0 plink 1 pxattr 0 plocal 1 mtime 2025-07-09T14:37:45.685420+0000 ctime 2025-07-10T04:18:24.981482+0000 change_attr 27850 valid=1
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.cache.ino(0x10000000011) encode_inodestat issuing pAsXsFscr seq 8
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.cache.ino(0x10000000011) encode_inodestat caps pAsXsFscr seq 8 mseq 0 xattrv 4
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.cache.ino(0x10000000011) including xattrs version 4
2025-07-10T04:18:25.045+0000 7fb6a8239640 20 mds.0.server set_trace_dist added snap head in [inode 0x10000000011 [2,head] /volumes/csi/csi-vol-31f477b6-d431-4df3-82c7-66f844f893ee/2bcfc90d-7335-495b-9fb2-d92271296489/work/new1/fileabc0 auth v554328 ap=4 DIRTYPARENT s=104857600 n(v0 rc2025-07-10T04:18:24.981482+0000 b104857600 1=1+0) (iauth sync r=1) (ilink xlockdone x=1) (ixattr sync r=1) (iversion lock w=1 last_client=630601) (iquiesce lock w=1 last_client=630601) caps={591898=pAsXsFscr/-@1,597609=pAsXsFscr/-@15,630601=pAsXsFscr/-@8} | request=2 lock=7 caps=1 dirtyparent=1 dirty=1 waiter=0 authpin=1 0x555d8c406580]
2025-07-10T04:18:25.045+0000 7fb6a8239640 10 mds.0.541 send_message_client client.630601 100.64.0.6:0/4293942077 client_reply(???:55028 = 0 (0) Success)
IOW, snaprealm(0x1000000000c), inode/dir 0x1000000000f [parent], inode 0x10000000011 [looked up file]. This reply is received by the client. But before we see what happens in the client when receiving a reply, let's see this very (lookup) request from the client:
Jul 10 04:18:25 worker-0 kernel: ceph: __register_request 00000000730f4f1d tid 55028
...
...
Jul 10 04:18:25 worker-0 kernel: ceph: __prepare_send_request 00000000730f4f1d tid 55028 lookup (attempt 1)
...
Jul 10 04:18:25 worker-0 kernel: ceph: build_path on 000000005837199d 4 built 1000000000f 'fileabc0'
...
Jul 10 04:18:25 worker-0 kernel: ceph: dentry 000000005837199d 1000000000f/fileabc0
...
...
Jul 10 04:18:25 worker-0 kernel: ceph: r_parent = 00000000fcec9de6
r_parent is 00000000fcec9de6 (which is a part of the MDS request structure on the client side: struct inode r_parent; / parent dir inode */). If we refer back to Alex's update in comment #124
60c9 is Ino 000f
9de6 is Ino 0010
00000000fcec9de6 is inode #0x10000000010, which implies this lookup request is for 0x10000000010/fileabc0, however the path built by the client for the MDS request is 1000000000f/fileabc0. This is done by ceph_mds_build_path0, which essentially uses the linkages in the dentry* to get the parent dentry and thereby the parent inode (number)[1]. What I see happening is a rename reply (for fileabc0) interleaving during path building:
Jul 10 04:18:25 worker-0 kernel: ceph: fill_trace no dentry lease or dir cap
...
Jul 10 04:18:25 worker-0 kernel: ceph: src 000000005837199d 'fileabc0' dst 00000000c7b855a3 'fileabc0'
Jul 10 04:18:25 worker-0 kernel: ceph: fill_trace doing d_move 000000005837199d -> 00000000c7b855a3
...
Jul 10 04:18:25 worker-0 kernel: ceph: src 000000005837199d 'fileabc0' dst 00000000c7b855a3 'fileabc0'
Jul 10 04:18:25 worker-0 kernel: ceph: build_path on 000000005837199d 4 built 1000000000f 'fileabc0'
Jul 10 04:18:25 worker-0 kernel: ceph: dn 000000005837199d gets new offset 1151484276747796482
Jul 10 04:18:25 worker-0 kernel: ceph: dentry 000000005837199d 1000000000f/fileabc0
Jul 10 04:18:25 worker-0 kernel: ceph: final dn 000000005837199d
Jul 10 04:18:25 worker-0 kernel: ceph: fill_trace done err=0
Jul 10 04:18:25 worker-0 kernel: ceph: r_parent = 00000000fcec9de6
This happens here2 and if my code reading serves my right the d_move() is the thing that flips the parent dentry.
Now when the reply for the lookup is received (tid: 55028), the client will use r_parent from the request structure (for this tid)[3] and use the cap bits sent by the MDS to update the inode4 as per:
Jul 10 04:18:25 worker-0 kernel: ceph: __unregister_request 00000000730f4f1d tid 55028
Jul 10 04:18:25 worker-0 kernel: ceph: handle_reply tid 55028 result 0
...
...
Jul 10 04:18:25 worker-0 kernel: ceph: fill_trace 00000000730f4f1d is_dentry 1 is_target 1
Jul 10 04:18:25 worker-0 kernel: ceph: ceph_fill_inode 00000000fcec9de6 ino 10000000010.fffffffffffffffe v 2231004 had 2230991
Jul 10 04:18:25 worker-0 kernel: ceph: get_cap ctx=000000006f516d7e (2) 1040 = 15 used + 2 resv + 1023 avail
Jul 10 04:18:25 worker-0 kernel: ceph: __ceph_caps_issued 00000000fcec9de6 cap 000000008bf8d692 issued pAsLsXs
Jul 10 04:18:25 worker-0 kernel: ceph: 00000000fcec9de6 mode 042775 uid.gid 1000750000.1000750000
Jul 10 04:18:25 worker-0 kernel: ceph: add_cap 00000000fcec9de6 mds0 cap 6a3a2 pAsLsXsFs seq 34097
[0]: https://github.com/ceph/ceph-client/blob/for-linus/fs/ceph/mds_client.c#L2702
[1]: https://github.com/ceph/ceph-client/blob/for-linus/fs/ceph/mds_client.c#L2797
[2]: https://github.com/ceph/ceph-client/blob/for-linus/fs/ceph/inode.c#L1691
[3]: https://github.com/ceph/ceph-client/blob/for-linus/fs/ceph/inode.c#L1539
[4]: https://github.com/ceph/ceph-client/blob/for-linus/fs/ceph/inode.c#L1259
AM Updated by Alex Markuze over 1 year ago
The analysis is correct, fix sent upstream for review.
AM Updated by Alex Markuze over 1 year ago
- Status changed from New to Fix Under Review
VS Updated by Venky Shankar 5 months ago
- Status changed from Fix Under Review to Resolved
The kernel driver fixes are in mainline.
AM Updated by Alex Markuze 5 months ago
Picked up in v6.17-rc6 and released in v6.17. Present in all subsequent kernels (6.18, 6.19, etc.). It went upstream via the ceph-for-6.17-rc6 pull request.
Was also backported to RHEL 9 and RHEL 10.