fs/nfs/nfs4renewd.c
Source file repositories/reference/linux-study-clean/fs/nfs/nfs4renewd.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/nfs4renewd.c- Extension
.c- Size
- 4802 bytes
- Lines
- 161
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mm.hlinux/pagemap.hlinux/sunrpc/sched.hlinux/sunrpc/clnt.hlinux/nfs.hlinux/nfs4.hlinux/nfs_fs.hnfs4_fs.hdelegation.h
Detected Declarations
function nfs4_renew_statefunction nfs4_schedule_state_renewalfunction nfs4_kill_renewdfunction nfs4_set_lease_period
Annotated Snippet
if (cred == NULL) {
if (!(renew_flags & NFS4_RENEW_DELEGATION_CB)) {
set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
goto out;
}
nfs_expire_all_delegations(clp);
} else {
int ret;
/* Queue an asynchronous RENEW. */
ret = ops->sched_state_renewal(clp, cred, renew_flags);
put_cred(cred);
switch (ret) {
default:
goto out_exp;
case -EAGAIN:
case -ENOMEM:
break;
}
}
} else {
dprintk("%s: failed to call renewd. Reason: lease not expired \n",
__func__);
}
nfs4_schedule_state_renewal(clp);
out_exp:
nfs_expire_unreferenced_delegations(clp);
out:
dprintk("%s: done\n", __func__);
}
void
nfs4_schedule_state_renewal(struct nfs_client *clp)
{
long timeout;
spin_lock(&clp->cl_lock);
timeout = (2 * clp->cl_lease_time) / 3 + (long)clp->cl_last_renewal
- (long)jiffies;
if (timeout < 5 * HZ)
timeout = 5 * HZ;
dprintk("%s: requeueing work. Lease period = %ld\n",
__func__, (timeout + HZ - 1) / HZ);
mod_delayed_work(system_percpu_wq, &clp->cl_renewd, timeout);
set_bit(NFS_CS_RENEWD, &clp->cl_res_state);
spin_unlock(&clp->cl_lock);
}
void
nfs4_kill_renewd(struct nfs_client *clp)
{
cancel_delayed_work_sync(&clp->cl_renewd);
}
#define MAX_LEASE_PERIOD (60 * 60) /* 1 hour */
/**
* nfs4_set_lease_period - Sets the lease period on a nfs_client
*
* @clp: pointer to nfs_client
* @period: new value for lease period (in seconds)
*/
void nfs4_set_lease_period(struct nfs_client *clp, u32 period)
{
unsigned long lease;
/* Limit the lease period */
if (period < MAX_LEASE_PERIOD)
lease = period * HZ;
else
lease = MAX_LEASE_PERIOD * HZ;
spin_lock(&clp->cl_lock);
clp->cl_lease_time = lease;
spin_unlock(&clp->cl_lock);
/* Cap maximum reconnect timeout at 1/2 lease period */
rpc_set_connect_timeout(clp->cl_rpcclient, lease, lease >> 1);
}
Annotation
- Immediate include surface: `linux/mm.h`, `linux/pagemap.h`, `linux/sunrpc/sched.h`, `linux/sunrpc/clnt.h`, `linux/nfs.h`, `linux/nfs4.h`, `linux/nfs_fs.h`, `nfs4_fs.h`.
- Detected declarations: `function nfs4_renew_state`, `function nfs4_schedule_state_renewal`, `function nfs4_kill_renewd`, `function nfs4_set_lease_period`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.