Unverified Commit 7cec0a45 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12460 NFSD: Limit the number of concurrent async COPY operations

parents 98d688b7 3bb713fe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ struct nfsd_net {
	u32		s2s_cp_cl_id;
	struct idr	s2s_cp_stateids;
	spinlock_t	s2s_cp_lock;
	atomic_t	pending_async_copies;

	/*
	 * Version information
+9 −2
Original line number Diff line number Diff line
@@ -1113,6 +1113,7 @@ void nfs4_put_copy(struct nfsd4_copy *copy)
{
	if (!refcount_dec_and_test(&copy->refcount))
		return;
	atomic_dec(&copy->cp_nn->pending_async_copies);
	kfree(copy);
}

@@ -1524,10 +1525,16 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
	if (!copy->cp_synchronous) {
		struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);

		status = nfserrno(-ENOMEM);
		async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
		if (!async_copy)
			goto out_err;
		async_copy->cp_nn = nn;
		/* Arbitrary cap on number of pending async copy operations */
		if (atomic_inc_return(&nn->pending_async_copies) >
				(int)rqstp->rq_pool->sp_nrthreads) {
			atomic_dec(&nn->pending_async_copies);
			goto out_err;
		}
		if (!nfs4_init_copy_state(nn, copy))
			goto out_err;
		refcount_set(&async_copy->refcount, 1);
@@ -1552,7 +1559,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
out_err:
	if (async_copy)
		cleanup_async_copy(async_copy);
	status = nfserrno(-ENOMEM);
	status = nfserr_jukebox;
	/*
	 * source's vfsmount of inter-copy will be unmounted
	 * by the laundromat
+1 −0
Original line number Diff line number Diff line
@@ -7340,6 +7340,7 @@ static int nfs4_state_create_net(struct net *net)
	spin_lock_init(&nn->client_lock);
	spin_lock_init(&nn->s2s_cp_lock);
	idr_init(&nn->s2s_cp_stateids);
	atomic_set(&nn->pending_async_copies, 0);

	spin_lock_init(&nn->blocked_locks_lock);
	INIT_LIST_HEAD(&nn->blocked_locks_lru);
+1 −0
Original line number Diff line number Diff line
@@ -579,6 +579,7 @@ struct nfsd4_copy {
	struct vfsmount		*ss_mnt;
	struct nfs_fh		c_fh;
	nfs4_stateid		stateid;
	struct nfsd_net		*cp_nn;
};
extern bool inter_copy_offload_enable;