Skip to content

tools/cephfs: allow scanning and flushing journal in batches - #68813

Merged
vshankar merged 5 commits into
ceph:mainfrom
dparmar18:fix-cephfs-journal-tool
Jul 16, 2026
Merged

vshankar merged 5 commits into
ceph:mainfrom
dparmar18:fix-cephfs-journal-tool

Conversation

@dparmar18

@dparmar18 dparmar18 commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

NOTE: exclusive to only event recover_dentries

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
EventMap called events. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient.

The way to curb the memory bomb is to scan and flush journal in batches. The
flush boundary is based on the batch size and at event EVENT_SUBTREEMAP or
EVENT_SUBTREEMAP_TEST(subtree event(s) mark a clear boundary). The knob to
control this setting is via providing --max-rss <bytes> with the journal
tool command. This patch divides the provided limit by three to create the
batch since it is observed that the decoded journal events weight on an avg
~3x the encoded stream.

Co-authored-by: Patrick Donnelly [email protected]
Signed-off-by: Dhairya Parmar [email protected]

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions github-actions Bot added the cephfs Ceph File System label May 8, 2026
@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch 4 times, most recently from b5ae824 to 111f6ea Compare May 8, 2026 15:06
@dparmar18
dparmar18 marked this pull request as ready for review May 8, 2026 15:06
@dparmar18
dparmar18 requested a review from batrick May 8, 2026 15:08
@dparmar18 dparmar18 changed the title tools/cephfs: do not load entire decoded journal in memory tools/cephfs: flush every journal event as soon as it is scanned May 8, 2026

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

@batrick

batrick commented May 8, 2026

Copy link
Copy Markdown
Member

This PR has been added to main integration testing by pdonnell started 2026-05-08-16:17.

@batrick

batrick commented May 8, 2026

Copy link
Copy Markdown
Member

@dparmar18 please don't forget to make a tracker ticket for backport. Please document here what local testing you've done.

If I don't get around to it, please schedule recovery tests (any test runnning cephfs-journal-tool) using the branch I created above.

@vshankar

Copy link
Copy Markdown
Contributor

@dparmar18 please don't forget to make a tracker ticket for backport. Please document here what local testing you've done.

https://tracker.ceph.com/issues/76422

The above tracker additionally demands explaining why the messenger layer holds the anonymous memory after the journal tool has decoded the buffers, I would consider this change to partially fix the problem (use Partially-Fixes: ... in the commit message).

If I don't get around to it, please schedule recovery tests (any test runnning cephfs-journal-tool) using the branch I created above.

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove Co-authored-by for yourself since you already have a signed-off-by tag.

Also as discussed in slack, a test case simulating the journal tool processing a large-ish journal would be beneficial.

Comment thread src/tools/cephfs/JournalTool.cc Resolved
Comment thread src/tools/cephfs/EventOutput.cc Resolved
Comment thread src/tools/cephfs/JournalTool.cc Resolved
@vshankar

Copy link
Copy Markdown
Contributor

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
EventMap called events. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient. The way to solve
this is to flush the journal entry object into the backing store (i.e. RADOS)
as soon as it is scanned in JournalScanner::scan_events() via a callback
registered in JournalTool::main_event.

I let a comment above. Please explain in the commit message as to how the RSS bloat is taken care by processing the journal entries as they are scanned.

@dparmar18

Copy link
Copy Markdown
Contributor Author

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
EventMap called events. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient. The way to solve
this is to flush the journal entry object into the backing store (i.e. RADOS)
as soon as it is scanned in JournalScanner::scan_events() via a callback
registered in JournalTool::main_event.

I let a comment above. Please explain in the commit message as to how the RSS bloat is taken care by processing the journal entries as they are scanned.

its there -> "flush the journal entry object as soon as it is scanned"

@vshankar

vshankar commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
EventMap called events. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient. The way to solve
this is to flush the journal entry object into the backing store (i.e. RADOS)
as soon as it is scanned in JournalScanner::scan_events() via a callback
registered in JournalTool::main_event.

I let a comment above. Please explain in the commit message as to how the RSS bloat is taken care by processing the journal entries as they are scanned.

its there -> "flush the journal entry object as soon as it is scanned"

I read that, but that's not enough, especially if we are not 100% sure that the messenger buffers would be freed or not.

EDIT: fixed typo.

@github-actions github-actions Bot added the tests label May 11, 2026
@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch 6 times, most recently from 7fee9b2 to dcd86e1 Compare May 12, 2026 07:22
@dparmar18

Copy link
Copy Markdown
Contributor Author

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
EventMap called events. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient. The way to solve
this is to flush the journal entry object into the backing store (i.e. RADOS)
as soon as it is scanned in JournalScanner::scan_events() via a callback
registered in JournalTool::main_event.

I let a comment above. Please explain in the commit message as to how the RSS bloat is taken care by processing the journal entries as they are scanned.

its there -> "flush the journal entry object as soon as it is scanned"

I read that, but that's not enough, especially if we are not 100% sure that the messenger buffers would be freed or not.

EDIT: fixed typo.

once you validate the corretness of https://tracker.ceph.com/issues/76422#note-6, i'll add it to the commit description

@dparmar18

Copy link
Copy Markdown
Contributor Author

apart from this, the PR is ready @vshankar

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits. Otherwise LGTM.

Comment thread qa/tasks/cephfs/test_journal_repair.py Resolved
Comment thread qa/tasks/cephfs/test_journal_repair.py Resolved
self.fs.set_joinable(False)

# Set the MDS cache limit to 32GiB
self.config_set('mds', 'mds_cache_memory_limit', '34359738368')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why would this be required? Does the test depend on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num of segments and the trim interval are both drastically skewed, it should stress out the mds cache, no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but I doubt it to this extent. Have you done preliminary tests to see how much cache memory the MDS actually uses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. its an assumption based on the data shared in private forum.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe it actually does. Let's do a sample test to see how much is consumed.

@vshankar

Copy link
Copy Markdown
Contributor

@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch from dcd86e1 to fbe44e7 Compare May 13, 2026 07:37
Comment thread qa/tasks/cephfs/test_journal_repair.py Outdated
(
d="w${w}"
mkdir -p "$d/a" "$d/b" "$d/c"
for ((i = 0; i < 100000; i++)); do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce to 1/10th?

@dparmar18 dparmar18 Jun 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test case now generates 1.2M metadata ops. this looks to be not too less, not too more

@dparmar18

Copy link
Copy Markdown
Contributor Author

a detailed RCA on why the memory bloat takes place while replaying the journal and while recovering dentries is added as a tracker comment https://tracker.ceph.com/issues/76422#note-10. Thanks to @vshankar for helping me point in the right direction.

@vshankar

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by vshankar started 2026-06-23-12:41.

@vshankar

vshankar commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@dparmar18 - It is possible that this change is causing a test failure. See: https://pulpito.ceph.com/vshankar-2026-06-25_12:37:46-fs-wip-vshankar-testing-20260624.105849-distro-default-trial/316056/

2026-06-25T14:05:48.392 INFO:tasks.cephfs_test_runner:======================================================================
2026-06-25T14:05:48.392 INFO:tasks.cephfs_test_runner:ERROR: test_rebuild_simple (tasks.cephfs.test_recovery_pool.TestRecoveryPool.test_rebuild_simple)
2026-06-25T14:05:48.392 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2026-06-25T14:05:48.392 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-ci_ddf9bbff4f684516188a1c2332ddc183964ff266/qa/tasks/cephfs/test_recovery_pool.py", line 179, in test_rebuild_simple
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:    self._rebuild_metadata(SimpleOverlayWorkload())
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-ci_ddf9bbff4f684516188a1c2332ddc183964ff266/qa/tasks/cephfs/test_recovery_pool.py", line 151, in _rebuild_metadata
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:    recovery_fs.journal_tool(['event', 'recover_dentries', 'list',
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-ci_ddf9bbff4f684516188a1c2332ddc183964ff266/qa/tasks/cephfs/filesystem.py", line 1751, in journal_tool
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:    return self._run_tool("cephfs-journal-tool", args, fs_rank, quiet)
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-ci_ddf9bbff4f684516188a1c2332ddc183964ff266/qa/tasks/cephfs/filesystem.py", line 1730, in _run_tool
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:    r = self.tool_remote.sh(script=base_args + args, stdout=StringIO()).strip()
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_3d64f77ffa2f18cfd41babdfd2412dc35d467e94/teuthology/orchestra/remote.py", line 97, in sh
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:    proc = self.run(**kwargs)
2026-06-25T14:05:48.393 INFO:tasks.cephfs_test_runner:           ^^^^^^^^^^^^^^^^^^
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_3d64f77ffa2f18cfd41babdfd2412dc35d467e94/teuthology/orchestra/remote.py", line 596, in run
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:    r = self._runner(client=self.ssh, name=self.shortname, **kwargs)
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_3d64f77ffa2f18cfd41babdfd2412dc35d467e94/teuthology/orchestra/run.py", line 461, in run
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:    r.wait()
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_3d64f77ffa2f18cfd41babdfd2412dc35d467e94/teuthology/orchestra/run.py", line 161, in wait
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:    self._raise_for_status()
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_3d64f77ffa2f18cfd41babdfd2412dc35d467e94/teuthology/orchestra/run.py", line 181, in _raise_for_status
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:    raise CommandFailedError(
2026-06-25T14:05:48.394 INFO:tasks.cephfs_test_runner:teuthology.exceptions.CommandFailedError: Command failed on trial089 with status 251: 'cephfs-journal-tool --debug-mds=20 --debug-ms=1 --debug-objecter=1 --rank recovery_fs:0 event recover_dentries list --alternate-pool recovery_fs_metadata'

The test fails due to

2026-06-25T14:05:38.145 INFO:teuthology.orchestra.run.trial089.stderr:Error (2026-06-25T14:05:38.128+0000 7fc012208480 -1 Pointer 400.00000000 is absent
2026-06-25T14:05:38.145 INFO:teuthology.orchestra.run.trial089.stderr:2026-06-25T14:05:38.128+0000 7fc012208480 -1 main_event: Journal header is not present or is damaged, cannot recover dentries
2026-06-25T14:05:38.145 INFO:teuthology.orchestra.run.trial089.stderr:(5) Input/output error2026-06-25T14:05:38.128+0000 7fc012208480  4 0 events
2026-06-25T14:05:38.145 INFO:teuthology.orchestra.run.trial089.stderr:)

Now, I haven't debugged more as to why this fails, but just FYI in case you get to it first.

@dparmar18

Copy link
Copy Markdown
Contributor Author

2026-06-25T14:05:48.392 INFO:tasks.cephfs_test_runner:ERROR: test_rebuild_simple (tasks.cephfs.test_recovery_pool.TestRecoveryPool.test_rebuild_simple)

i think ive found the issue. will update in some time

@dparmar18

Copy link
Copy Markdown
Contributor Author

The above issue looks to be something this PR patch discovered. I checked out commit prior to mines and ran the test with some custom debug logs and as I had expected the journal tool didnt run scan_header() and scan_events() meaning the tool exited without recovering any dentry:

2026-07-01T20:10:05.699+0530 7fd076ea6340  1 main_event: Using alternate pool recovery_fs_metadata
2026-07-01T20:10:05.699+0530 7fd076ea6340  1 running scan() without my (journal batching) changes
2026-07-01T20:10:05.699+0530 7fd076ea6340  1 --2- 127.0.0.1:0/292371429 >> [v2:127.0.0.1:6818/3675684147,v1:127.0.0.1:6819/3675684147] conn(0x55af8e0e5000 0x55af8df5cc00 unknown :-1 s=NONE pgs=0 gs=0 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=0 crypto rx=0 tx=0 comp rx=0 tx=0).connect
2026-07-01T20:10:05.699+0530 7fd07420a6c0  1 --2- 127.0.0.1:0/292371429 >> [v2:127.0.0.1:6800/1350665123,v1:127.0.0.1:6801/1350665123] conn(0x55af8e0e4400 0x55af8df5bb80 unknown :-1 s=BANNER_CONNECTING pgs=0 gs=4 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=0 crypto rx=0 tx=0 comp rx=0 tx=0)._handle_peer_banner_payload supported=3 required=0
2026-07-01T20:10:05.699+0530 7fd076ea6340  1 -- 127.0.0.1:0/292371429 --> [v2:127.0.0.1:6818/3675684147,v1:127.0.0.1:6819/3675684147] -- osd_op(unknown.0.0:1 6.f 6:f1f69726:::400.00000000:head [read 0~2147483647] snapc 0=[] ondisk+read+known_if_redirected+supports_pool_eio e38) -- 0x55af8d58a000 con 0x55af8e0e5000
2026-07-01T20:10:05.699+0530 7fd0732086c0  1 --2- 127.0.0.1:0/292371429 >> [v2:127.0.0.1:6818/3675684147,v1:127.0.0.1:6819/3675684147] conn(0x55af8e0e5000 0x55af8df5cc00 unknown :-1 s=BANNER_CONNECTING pgs=0 gs=5 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=0 crypto rx=0 tx=0 comp rx=0 tx=0)._handle_peer_banner_payload supported=3 required=0
2026-07-01T20:10:05.699+0530 7fd07420a6c0  1 --2- 127.0.0.1:0/292371429 >> [v2:127.0.0.1:6800/1350665123,v1:127.0.0.1:6801/1350665123] conn(0x55af8e0e4400 0x55af8df5bb80 secure :-1 s=READY pgs=137 gs=4 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=1 crypto rx=0x55af891de480 tx=0x55af8d4c5200 comp rx=0 tx=0).ready entity=mgr.4125 client_cookie=0 server_cookie=0 in_seq=0 out_seq=0
2026-07-01T20:10:05.699+0530 7fd0732086c0  1 --2- 127.0.0.1:0/292371429 >> [v2:127.0.0.1:6818/3675684147,v1:127.0.0.1:6819/3675684147] conn(0x55af8e0e5000 0x55af8df5cc00 crc :-1 s=READY pgs=16 gs=5 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=1 crypto rx=0 tx=0 comp rx=0 tx=0).ready entity=osd.2 client_cookie=0 server_cookie=0 in_seq=0 out_seq=0
2026-07-01T20:10:05.700+0530 7fd0732086c0  1 -- 127.0.0.1:0/292371429 <== osd.2 v2:127.0.0.1:6818/3675684147 1 ==== osd_op_reply(1 400.00000000 [read 0~2147483647] v0'0 uv0 ondisk = -2 ((2) No such file or directory)) ==== 156+0+0 (crc 0 0 0) 0x55af8dfb4fc0 con 0x55af8e0e5000
2026-07-01T20:10:05.700+0530 7fd076ea6340 -1 Pointer 400.00000000 is absent
2026-07-01T20:10:05.700+0530 7fd076ea6340  1 did scan_header() get called? false
2026-07-01T20:10:05.700+0530 7fd076ea6340  1 did scan_events() get called? false
2026-07-01T20:10:05.700+0530 7fd076ea6340  1 main_event: js.events size: 0
2026-07-01T20:10:05.700+0530 7fd076ea6340  4 main_event: consumed 0 inodes

Every loop was a no-op.

@dparmar18

Copy link
Copy Markdown
Contributor Author

And it's because the entire metadata pool is purged

def damage(self, fs):
"""
Damage the filesystem pools in ways that will be interesting to recover from. By
default just wipe everything in the metadata pool
"""
pool = fs.get_metadata_pool_name()
fs.rados(["purge", pool, '--yes-i-really-really-mean-it'])

This makes sense on why is the Journal Pointer absent. The only thing that the tool did was silently exit without reporting the error. And this is an error worth notifying since without journal pointer there is no scan_header(), without scan_header() there is no scan_event() i.e. no dentry recovery

@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch from 5747e88 to f42aeea Compare July 1, 2026 17:50
@vshankar

vshankar commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

And it's because the entire metadata pool is purged

def damage(self, fs):
"""
Damage the filesystem pools in ways that will be interesting to recover from. By
default just wipe everything in the metadata pool
"""
pool = fs.get_metadata_pool_name()
fs.rados(["purge", pool, '--yes-i-really-really-mean-it'])

This makes sense on why is the Journal Pointer absent. The only thing that the tool did was silently exit without reporting the error. And this is an error worth notifying since without journal pointer there is no scan_header(), without scan_header() there is no scan_event() i.e. no dentry recovery

Makes sense. So, this change was actually ignoring and not throwing the error causing the test to go ahead with scan_events() and thereby failing, yes?

@vshankar

vshankar commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

jenkins retest this please

@dparmar18

Copy link
Copy Markdown
Contributor Author

And it's because the entire metadata pool is purged

def damage(self, fs):
"""
Damage the filesystem pools in ways that will be interesting to recover from. By
default just wipe everything in the metadata pool
"""
pool = fs.get_metadata_pool_name()
fs.rados(["purge", pool, '--yes-i-really-really-mean-it'])

This makes sense on why is the Journal Pointer absent. The only thing that the tool did was silently exit without reporting the error. And this is an error worth notifying since without journal pointer there is no scan_header(), without scan_header() there is no scan_event() i.e. no dentry recovery

Makes sense. So, this change was actually ignoring and not throwing the error causing the test to go ahead with scan_events() and thereby failing, yes?

since the errors are ignored the tc passes. I'm actually looking to tighten up the errno reporting a bit, rn if jp or header is absent then 0 is returned which is incorrect IMO. I was really intrigued to understand why is it done this way but I couldn't find any points. The io.read returns ENOENT and the funcs checking jp or header then returns 0...

Comment thread src/tools/cephfs/JournalTool.cc Resolved
@dparmar18

Copy link
Copy Markdown
Contributor Author

@vshankar PTAL at the last two commits:

  • 35da618747fb90494be18f5e963b658f689acf5a highlights the failure better and it also made a change to how we run scan_events which I think is critical. You can checkout the commit description.
  • 5b5220ff5ef71653c9934d6533592b10b05904cb is a tiny enhancement I think makes sense till we arrive at a permanent solution for dnbl bloating.

This PR now passes the TC which failed earlier (at least locally)

2026-07-03 16:37:22,202.202 INFO:__main__:> ./bin/ceph log 'Ended test tasks.cephfs.test_recovery_pool.TestRecoveryPool.test_rebuild_simple'
2026-07-03 16:37:23,011.011 INFO:__main__:Stopped test: test_rebuild_simple (tasks.cephfs.test_recovery_pool.TestRecoveryPool.test_rebuild_simple) in 51.185392s
2026-07-03 16:37:23,011.011 INFO:__main__:test_rebuild_simple (tasks.cephfs.test_recovery_pool.TestRecoveryPool.test_rebuild_simple) ... ok
2026-07-03 16:37:23,011.011 INFO:__main__:
2026-07-03 16:37:23,011.011 INFO:__main__:----------------------------------------------------------------------
2026-07-03 16:37:23,011.011 INFO:__main__:Ran 1 test in 51.186s
2026-07-03 16:37:23,011.011 INFO:__main__:
2026-07-03 16:37:23,011.011 INFO:__main__:OK

@dparmar18

Copy link
Copy Markdown
Contributor Author

client log now looks like this:

2026-07-03T16:37:04.707+0530 7f92d00b0340 -1 Pointer 400.00000000 is absent
2026-07-03T16:37:04.707+0530 7f92d00b0340 -1 Aborting journal scan
2026-07-03T16:37:04.707+0530 7f92d00b0340 -1 main_event: Cannot recover dentries: journal pointer is missing

JournalScanner::EventError(scav_r, cpp_strerror(scav_r))));
}
}
it = js.events.erase(it);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fold this commit onto the change that introduces batch processing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, also rebased.

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch from 5b5220f to 49e7f04 Compare July 9, 2026 09:04
dparmar18 and others added 5 commits July 9, 2026 14:35
NOTE: exclusive to only `event recover_dentries`

JournalScanner::scan() runs a loop and loads the entire decoded journal in an
`EventMap` called `events`. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient.

The way to curb the memory bomb is to scan and flush journal in batches. The
flush boundary is based on the batch size and at event EVENT_SUBTREEMAP or
EVENT_SUBTREEMAP_TEST(subtree event(s) mark a clear boundary). The knob to
control this setting is via providing `--max-rss <bytes>` with the journal
tool command. This patch divides the provided limit by three to create the
batch since it is observed that the decoded journal events weight on an avg
~3x the encoded stream.

Also: Currently, the events map retains all decoded events until all dentries
are recovered, causing unnecessary memory retention.

Fix this by erasing each event from the map right after it is processed.
While the primary RSS bloat is caused by dnbl holding the encoded stream
in memory, this incremental cleanup provides a minor optimization until
a permanent fix is implemented (https://tracker.ceph.com/issues/77909).

Partially-Fixes: https://tracker.ceph.com/issues/76422

Co-authored-by: Patrick Donnelly <[email protected]>
Signed-off-by: Dhairya Parmar <[email protected]>
iIf the journal pointer and/or header is missing or corrupt, the tool silently
returns with no-op. There is no dentry recovery happening if any of the objects
are missing but it should be explicit to the user.

This still doesn't change returning errnos on failures to maintain status quo
until https://tracker.ceph.com/issues/77913 is addressed

One important change: The condition to scan events is now changed from
header_present to header_valid. The reason for this can be understood by
reading JournalScanner::scan_header -- if the header could not be decoded, it
is set to null, using this in JournalTool::recover_dentries would segfault and
other corruptions include bad magic or inconsistent offsets. A recovery should
not proceed with distorted magic/offset.

Fixes: https://tracker.ceph.com/issues/76422
Signed-off-by: Dhairya Parmar <[email protected]>
@dparmar18
dparmar18 force-pushed the fix-cephfs-journal-tool branch from 49e7f04 to 0e9af4b Compare July 9, 2026 09:05

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshankar

Copy link
Copy Markdown
Contributor

jenkins test api

1 similar comment
@vshankar

Copy link
Copy Markdown
Contributor

jenkins test api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants