Project

General

Profile

Actions

Bug #81672

open
XL XL

mds: segfault in MDCache::project_rstat_inode_to_frag() with mds_snap_rstat after a stray dir's old inode is purged

Bug #81672: mds: segfault in MDCache::project_rstat_inode_to_frag() with mds_snap_rstat after a stray dir's old inode is purged

Added by Xiubo Li about 2 months ago. Updated about 2 months ago.

Status:
Fix Under Review
Priority:
Normal
Assignee:
Category:
-
Target version:
Due date:
% Done:

0%

Source:
Community (dev)
Backport:
tentacle, squid, umbrella
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(FS):
Labels (FS):
crash, snapshots
Pull request ID:
Tags (freeform):
Merge Commit:
Fixed In:
Released In:
Upkeep Timestamp:

Description

With mds_snap_rstat enabled, ceph-mds segfaults while propagating the rstats
of a stray directory:

 *** Caught signal (Segmentation fault) **
 in thread mds-log-trim (also seen in mds-rank-fin via "flush journal")
 1: /lib64/libc.so.6(+0x1a0b0)
 2: (MDCache::project_rstat_inode_to_frag(boost::intrusive_ptr<MutationImpl> const&, CInode*, CDir*, snapid_t, int, SnapRealm*)+0x32e)
 3: (CDir::assimilate_dirty_rstat_inodes(boost::intrusive_ptr<MutationImpl>&)+0x10e)
 5: (Locker::scatter_writebehind(ScatterLock*)+0x467)
 6: (Locker::scatter_nudge(ScatterLock*, MDSContext*, bool)+0x567)
 7: (LogSegment::try_to_expire(MDSRank*, C_GatherBuilderBase<...>&, int)+0xb16)
 8: (MDLog::try_expire(std::shared_ptr<LogSegment> const&, int)+0x66)
 9: (MDLog::trim()+0x5b5)
 10: (MDLog::log_trim_upkeep()+0x3e8)

The standby that takes over crashes the same way during replay/trim.

It is hit by qa/tasks/cephfs/volumes/test_clone_stats.py
(TestCloneProgressReporter), which sets mds_snap_rstat=true.

Root cause:

1. The stray dirs (~mdsN/strayX) live in the global snaprealm, so once any
snapshot has been taken, cow_old_inode() cows an old inode for them.
As its rstat is not fully accounted, it also records the snapid in
dirty_old_rstats.
2. Committing the ~mdsN dirfrag calls CInode::purge_stale_snap_data() on
the stray dir. No snapshot covers that old inode, so it is purged, but
its dirty_old_rstats entry is left behind.
3. The next nest scatter of ~mdsN (e.g. from LogSegment::try_to_expire)
runs project_rstat_inode_to_frag(), which does
cur->get_old_inodes()->at(p) for each dirty_old_rstats entry.
old_inodes is now null -> SIGSEGV. When only some old inodes were
purged it would throw std::out_of_range instead.

From the log (mds.0, stray0 = 0x600):

  ... ino(0x600) cow_old_inode head to [2,2] on [inode 0x600 [...3,head] ~mds0/stray0/ ...]
  ... ino(0x600) purge_stale_snap_data
  ... ino(0x600)  purging old_inode [2,2]
  ... dir(0x100) assimilate_dirty_rstat_inodes
  ... projected_rstat_inode_to_frag first 3 linkunlink 0 [inode 0x600 ...]
  <segfault>


Reproducer (vstart, 1 MDS, ceph-fuse), crashes in the first round:
  ceph config set mds mds_snap_rstat true
  mkdir $MNT/d
  mkdir $MNT/d/.snap/s && rmdir $MNT/d/.snap/s
  for i in $(seq 10); do echo data > $MNT/d/f$i; done; sync
  rm -f $MNT/d/f*; sync
  ceph tell mds.a flush journal

XL Updated by Xiubo Li about 2 months ago Actions #1

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

Also available in: PDF Atom