Repository navigation
Conversation
Config Diff Tool Output+ added: mds_bal_split_bytes (mds.yaml.in)
+ added: mds_verify_frag_bytes (mds.yaml.in)
The above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
1a8735b to
787a872
Compare
00046c4 to
09eb3e7
Compare
|
source code is ready for review. only documentation is pending. will fix the config changes check later. EDIT: doc added |
|
/config check ok |
|
[2026-10-05T14:47:35.761Z] The following tests FAILED: |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
persists a new field in fnode_t called frag_bytes and is updated in the fnode the mutation projects and journals. The way it works is it adds dentry's counted_size() to the projected fnode (just like fragstat is maintained). Fixes: https://tracker.ceph.com/issues/77513 Signed-off-by: Dhairya Parmar <[email protected]>
these helpers calculate the variable-length bytes added by the containers in inode_t or sr_t during ::encode(). Fixes: https://tracker.ceph.com/issues/77513 Signed-off-by: Dhairya Parmar <[email protected]>
the test creates 100 subdirectories, each with a 1 KB xattr, and runs 8 rounds of a snapshot followed by a touch of every dir. it sets mds_bal_split_bytes to 256 KiB, disables temperature-based splits and enables mds_verify_frag_bytes, so every committed dentry value is length-checked. it tests: - after every round every fragment's frag_bytes is within mds_bal_split_bytes i.e. the directory splits on bytes long before it has mds_bal_split_size entries - no fragment is merged back - post journal flush each fragment object holds no more than its frag_bytes and no more than mds_bal_split_bytes - since osd_deep_scrub_large_omap_object_value_sum_threshold set to mds_bal_split_bytes, a deep scrub of the fragments pgs finds no large omap object, and LARGE_OMAP_OBJECTS is not raised Fixes: https://tracker.ceph.com/issues/77513 Signed-off-by: Dhairya Parmar <[email protected]> Assisted-by: Claude Opus 5.5 <[email protected]> (helped with adding the helpers and correcting code comment grammar)
also added a section in scrub docs explains how a scrub repair deals with the new dirfrag field. Fixes: https://tracker.ceph.com/issues/77513 Signed-off-by: Dhairya Parmar <[email protected]> Assisted-by: Claude Opus 5.5 <[email protected]>
vshankar
left a comment
There was a problem hiding this comment.
I am concerned about frag_bytes as introduced here. It is part of fnode_t, and EMetaBlob::dirlump::encode() writes the whole fnode. add_dir() does that for every dirfrag in the event. predirty_journal_parents() and add_dir_context() also pull in ancestors, so a leaf update re-encodes those ancestors fnodes too. The new field is an int64_t, so that is 8 bytes on every one of those dirlumps, including ancestors whose omap size did not change.
I suggest tracking the sum on the CDir rather than in fnode_t. The split/merge decision can then be made only once that dirfrag has been fully fetched and is complete. The MDS fetches the whole fragment by default (mds_dir_prefetch=true), so the value are already in hand and the sum does not need to be stored in the journaled header. If prefetch is disabled, the existing background full fetch is what produces the sum, without putting the lookup itself on that read. I think that is a fair trade-off.
xiubli
left a comment
There was a problem hiding this comment.
Thanks for this. I tested it on a vstart cluster (1 MON, 3 OSD, 1-2 MDS, kernel client), swapping only ceph-mds between this PR and its base.
The tracker scenario reproduces, and the PR fixes it. I used 100 child directories, each with a 1 KB xattr, and ran 8 rounds of snapshot + touch.
- base: one dirfrag object with 100 keys and 1,388,842 bytes of omap values; deep scrub raises
LARGE_OMAP_OBJECTS. - PR with
mds_bal_split_bytes=256K: the fragment splits into 8 in the second round;frag_bytesmatches the objects' value bytes exactly; no warning.
unittest_mds_inode_encoded_len passes. I also ran fsstress (4 procs x 3 loops) with rolling snapshots, mds_verify_frag_bytes=true and low split thresholds: 324 splits, 545 merges, 0 verify aborts, 0 "fnode not projected", and a clean journal replay. Multi-MDS rename rollback (mds_kill_rename_at=3/4, 3 peer rollbacks) also leaves frag_bytes equal to the object bytes.
| object holds: for example, when the MDS writes an entry back after the | ||
| snapshots it was keeping copies for are removed, it drops those copies | ||
| without lowering the total. A higher total can only make a split happen | ||
| earlier. |
There was a problem hiding this comment.
A higher total also stops merges (should_merge() compares it with split_bytes >> split_bits). And it builds up with every snapshot that is removed, and does not go away without a repair scrub, so this sentence undersells the effect. If the over-count is fixed, this paragraph can go.
| if (struct_v >= 5) { | ||
| decode(frag_bytes, bl); | ||
| } else { | ||
| frag_bytes = -1; |
There was a problem hiding this comment.
mds_bal_split_bytes defaults to 512M, so every dirfrag written before the upgrade gets -1 here, and then:
should_split()never splits it on bytes, so the directories this PR is meant to fix, the ones that already have large omap objects, stay as they are;should_merge()never merges it, even when it is almost empty.
Both last until a recursive "scrub ... repair" over the whole file system. On a large fs that is expensive, and nothing in the cluster tells the user to run it.
Reproduced: create 12000 files with the base MDS (8 frags), switch to this PR, and delete down to 10 files. base merges back to 1 frag; the PR stays at 8 frags with frag_bytes=-1 and 0 merges. Only "scrub start /recursive,repair" lets it merge.
Could the total be set when the dirfrag is fetched complete and frag_bytes < 0? _omap_fetched already stores each value's bl.length() in counted_size, so the total is known after the first fetch, with no scrub needed. Stale keys still in the object would need counting too.
|
|
||
| if (mdcache->mds->balancer->get_bal_split_bytes() > 0) { | ||
| int64_t bytes = get_frag_bytes(); | ||
| if (bytes < 0 || |
There was a problem hiding this comment.
When the total is unknown, could this skip only the byte check and fall back to the item count, instead of refusing to merge? Otherwise any frag that loses its total (upgrade, offline tools, "fnode not projected") keeps its split layout for good, until a repair scrub.
| mdcache->insert_taken_inos(in->ino()); | ||
| dn = add_primary_dentry(dname, in, std::move(alternate_name), first, last); // link | ||
| } | ||
| dn->counted_size = bl.length(); |
There was a problem hiding this comment.
Two cases on the fetch path leave frag_bytes higher than the object:
-
Stale snapshot dentries are skipped above: they go into stale_items and are removed by the next commit , but their value bytes are never subtracted from frag_bytes.
-
purge_stale_snap_data()at line 2067 shrinksold_inodesbefore this line, socounted_sizeis the pre-purge on-disk length. The next commit writes the smaller value without lowering the total.
Tested: each round, create 200 files, snapshot, unlink all, rmsnap, then restart the MDS. The stale keys are gone, but frag 110 keeps frag_bytes=136566 with 0 bytes in its object. That is above get_bal_merge_bytes(), so it never merges back.
After fsstress + rolling snapshots + an MDS restart, a non-repair scrub reports 1026 dirfrags with frag_bytes != counted, all of them over-counts.
For example, 0x100000001f7.001* has frag_bytes=15034, counted=0, and its object holds 20 keys / 15034 bytes, all fd_* dentries of removed snapids.
Keeping the value length next to the key in stale_items, and subtracting it in the commit that removes the key, would fix the first case.
| _parse_dentry(dn, item, snaps, dfts); | ||
| item.dft_len = dfts.length() - off; | ||
|
|
||
| if (mdcache->get_verify_frag_bytes()) { |
There was a problem hiding this comment.
The commit path drops bytes without lowering frag_bytes too:
-
try_trim_snap_dentry()just above (line 2712) removes the dentry and its key, but dn->counted_size stays in the total. -
_parse_dentry()callspurge_stale_snap_data()and writes a smaller value, with noaccount_dentry_bytes().
Since the key removal and the fnode write happen in the same omap op, could the difference be taken off the fnode this commit writes?
| old_inodes = std::move(ptr); | ||
| // an absent or empty map encodes __u32 with value 0. old_inodes map's | ||
| // length is unknown until get_old_inodes_len() computes it | ||
| old_inodes_len = (!old_inodes || old_inodes->empty()) ? |
There was a problem hiding this comment.
project_rstat_frag_to_inode() and Locker::_do_snap_update() call reset_old_inodes(), so the next account_dentry_bytes() encodes the whole old_inodes map again.
In project_rstat_frag_to_inode(), most changes only update rstat inside existing entries, and nest_info_t encodes to a fixed size, so the length does not change. Only a range split adds an entry. cow_old_inode() already keeps the length up to date incrementally; could these two callers do the same?
Measured with 50 child dirs, each with ~40 old_inodes entries carrying a 4000-byte xattr (9.2 MB in the parent's object). Each round snapshots the parent, then creates 20 files in each child; 10000 creates per run, ABBA order:
run ops/s p50 p90 p95 p99 p99.9 p99.99 max (us)
base #1 83 2575 5266 6540 13484 50961 155065 155065
PR #1 89 2766 5615 6862 13650 42942 55494 55494
PR #2 102 2882 5775 7013 15064 55052 103898 103898
base #2 91 2729 5648 6844 14911 58929 111600 111600
Throughput is unchanged because this setup is not CPU-bound. MDS user-space CPU is +13% / +17% (two perf pairs); buffer::ptr::append, ptr::end_c_str and list::append together go from ~1100 to ~2070 samples, about 0.1 ms more MDS CPU per create.
| uint64_t new_len = dir->dentry_value_length(dn, true); | ||
| auto pf = dir->project_fnode(MutationRef(mut)); | ||
| if (pf->frag_bytes >= 0) { | ||
| pf->frag_bytes += (int64_t)new_len - (int64_t)dn->counted_size; |
There was a problem hiding this comment.
When the dentry belongs to an ancestor, e.g. from journal_dirty_inode() in predirty_journal_parents() , the total grows but nothing calls maybe_fragment() for that dirfrag. It is only checked from request handlers, from hit_dir(), or when the dirfrag is committed.
Tested with mds_bal_split_bytes=256K and 50 child dirs, each with a 1 KB xattr. Each round snapshots the parent, then creates one file in each child, so nothing touches the parent itself. frag_bytes grows 28550 -> 547350 (2.1x the threshold) and the dirfrag is not split after
300 s idle. "flush journal" then splits it into 8 within 5 s (hit_dir type 4, STORE). A directory that grows through cap flushes / flushsnap splits right away, through file_update_finish() -> hit_inode().
This is the growth pattern from the tracker, so could this queue maybe_fragment() for the dirfrag once its total crosses split_bytes?
|
|
||
| // encoded length of old_inodes and the features it was computed with. | ||
| // -1 = unknown. | ||
| int64_t old_inodes_len = sizeof(__u32); |
There was a problem hiding this comment.
These two fields take sizeof(CInode) from 1400 to 1416 bytes, which moves it from tcmalloc's 1408-byte size class to the 1536-byte one. Measured with 160k inodes loaded into cache via "ls -lR" (fresh MDS each time, ABBA order):
mempool mds_co increase: base 515.7 MB, PR 519.4 MB (+24 B/inode)
RSS increase: base 589,248 KB,
PR 613,032 / 611,320 KB (+~158 B/inode, +4%)
Saving 8 bytes would avoid most of this: for example int32_t for old_inodes_len (an old_inodes map over 2 GB is not realistic), or a small generation number instead of the 64-bit old_inodes_len_features.
| version_t version = 0; // dir version when last touched. | ||
| version_t projected_version = 0; // what it will be when i unlock/commit. | ||
|
|
||
| uint32_t counted_size = 0; |
There was a problem hiding this comment.
This takes sizeof(CDentry) from 592 to 600 bytes, which looks like padding after projected_version. Is there a 4-byte hole elsewhere in CDentry it could fill?
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
Fixes: https://tracker.ceph.com/issues/77513
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.