Skip to content

dbd: add -i option to invalidate AppleDouble CNID hints#2863

Draft
rdmark wants to merge 1 commit intomainfrom
rdmark-dbd-invalidate-hint
Draft

dbd: add -i option to invalidate AppleDouble CNID hints#2863
rdmark wants to merge 1 commit intomainfrom
rdmark-dbd-invalidate-hint

Conversation

@rdmark
Copy link
Copy Markdown
Member

@rdmark rdmark commented Apr 6, 2026

When nested volumes leave behind stale CNID hints in AppleDouble files, dbd -f alone cannot fix them because cnid_add() still receives the stale hint. The new -i flag skips reading AD hints entirely, letting the database assign fresh CNIDs which are then written back to the AppleDouble files.

When nested volumes leave behind stale CNID hints in AppleDouble files,
dbd -f alone cannot fix them because cnid_add() still receives the
stale hint. The new -i flag skips reading AD hints entirely, letting
the database assign fresh CNIDs which are then written back to the
AppleDouble files.
@rdmark rdmark force-pushed the rdmark-dbd-invalidate-hint branch from 42ffbcd to 75e1d6e Compare April 6, 2026 07:50
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 6, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

🔥 Spectest (AFP 3.4) - Flamegraph (AFP_ASSERT active)

Commit: 75e1d6ea0f8ec9086c1bc16040d5791916aa4cc3
Profiling: On-CPU sampling @ 999 Hz, DWARF call-graph, x86_64
Build: debugoptimized (-O2 -g -fno-omit-frame-pointer)
Runtime: 66s, Stacks: 984, SVG size: 528K

🔥 Open interactive Flamegraph (SVG)

Flamegraph preview

📥 Download from artifacts →

🔝 Top 10 leaf functions
Function Samples
_raw_spin_unlock_irqrestore 311311311
[ld-musl-x86_64.so.1] 131131131
do_syscall_64 114114114
find_get_block_common 60060060
dircache_remove_children 43043043
srso_alias_safe_ret 34034034
memcmp 34034034
dircache_process_deferred_chain 24024024
__cond_resched 21021021
x64_sys_call 19019019

@andylemin
Copy link
Copy Markdown
Contributor

This is useful, however I'm not convinced -f cannot fix them?

On rebuild Dbd -f will see that the CNID hint does not match the database, and the database wins, and the CNID ID from the DB is used overwriting the CNID hint.

If the DB has no entry it saves the CNID hint into the DB checking the unique constraint on the ID key.
So any secondary duplicate CNID hint will have a key collision at which point it falls back to generating a fresh ID.

Am I missing something?
I understand this might be related to the different vol's but the CNIDs are unique per vol, so after the vol's are separated the rebuild still should work?

Approving as I like the start fresh ability anyway, just want to confirm my understanding

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 6, 2026

🤖 Augment PR Summary

Summary: Adds a new -i flag to dbd to ignore CNID hints stored in AppleDouble metadata so stale hints (e.g., from nested volumes) don’t influence CNID rebuilds.
Changes: Updates CLI parsing/usage + manpage, introduces DBD_FLAGS_STRIP_AD, and adjusts CNID scanning to skip reading AppleDouble CNID hints and rewrite metadata with the database-assigned CNID.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread bin/dbd/cmd_dbd_scanvol.c
ad_cnid = CNID_INVALID;

if (ADFILE_OK) {
if (dbd_flags & DBD_FLAGS_STRIP_AD) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bin/dbd/cmd_dbd_scanvol.c:649: With DBD_FLAGS_STRIP_AD set, check_cnid() skips the ad_open() probe that previously set adfile_ok=1 on AD_VERSION_EA files lacking meta EA, so the later overwrite path can treat ad_open(...RDWR) failures as fatal and return CNID_INVALID for those entries.

Severity: high

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread bin/dbd/cmd_dbd_scanvol.c

if (ADFILE_OK) {
if (dbd_flags & DBD_FLAGS_STRIP_AD) {
dbd_log(LOGDEBUG, "Ignoring AppleDouble CNID hint for '%s/%s'", cwdbuf, name);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bin/dbd/cmd_dbd_scanvol.c:650: Because -i forces ad_cnid to stay CNID_INVALID, the ad_cnid != db_cnid && adfile_ok == 0 overwrite path will execute for every existing AppleDouble file even when DBD_FLAGS_SCAN (-s) is set, which appears to violate the documented “read only / no filesystem modifications” behavior.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@rdmark rdmark marked this pull request as draft April 7, 2026 19:22
@rdmark
Copy link
Copy Markdown
Member Author

rdmark commented Apr 7, 2026

this is fair feedback, I wrote this as a hypothetical measure for the scenario where an invalid CNID was stored as AD hint, but I only tested with "normal" CNID hint repair scenarios

let me bring this back to draft status and gather some evidence that the new logic is actually required

@andylemin
Copy link
Copy Markdown
Contributor

this is fair feedback, I wrote this as a hypothetical measure for the scenario where an invalid CNID was stored as AD hint, but I only tested with "normal" CNID hint repair scenarios

let me bring this back to draft status and gather some evidence that the new logic is actually required

I still like this 😉 resetting all CNIDs is feel-good

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants