Skip to content

Make the SMB deadtime configurable - #298

Closed
artem-from-ua wants to merge 2 commits into
jamesyc:mainfrom
artem-from-ua:feature/configurable-smb-deadtime
Closed

Make the SMB deadtime configurable#298
artem-from-ua wants to merge 2 commits into
jamesyc:mainfrom
artem-from-ua:feature/configurable-smb-deadtime

Conversation

@artem-from-ua

@artem-from-ua artem-from-ua commented Sep 1, 2026

Copy link
Copy Markdown

Summary

deadtime is hard-coded to 15 minutes in the generated smb.conf. On a Time Machine target that value works against the device: the share can sit idle/standby even between hourly backups, at the moment smbd tears the session down every 15 minutes, and macOS re-establishes it immediately, re-running session setup, tree connect and durable handle negotiation each time — on hardware where that path is already fragile.

This adds TC_SMB_DEADTIME, plumbed the same way as TC_ATA_IDLE_SECONDS / TC_ATA_STANDBY, with a default of 60 minutes. 0 disables the idle disconnect entirely.

Environment

  • Tested against upstream 173fc60 ("docs(faq): explain reusing existing Time Machine backups")
  • Server: Samba 4.24.3 on NetBSD, Apple Time Capsule Gen 8, 128 MB RAM
  • Client: macOS 27.0 beta (build 26A5425a), SMB 3.1.1
  • Link: Wi-Fi 802.11ac, 5 GHz, same room as the capsule

Why the 15m value is not optimal here

The 15-minute value came in with 2ccff2b ("Tune Samba defaults for lower Time Capsule resource usage"), where trimming idle sessions was part of keeping resource use down. With the configuration as it stands now — and more so if #297 lands — that trade-off no longer pays for itself: the disconnects free nothing worth reclaiming, while the reconnects they cause keep waking the capsule's disk.

The concrete case is Spotlight. It keeps a session on the share that is idle for long stretches but reconnects on its own, so a 15-minute deadtime produces a disconnect/reconnect cycle indefinitely rather than freeing anything. Indexing cannot be turned off to avoid this — per Apple's own documentation, "this indexing is necessary for Time Machine to function properly and can't be disabled", and those who forced it off at the command line found that Time Machine backups stopped along with it (The Eclectic Light Company, "You cannot turn off Spotlight indexing on your Time Machine backup", citing Apple KB PH18794). The volume is also mounted more than once under /Volumes/.timemachine/ (Time Machine and Spotlight mount it separately, under different spellings of the host), so each mount is a session of its own that the timer tears down independently.

That is not just a reconnect cost. Each disconnect/reconnect wakes the disk, so the drive can never stay in IDLE or STANDBY for longer than deadtime minus the ATA timer — with deadtime = 15 and TC_ATA_IDLE_SECONDS = 300 that leaves roughly ten minutes of quiet before the next wake-up restarts the countdown. A short deadtime therefore puts a ceiling on how long the disk can stay spun down, which is the opposite of what the resource-saving intent was after. The reconnect itself is not free either: each one re-runs session setup, tree connect and durable handle negotiation, and during one incident here a reconnect loop firing every ~15 s wedged smbd outright under Time Machine write load.

Changes

44 files, +335/−7, in two commits:

  • Make the SMB deadtime configurableTC_SMB_DEADTIME through core/config.py (defaults, env keys, validator, both validated-key tuples), services/configure.py, services/deploy.py, app/ops/, telemetry option keys, and the runtime shell: default and sanitisation in 00-env-log.sh, substitution in the smb.conf heredoc, and the value added to tc_manager_samba_config_signature so a changed setting actually triggers a regenerate.
  • Add the SMB deadtime setting to the macOS app — profile model with migration for existing profiles, editor validation, both settings panes, deploy/configure params, diagnostics, and the four localization keys across all ten languages.

Hidden configure flag, matching --ata-idle-seconds:

tcapsule configure --smb-deadtime 480

Verified

  • Full Python suite green (1683 tests); ruff clean
  • New shell tests cover a configured value reaching smb.conf and an invalid value falling back to 60 with a warning
  • Deployed to the device: deadtime = 480 in the generated smb.conf, and the setting is visible and editable in the app's Settings pane
  • One full hourly backup on the patched build: 49 minutes, no session drops (97 of 97 samples held the same socket)

artem-from-ua and others added 2 commits September 2, 2026 00:39
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jamesyc jamesyc closed this Sep 3, 2026
@jamesyc

jamesyc commented Sep 3, 2026

Copy link
Copy Markdown
Owner

I just set it larger. We need a cleanup more than once per day, but we don't need it super often.

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