Skip to content

Conversation

@carli2
Copy link

@carli2 carli2 commented Sep 18, 2025

Summary

  • Adds a per-handle in-RAM cache with full PUT on close/fsync and inactivity auto-flush.
  • Allows read–write mounts even when the server lacks partial write support.
  • Adds cache_threshold options to bypass RAM cache for large files (when ranged I/O is supported).
  • Improves unmount on signals and process exit.

Motivation

  • Many WebDAV servers don’t support partial writes, making efficient random I/O hard. This change enables reliable read–write behavior via an in-memory buffer that uploads on close, while
    still using ranged I/O where available and beneficial.

Key Changes

  • RAM cache handle for reads/writes, PUT on close/fsync, 10s inactivity auto-flush:
    • memhandle.go:1
    • fuse.go:805 (Open), 520 (Create), 572 (ftruncate path for RAM), 281 (Remove local-only), 176 (Rename fast path)
  • Size-based decision: use RAM cache for small files, ranged I/O for large files:
    • fuse.go:829
    • main.go:202 (default 64 MiB)
    • mountoptions.go:9 (CacheThreshold), 87 (cache_threshold), 94 (cache_threshold_mb)
  • Allow mounting and operating without PUT-Range; warn and fallback to RAM cache:
    • main.go:286 (dav.Mount), 202–206, 286–305 (mount + capability messaging)
  • Robust unmount on signals and exit (graceful + lazy detach fallback):
    • main.go:336–359

New/Updated Options

  • cache_threshold: Size in bytes above which files prefer non‑cached ranged I/O (when available). Default 67108864 (64 MiB).
  • cache_threshold_mb: Same as above, but in MiB.
  • Behavior notes:
    • If the server lacks partial writes, all files use the in‑RAM cache regardless of size.
    • RAM cache auto‑flushes after 10s of inactivity per handle, and on fsync/close.

Docs

  • README updated with RAM cache mode, auto-flush, options, and behavior:
    • README.md:1
  • DAV requirements expanded with fallback semantics and references:
    • DAV-requirements.md:1

Behavior Details

  • Open/Create: Loads file into RAM buffer for small files or when no range support; large files use ranged I/O when supported:
    • fuse.go:805, 520, 829
  • Truncate: Resizes in-memory buffer when using RAM handles; otherwise uses PUT/PUT-Range appropriately:
    • fuse.go:572
  • Rename/Delete: Optimized local operations for files not yet uploaded or with open RAM handles:
    • fuse.go:176, 281
  • Unmount: On SIGINT/SIGTERM/SIGHUP, attempts graceful unmount, closes FUSE, falls back to lazy unmount on Linux:
    • main.go:336–359

Backward Compatibility

  • No breaking changes to existing mounts.
  • Defaults preserve previous ranged-I/O behavior where supported, with a clear default threshold and safe fallback when not.

Testing Notes

  • Scenarios exercised:
    • Mount against SabreDAV/Apache with partial update support and without.
    • Small file random writes; verify upload on close and after ~10s inactivity.
    • Large file I/O above threshold uses ranged operations.
    • Create with O_EXCL semantics; rename/delete before upload completes.
    • Signal handling triggers unmount and process exit.
  • Example:
    • mount -t webdavfs -o username=...,password=...,cache_threshold_mb=64 https://host/dav /mnt
    • Write small file, keep open >10s to see auto-flush; write large file and observe ranged I/O logs (with -T webdav,httpreq).

Notes for Reviewers

  • The inactivity timer is per open handle and aims to balance durability vs. overhead.
  • Conditional headers are used on full PUTs to avoid overwriting unexpected states where possible.
  • Default 64 MiB threshold is conservative; can be tuned per environment.

Checklist

  • Feature: RAM cache, auto-flush, and thresholded I/O
  • Mounting without PUT-Range support
  • Updated docs: README and DAV requirements
  • Manual tests across supported scenarios
  • Optional: add integration tests against mock DAV endpoints

…UT-Range; apply RAM-backed reads/writes; inactivity auto-flush; robust unmount on signals and exit; various fixes
…or files larger than threshold when supported
…ount without PUT-Range, and cache_threshold options
@carli2
Copy link
Author

carli2 commented Sep 18, 2025

This makes webdavfs mount against Servers using the PHP sabre/dav library and improves performance on small file handling

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.

1 participant