)]}'
{
  "commit": "50958bb928bad3bdba9e5d1b7ff4bbadcf6951e6",
  "tree": "23ce551235ad3d707b341009a4749615ba0fb630",
  "parents": [
    "a6c4250b81bd30beae94e1b7a4b26fa1193ad2e4"
  ],
  "author": {
    "name": "Max Kellermann",
    "email": "max.kellermann@ionos.com",
    "time": "Mon Jul 06 17:06:59 2026 +0200"
  },
  "committer": {
    "name": "Ilya Dryomov",
    "email": "idryomov@gmail.com",
    "time": "Thu Jul 23 20:29:42 2026 +0200"
  },
  "message": "ceph: fix hanging __ceph_get_caps() with stale mds_wanted\n\nA reader can hang forever in __ceph_get_caps() when the client no\nlonger holds `FILE_RD`, but local cap state still says that the\ncapability is already wanted (via `mds_wanted`).\n\nOne way to trigger this is through MDS cap revocation.  If another\nclient performs a conflicting operation, the MDS can revoke `FILE_RD`\nfrom the reader; the next read then has to reacquire `FILE_RD`.  If\nthe cap update that should request `FILE_RD` never reaches the MDS\nafter `cap-\u003emds_wanted` was raised, the reader is left holding only\nnon-file caps while local `mds_wanted` still includes the file read\ncaps.\n\nIn that state, try_get_cap_refs() sees `need \u003c\u003d mds_wanted` and\nreturns 0, so __ceph_get_caps() just waits on `i_cap_wq`.  If the cap\nupdate that was supposed to request `FILE_RD never reaches the MDS\nafter `cap-\u003emds_wanted was` raised, no further request is sent and the\nwaiter can sleep indefinitely until unrelated cap traffic happens to\nwake it up.\n\nThe ordering issue is that `cap-\u003emds_wanted` is updated in\n__prep_cap() before the `CEPH_MSG_CLIENT_CAPS message` is actually\nqueued for send.  That makes one field serve two different meanings at\nonce: what this client wants, and what the client believes the MDS\nalready knows it wants.\n\nA proper fix would be to split those states and track whether a cap\nupdate is actually in flight or has been observed by the MDS.\nHowever, simply moving the `cap-\u003emds_wanted assignment` later would\nnot be sufficient: queueing the message in the messenger does not\nguarantee that the MDS processed that specific wanted set, and\nreconnect or message loss can still invalidate that assumption.\nFixing that properly would require a larger rework of the cap state\nmachine.\n\nTo allow simpler backports to stable kernels, this patch implements a\nsimpler workaround:\n\n- stop waiting forever in __ceph_get_caps(); after a bounded wait,\n  fall back to the renew path\n\n- make ceph_renew_caps() issue a synchronous `OPEN` request whenever\n  the inode still does not actually hold the wanted caps, instead of\n  only calling ceph_check_caps()\n\nThe extra issued-vs-wanted check in ceph_renew_caps() is necessary\nbecause the previous test only checked whether the inode still had any\nreal caps at all.  That is not enough after revocation: the client can\nstill hold something like `pLs` and yet be missing `FILE_RD`\ncompletely.  In that case, falling back to ceph_check_caps() is not\nsufficient, because it still trusts `cap-\u003emds_wanted` and may resend\nnothing.  By requiring `(issued \u0026 wanted) \u003d\u003d wanted` before taking the\nasynchronous path, the code only uses ceph_check_caps() when the\n`wanted caps` are already actually issued.  Otherwise, it sends the\nsynchronous `OPEN` renew.\n\nThis preserves the existing asynchronous fast path when the wanted\ncaps are already issued, avoids changing cap-state semantics, and\nfixes the hang by guaranteeing that a stalled waiter eventually\nretries through a path that does not rely on the stale `mds_wanted`\nstate.\n\n[ idryomov: move CEPH_GET_CAPS_WAIT_TIMEOUT from libceph.h to\n  mds_client.h, formatting ]\n\nCc: stable@vger.kernel.org\nFixes: 0a454bdd501a (\"ceph: reorganize __send_cap for less spinlock abuse\")\nSigned-off-by: Max Kellermann \u003cmax.kellermann@ionos.com\u003e\nReviewed-by: Alex Markuze \u003camarkuze@redhat.com\u003e\nSigned-off-by: Ilya Dryomov \u003cidryomov@gmail.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "77b23fe514257a029a1a0db1cffe4aa33e028c24",
      "old_mode": 33188,
      "old_path": "fs/ceph/caps.c",
      "new_id": "d7283fb54cec4d8edc18c7b8c966ea7fcb913edd",
      "new_mode": 33188,
      "new_path": "fs/ceph/caps.c"
    },
    {
      "type": "modify",
      "old_id": "71161f2b215136ecfe404947dd36671e721130b7",
      "old_mode": 33188,
      "old_path": "fs/ceph/file.c",
      "new_id": "a4a2a4b6a027d4da63bdd9e12819b2eeece65bc7",
      "new_mode": 33188,
      "new_path": "fs/ceph/file.c"
    },
    {
      "type": "modify",
      "old_id": "731d6ad04956dd936027e660af80aaa8e05fb83b",
      "old_mode": 33188,
      "old_path": "fs/ceph/mds_client.h",
      "new_id": "0ece4c9e3529f55e6bb797aca336c1e147b71641",
      "new_mode": 33188,
      "new_path": "fs/ceph/mds_client.h"
    }
  ]
}
