Re: [PATCH 1/4] NFS: cleanup nfs_inode_reclaim_delegation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2025-07-14 at 13:16 +0200, Christoph Hellwig wrote:
> Reduce a level of indentation for most of the code in this function.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  fs/nfs/delegation.c | 48 ++++++++++++++++++++++-----------------------
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
> index 519bdc91112c..56bb2a7e1793 100644
> --- a/fs/nfs/delegation.c
> +++ b/fs/nfs/delegation.c
> @@ -237,34 +237,34 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
>  
>  	rcu_read_lock();
>  	delegation = rcu_dereference(NFS_I(inode)->delegation);
> -	if (delegation != NULL) {
> -		spin_lock(&delegation->lock);
> -		nfs4_stateid_copy(&delegation->stateid, stateid);
> -		delegation->type = type;
> -		delegation->pagemod_limit = pagemod_limit;
> -		oldcred = delegation->cred;
> -		delegation->cred = get_cred(cred);
> -		switch (deleg_type) {
> -		case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG:
> -		case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG:
> -			set_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
> -			break;
> -		default:
> -			clear_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
> -		}
> -		clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
> -		if (test_and_clear_bit(NFS_DELEGATION_REVOKED,
> -				       &delegation->flags))
> -			atomic_long_inc(&nfs_active_delegations);
> -		spin_unlock(&delegation->lock);
> -		rcu_read_unlock();
> -		put_cred(oldcred);
> -		trace_nfs4_reclaim_delegation(inode, type);
> -	} else {
> +	if (!delegation) {
>  		rcu_read_unlock();
>  		nfs_inode_set_delegation(inode, cred, type, stateid,
>  					 pagemod_limit, deleg_type);
> +		return;
> +	}
> +
> +	spin_lock(&delegation->lock);
> +	nfs4_stateid_copy(&delegation->stateid, stateid);
> +	delegation->type = type;
> +	delegation->pagemod_limit = pagemod_limit;
> +	oldcred = delegation->cred;
> +	delegation->cred = get_cred(cred);
> +	switch (deleg_type) {
> +	case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG:
> +	case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG:
> +		set_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
> +		break;
> +	default:
> +		clear_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags);
>  	}
> +	clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
> +	if (test_and_clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
> +		atomic_long_inc(&nfs_active_delegations);
> +	spin_unlock(&delegation->lock);
> +	rcu_read_unlock();
> +	put_cred(oldcred);
> +	trace_nfs4_reclaim_delegation(inode, type);
>  }
>  
>  static int nfs_do_return_delegation(struct inode *inode,

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux