Commit f5883d5
authored
perf(virtiofs): eliminate readdir per-entry lookups (#2125)
* perf(virtiofs): eliminate readdir per-entry lookups
Preserve filesystem-provided inode, type, and opaque cookie data through FUSE, VFS, mount wrappers, and overlayfs so directory scans no longer fall back to lookup plus getattr for every entry.
Serialize per-open directory snapshots with seek state, implement READDIRPLUS_AUTO behavior, bound the positive lookup cache with lazy LRU eviction, and retain overlay inode identity and whiteout semantics.
Extend the virtiofs benchmark with deterministic readdir datasets and request-count assertions, and add dunitest coverage for typed records, cookie resume, shared-fd concurrency, AUTO request sequencing, and overlay lower-layer scans.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(fuse): harden readdir compatibility
Preserve opaque FUSE directory cookies and raw name bytes through the VFS getdents path. Keep per-open snapshots stable across zero-cookie records and undersized userspace buffers, detect daemon offset cycles without rejecting valid records, and retry READDIR after READDIRPLUS returns ENOSYS.
Guarantee RELEASEDIR after every opened-directory request or parser failure, balance non-UTF-8 READDIRPLUS lookup references with FORGET, and forward byte-oriented lookup through mount wrappers and overlay whiteout checks.
Restore bounded positive-cache expiry cleanup without scanning or perturbing live LRU entries. Correct the local test daemon's root-child enumeration and populate READDIRPLUS validity fields so the tests exercise real Linux-compatible cache behavior.
Validated with make fmt, make kernel, FuseCore 5/5, and FuseExtended 70/70 in a DragonOS QEMU guest.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(vfs): resume rebuilt directory snapshots
Honor a nonzero saved directory cookie when getdents rebuilds a snapshot after rewind. Use one cookie-to-index path for both lseek against an existing snapshot and deferred positioning after a new snapshot is populated.
Keep zero-cookie streams distinct from an explicit rewind, and preserve the selected entry across an undersized getdents buffer. Extend the FUSE typed-directory regression with rewind, saved-cookie seek, EINVAL retry, and resume assertions.
Validated with make fmt, make kernel, FuseCore 5/5, and FuseExtended 70/70 in a DragonOS QEMU guest.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(vfs): preserve directory cursor semantics
Treat SEEK_CUR with a zero delta as a serialized position query so zero and repeated opaque cookies cannot rewind a live directory snapshot. Reject cookies outside the signed getdents64 and lseek range before emitting a record or advancing file state.
Make native typed directory records an explicit optional capability. FUSE and overlay keep their typed fast path, while legacy filesystems cache names and resolve metadata only as the caller buffer advances; overlay materializes legacy metadata only when a full layer merge requires it.
Balance READDIRPLUS lookup references when a complete name is followed by truncated alignment padding without changing Linux short-record behavior. Extend coverage for zero and duplicate cookies, SEEK_CUR queries, signed-cookie bounds, and truncated lookup accounting.
Validated with make fmt, make kernel, FuseCore 5/5, FuseExtended 70/70, and DevtmpfsSemantics 7/7 in a DragonOS QEMU guest.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(virtiofs): report readdir pre-scan failures
Ensure readdir_scan always terminates its transcript with a machine-readable result when pre-scan quiescence times out or the statistics baseline is unavailable. Preserve the first failure while closing the dataset directory and report ETIMEDOUT or EIO explicitly.
Extend the host transcript regression suite to exercise both failure paths and verify their single-result contract.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(fuse): synchronize shared readdir test workers
Replace volatile start, stop, and readiness flags in the shared-directory readdir regression with C++ atomics. Use release stores and acquire loads so worker startup and shutdown have defined happens-before relationships on optimized and weakly ordered targets.
Keep worker result fields non-atomic because they are consumed only after pthread_join, which provides the required completion synchronization.
Signed-off-by: longjin <longjin@dragonos.org>
---------
Signed-off-by: longjin <longjin@dragonos.org>1 parent fcfc8eb commit f5883d5
13 files changed
Lines changed: 2075 additions & 377 deletions
File tree
- kernel/src/filesystem
- fuse
- inode
- overlayfs
- vfs
- mount
- user/apps
- tests/dunitest/suites/fuse
- virtiofs_bench
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1365 | 1372 | | |
1366 | 1373 | | |
1367 | 1374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
291 | 296 | | |
292 | 297 | | |
293 | 298 | | |
| |||
330 | 335 | | |
331 | 336 | | |
332 | 337 | | |
| 338 | + | |
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
| |||
370 | 376 | | |
371 | 377 | | |
372 | 378 | | |
373 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
| |||
1174 | 1184 | | |
1175 | 1185 | | |
1176 | 1186 | | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | 1187 | | |
1182 | 1188 | | |
1183 | 1189 | | |
| |||
1374 | 1380 | | |
1375 | 1381 | | |
1376 | 1382 | | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | 1383 | | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
| 1384 | + | |
1385 | 1385 | | |
1386 | 1386 | | |
1387 | | - | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1388 | 1394 | | |
1389 | | - | |
| 1395 | + | |
1390 | 1396 | | |
1391 | | - | |
| 1397 | + | |
1392 | 1398 | | |
1393 | 1399 | | |
1394 | 1400 | | |
| |||
0 commit comments