Skip to content

Commit 7375bba

Browse files
Christoph HellwigTrond Myklebust
authored andcommitted
NFS: cleanup nfs_inode_reclaim_delegation
Reduce a level of indentation for most of the code in this function. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Link: https://lore.kernel.org/r/20250718081509.2607553-3-hch@lst.de Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 6717386 commit 7375bba

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

fs/nfs/delegation.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,34 +237,34 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
237237

238238
rcu_read_lock();
239239
delegation = rcu_dereference(NFS_I(inode)->delegation);
240-
if (delegation != NULL) {
241-
spin_lock(&delegation->lock);
242-
nfs4_stateid_copy(&delegation->stateid, stateid);
243-
delegation->type = type;
244-
delegation->pagemod_limit = pagemod_limit;
245-
oldcred = delegation->cred;
246-
delegation->cred = get_cred(cred);
247-
switch (deleg_type) {
248-
case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG:
249-
case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG:
250-
set_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
251-
break;
252-
default:
253-
clear_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
254-
}
255-
clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
256-
if (test_and_clear_bit(NFS_DELEGATION_REVOKED,
257-
&delegation->flags))
258-
atomic_long_inc(&nfs_active_delegations);
259-
spin_unlock(&delegation->lock);
260-
rcu_read_unlock();
261-
put_cred(oldcred);
262-
trace_nfs4_reclaim_delegation(inode, type);
263-
} else {
240+
if (!delegation) {
264241
rcu_read_unlock();
265242
nfs_inode_set_delegation(inode, cred, type, stateid,
266243
pagemod_limit, deleg_type);
244+
return;
245+
}
246+
247+
spin_lock(&delegation->lock);
248+
nfs4_stateid_copy(&delegation->stateid, stateid);
249+
delegation->type = type;
250+
delegation->pagemod_limit = pagemod_limit;
251+
oldcred = delegation->cred;
252+
delegation->cred = get_cred(cred);
253+
switch (deleg_type) {
254+
case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG:
255+
case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG:
256+
set_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
257+
break;
258+
default:
259+
clear_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
267260
}
261+
clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
262+
if (test_and_clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
263+
atomic_long_inc(&nfs_active_delegations);
264+
spin_unlock(&delegation->lock);
265+
rcu_read_unlock();
266+
put_cred(oldcred);
267+
trace_nfs4_reclaim_delegation(inode, type);
268268
}
269269

270270
static int nfs_do_return_delegation(struct inode *inode,

0 commit comments

Comments
 (0)