Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6902650rdb; Fri, 15 Dec 2023 11:17:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzQJMmV1ZLwSjaZzanXTI2cJ7lSNT673+wbwdoYdts/T6mUgEff6OEV120/I4x6OoRqp/u X-Received: by 2002:a50:ab12:0:b0:551:188f:8bb with SMTP id s18-20020a50ab12000000b00551188f08bbmr6255967edc.45.1702667866693; Fri, 15 Dec 2023 11:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702667866; cv=none; d=google.com; s=arc-20160816; b=LZu5s/lhInn5K7N8AOkyd0c7kslh5Iqk++P3n4sRhQ78k5Wx5UGCcYQYWrDZ6Phsn4 iLv60ExxAICvCfpC5BZHdGfaW6nvz7T1nyQprFscd8CEDilRPo430kYOVOGwg/+PF6lW +gIdoBcfo0g5VSNzwLqC6N6GZiujPebcRfS8u5tpbPhcAPF1nbx3eb48zXmXU7vdoMjz 6Ym5uEUmcakZScN8VXgLuKV1eZ4tiMS2HM6K0JbxyL/zaCIAtYmJPbMaSl8BJiMrK6XA jcZGDILMLYZeasrL2hN2R1PGrW+JsWE4tcyF6IYFwrC7eYpJ+xkCWpOFVIOST6HTgG5X 18hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=n4ujrx9voqvIVS/sjBPNAir6ur/tgh0jeTvzuCmTNo4=; fh=9WVYkZZswu7tyxO2G/iFh5l6I+hfRv2+m7yU+1XOfCw=; b=n9dJ2nwMR87l5xZUIhShkdKYZJcQLTlLreS4NRyYYJDmE1LVEfbZQDfbEhdd9QnF15 OE+CwAC1Thnu0sV7x3NdFIOtd3zEwQ7HxjCMVXy82of4yDiHYdY5MKnsCgL0mLdgPiIB +q1v3IC5kjsY8cJZpB1IjCYDInrDDd2M8SHDDosz2VyNYmxRW4Mz52VKbRT8tHJgJz9p x1MNZmIjMqja6IaIB/QEUEXwgQdrfMcN89Qa0n7VW2KfG99IEYrOYRaHk6HBNT3bZO5c ITDB8RDpfINuJOC4BUs+Ek+LAh0t6jbmv9AEkyO1pLXwWlTdf1YIrtGg4FG/5vsV57Je kFEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=mZJ+Vzbp; spf=pass (google.com: domain of linux-nfs+bounces-635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id co7-20020a0564020c0700b00552f68f4596si35240edb.423.2023.12.15.11.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 11:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=mZJ+Vzbp; spf=pass (google.com: domain of linux-nfs+bounces-635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 75B361F24A63 for ; Fri, 15 Dec 2023 19:17:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CC2C3FE3F; Fri, 15 Dec 2023 19:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mZJ+Vzbp" X-Original-To: linux-nfs@vger.kernel.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 933A43FE2C for ; Fri, 15 Dec 2023 19:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BFI49iE022609; Fri, 15 Dec 2023 19:15:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=n4ujrx9voqvIVS/sjBPNAir6ur/tgh0jeTvzuCmTNo4=; b=mZJ+VzbpfbgiWt8dZD/Ky2rB+LYPxB7nJSsSprzfJjhxx4yQHiRMz5Fpzn8cLnd6C313 dcc6Io9TSJJBdu8chhe6y7VgDEQ87lCCup3riS7AhCV/2LUF68UDXdLjDl0b57bdijxL D0CSETfsAm4NAkrJnXPjKmOTTfZSzPeVwUumfMwURQnXTpKuPqp295EZAunlYyTZOrO2 dfawFfOt4dmEgMLQJXVS4T63tFLfzuncKA6E72Z5Rb1JPhTyWfVSaJt7aj8bbh7+tuz0 jPaRaNjktOEYo1GOfc1woGhDifshjkaGIHrx/vHZ6eVdNBQ5fcPIfF1Lw6zd2WfrmNkm kw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uvg9de7xr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Dec 2023 19:15:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3BFIJI7O016695; Fri, 15 Dec 2023 19:15:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3uvepcfqnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Dec 2023 19:15:24 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BFJEAbU013855; Fri, 15 Dec 2023 19:15:24 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3uvepcfqmh-3; Fri, 15 Dec 2023 19:15:24 +0000 From: Dai Ngo To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, linux-nfs@stwm.de Subject: [PATCH 2/3] NFSD: restore delegation's sc_count if nfsd4_run_cb fails Date: Fri, 15 Dec 2023 11:15:02 -0800 Message-Id: <1702667703-17978-3-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1702667703-17978-1-git-send-email-dai.ngo@oracle.com> References: <1702667703-17978-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-15_10,2023-12-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312150135 X-Proofpoint-GUID: 5RL8H_Rni1u-eSEmEczIdcd_isvvHk3Y X-Proofpoint-ORIG-GUID: 5RL8H_Rni1u-eSEmEczIdcd_isvvHk3Y Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Under some load conditions the callback work request can not be queued and nfsd4_run_cb returns 0 to caller. When this happens, the sc_count of the delegation state was left with an extra reference count preventing the state to be freed later. Signed-off-by: Dai Ngo --- fs/nfsd/nfs4state.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 40415929e2ae..175f3e9f5822 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2947,8 +2947,14 @@ void nfs4_cb_getattr(struct nfs4_cb_fattr *ncf) if (test_and_set_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags)) return; + refcount_inc(&dp->dl_stid.sc_count); - nfsd4_run_cb(&ncf->ncf_getattr); + if (!nfsd4_run_cb(&ncf->ncf_getattr)) { + refcount_dec(&dp->dl_stid.sc_count); + clear_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags); + wake_up_bit(&ncf->ncf_cb_flags, CB_GETATTR_BUSY); + WARN_ON_ONCE(1); + } } static struct nfs4_client *create_client(struct xdr_netobj name, @@ -4967,7 +4973,10 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) * we know it's safe to take a reference. */ refcount_inc(&dp->dl_stid.sc_count); - WARN_ON_ONCE(!nfsd4_run_cb(&dp->dl_recall)); + if (!nfsd4_run_cb(&dp->dl_recall)) { + refcount_dec(&dp->dl_stid.sc_count); + WARN_ON_ONCE(1); + } } /* Called from break_lease() with flc_lock held. */ @@ -8543,12 +8552,12 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode, return 0; } break_lease: - spin_unlock(&ctx->flc_lock); nfsd_stats_wdeleg_getattr_inc(); - dp = fl->fl_owner; ncf = &dp->dl_cb_fattr; nfs4_cb_getattr(&dp->dl_cb_fattr); + spin_unlock(&ctx->flc_lock); + wait_on_bit(&ncf->ncf_cb_flags, CB_GETATTR_BUSY, TASK_INTERRUPTIBLE); if (ncf->ncf_cb_status) { status = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ)); -- 2.39.3