From patchwork Thu Sep 7 17:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13376735 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32D2EC874C for ; Thu, 7 Sep 2023 17:47:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 467D56B0074; Thu, 7 Sep 2023 13:47:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F2726B0072; Thu, 7 Sep 2023 13:47:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2905D6B0074; Thu, 7 Sep 2023 13:47:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 14D396B0071 for ; Thu, 7 Sep 2023 13:47:26 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E8BF1140F8D for ; Thu, 7 Sep 2023 17:47:25 +0000 (UTC) X-FDA: 81210533250.01.8F4D12C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 5ADC6A000D for ; Thu, 7 Sep 2023 17:47:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nF26xSCA; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694108844; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wD6jndt8wbHj+DL+KkiwehRezl2XHcQmRoPgvfO+F4I=; b=O8wY0R1ua3BrgstlHFK1rilk5y0MpMX6gM9c95Xxzp7MhSeymAUSVhhmp8wNK3DYap7TMc xG/n8sDaSl6nxIEGhhv9Z20bN0AeU40MSONzFkLAPMk0AOqA2pjpg0dFuX9wkxWRteY3zm w/bfsQVjI+oMvFWSYHdFWRaqWA3docs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694108844; a=rsa-sha256; cv=none; b=3+HrKyvH2AUuXGmDRtyoq0JFGdH9r8tNa+Wu1Tk7HVvE1nMQtd+bS3rphX2JZFMnPr19Ca 9oXfrcqtPA6DacXVjhiy1EWL9akeC8s9tXdURi39FTuPmBdKKa0kg2w1ULxY8mFxN3yeIE Mp4n+Bxq0w5rSmOLATz9avw9h6gaEJY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nF26xSCA; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wD6jndt8wbHj+DL+KkiwehRezl2XHcQmRoPgvfO+F4I=; b=nF26xSCABiPufnNgK3G2trN8Zm 15ekZrNYw2ptW9dbui8bV+AHuMNUASEcvB5o1xmBMGDWlFSCSX0C5wAj/svU/64WCqMG5XQ9K+tvj EYN10+S4ZDVeKfrKGbK/HyNHnzL509E2KUjoiBr8rEyDoxk3s1ie3fda6OIL+WD7qTFg/2IxxjK7Q U/3tHfGX4klo3XbKbbvi/aFGhGAiO7HckY8AwXoRANtBsxk4K+scpYQJ4NYQIvbAe9ocTPbszSS1L kyQLCkX0txtmHtVJUcG6kiR4BCbB6Rj6griCoOTUOy1OoPPO1Z1zynUfx0vwTpeNi7JRe4nfQ0pN2 GEq9iA8w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qeJ5w-00CUFP-3W; Thu, 07 Sep 2023 17:47:08 +0000 From: "Matthew Wilcox (Oracle)" To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chandan Babu R , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 3/5] xfs: Use rwsem_is_write_locked() Date: Thu, 7 Sep 2023 18:47:03 +0100 Message-Id: <20230907174705.2976191-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230907174705.2976191-1-willy@infradead.org> References: <20230907174705.2976191-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: ncsj6fugmb8jhafiefytnacxmq6rs1ko X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5ADC6A000D X-Rspam-User: X-HE-Tag: 1694108844-23055 X-HE-Meta: U2FsdGVkX1/jhpyXv7lMwaFDW6sPtBvAviVDqeIMEjy0NUMdBECTQ1Zm9uPG7h3kXo9YOPgZbEG9y+qFEbhOViJkFE4RIJjAyZiZNIQTZpx036QA0ofaZxKWEdMB3vtFKKumk0GSIF3ha+poa8jfXSuJQMAmA90UE+t0EOFqLwk2aj1jy9CCMq2C2WKaMRFwB1fsvmA+OQ4ZqlRV1Pc+ZQkHzd311BdlCG6zgVcRCpNd3N29pLgomEClPdZqetv/nNlENDZUIiqhNa+JGqX3NGNKHJzlIGqZNcRiSYgzzICM02VZhpLNZ/blF5ArQ3sNTBACvHqoAZVHDS7Rt1vtRUjyVXQsbiTzya/pOYLZ5IXLS2IiQcgJkC0XtI8Phq60RlQTcPABXmBCikf+XLMsZBUQW7mitMOtENrE/NH3a1Npdt21K8f4yzxrp4xbSJm81TfVDyuYHOh1WOEauxF0NPJ+g91uLHVEUMZ1nN/zm3harpttS1IxjUJXDBMAEtdbDQfbUm9Ltz7dVyHl7iyOiXz3EsIWRnueCoTzzEntLmjdkpbcqtMgMwkHdi8+sonbhuvJGme643KGgf4onOV2S/TT9Mmq6E5PklnedxtHI/Hv0PG6NGzk+Apcxzv5olHg4l/XMCnPLVyjaSlp9HFpUAZwr6VQ9W+KEsQIqRqCOJDiYB3zHS+MbpPwDJaSg3GOZAl73brXkAfo/2ia+p1Qhxw/+WPG1PQm2ih10fiq52XBKORj0NMzVeq6Ub52SWF8K6R8k2xYqGmJKdTHOlSB0jTjennQkLt/5EdOIO6KF0PhgcmBPAOXaXp9YL+gSpf/h+GXPDNz7bb/R40b122SRv45GR4G6onpxhhGPsEWVMrgztsDLgfZPeTPDhisN8zV5y5c/7vmtQShGGUEpOt8HZpU26XXgZKdp5dndPetfEZYoeGJvI9mrA8yEi888vMAtqO0+LxUHz0pYTnoM8o SMlmgtLG HuRDg/qrFyCK/KYn7CRc6Datq1YsvcdDbPBhqr8XdbmmmqZ7/p29LSBAnFQ+tMf/OQVY+aD1i5GVJFsFBjJzDKU/jOH6dUURMwp5Ee0tSP7Kb8A4VJMzyVbVSwosAI8yMMeIamkr6N9qDOwikbboFtiGCA8rJ1hRSc9lta9o5t+8mATytbJUEmIlVLq4qMtSh4Pl8aFa2Vp38nfK1dbHDNWww93hXPmcBng+v X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This avoids using the mr_writer field to check the XFS ILOCK is held for write. It also improves the checking we do when lockdep is disabled. Signed-off-by: Matthew Wilcox (Oracle) --- fs/xfs/xfs_inode.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 360fe83a334f..e58d84d23f49 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -339,8 +339,11 @@ __xfs_rwsem_islocked( struct rw_semaphore *rwsem, bool shared) { - if (!debug_locks) + if (!debug_locks) { + if (!shared) + return rwsem_is_write_locked(rwsem); return rwsem_is_locked(rwsem); + } if (!shared) return lockdep_is_held_type(rwsem, 0); @@ -359,12 +362,10 @@ xfs_isilocked( struct xfs_inode *ip, uint lock_flags) { - if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) { - if (!(lock_flags & XFS_ILOCK_SHARED)) - return !!ip->i_lock.mr_writer; + if (lock_flags & XFS_ILOCK_SHARED) return rwsem_is_locked(&ip->i_lock.mr_lock); - } - + if (lock_flags & XFS_ILOCK_EXCL) + return rwsem_is_write_locked(&ip->i_lock.mr_lock); if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) { return __xfs_rwsem_islocked(&VFS_I(ip)->i_mapping->invalidate_lock, (lock_flags & XFS_MMAPLOCK_SHARED));