How can an SMB client read files without updating last-access timestamps (atime)?
Standard SMB workarounds for scanning files without modifying last-access timestamps (atime) – such as FILE_OPEN_FOR_BACKUP_INTENT, [MS-FSCC] -1 timestamp suspension, or exclusive share locks – either fail on modern multiprotocol NAS platforms or disrupt live users. By implementing [MS-SMB2] file leases with deferred manual acknowledgment (autoAckLeases = false), a write-through client like jNQ uses write-class lease breaks as a real-time, cross-protocol signal (covering SMB, NFS, S3, and REST) to restore original atime metadata before acknowledging a peer access.

How a write-through SMB client learned to speak leases – and why we said no first
There is a class of software that has to read your files without you ever knowing it was there. Backup engines, e-discovery crawlers, data-loss-prevention scanners, and data-security classifiers all share the same awkward requirement: open a file, read every byte, and leave the file looking exactly as it did before – same content, same metadata, same story told to the storage system underneath.
That last part is harder than it sounds. This is the account of one customer’s version of the problem, why the obvious solutions don’t work, why we initially declined to build the feature they asked for, and what changed our minds.
The problem: last-access time is a lie detector
The customer is a data-security software vendor. Their product scans enterprise file storage, classifies sensitive documents, and – this detail matters later – remediates them: it opens a live file, reads the content, injects a classification label, and writes the file back.
Their constraint was the last-access timestamp, atime. In modern enterprise storage, atime is not a cosmetic field. It drives automated tiering (cold data demoted to cheaper media), retention and cleanup policies, and lifecycle decisions across the cluster. A scanner that reads a million files and bumps every atime to “now” has just told the storage array that a million cold files are suddenly hot. Tiering thrashes, cleanup schedules break, and the customer’s own product becomes the thing polluting the environment it was hired to protect.
So the requirement was blunt: read and classify files without updating atime, and do it transparently – without locking real users out, and without the scan being visible to anyone.
Why the obvious fixes fail
The customer had already been down every reasonable road, and each one dead-ended on their target platform, a modern multiprotocol NAS (Qumulo Core):
- Open with backup intent. FILE_OPEN_FOR_BACKUP_INTENT is widely believed to suppress atime updates. It doesn’t. It is a privilege-check mechanism, nothing more. The reason backup software appears to get away with it is that Windows/NTFS has disabled last-access updates by default since Windows Vista – the server isn’t honouring backup intent, it simply isn’t tracking atime in the first place. A NAS that does track atime updates it regardless.
- Suspend updates on the handle. [MS-FSCC] (section 2.4.7, FileBasicInformation) specifies that setting a timestamp field to -1 instructs the server not to update that attribute for I/O performed through that handle – a later -2 resumes updates. It is the one client-visible, specification-blessed mechanism for a reader to avoid leaving its own footprint. The customer’s target server ignored it.
- Read, then restore. Query atime, read the file, set atime back to what it was. This introduces a race: if a genuine user reads the file during the scan, the server records the user’s access, and the scanner’s well-meaning restore then erases that record. The restore also isn’t free – an explicit timestamp set updates the file’s change time and adds a metadata write per file, so at scan scale you trade atime noise for change-time noise plus write amplification against the very cluster you’re trying not to disturb.
- Lock everyone else out. Open with no sharing (FILE_SHARE_NONE) so nothing can touch the file mid-scan. This guarantees atime correctness within SMB and nothing else. Genuine users hit a hard STATUS_SHARING_VIOLATION – an error, not a wait – so the scanner skips exactly the files people are actively using, which for a data-security scan is usually the data that matters most. And the guarantee is SMB-only: the same file reached over NFS, S3, or REST is neither blocked nor detected.
Every path either failed on a strict server, corrupted metadata, or destroyed the transparency the whole exercise depended on.
Approach | How It Attempts to Preserve atime | Why It Fails in Enterprise NAS Environments |
FILE_OPEN_FOR_BACKUP_INTENT | Requests backup privilege during CREATE. | Only bypasses access checks; servers that actively track atime still update it. |
[MS-FSCC] -1 Timestamp | Sets FileBasicInformation fields to -1 on the handle. | Optional on the wire; strict or non-Windows multiprotocol servers often ignore it. |
Blind Read & Restore | Queries atime, reads bytes, writes atime back. | Introduces a race condition that overwrites real user access and doubles metadata writes (ctime churn). |
Exclusive Lock (FILE_SHARE_NONE) | Blocks all concurrent opens mid-scan. | Causes STATUS_SHARING_VIOLATION errors for live users and is blind to NFS, S3, or REST access. |
Read-Only Snapshots | Scans an immutable point-in-time snapshot. | Cannot support remediation workflows that write classification labels back to live files. |
Write-Class Lease + Deferred Ack | Uses [MS-SMB2] lease break as a pre-access interrupt to restore atime before acking. | Succeeds: Cross-protocol visibility, zero user disruption, and deadlock-free write-through execution. |
Why we said no to leases
The customer’s proposed answer was SMB2 leases, and they asked us to add lease support to jNQ, our pure-Java SMB client library. Our first answer was no – and it is worth explaining why, because the reason is the same reason the feature was interesting once we reconsidered.
SMB2 leases exist for one purpose: they let a client cache file data, metadata, and handles locally while the server guarantees coherency by breaking the lease when another client’s access would conflict. They are a performance optimization for caching clients. The Windows redirector requests leases aggressively because it maintains a large local cache and wants to keep it valid.
jNQ is deliberately not that kind of client. It is write-through by design: every read, write, and metadata operation goes straight to the server, with no local cache. With nothing cached, a lease has nothing to protect and buys nothing. And nothing is lost by operating without one – oplocks and leases are optional in SMB2, SMB2_OPLOCK_LEVEL_NONE is fully conformant, and none of the guarantees jNQ actually exposes (data integrity, byte-range locking, share modes, change notifications) depend on lease state. Adding a caching feature to a client whose entire architecture is the deliberate absence of a cache would have been a feature in search of a justification.
We were also skeptical of the specific design the customer proposed – a read lease with “back off on break.” On close inspection the signal is inverted relative to the need. The lease state a scanner can hold on a shared, in-use file is read caching, and read caching is a shared state: another client reading the same file does not break it. But reads are precisely what update atime. So a genuine user reads the file during the scan, atime changes, no break fires, the scanner’s back-off never triggers, and the restore overwrites the user’s access record – the exact race they were trying to close, now hidden rather than solved.
We recommended a different approach entirely (reading through the platform’s read-only snapshots) and left it there.
The reframing: a lease is a signal, not a cache
Two facts brought the conversation back, and both came from the customer as evidence rather than insistence.
First, snapshots couldn’t cover their whole product. Snapshots are read-only, and the customer doesn’t only read – they remediate, writing labels back to live files. A read-only path can’t carry a write.
Second, and more importantly, they weren’t actually asking for caching. They wanted the lease-break notification – the moment the server tells the client “someone else is about to touch this file” – as a real-time concurrency signal. On their platform, the lease/oplock system is global across protocols: an access arriving over NFS, S3, or REST triggers an SMB lease break to the holding client. That closes the cross-protocol blind spot that had sunk the exclusive-lock approach. A write-class lease breaks when another client opens the file, which is exactly the event a scanner needs to hear about.
That reframing is what made the feature clean. jNQ didn’t need a cache. It needed to request a lease, honour it on the wire, and hand the break notification up to the application – letting the application decide what the signal means. The lease stops being a caching mechanism and becomes a coordination primitive. jNQ provides the mechanism; the customer’s scanner provides the policy.
What we built – mechanism, not policy
The implementation is SMB2/SMB3 file leasing exactly as [MS-SMB2] specifies it, and nothing more: construct the lease create context on CREATE, gated on a negotiated dialect of SMB 2.1 or higher; parse the granted state, correctly handling a grant that is less than requested (a lesser lease state, a legacy batch oplock, or no lease at all); generate and track a per-file lease key in a client-side lease table; receive break notifications, perform the state transition, and acknowledge within the server’s window. It is write-through throughout – jNQ requests, tracks, and honours lease state on the wire, but adds no local data cache. That boundary is what kept the feature small and the timeline firm.
Two design decisions did the real work for this use case.
- Leasing is opt-in at two levels. A mount announces that it supports leasing (MountParams.useLeases); each individual open then decides whether to request one, and which state to request, rather than the library always demanding the maximal grant. This matches how the customer’s scanner works – most opens want nothing, specific opens want a write-class lease.
- Acknowledgment can be deferred to the application. This is the subtle part. By default (autoAckLeases = true) jNQ acknowledges a break automatically and the application is merely notified after the fact. But the customer needed to act during the break – specifically, to restore the original timestamp before the acknowledgment reaches the server, in order to defeat the server’s atime update-deferral window. With autoAckLeases = false, the break is delivered to the application’s listener before any acknowledgment; jNQ sends nothing until the application calls file.acknowledgeLeaseBreak(targetState). In between, the application may run operations on the open handle – including the timestamp restore.
The customer initially asked for this as a synchronous callback on the packet-receiver thread that would block acknowledgment until it returned. We declined that shape: a synchronous hook that issues a follow-up request on the receiver thread deadlocks by construction, because the response it waits for arrives on the same thread it has blocked. The deferred manual-ack model achieves the identical outcome without the deadlock, and it is protocol-legitimate – deferring the ack inside the break window is the same right a caching client uses to flush before acknowledging.
Integration testing then surfaced a case the spec discussion hadn’t: what happens when the connection drops while a lease is held? The lease dies with the connection, so a restore issued from the break path is doomed – there is no session to carry it. A break caused by a peer conflict (host reachable, restore should run) and a break caused by a disconnect (host gone, restore must be skipped) look identical to a naïve listener. We added a signal – the break callback reports whether the host is still usable – so the application can branch: on a peer break, restore then acknowledge; on connection loss, skip the restore, log the failure without crashing, and fall back to its own out-of-band recovery.
Underneath, a few structural choices kept the behaviour correct under concurrency. A dedicated lease object and a path-keyed lease table live on the connection, independent of any single file handle, so multiple opens of the same path share one lease and a lease can survive the CREATE round trip. Break notifications are dispatched through jNQ’s existing oplock-break infrastructure, with the encrypted SMB 3.x path delegating to the same handler rather than duplicating it. SMB 3.x leases carry an epoch counter to order break notifications; the implementation compares epochs with wraparound awareness so a stale, out-of-order break can’t regress the tracked state – while still always delivering the break to the application and still sending any required acknowledgment. And because several handles can share one lease, exactly one application callback and one acknowledgment are produced per break, regardless of how many handles are involved.
The discipline: we guarantee the mechanism, not the outcome
The most important line in the engagement was a boundary. jNQ implements leasing to [MS-SMB2] as a fixed, testable target. The outcome the customer is building on top of it – timestamp restoration semantics, a particular server’s atime deferral behaviour, cross-protocol coverage – depends on server-specific implementation details that are not the library’s to guarantee. jNQ warrants that the mechanism is correct per specification; it does not warrant the result of the choreography on any one server.
This isn’t a disclaimer to hide behind – it’s what made the work deliverable. A conformant client behaves correctly per spec; where a specific server departs from the spec, that is resolved on the server side, not patched into the client. Holding that line is precisely what let us commit to a fixed scope, a fixed price, and a one-month timeline. The customer understood and accepted it explicitly: they owned end-to-end validation on their own platforms, and we owned a spec-correct library.
Qualification is the actual work
It is tempting to think the engineering is the code. It isn’t. A first build that requests, parses, and acknowledges a lease against one server comes together quickly. The month goes into qualification, because servers differ materially in how they grant, downgrade, and break leases – you might get the state you asked for, a lesser one, a legacy oplock, or nothing, with different timing in each case. A build that has only met one server will surprise you on the next.
So the feature was qualified across the servers real deployments actually run – every supported generation of Windows Server, several Samba releases, NetApp ONTAP, macOS, and the customer’s own multiprotocol NAS. Each grants, downgrades, and breaks leases differently enough to matter, and a build proven against one is not proven against the next.
Qualification found exactly the kind of thing qualification is for. Samba misbehaved when two users on the same client requested a write/read/handle lease on the same file. And we found jNQ had been quietly asking the server for handle caching it never used – harmless in isolation, but it provoked unnecessary lease breaks, so we stopped requesting it. Neither was in the original design; both are the difference between a feature that demos and a feature you can rely on.
The result
The customer validated the delivered build in their own lab, against their own platform, end to end. Write-class leases were granted as expected; concurrent access broke the lease and the break was observable in the client; the timestamp restore executed correctly on the break path before acknowledgment; and their full agent integration passed – the ordinary case, the contended case where a real user arrives mid-scan, and the connection-loss case where the session is severed mid-transfer and the agent recovers without disruption. The feature shipped and folded into the standard maintenance line of the product.
The scanner can now touch a file and leave no trace – not because SMB has a “read without a trace” flag (it doesn’t), but because a write-through client was taught to hear the one signal that tells it when a real user is about to arrive, and to get out of the way.
Building a DLP, Backup, or Data-Classification Engine for Enterprise Storage?
Scan and classify SMB shares without altering last-access timestamps or blocking live users. Test jNQ’s granular SMB2/SMB3 lease controls, deferred break acknowledgments, and full SMB 3.1.1 dialect support against your storage targets.
The takeaway
Two things travel beyond this one engagement.
The first is architectural. A protocol feature designed for one purpose – leases exist to keep client caches coherent – can serve an entirely different one if you separate the mechanism from the policy. A write-through client has no use for a lease as a cache. As a real-time, cross-protocol signal of who is about to touch a file, it turned out to be the missing piece. The feature that made no sense for our architecture made perfect sense once we stopped assuming what it was for.
The second is about how bespoke protocol work stays deliverable. The specification is the contract. Implement to it exactly, draw a hard line around server-specific behaviour, and let the customer own the outcome that depends on their environment. That boundary is not a way of doing less – it is what lets you commit to doing it at all.
Frequently Asked Questions
Does FILE_OPEN_FOR_BACKUP_INTENT prevent SMB servers from updating atime?
No. FILE_OPEN_FOR_BACKUP_INTENT is strictly a privilege-check mechanism. It appears to preserve atime on Windows/NTFS only because NTFS disables last-access timestamp updates by default. Enterprise NAS platforms that actively track atime will still update it regardless of backup intent.
Why would a write-through SMB client without a local cache use SMB2/SMB3 leases?
Even without caching file data locally, a write-through SMB client can use a write-class lease as a real-time concurrency signal. On multiprotocol NAS platforms, an incoming access over SMB, NFS, S3, or REST triggers an SMB lease break notification, alerting the scanning application before a peer touches the file.
How does deferred lease break acknowledgment prevent deadlocks and race conditions?
Instead of blocking the packet-receiver thread with a synchronous callback, jNQ dispatches the lease break notification to an application listener while deferring the wire acknowledgment (autoAckLeases = false). The application can safely issue a metadata restore on the open handle and then call acknowledgeLeaseBreak() once complete.
Lilia Wasserman, VP R&D, Visuality Systems




