fix(native): replace the writing client before verification

The writing client kept the caps of the files it wrote last. Every
lookup of the verification client on one of them made the MDS recall
the caps entry by entry, which cost about five seconds per lookup in
the lab and stalled a 100,000-file verification near its end.

Verify now opens a fresh target client, closes the writer, which
returns all caps at once, and keeps writing through the fresh client.
The claim lock is held through a client of its own, so it survives the
change.

Verify also checks non-directory entries in parallel with the
configured number of workers. The walk and the directories stay
serial, so skipped subtrees are handled in walk order.

Transfer statistics report the duration of each round in seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-12-03 21:50:35 +01:00
1 parent c655318c47
commit e2c4549ade
7 files changed
+528 -109

No files matched your search

+32 -1
View File
@@ -97,7 +97,38 @@ func (a nativeAccess) Claim(ctx context.Context, c Config, fsid, id string) (io.
return nil, err
}
fs := a.backend.target
if a.backend.openTarget == nil {
return claimNative(a.backend.target, c, fsid, id)
}
// The lock lives as long as this client; Verify replaces target.
client, err := a.backend.openTarget()
if err != nil {
return nil, fmt.Errorf("native claim client: %w", err)
}
f, err := claimNative(client, c, fsid, id)
if err != nil {
client.Close()
return nil, err
}
return nativeClaim{file: f, client: client}, nil
}
// nativeClaim is a claim lock held through a client of its own.
type nativeClaim struct {
file storage.File
client storage.FS
}
func (c nativeClaim) Close() error {
return errors.Join(c.file.Close(), c.client.Close())
}
// claimNative creates the claim file for id if needed, locks it through fs
// and checks that it names id. The returned file holds the lock.
func claimNative(fs storage.FS, c Config, fsid, id string) (storage.File, error) {
current := "/"
for _, component := range []string{".cephmig", "claims"} {
current = path.Join(current, component)