Project

General

Profile

Actions

Bug #62663

closed
AA XL

MDS: inode nlink value is -1 causing MDS to continuously crash

Bug #62663: MDS: inode nlink value is -1 causing MDS to continuously crash

Added by Austin Axworthy over 3 years ago. Updated about 1 month ago.

Status:
Backporting
Priority:
High
Assignee:
Category:
Correctness/Safety
Target version:
Due date:
% Done:

0%

Source:
Community (user)
Backport:
tentacle,squid
Regression:
No
Severity:
1 - critical
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(FS):
MDS
Labels (FS):
crash
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-4651-g859472b905
Released In:
Upkeep Timestamp:
2026-10-19T10:29:57+00:00

Description

All MDS daemons are continuously crashing. The logs are reporting an inode nlink value is set to -1. I have included details below of the filesystem workflow.

Workflow:
This filesystem has a heavy workload using hardlinks. Data within the filesystem can be processed with up to 10-20 processes at a time. Each process will generate a hardlink, meaning there could be up to 20 hardlinks at a time. Once the processing is complete the hard links are removed and cleaned up.
Leading up to the crash, the MDS performance was very degraded, which lead to a restart of the active MDS. The secondary daemon was experiencing similar issues, and eventually the MDS was failed back over to the original daemon. The original MDS then entered a continuous crash, causing the filesystem to go offline. When investigating the logs the following error was found, inode 0x10005f79654 nl=-1 as well as FAILED ceph_assert(stray_in->get_inode()->nlink >= 1).

4982059 2023-07-12T13:16:33.413-0400 7f337eec5700 10 mds.0.cache.strays  inode is [inode 0x10005f79654 [...10,head] ~mds0/stray1/10005f79654 auth v22224244 snaprealm=0x55b0a8b17600 DIRTYPARENT s=13123258 nl=-1 n(v04982059  rc2023-07-03T14:19:43.854341-0400 b13123258 1=1+0) (iversion lock) | openingsnapparents=0 dirtyparent=1 dirty=0 0x55b0aa54ec00]
4982060 2023-07-12T13:16:33.413-0400 7f337eec5700 20 mds.0.cache.strays _eval_stray_remote [dentry #0x100/stray1/10005f79654 [10,head] auth (dversion lock) v=22224244 ino=0x10005f79654 state=1342177296 | inodepin=14982060  dirty=0 0x55b0a9306f00]
4982061 2023-07-12T13:16:33.414-0400 7f337eec5700 -1 /home/jenkins-build/build/workspace/ceph-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/17.2.6/rpm/el84982061 /BUILD/ceph-17.2.6/src/mds/StrayManager.cc: In function 'void StrayManager::_eval_stray_remote(CDentry*, CDentry*)' thread 7f337eec5700 time 2023-07-12T13:16:33.414966-0400
4982062 /home/jenkins-build/build/workspace/ceph-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/17.2.6/rpm/el8/BUILD/ceph-17.2.6/src/mds/StrayManager.cc: 64982062 22: FAILED ceph_assert(stray_in->get_inode()->nlink >= 1)

A "cephfs-data-scan scan_links" was done after removing the omap key of the object reporting the issue. The output of the scan_links is as follows.

]

2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609ae80 expected 1 has 0
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609ae85 from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609ae85 expected 1 has 0
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609ae8f from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609ae8f expected 1 has 0
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609aec5 from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609aec5 expected 1 has 0
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609aeda from 0x1000609aed9/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609aede expected 1 has 0 
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609aeed expected 1 has 0 
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609aefb expected 1 has 0 
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609af05 expected 1 has 0 
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609af0e expected 1 has 0 
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609af1b from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7700195a4740 -1 datascan.scan_links: Bad link on 0x1000609af1b expected 1 has 0 
2023-07-24T21:23:19.830-0400 700195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609af3a from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Bad link on 0x1000609af3a expected 1 has 0
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609af44 from 0x10005fa3bd4/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Bad nlink on 0x1000609af44 expected 1 has 0 
2023-07-24T21:23:19.830-0400 700195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609af6c from 0x1000609af6b/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609b32f from 0x1000609b32c/filename
2023-07-24T21:23:19.830-0400 700195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609c012 from 0x1000609c011/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609c968 from 0x1000609c966/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609cb02 from 0x1000609cb00/filename
2023-07-24T21:23:19.830-0400 700195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609d3c2 from 0x1000609d3c1/filename
2023-07-24T21:23:19.830-0400 7100195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609d523 from 0x1000609d522/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609d7fc from 0x1000609d7fa/filename
2023-07-24T21:23:19.830-0400 7f00195a4740 -1 datascan.scan_links: Remove duplicated ino 0x0x1000609dbec from 0x1000609dbea/filename

It was determined that the specific inode reporting the error had 3 hardlinks, one of which was in the process of being deleted when the issues first presented.

The filesystem has a single rank with a standby daemon. This cluster has had ENOSPCE issues in the past due to the number of stray files generated by the deletion of hardlinks.


Related issues 2 (2 open — 0 closed)

Copied to CephFS - Backport #81891: squid: MDS: inode nlink value is -1 causing MDS to continuously crashNewXiubo Li

Actions
Copied to CephFS - Backport #81892: tentacle: MDS: inode nlink value is -1 causing MDS to continuously crashFix Under ReviewXiubo Li

Actions

VS Updated by Venky Shankar about 3 years ago Actions #1

  • Project changed from Ceph to CephFS
  • Category set to Correctness/Safety
  • Target version set to v19.0.0
  • Component(FS) MDS added

VS Updated by Venky Shankar about 3 years ago Actions #2

Austin Axworthy wrote:

All MDS daemons are continuously crashing. The logs are reporting an inode nlink value is set to -1. I have included details below of the filesystem workflow.

Workflow:
This filesystem has a heavy workload using hardlinks. Data within the filesystem can be processed with up to 10-20 processes at a time. Each process will generate a hardlink, meaning there could be up to 20 hardlinks at a time. Once the processing is complete the hard links are removed and cleaned up.
Leading up to the crash, the MDS performance was very degraded, which lead to a restart of the active MDS. The secondary daemon was experiencing similar issues, and eventually the MDS was failed back over to the original daemon. The original MDS then entered a continuous crash, causing the filesystem to go offline. When investigating the logs the following error was found, inode 0x10005f79654 nl=-1 as well as FAILED ceph_assert(stray_in->get_inode()->nlink >= 1).

The ceph version used here (17.2.6) is pretty recent which is makes me worried about this bug lurking around. I don't have an explanation about the root cause atm.

[...]

A "cephfs-data-scan scan_links" was done after removing the omap key of the object reporting the issue. The output of the scan_links is as follows.

Did you flush the mds journal before removing the omap key?

The scan tool detected duplicate primary inodes. I think there is a corner case that could possibly make this happen - need to carefully look at that bit.

Anyhow, for the duplicate primaries, the scan tool will choose the one which has the highest version and remove others and expects the number of hardlinks to match the nlink count in the inode. The nlink count in the inode is fixed up with the number of hardlinks it found while scanning. I hope tool recovered the file system?

[...]

It was determined that the specific inode reporting the error had 3 hardlinks, one of which was in the process of being deleted when the issues first presented.

Nothing unusual stands out with having a bunch of hardlinks and deleting some. The unlink code probably needs to be carefully inspected to explain this problem.

Could you help us out with anything else out of the ordinary - custom packages, destructive commands/tools used when the file system was online, etc.?

VS Updated by Venky Shankar about 3 years ago Actions #3

  • Priority changed from Normal to High
  • Source set to Community (user)
  • Severity changed from 2 - major to 1 - critical

AA Updated by Austin Axworthy about 3 years ago Actions #4

The issue originally occurred on 15.2.17. Apologies for the confusion on that the cluster during the troubleshooting.

Originally the omap key value was removed, but replaying the journal recreated the key. Removing the omap key and flushing the MDS journal allowed the MDS to recover.

Nothing out of the ordinary is running on the cluster, it is a bare metal deployment using ceph-ansible. The clients connect to the storage through CephFS mounts. No other software is stored on the cluster nodes.

VS Updated by Venky Shankar about 3 years ago Actions #5

  • Status changed from New to Can't reproduce

Hi Austin,

Austin Axworthy wrote:

The issue originally occurred on 15.2.17. Apologies for the confusion on that the cluster during the troubleshooting.

Originally the omap key value was removed, but replaying the journal recreated the key. Removing the omap key and flushing the MDS journal allowed the MDS to recover.

Nothing out of the ordinary is running on the cluster, it is a bare metal deployment using ceph-ansible. The clients connect to the storage through CephFS mounts. No other software is stored on the cluster nodes.

Since we do not have enough point to debug and given that this issue was first experienced in. EOL'd release, I'm marking this tracker as "Can't reproduce". Please reopen if this is seen again and it would be immensely helpful that MDS debug logs be shared.

XL Updated by Xiubo Li 6 months ago Actions #6

  • Status changed from Can't reproduce to New
  • Target version deleted (v19.0.0)

This could be seen again:

2026-06-14T07:59:45.950+0000 779a9ead0640  0 mds.1.cache.ino(0x10001e21621) have open dirfrag * but not leaf in fragtree_t(*^2 01*^1 11*^1): [dir 0x10001e21621 /file/643/df445c3e1-ae29-2f3a-93f3-3e3f36333c3a/a/cur/ [2,head] auth{0=2} v=0 cv=0/0 state=1140850688 f() n() hs=76+0,ss=0+0 | child=1 replicated=1 0x596439b11a80]
2026-06-14T07:59:46.040+0000 779aa0ad4640  2 mds.1.cache Memory usage:  total 5508812, rss 5275596, heap 207124, baseline 182548, 0 / 1031795 inodes have caps, 0 caps, 0 caps per inode
2026-06-14T07:59:46.793+0000 779a9ead0640 -1 /runner/scratch/rpms/ceph/18.2.7/BUILD/ceph-18.2.7/src/mds/StrayManager.cc: In function 'void StrayManager::_eval_stray_remote(CDentry*, CDentry*)' thread 779a9ead0640 time 2026-06-14T07:59:46.793257+0000
/runner/scratch/rpms/ceph/18.2.7/BUILD/ceph-18.2.7/src/mds/StrayManager.cc: 628: FAILED ceph_assert(stray_in->get_inode()->nlink >= 1)

 ceph version 18.2.7 (f4de932220456e216f630e5325e9a544041a70a9) reef (stable)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x117) [0x779aaa550ced]
 2: /usr/lib64/ceph/libceph-common.so.2(+0x16beac) [0x779aaa550eac]
 3: (StrayManager::_eval_stray_remote(CDentry*, CDentry*)+0x603) [0x5963a52e3b83]
 4: (CDir::_load_dentry(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, snapid_t, ceph::buffer::v15_2_0::list&, int, std::set<snapid_t, std::less<snapid_t>, std::allocator<snapid_t> > const*, double, bool*)+0xec3) [0x5963a536d893]
 5: (CDir::_omap_fetched(ceph::buffer::v15_2_0::list&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, ceph::buffer::v15_2_0::list, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, ceph::buffer::v15_2_0::list> > >&, bool, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int)+0x944) [0x5963a536f304]
 6: /usr/bin/ceph-mds(+0x3458eb) [0x5963a53698eb]
 7: (MDSContext::complete(int)+0x5c) [0x5963a53f078c]
 8: (MDSIOContextBase::complete(int)+0x36c) [0x5963a53f0c4c]
 9: (Finisher::finisher_thread_entry()+0x17d) [0x779aaa606f6d]
 10: /lib64/libc.so.6(+0x8a19a) [0x779aa9f0119a]
 11: /lib64/libc.so.6(+0x10f240) [0x779aa9f86240]

2026-06-14T07:59:46.793+0000 779a9ead0640 -1 *** Caught signal (Aborted) **
 in thread 779a9ead0640 thread_name:mds-rank-fin

XL Updated by Xiubo Li 6 months ago Actions #7

  • Assignee set to Xiubo Li

XL Updated by Xiubo Li 6 months ago Actions #8

  • Status changed from New to In Progress

VS Updated by Venky Shankar 6 months ago Actions #9

  • Target version set to v21.1.0
  • Backport set to tentacle,squid
  • Affected Versions v18.2.7 added
  • Labels (FS) crash added

VS Updated by Venky Shankar 5 months ago Actions #11

  • Status changed from In Progress to Fix Under Review
  • Pull request ID set to 69572

XL Updated by Xiubo Li 5 months ago Actions #12

We also hit the nlink < 0 case:

48054 
48055 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c43a1 expected 0 has 1
48056 
48057 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c43a3 expected 0 has 1
48058 
48059 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c43f8 expected 0 has 1
48060 
48061 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c478c expected 0 has -1                                                                                                                                                                       
48062 
48063 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c48d9 expected 1 has 0
48064 
48065 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c4f35 expected 1 has 0
48066 
48067 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c599b expected 0 has 1
48068 
48069 2026-07-01T12:16:44.996+0000 7f5ae0d1c500 -1 datascan.scan_links: Bad nlink on 0x2000c0c5a81 expected 0 has 1
48070 

XL Updated by Xiubo Li 5 months ago Actions #13

Appended a new commit to fix the race windows between rename/link/unlink,etc and notify_stray():

https://github.com/ceph/ceph/pull/69572/commits/eae58333b4fdcfe36711671882e43a3ddd03fd9e

Background

Key Design Points

1. Primary unlink immediately moves the inode to stray — does not wait for nlink to reach zero

  // handle_client_unlink → _unlink_local
  if (dnl->is_primary()) {
      straydn = prepare_stray_dentry(mdr, dnl->get_inode());  // ← always created
  }
  if (straydn) {
      straydn->push_projected_linkage(in);  // ← moves to stray immediately, regardless of nlink
  }
  pi.inode->nlink--;
The primary dentry is the inode's "home identity." When it is unlinked, the inode immediately enters the stray directory. nlink is decremented but may not reach zero. Later, _eval_stray checks nlink: reintegrate if > 0, purge if <= 0. 2. CDir::commit() and Journal flush are not atomic
  Journal flush ✅  event durable on RADOS
          │
          ├─ callback fires (_unlink_local_finish)
          │    · mdr->apply()      in-memory state committed
          │    · mark_dirty()       directory marked dirty
          │    · respond_to_request()  reply sent to client
          │
          └─ CDir::commit()  ❌  directory omap write is asynchronous;
                 │                may happen long after callback
                 │
                 └─ MDS crashes here → directory omap on RADOS is still the old version
3. respond_to_request() drops all xlocks
  respond_to_request(mdr, 0)
    → reply_client_request()
      → request_drop_non_rdlocks(mdr)  // releases linklock and all other non-read locks
---
Scenario 1: nlink Underflow (0 → −1) Initial State
    /foo/bar (primary) ──→ inode (nlink=2)
    /baz/qux (remote)  ──→ same inode
Normal Execution (before crash)
  time ────────────────────────────────────────────────────────

    unlink /foo/bar (primary)              unlink /baz/qux (remote)
    ──────────────────────                ────────────────────────
    _unlink_local(straydn set)             _unlink_local(straydn=NULL)
      nlink: 2→1                            nlink: 1→0
      inode moved to /stray/                remote dentry → null
      journal event A flush ✅              journal event B flush ✅
            │                                     │
            ▼                                     ▼
    _unlink_local_finish(A)               _unlink_local_finish(B)
      notify_stray: nlink=1 (>0)            notify_stray: nlink=0 (<=0)
      → _eval_stray_remote attempts        → purge path
        reintegration                              │
                                            CDir::commit()
                                            neither dir's omap has been written yet!


MDS Crash + Recovery RADOS state (after crash):
    Journal:            ✅  event A + event B both durable
    /foo/ omap:         ❌  bar → primary(ino)   (stale primary)
    /baz/ omap:         ❌  qux → remote(ino)    (stale remote)
    inode nlink:        ✅  0
Recovery flow:
    ① Journal replay → nlink=0, inode in /stray/
    ② Load /baz/ dirfrag → decodes stale remote "qux → ino=X" 
       → link_remote(dnl, in)
         → in->add_remote_parent(this)  ← discovery mechanism, attaches to list
         → eval_remote(this)
           → _eval_stray_remote(stray_dn, remote_dn)
             → nlink <= 0 → return     ← discovers but defers to purge
    ③ _eval_stray purge path:
         → iterates remote_parents, unlink_remote cleans up the residue
         → enqueue(dn, false) final deletion
▎ Why is stale primary /foo/bar harmless? During recovery the inode already has /stray/xxx as its primary parent. An inode can only have one primary parent, so the stale primary load is naturally ignored. Both directories have stale data on omap — the difference is that primary has natural exclusivity protection. Race Window (Old Code)
  _unlink_local_finish(B) — OLD:

    respond_to_request(mdr, 0)
      → request_drop_non_rdlocks(mdr)       ← linklock xlock released

        ┌─ Race window ────────────────────────────────────────┐
        │                                                      │
        │  Path A: client replay unlink                        │
        │    Client never received reply before MDS crashed     │
        │    → have_completed_request(tid) = false             │
        │    → re-executes _unlink_local                       │
        │    → pi.inode->nlink--                               │
        │    → nlink: 0 → -1                                   │
        │                                                      │
        │  Path B: peer remote unlink                          │
        │    Another MDS rank initiates remote unlink           │
        │    → handle_peer_link_prep(OP_UNLINKPREP)            │
        │    → pi.inode->nlink--                               │
        │    → nlink: 0 → -1                                   │
        │                                                      │
        └──────────────────────────────────────────────────────┘

    notify_stray(straydn)
      → _eval_stray(dn)
        → nlink == -1  ← reads the race-contaminated value!

    _eval_stray (before cf4cc0b530c):
      if (nlink == 0)  → -1 != 0, skips purge  →  inode leaked forever

    _eval_stray_remote (before cf4cc0b530c):
      assert(nlink >= 0)  → -1 triggers assertion  →  MDS CRASH
After Fix
  _unlink_local_finish(B) — NEW:

    notify_stray(straydn)     ← lock still held, nlink guaranteed to be 0 (correct)
      → _eval_stray(dn)
        → nlink == 0, enters purge
        → iterates remote_parents, unlink_remote cleans up
        → enqueue(dn, false)

    respond_to_request(mdr, 0)   ← lock released only here, race window eliminated
notify_stray executes under xlock protection — the nlink it reads is the genuine result of the just-completed unlink. Even if replay later does nlink-- again, the stray evaluation has already completed and is unaffected. ---
Scenario 2: Concurrent Link Causes nlink Jump (0 → 1)
  _unlink_local_finish — OLD:

    respond_to_request(mdr, 0)     ← linklock released

        ┌─ Race window ──────────────────────────────────┐
        │  Concurrent link request:                       │
        │    handle_client_link()                         │
        │    → xlock linklock ✓ (just released)           │
        │    → nlink: 0 → 1                               │
        │    → discovers inode is in stray                │
        │    → reintegrate_stray (async rename)           │
        └────────────────────────────────────────────────┘

    notify_stray(straydn)
      → _eval_stray(dn)
        → nlink == 1 (>0)
        → does not purge
        → _eval_stray_remote(dn, NULL)  ← attempts reintegration a second time

Consequence: two reintegration requests may interfere with each other.
Stray evaluation is based on a value that is not the
true result of the unlink operation. After Fix
    notify_stray(straydn)     ← under lock: nlink==0, enters purge
    respond_to_request(mdr, 0)   ← when lock is released, purge is already scheduled;
                                    link request cannot intervene
Not purging may seem correct (someone did link it again), but reintegrate_stray is asynchronous and has no coordination with the purge path — double processing is possible. Evaluating under lock guarantees atomicity of the decision. ---
Scenario 3: Wider Race Window in _rename_finish
  _rename_finish — OLD:

    respond_to_request(mdr, 0)           ← releases all xlocks

    if (need_eval)
        mds->locker->eval(in, CEPH_CAP_LOCKS, true)
                                         ← CAP evaluation is non-trivial, can take time
        ┌─ Race window (wider than Scenario 1) ────────────┐
        │  All concurrent operations from Scenarios 1+2:     │
        │  · client replay unlink → nlink--                 │
        │  · peer remote unlink   → nlink--                 │
        │  · concurrent link      → nlink++                 │
        └───────────────────────────────────────────────────┘

    if (straydn && ...)
        mdcache->notify_stray(straydn)  ← nlink may already be rewritten


After Fix
  _rename_finish — NEW:

    if (straydn && ...)
        mdcache->notify_stray(straydn)  ← evaluate first, lock still held

    respond_to_request(mdr, 0)         ← release locks afterward

    if (need_eval)
        mds->locker->eval(in, ...)     ← CAP evaluation comes last, doesn't affect stray

The stray status of the source inode is determined as soon as _rename completes. Evaluating before lock release prevents the rename's side effect from being contaminated by subsequent concurrent operations.

UB Updated by Upkeep Bot about 1 month ago Actions #14

  • Copied to Backport #81891: squid: MDS: inode nlink value is -1 causing MDS to continuously crash added

UB Updated by Upkeep Bot about 1 month ago Actions #15

  • Copied to Backport #81892: tentacle: MDS: inode nlink value is -1 causing MDS to continuously crash added

UB Updated by Upkeep Bot about 1 month ago Actions #16

  • Status changed from Fix Under Review to Backporting
  • Merge Commit set to 859472b905ccbb91f38e9ae15b9d4e7f604a60e7
  • Fixed In set to v21.3.0-4651-g859472b905
  • Upkeep Timestamp set to 2026-10-19T10:29:57+00:00
Actions

Also available in: PDF Atom