From patchwork Fri Jun 18 18:53:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12332025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B131C48BE8 for ; Fri, 18 Jun 2021 18:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B37D613E9 for ; Fri, 18 Jun 2021 18:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbhFRS4K (ORCPT ); Fri, 18 Jun 2021 14:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbhFRS4J (ORCPT ); Fri, 18 Jun 2021 14:56:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF18A613E2; Fri, 18 Jun 2021 18:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624042439; bh=/s07VwNw72ghCw8RDkaH2rD3zQgSoHypDk34lH8Zyik=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=W7ieP0mgONcSCFwc4TmuYpcaXPexfI0LUnsKsDdj6o7mozx+zKRjmAVafcNpghXWr hivmwnNWowvb+KXRBdocw5HWnvORQd0QGyXgi9658TROM1aNGJJTFWvwhKgIVHLM8L Nx1/onUv4tYSG6AgYZbin593McIDYH9Jl9L0YNPBhq3cpdnaMXkCKtdBd03Kqc43IH QY4qqggiAk9fb3yhqIBr6IgAwjtEJpgXtSC/dnrP2Pq/RgehBYLQdJ0v6KGflc5j5E DUJSB/molBB4bvLVir5sadofAATDaAO93ZhKVYi4N6RSBb4FY5WTJf73WDrMO1QbOw cf/jcf9hWT8RQ== Subject: [PATCH 1/3] xfs: fix type mismatches in the inode reclaim functions From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , Chandan Babu R , linux-xfs@vger.kernel.org, hch@infradead.org, chandanrlinux@gmail.com, bfoster@redhat.com Date: Fri, 18 Jun 2021 11:53:59 -0700 Message-ID: <162404243951.2377241.4625544936148599795.stgit@locust> In-Reply-To: <162404243382.2377241.18273624393083430320.stgit@locust> References: <162404243382.2377241.18273624393083430320.stgit@locust> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong It's currently unlikely that we will ever end up with more than 4 billion inodes waiting for reclamation, but the fs object code uses long int for object counts and we're certainly capable of generating that many. Instead of truncating the internal counters, widen them and report the object counts correctly. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Chandan Babu R Reviewed-by: Dave Chinner --- fs/xfs/xfs_icache.c | 8 ++++---- fs/xfs/xfs_icache.h | 6 +++--- fs/xfs/xfs_trace.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 6b44fc734cb5..6007683482c6 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -1084,11 +1084,11 @@ xfs_reclaim_inodes( long xfs_reclaim_inodes_nr( struct xfs_mount *mp, - int nr_to_scan) + unsigned long nr_to_scan) { struct xfs_icwalk icw = { .icw_flags = XFS_ICWALK_FLAG_SCAN_LIMIT, - .icw_scan_limit = nr_to_scan, + .icw_scan_limit = min_t(unsigned long, LONG_MAX, nr_to_scan), }; if (xfs_want_reclaim_sick(mp)) @@ -1106,13 +1106,13 @@ xfs_reclaim_inodes_nr( * Return the number of reclaimable inodes in the filesystem for * the shrinker to determine how much to reclaim. */ -int +long xfs_reclaim_inodes_count( struct xfs_mount *mp) { struct xfs_perag *pag; xfs_agnumber_t ag = 0; - int reclaimable = 0; + long reclaimable = 0; while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) { ag = pag->pag_agno + 1; diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index 00dc98a92835..c751cc32dc46 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h @@ -15,7 +15,7 @@ struct xfs_icwalk { kgid_t icw_gid; prid_t icw_prid; __u64 icw_min_file_size; - int icw_scan_limit; + long icw_scan_limit; }; /* Flags that reflect xfs_fs_eofblocks functionality. */ @@ -49,8 +49,8 @@ void xfs_inode_free(struct xfs_inode *ip); void xfs_reclaim_worker(struct work_struct *work); void xfs_reclaim_inodes(struct xfs_mount *mp); -int xfs_reclaim_inodes_count(struct xfs_mount *mp); -long xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan); +long xfs_reclaim_inodes_count(struct xfs_mount *mp); +long xfs_reclaim_inodes_nr(struct xfs_mount *mp, unsigned long nr_to_scan); void xfs_inode_mark_reclaimable(struct xfs_inode *ip); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 428dc71f7f8b..85fa864f8e2f 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3894,7 +3894,7 @@ DECLARE_EVENT_CLASS(xfs_icwalk_class, __field(uint32_t, gid) __field(prid_t, prid) __field(__u64, min_file_size) - __field(int, scan_limit) + __field(long, scan_limit) __field(unsigned long, caller_ip) ), TP_fast_assign( @@ -3909,7 +3909,7 @@ DECLARE_EVENT_CLASS(xfs_icwalk_class, __entry->scan_limit = icw ? icw->icw_scan_limit : 0; __entry->caller_ip = caller_ip; ), - TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %d caller %pS", + TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %ld caller %pS", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->flags, __entry->uid, From patchwork Fri Jun 18 18:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12332027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88233C48BDF for ; Fri, 18 Jun 2021 18:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 700C161209 for ; Fri, 18 Jun 2021 18:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbhFRS4P (ORCPT ); Fri, 18 Jun 2021 14:56:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:57058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbhFRS4O (ORCPT ); Fri, 18 Jun 2021 14:56:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 55E8C613E2; Fri, 18 Jun 2021 18:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624042445; bh=f1hw58I/DOcO+olYszejb9hFX41cDm58bja+XIhTh0w=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bUSLXezew2lrZGHfK1tJLe4VKaTVhEZSEKyEcHgSuBgygCbdrH5VHIB0Cli6d50DH B5WEe5z26WkItPw0tBytwqn7BLYT+BJgoSjN3kSa7zyMc35UbhQVHJdT4vUCzQbbyp ez2jaZ8VAy8WaCbPPxxI6kTA8Zahd2KA2s2mHHJzUOQjxXRC18Z9FiOntjs9enp+G3 3wCPvJB1Ulsa5hkEQHRIS7TYOwxw6K/yOvxOtNF5f5eLH+RBDQxVG4L1kzPbDRxHlO AcglmruvUIhotXoYiul6zqzto3gyCdV25CsuRbA3mtDCh1n1Hz5Ft4fhVu2V5krmCl ++1fJcUxwarOw== Subject: [PATCH 2/3] xfs: print name of function causing fs shutdown instead of hex pointer From: "Darrick J. Wong" To: djwong@kernel.org Cc: Brian Foster , linux-xfs@vger.kernel.org, hch@infradead.org, chandanrlinux@gmail.com, bfoster@redhat.com Date: Fri, 18 Jun 2021 11:54:05 -0700 Message-ID: <162404244503.2377241.5074228710477395763.stgit@locust> In-Reply-To: <162404243382.2377241.18273624393083430320.stgit@locust> References: <162404243382.2377241.18273624393083430320.stgit@locust> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In xfs_do_force_shutdown, print the symbolic name of the function that called us to shut down the filesystem instead of a raw hex pointer. This makes debugging a lot easier: XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file fs/xfs/xfs_log.c. Return address = ffffffffa038bc38 becomes: XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file fs/xfs/xfs_log.c. Return address = xfs_trans_mod_sb+0x25 Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Dave Chinner Reviewed-by: Chandan Babu R Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_fsops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 07c745cd483e..b7f979eca1e2 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -543,7 +543,7 @@ xfs_do_force_shutdown( } xfs_notice(mp, -"%s(0x%x) called from line %d of file %s. Return address = "PTR_FMT, +"%s(0x%x) called from line %d of file %s. Return address = %pS", __func__, flags, lnnum, fname, __return_address); if (flags & SHUTDOWN_CORRUPT_INCORE) { From patchwork Fri Jun 18 18:54:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12332029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31375C48BDF for ; Fri, 18 Jun 2021 18:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15447613ED for ; Fri, 18 Jun 2021 18:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbhFRS4V (ORCPT ); Fri, 18 Jun 2021 14:56:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:57086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbhFRS4U (ORCPT ); Fri, 18 Jun 2021 14:56:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF06561209; Fri, 18 Jun 2021 18:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624042450; bh=ykhEUEm9WONsb4V/zWKuyrCWMmqeDg2xWoxVdZMCusc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bJSsMeWo/ZHkub6JAype91QjJeBec8GTHPnp6gC9HXXy7R0eo21L3W4P7hQF5WMrf PbVRj5/jViz7VzaPErrzbYR8x7adbwpf0H7OxotYNUNwaVFJe1+HiRWt/hZFGdl8DF EI3THd5Z6MYg454t3OUfhZt87xhiDt3FWJgstSzkmfdwRGSrmzFP83PqopM0zDSgq5 Y8O73kwUgYwrCJY3Q/Q4BG1vfyngBYkOjnTwF7d6d/PwkYeXezKuQSX/yc4vDxSq1D S6SKEqmoFGzUR+H7A+ZAx2ybQmhRUZWoIq1CO8uwJxWi5jGoaw18ImZanBRhYF7x2P A5OYYj0Znhe0g== Subject: [PATCH 3/3] xfs: shorten the shutdown messages to a single line From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@infradead.org, chandanrlinux@gmail.com, bfoster@redhat.com Date: Fri, 18 Jun 2021 11:54:10 -0700 Message-ID: <162404245053.2377241.2678360661858649500.stgit@locust> In-Reply-To: <162404243382.2377241.18273624393083430320.stgit@locust> References: <162404243382.2377241.18273624393083430320.stgit@locust> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Chandan Babu R --- fs/xfs/xfs_fsops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index b7f979eca1e2..6ed29b158312 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -538,25 +538,25 @@ xfs_do_force_shutdown( if (flags & SHUTDOWN_FORCE_UMOUNT) { xfs_alert(mp, -"User initiated shutdown received. Shutting down filesystem"); +"User initiated shutdown (0x%x) received. Shutting down filesystem", + flags); return; } - xfs_notice(mp, -"%s(0x%x) called from line %d of file %s. Return address = %pS", - __func__, flags, lnnum, fname, __return_address); - if (flags & SHUTDOWN_CORRUPT_INCORE) { xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT, -"Corruption of in-memory data detected. Shutting down filesystem"); +"Corruption of in-memory data (0x%x) detected at %pS (%s:%d). Shutting down filesystem", + flags, __return_address, fname, lnnum); if (XFS_ERRLEVEL_HIGH <= xfs_error_level) xfs_stack_trace(); } else if (logerror) { xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR, - "Log I/O Error Detected. Shutting down filesystem"); +"Log I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem", + flags, __return_address, fname, lnnum); } else { xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR, - "I/O Error Detected. Shutting down filesystem"); +"I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem", + flags, __return_address, fname, lnnum); } xfs_alert(mp,