NFS4 lease duration, delegation and grace period

Parent Previous Next

NFS4 lease duration, delegation and grace period


1. NFSv4 Lock Lease Duration

Definition

The lease duration is the period of time during which the NFSv4 server guarantees that a client’s state (like open files or locks) remains valid without explicit renewal.

It defines how long the server will remember the client’s locks and opens in the absence of communication.


Typical Value

Default lease period is 90 seconds, but it’s configurable on the NFS server.

RFC 7530 specifies the lease period is negotiated at client-server session establishment (via SETCLIENTID / SETCLIENTID_CONFIRM).


Mechanism

The client must periodically send operations (like READ, WRITE, RENEW, OPEN, or LOCK) within the lease duration to renew its lease.

If no request is seen for longer than the lease period, the server may:

Expire the client’s state (assume the client is dead)

Release all locks and opens associated with it


Example


If lease = 90s:

Client locks a file at T=0.

By T=80s, the client should send any valid NFSv4 operation (including a RENEW) to refresh its lease.

If the server receives nothing by T=90s → server frees the client’s state.


2. NFSv4 Delegation

Definition

Delegation is a performance optimization where the NFS server temporarily delegates certain control of a file to a client.

This allows the client to cache data and metadata aggressively without constantly contacting the server.


Types of Delegation


Read delegation

Given when no other clients are writing the file.

Client can cache file data and attribute updates locally.


Write delegation

Given when a client has exclusive access (no one else has file open).

Client can buffer writes locally and delay sending them until close.


Purpose

Reduce network traffic.

Improve performance by minimizing server calls for repeated I/O on the same file.


Revocation

If another client requests conflicting access (e.g., another wants to open the same file for write):


Server recalls the delegation.

The delegated client must flush changes and return the delegation via a DELEGRETURN call.


3. Grace Period

Definition

The grace period is a special time window after a server reboot during which clients can reclaim previously held locks.


Purpose

Allows NFS clients to reclaim locks they held before the server crashed or restarted.

Prevents new locks from being granted until all old clients have had a chance to reclaim.


Behavior

During the grace period:

Only reclaim operations (LOCK with reclaim=TRUE) are allowed.

New lock requests (non-reclaim) will fail with NFS4ERR_GRACE.


Duration

Typically equal to or slightly longer than the lease period (e.g., if lease = 90s, grace period may also be ~90s).

After grace period expires:

Normal operations resume (new locks are accepted).


Any locks not reclaimed are considered lost.


Putting It All Together

| Concept            | When It Applies            | Purpose                                                     | Typical Duration     |

| ------------------ | -------------------------- | ----------------------------------------------------------- | -------------------- |

| **Lease Duration** | Normal operation           | Ensures server knows clients are alive and state is current | ~90s                 |

| **Delegation**     | During active use of files | Performance optimization (local caching)                    | Valid until recalled |

| **Grace Period**   | After server reboot/crash  | Allows clients to reclaim previous locks safely             | ≈ Lease duration     |


www.traceinside.com