From patchwork Thu Feb 10 04:52:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dai Ngo X-Patchwork-Id: 12741272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDA2DC433EF for ; Thu, 10 Feb 2022 04:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233733AbiBJEwT (ORCPT ); Wed, 9 Feb 2022 23:52:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233689AbiBJEwQ (ORCPT ); Wed, 9 Feb 2022 23:52:16 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E948E1B2; Wed, 9 Feb 2022 20:52:18 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21A4BUuo008865; Thu, 10 Feb 2022 04:52:16 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-2021-07-09; bh=Vi53N9K+no5Si4hDwTa3a+jRSwTqKUCqjS/7QKeHLJE=; b=YBNk5P1w/AzesyHWzMu97QMUIgre2bZTD3g48vhNqieqjpyf14X2UoPC5DJwcCBT8cgU LTX/1juay5l0RxRTWe5bqFrqnf00InX+0lv27Nnuu6Y3z9ZnxaiSR+0ZF/8G3pmUk864 zkCrnDqmb5yd27LqEoCFxrkhLK6D8oULxOU20GNLSKNWb7icLC2oCOn7mqAPS0SftOZ1 2AMB8Mj5U9yncNO/34AmJWtMxa99qpkorv+FhkpiOMyNr27DYTUeiAm7hvJwxQz0hF28 RBgYCx2NBbWMw4sERlH0/fdM13dLOr7mqyA0fqYx6NlqKu/og1u31Un9WBS2TP64o5Np 7g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3fpgpxvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Feb 2022 04:52:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21A4oCX3015373; Thu, 10 Feb 2022 04:52:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 3e1f9jk20t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Feb 2022 04:52:14 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 21A4qC5Q020851; Thu, 10 Feb 2022 04:52:14 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by aserp3030.oracle.com with ESMTP id 3e1f9jk1y6-3; Thu, 10 Feb 2022 04:52:14 +0000 From: Dai Ngo To: chuck.lever@oracle.com, bfields@fieldses.org Cc: jlayton@redhat.com, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH RFC v12 2/3] fs/lock: only call lm_breaker_owns_lease if there is conflict. Date: Wed, 9 Feb 2022 20:52:08 -0800 Message-Id: <1644468729-30383-3-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1644468729-30383-1-git-send-email-dai.ngo@oracle.com> References: <1644468729-30383-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-GUID: WUEzyr6ZTW3pjHD-xp-eUkj5LdDJqtYw X-Proofpoint-ORIG-GUID: WUEzyr6ZTW3pjHD-xp-eUkj5LdDJqtYw Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Modify leases_conflict to call lm_breaker_owns_lease only if there is real conflict. This is to allow the lock manager to resolve the conflict if possible. Signed-off-by: Dai Ngo --- fs/locks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 052b42cc7f25..456717873cff 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1357,9 +1357,6 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker) { bool rc; - if (lease->fl_lmops->lm_breaker_owns_lease - && lease->fl_lmops->lm_breaker_owns_lease(lease)) - return false; if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) { rc = false; goto trace; @@ -1370,6 +1367,9 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker) } rc = locks_conflict(breaker, lease); + if (rc && lease->fl_lmops->lm_breaker_owns_lease && + lease->fl_lmops->lm_breaker_owns_lease(lease)) + rc = false; trace: trace_leases_conflict(rc, lease, breaker); return rc;