Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3086313ybt; Mon, 29 Jun 2020 15:01:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnw0ENMDzKCxhwp+EiKf7lcA6tbUywFLh8lkDtm3c3UItlGMbPlx6I/4wy1ziA2lJ+UIM2 X-Received: by 2002:a17:906:328d:: with SMTP id 13mr16153208ejw.71.1593468060555; Mon, 29 Jun 2020 15:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593468060; cv=none; d=google.com; s=arc-20160816; b=Yp+03iDmsxiTK/kX0dNTlrC3WutYSIGoGI4TWvmp/gul49maT3auUT4S0NfSglmHWX gSSUSs1/W2COl6opSiY4HG5Y4BbYWAUg9HbQ5lApS0JjRALEaAr5wl74D+aQqEMiLcgf N4DltUhdZU/XCy/DwP2LQb6qGMWTqeX5AuF7gx6peZjDKtbdLLm5H0QWjYV/co8ERWDU fUYRm9vG1HiJD5Hgj3k86kZfZY31hE4muKT5lkm2UQAIsc/H1G/ZrSNPk63Er2sODxCc auldYSZ+g6UnwIopShn91A6Plj0U+hkvuEFV55C8UJByoBZtIzGiy3mBruLtLRGUSWhK Stiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rmRjGxG4d1/VM5pwFzt1lVU30un81dAbrzeJ1PqVSm4=; b=C/3NSmvtsefFDy1CTVWg9a8DlX6qrISwTETo04Um9QUaNRDh7OZzXP+AHIKeTYRsgp 5FVFeQ04IaFxNaBWtLsEuJLT4B5wertujAQDnbnzCT9TL9AnqcOKgZlRzuXEQ9Qjm8UP bbC844ojkia7jfDwF6XCLp55nf0A07Iox5LPu/DZQRzQnTae5QKnCgi7oVi2Y5RlPHwh 6C28WdbEY7SM/pwIrW5856QHgkVVHmFDv2ljk93nLQYhp8fyDyuVqY2Nkjei+GCGfcHB By4PO97rPk1vrOjBCPcn2RMmMgrc7ycq89lWRsrSlE9dhdrUrp5MwCQpdX+dqsHMcNCY Ikng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V3tU5ljD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw21si435029edb.600.2020.06.29.15.00.37; Mon, 29 Jun 2020 15:01:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V3tU5ljD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404707AbgF2V5c (ORCPT + 99 others); Mon, 29 Jun 2020 17:57:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:56890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726493AbgF2Sf3 (ORCPT ); Mon, 29 Jun 2020 14:35:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3B4F247B6; Mon, 29 Jun 2020 15:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444122; bh=+lP1ivIjJCHetDSwDDW71ytRb636cQUIiBGy7Wq4WhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V3tU5ljD1OfTD/5R7gemaE02TVD5lSk4SFKTY43lrynpcVhMGOD9LrQ77+mQHMEGO LEsAnevhHbf0fbQ6oTs7JvMsJ8iAdIIVfWZ3ESvVBFnMhdpgFrCcfplOdnKLEbGJDE LF5ep+ooh/d8J17UaY1+oh8iduHdeZ1fO8zfMnqs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Junxiao Bi , Joseph Qi , Changwei Ge , Gang He , Joel Becker , Jun Piao , Mark Fasheh , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman Subject: [PATCH 5.7 231/265] ocfs2: avoid inode removal while nfsd is accessing it Date: Mon, 29 Jun 2020 11:17:44 -0400 Message-Id: <20200629151818.2493727-232-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Junxiao Bi commit 4cd9973f9ff69e37dd0ba2bd6e6423f8179c329a upstream. Patch series "ocfs2: fix nfsd over ocfs2 issues", v2. This is a series of patches to fix issues on nfsd over ocfs2. patch 1 is to avoid inode removed while nfsd access it patch 2 & 3 is to fix a panic issue. This patch (of 4): When nfsd is getting file dentry using handle or parent dentry of some dentry, one cluster lock is used to avoid inode removed from other node, but it still could be removed from local node, so use a rw lock to avoid this. Link: http://lkml.kernel.org/r/20200616183829.87211-1-junxiao.bi@oracle.com Link: http://lkml.kernel.org/r/20200616183829.87211-2-junxiao.bi@oracle.com Signed-off-by: Junxiao Bi Reviewed-by: Joseph Qi Cc: Changwei Ge Cc: Gang He Cc: Joel Becker Cc: Jun Piao Cc: Mark Fasheh Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/dlmglue.c | 17 ++++++++++++++++- fs/ocfs2/ocfs2.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 152a0fc4e9051..751bc4dc74663 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -689,6 +689,12 @@ static void ocfs2_nfs_sync_lock_res_init(struct ocfs2_lock_res *res, &ocfs2_nfs_sync_lops, osb); } +static void ocfs2_nfs_sync_lock_init(struct ocfs2_super *osb) +{ + ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb); + init_rwsem(&osb->nfs_sync_rwlock); +} + void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb) { struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; @@ -2855,6 +2861,11 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex) if (ocfs2_is_hard_readonly(osb)) return -EROFS; + if (ex) + down_write(&osb->nfs_sync_rwlock); + else + down_read(&osb->nfs_sync_rwlock); + if (ocfs2_mount_local(osb)) return 0; @@ -2873,6 +2884,10 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex) if (!ocfs2_mount_local(osb)) ocfs2_cluster_unlock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE); + if (ex) + up_write(&osb->nfs_sync_rwlock); + else + up_read(&osb->nfs_sync_rwlock); } int ocfs2_trim_fs_lock(struct ocfs2_super *osb, @@ -3340,7 +3355,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) local: ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); - ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb); + ocfs2_nfs_sync_lock_init(osb); ocfs2_orphan_scan_lock_res_init(&osb->osb_orphan_scan.os_lockres, osb); osb->cconn = conn; diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 9150cfa4df7dc..9461bd3e1c0c8 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -394,6 +394,7 @@ struct ocfs2_super struct ocfs2_lock_res osb_super_lockres; struct ocfs2_lock_res osb_rename_lockres; struct ocfs2_lock_res osb_nfs_sync_lockres; + struct rw_semaphore nfs_sync_rwlock; struct ocfs2_lock_res osb_trim_fs_lockres; struct mutex obs_trim_fs_mutex; struct ocfs2_dlm_debug *osb_dlm_debug; -- 2.25.1