From patchwork Wed Sep 15 23:06:40 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: 12497729 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.4 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 21AFFC433F5 for ; Wed, 15 Sep 2021 23:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03F9760EE3 for ; Wed, 15 Sep 2021 23:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232133AbhIOXIA (ORCPT ); Wed, 15 Sep 2021 19:08:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:59222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbhIOXIA (ORCPT ); Wed, 15 Sep 2021 19:08:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91C02606A5; Wed, 15 Sep 2021 23:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747200; bh=+NNk8NJIZuoJAGUQRQyXuasKf+moBwnT8d4wAJnO3NU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Dk1uHBOlVE6165tY8S/FAqRe0uLzX/NCmiEohJqrBGCk6Gg4gYJtr/6eXr4RT8r8o h2TovNH+fuByujgV1GDqKZtNRLk2nQx6deDHc2Q5ir+ctWR2gvWe6byGR3StHI9PaT S9BTKhtx7OMBiOc2YRLUW8xTahDthCQ4dKRxU49t2/GA2zeJdeANWQc+95UUm4vNgl u86fenut8ZJ6jxoYrp6bwHz5N6mzRxSoI6gTrSx0fVM+Y+Y32tyCX5O7PSFbFd2g/6 mnXaMlCUkJtfgEzyXMZ0hX3FsH1gYMxqs3Hi1N/fue1YpvmNw2/gayjPO2mUH4EhvY KIQGtZDnGmkoQ== Subject: [PATCH 01/61] mkfs: move mkfs/proto.c declarations to mkfs/proto.h From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:06:40 -0700 Message-ID: <163174720034.350433.11964220787370567480.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> 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 These functions are only used by mkfs, so move them to a separate header file that isn't in an internal library. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- include/xfs_multidisk.h | 5 ----- mkfs/proto.c | 1 + mkfs/proto.h | 13 +++++++++++++ mkfs/xfs_mkfs.c | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 mkfs/proto.h diff --git a/include/xfs_multidisk.h b/include/xfs_multidisk.h index abfb50ce..a16a9fe2 100644 --- a/include/xfs_multidisk.h +++ b/include/xfs_multidisk.h @@ -42,9 +42,4 @@ #define XFS_NOMULTIDISK_AGLOG 2 /* 4 AGs */ #define XFS_MULTIDISK_AGCOUNT (1 << XFS_MULTIDISK_AGLOG) -/* proto.c */ -extern char *setup_proto (char *fname); -extern void parse_proto (xfs_mount_t *mp, struct fsxattr *fsx, char **pp); -extern void res_failed (int err); - #endif /* __XFS_MULTIDISK_H__ */ diff --git a/mkfs/proto.c b/mkfs/proto.c index 6b22cc6a..ef130ed6 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -7,6 +7,7 @@ #include "libxfs.h" #include #include "libfrog/convert.h" +#include "proto.h" /* * Prototypes for internal functions. diff --git a/mkfs/proto.h b/mkfs/proto.h new file mode 100644 index 00000000..9ccbddf6 --- /dev/null +++ b/mkfs/proto.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2000-2001,2004-2005 Silicon Graphics, Inc. + * All Rights Reserved. + */ +#ifndef MKFS_PROTO_H_ +#define MKFS_PROTO_H_ + +extern char *setup_proto (char *fname); +extern void parse_proto (xfs_mount_t *mp, struct fsxattr *fsx, char **pp); +extern void res_failed (int err); + +#endif /* MKFS_PROTO_H_ */ diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 9c14c04e..16e347e5 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -11,6 +11,7 @@ #include "libfrog/fsgeom.h" #include "libfrog/topology.h" #include "libfrog/convert.h" +#include "proto.h" #include #define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog))) From patchwork Wed Sep 15 23:06:45 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: 12497731 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.4 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 4B72AC433F5 for ; Wed, 15 Sep 2021 23:06:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A432606A5 for ; Wed, 15 Sep 2021 23:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232193AbhIOXIF (ORCPT ); Wed, 15 Sep 2021 19:08:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:59320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbhIOXIF (ORCPT ); Wed, 15 Sep 2021 19:08:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C27F600D4; Wed, 15 Sep 2021 23:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747206; bh=fhMKfQR0w/iOzdOuz2Edc1i0i6yRSPzb3TkriaKtr5g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bAD+q0ePBqgCz2ze0IPF6GSAOs71x+tO2iaLpAf+eKtxXnLyYTni8kPwNPIpDygkc /U4DEBtRWsZd0w7vkNFRtxpOEb//nFNFeM/6564KPrIrajlAXdkXV36Y6vjml0AJYs aEtrF/MxKHbjFDoirhTQgBSzY5yIo1VR86zJ+73gC9122y1g9L+ZD0Mk27PQQsh/NZ 3YoQyaaafrLyvHp8NCQbcm0/lki5SUS7yKzz3zhAAiCQzg5DXr/tlB5RGGfGrT+CqZ 1vQmB8rzMbq9A6yW6KWaDuodR4z6xYwk2+l4pZcmkUz5+jD44V5SWE3dqiRLDGyb0m 2KBlWS2lBJ5Jg== Subject: [PATCH 02/61] libfrog: move topology.[ch] to libxfs From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:06:45 -0700 Message-ID: <163174720579.350433.12686413907945599656.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> 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 The topology code depends on a few libxfs structures and is only needed by mkfs and xfs_repair. Move this code to libxfs to reduce the size of libfrog and to avoid build failures caused by "xfs: move perag structure and setup to libxfs/xfs_ag.[ch]". Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- include/libxfs.h | 1 + libfrog/Makefile | 2 -- libxfs/Makefile | 10 ++++++---- libxfs/topology.c | 5 ++--- libxfs/topology.h | 6 +++--- mkfs/xfs_mkfs.c | 1 - repair/sb.c | 1 - 7 files changed, 12 insertions(+), 14 deletions(-) rename libfrog/topology.c => libxfs/topology.c (99%) rename libfrog/topology.h => libxfs/topology.h (88%) diff --git a/include/libxfs.h b/include/libxfs.h index bc07655e..36ae86cc 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -213,5 +213,6 @@ int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); #include "xfs_attr.h" +#include "topology.h" #endif /* __LIBXFS_H__ */ diff --git a/libfrog/Makefile b/libfrog/Makefile index 395ce308..01107082 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -27,7 +27,6 @@ projects.c \ ptvar.c \ radix-tree.c \ scrub.c \ -topology.c \ util.c \ workqueue.c @@ -47,7 +46,6 @@ projects.h \ ptvar.h \ radix-tree.h \ scrub.h \ -topology.h \ workqueue.h LSRCFILES += gen_crc32table.c diff --git a/libxfs/Makefile b/libxfs/Makefile index de595b7c..3e3c4bd0 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -20,6 +20,11 @@ PKGHFILES = xfs_fs.h \ xfs_log_format.h HFILES = \ + libxfs_io.h \ + libxfs_api_defs.h \ + init.h \ + libxfs_priv.h \ + topology.h \ xfs_ag_resv.h \ xfs_alloc.h \ xfs_alloc_btree.h \ @@ -48,10 +53,6 @@ HFILES = \ xfs_shared.h \ xfs_trans_resv.h \ xfs_trans_space.h \ - libxfs_io.h \ - libxfs_api_defs.h \ - init.h \ - libxfs_priv.h \ xfs_dir2_priv.h CFILES = cache.c \ @@ -60,6 +61,7 @@ CFILES = cache.c \ kmem.c \ logitem.c \ rdwr.c \ + topology.c \ trans.c \ util.c \ xfs_ag.c \ diff --git a/libfrog/topology.c b/libxfs/topology.c similarity index 99% rename from libfrog/topology.c rename to libxfs/topology.c index b1b470c9..a17c1969 100644 --- a/libfrog/topology.c +++ b/libxfs/topology.c @@ -4,14 +4,13 @@ * All Rights Reserved. */ -#include "libxfs.h" +#include "libxfs_priv.h" #include "libxcmd.h" #ifdef ENABLE_BLKID # include #endif /* ENABLE_BLKID */ #include "xfs_multidisk.h" -#include "topology.h" -#include "platform.h" +#include "libfrog/platform.h" #define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog))) #define GIGABYTES(count, blog) ((uint64_t)(count) << (30 - (blog))) diff --git a/libfrog/topology.h b/libxfs/topology.h similarity index 88% rename from libfrog/topology.h rename to libxfs/topology.h index 6fde868a..1a0fe24c 100644 --- a/libfrog/topology.h +++ b/libxfs/topology.h @@ -4,8 +4,8 @@ * All Rights Reserved. */ -#ifndef __LIBFROG_TOPOLOGY_H__ -#define __LIBFROG_TOPOLOGY_H__ +#ifndef __LIBXFS_TOPOLOGY_H__ +#define __LIBXFS_TOPOLOGY_H__ /* * Device topology information. @@ -36,4 +36,4 @@ extern int check_overwrite( const char *device); -#endif /* __LIBFROG_TOPOLOGY_H__ */ +#endif /* __LIBXFS_TOPOLOGY_H__ */ diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 16e347e5..53904677 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -9,7 +9,6 @@ #include "xfs_multidisk.h" #include "libxcmd.h" #include "libfrog/fsgeom.h" -#include "libfrog/topology.h" #include "libfrog/convert.h" #include "proto.h" #include diff --git a/repair/sb.c b/repair/sb.c index 17ce43cc..90f32e74 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -12,7 +12,6 @@ #include "protos.h" #include "err_protos.h" #include "xfs_multidisk.h" -#include "libfrog/topology.h" #define BSIZE (1024 * 1024) From patchwork Wed Sep 15 23:06:51 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: 12497733 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.4 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 CD9E4C433EF for ; Wed, 15 Sep 2021 23:06:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC5D2600D4 for ; Wed, 15 Sep 2021 23:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbhIOXIL (ORCPT ); Wed, 15 Sep 2021 19:08:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:59466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbhIOXIL (ORCPT ); Wed, 15 Sep 2021 19:08:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B28F600D4; Wed, 15 Sep 2021 23:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747211; bh=BoE6Mah6MLsucmaJwjn541X/VO8tKa+6QXmsPGJ+jMA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=BhlSYDsBVK+NssRCIqeS/Q60c9/9NtnXdltq59W6/g84GSoQox7ZgNEASIHgBFjJ1 04eVNrHKeXaKjoIm/wWWxUQ5JV0lXbCIEiOty3DULl2OUeOcLptYI5br3sIuj9RQqK cjYXPWScQ+7QKWbcQ457o/boMJPiwW6xTYvq3YH8Tahg+C7emkqp3j280u0GQk9Tg3 civY8CHrBTVNo2lj+PBK4h/XP995qf3EDRO7QEVAfeOp0rJCvte0e4rOovz5MZAix7 oWRYYJcps7y/0dMs3iU/8OKk/TXnWmsWToh5RuBDKYLZyqYD2nkHck+faDwWqoTUuu umjSwJ5PBI25A== Subject: [PATCH 03/61] libfrog: create header file for mocked-up kernel data structures From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:06:51 -0700 Message-ID: <163174721123.350433.6338166230233894732.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> 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 Create a mockups.h for mocked-up versions of kernel data structures to ease porting of libxfs code. Signed-off-by: Darrick J. Wong --- include/libxfs.h | 1 + libfrog/Makefile | 1 + libfrog/mockups.h | 19 +++++++++++++++++++ libxfs/libxfs_priv.h | 4 +--- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 libfrog/mockups.h diff --git a/include/libxfs.h b/include/libxfs.h index 36ae86cc..c297152f 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -17,6 +17,7 @@ #include "bitops.h" #include "kmem.h" #include "libfrog/radix-tree.h" +#include "libfrog/mockups.h" #include "atomic.h" #include "xfs_types.h" diff --git a/libfrog/Makefile b/libfrog/Makefile index 01107082..5381d9b5 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -41,6 +41,7 @@ crc32defs.h \ crc32table.h \ fsgeom.h \ logging.h \ +mockups.h \ paths.h \ projects.h \ ptvar.h \ diff --git a/libfrog/mockups.h b/libfrog/mockups.h new file mode 100644 index 00000000..f00a9e41 --- /dev/null +++ b/libfrog/mockups.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2000-2005 Silicon Graphics, Inc. + * All Rights Reserved. + */ +#ifndef __LIBFROG_MOCKUPS_H__ +#define __LIBFROG_MOCKUPS_H__ + +/* Mockups of kernel data structures. */ + +typedef struct spinlock { +} spinlock_t; + +#define spin_lock_init(lock) ((void) 0) + +#define spin_lock(a) ((void) 0) +#define spin_unlock(a) ((void) 0) + +#endif /* __LIBFROG_MOCKUPS_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 7181a858..727f6be8 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -47,6 +47,7 @@ #include "bitops.h" #include "kmem.h" #include "libfrog/radix-tree.h" +#include "libfrog/mockups.h" #include "atomic.h" #include "xfs_types.h" @@ -205,9 +206,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #endif /* miscellaneous kernel routines not in user space */ -#define spin_lock_init(a) ((void) 0) -#define spin_lock(a) ((void) 0) -#define spin_unlock(a) ((void) 0) #define likely(x) (x) #define unlikely(x) (x) #define rcu_read_lock() ((void) 0) From patchwork Wed Sep 15 23:06:56 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: 12497735 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.4 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 AAD41C433F5 for ; Wed, 15 Sep 2021 23:06:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ED14600D4 for ; Wed, 15 Sep 2021 23:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231197AbhIOXIR (ORCPT ); Wed, 15 Sep 2021 19:08:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232684AbhIOXIQ (ORCPT ); Wed, 15 Sep 2021 19:08:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E18FE606A5; Wed, 15 Sep 2021 23:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747217; bh=IrwHM9H1gSfqfl/PhxYIIq1VE280GzsFulhVyuktQbE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Bl5HU2kX21Q3W9HQeLZW9eFq4/MowKD37wgJi2VPTgwftWcHseM3cK5sX/7i09ScK aHfccuen5psL2qIqejayhMkLxZSHkqrkU4KM++n3FQ4Dgv0Zc2hF3W4fIOzL5yVE0l Bgtu1qNWBv7MF7Vir/e6rIUutAErAXjedfUN3U6UzyY40lU+AawumrLzOszBoDk6Na 5jlOwiBo9BryTbE0619tPSSJt8oOBeclD1JAzkc8xdpsDsjq3WkvcfRKRFYNWdKtk0 qPqdsGhrunVlTQ4L8oLHSBsUJDUxQ4NIsdg3bp6mW/v4+s27pVB+MdH7KzWrdjpqmo Di6pqDDKVw50g== Subject: [PATCH 04/61] libxfs: port xfs_set_inode_alloc from the kernel From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:06:56 -0700 Message-ID: <163174721668.350433.1083608596895028766.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> 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 To prepare to perag initialization code move to libxfs, port the xfs_set_inode_alloc function from the kernel and make libxfs_initialize_perag use it. The code isn't 1:1 identical, but AFAICT it behaves the same way. In a future kernel release we'll move the function into xfs_ag.c and update xfsprogs. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- libxfs/init.c | 142 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 53 deletions(-) diff --git a/libxfs/init.c b/libxfs/init.c index 1ec83791..6223181f 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -482,18 +482,102 @@ rtmount_init( return 0; } +/* + * Set parameters for inode allocation heuristics, taking into account + * filesystem size and inode32/inode64 mount options; i.e. specifically + * whether or not XFS_MOUNT_SMALL_INUMS is set. + * + * Inode allocation patterns are altered only if inode32 is requested + * (XFS_MOUNT_SMALL_INUMS), and the filesystem is sufficiently large. + * If altered, XFS_MOUNT_32BITINODES is set as well. + * + * An agcount independent of that in the mount structure is provided + * because in the growfs case, mp->m_sb.sb_agcount is not yet updated + * to the potentially higher ag count. + * + * Returns the maximum AG index which may contain inodes. + */ +xfs_agnumber_t +xfs_set_inode_alloc( + struct xfs_mount *mp, + xfs_agnumber_t agcount) +{ + xfs_agnumber_t index; + xfs_agnumber_t maxagi = 0; + xfs_sb_t *sbp = &mp->m_sb; + xfs_agnumber_t max_metadata; + xfs_agino_t agino; + xfs_ino_t ino; + + /* + * Calculate how much should be reserved for inodes to meet + * the max inode percentage. Used only for inode32. + */ + if (M_IGEO(mp)->maxicount) { + uint64_t icount; + + icount = sbp->sb_dblocks * sbp->sb_imax_pct; + do_div(icount, 100); + icount += sbp->sb_agblocks - 1; + do_div(icount, sbp->sb_agblocks); + max_metadata = icount; + } else { + max_metadata = agcount; + } + + /* Get the last possible inode in the filesystem */ + agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1); + ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino); + + /* + * If user asked for no more than 32-bit inodes, and the fs is + * sufficiently large, set XFS_MOUNT_32BITINODES if we must alter + * the allocator to accommodate the request. + */ + if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32) + mp->m_flags |= XFS_MOUNT_32BITINODES; + else + mp->m_flags &= ~XFS_MOUNT_32BITINODES; + + for (index = 0; index < agcount; index++) { + struct xfs_perag *pag; + + ino = XFS_AGINO_TO_INO(mp, index, agino); + + pag = xfs_perag_get(mp, index); + + if (mp->m_flags & XFS_MOUNT_32BITINODES) { + if (ino > XFS_MAXINUMBER_32) { + pag->pagi_inodeok = 0; + pag->pagf_metadata = 0; + } else { + pag->pagi_inodeok = 1; + maxagi++; + if (index < max_metadata) + pag->pagf_metadata = 1; + else + pag->pagf_metadata = 0; + } + } else { + pag->pagi_inodeok = 1; + pag->pagf_metadata = 0; + } + + xfs_perag_put(pag); + } + + return (mp->m_flags & XFS_MOUNT_32BITINODES) ? maxagi : agcount; +} + static int libxfs_initialize_perag( xfs_mount_t *mp, xfs_agnumber_t agcount, xfs_agnumber_t *maxagi) { - xfs_agnumber_t index, max_metadata; + xfs_agnumber_t index; xfs_agnumber_t first_initialised = 0; xfs_perag_t *pag; - xfs_agino_t agino; - xfs_ino_t ino; - xfs_sb_t *sbp = &mp->m_sb; int error = -ENOMEM; /* @@ -522,55 +606,7 @@ libxfs_initialize_perag( } } - /* - * If we mount with the inode64 option, or no inode overflows - * the legacy 32-bit address space clear the inode32 option. - */ - agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1); - ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino); - - if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32) - mp->m_flags |= XFS_MOUNT_32BITINODES; - else - mp->m_flags &= ~XFS_MOUNT_32BITINODES; - - if (mp->m_flags & XFS_MOUNT_32BITINODES) { - /* - * Calculate how much should be reserved for inodes to meet - * the max inode percentage. - */ - if (M_IGEO(mp)->maxicount) { - uint64_t icount; - - icount = sbp->sb_dblocks * sbp->sb_imax_pct; - do_div(icount, 100); - icount += sbp->sb_agblocks - 1; - do_div(icount, sbp->sb_agblocks); - max_metadata = icount; - } else { - max_metadata = agcount; - } - - for (index = 0; index < agcount; index++) { - ino = XFS_AGINO_TO_INO(mp, index, agino); - if (ino > XFS_MAXINUMBER_32) { - index++; - break; - } - - pag = xfs_perag_get(mp, index); - pag->pagi_inodeok = 1; - if (index < max_metadata) - pag->pagf_metadata = 1; - xfs_perag_put(pag); - } - } else { - for (index = 0; index < agcount; index++) { - pag = xfs_perag_get(mp, index); - pag->pagi_inodeok = 1; - xfs_perag_put(pag); - } - } + index = xfs_set_inode_alloc(mp, agcount); if (maxagi) *maxagi = index; From patchwork Wed Sep 15 23:07:02 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: 12497737 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.4 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 02889C433EF for ; Wed, 15 Sep 2021 23:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDDF5600D4 for ; Wed, 15 Sep 2021 23:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbhIOXIX (ORCPT ); Wed, 15 Sep 2021 19:08:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:59724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232684AbhIOXIW (ORCPT ); Wed, 15 Sep 2021 19:08:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5991E606A5; Wed, 15 Sep 2021 23:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747222; bh=tysK1yawfYQYmqKb7uOa4YN0VfdAC9UTqV5rixYZKQk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bwMgdi+BAVOQeVbUchE9l6CxkQcfkRIomHCvOq0T1qhzbL4hi6nzWs3UXv+ZHTr8U 9temeUQegf+Xu6Et6RdgmjGoamSTdctZuTsB+Ml5PYLxfI1xSj4FbjrJ4zodsdbIJe 7Ls1Ob3IDMqfDlGIqtDsgEZV2iI3APBodiOsxnuUsF4Gfj9Twpzatn0dxSKOPebPyw v0pXK9lp4bDMK0nzS74VbWYF0hcWf+jfoS7vXEjV48zdmSn+25jptvrlskVWrkXPKn Kbiae74FvoHLSOUkGxOcWu0auWrxKKm/x2Jsu25yAMKnBoxyP65w1s1Z0UCXA9Lnwd u1VuAJE1qEqQw== Subject: [PATCH 05/61] libxfs: fix whitespace inconsistencies with kernel From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:07:02 -0700 Message-ID: <163174722210.350433.13099529255108655931.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> 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 Fix a few places where the whitespace isn't an exact match for the kernel. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- libxfs/xfs_btree.h | 2 +- libxfs/xfs_rmap_btree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 0f790234..10e50cba 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -88,7 +88,7 @@ uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum); */ #define XFS_BTREE_STATS_INC(cur, stat) \ XFS_STATS_INC_OFF((cur)->bc_mp, (cur)->bc_statoff + __XBTS_ ## stat) -#define XFS_BTREE_STATS_ADD(cur, stat, val) \ +#define XFS_BTREE_STATS_ADD(cur, stat, val) \ XFS_STATS_ADD_OFF((cur)->bc_mp, (cur)->bc_statoff + __XBTS_ ## stat, val) #define XFS_BTREE_MAXLEVELS 9 /* max of all btrees */ diff --git a/libxfs/xfs_rmap_btree.h b/libxfs/xfs_rmap_btree.h index 08c57dee..35b81fc8 100644 --- a/libxfs/xfs_rmap_btree.h +++ b/libxfs/xfs_rmap_btree.h @@ -4,7 +4,7 @@ * All Rights Reserved. */ #ifndef __XFS_RMAP_BTREE_H__ -#define __XFS_RMAP_BTREE_H__ +#define __XFS_RMAP_BTREE_H__ struct xfs_buf; struct xfs_btree_cur; From patchwork Wed Sep 15 23:07:07 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: 12497739 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=-21.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 E77DAC433EF for ; Wed, 15 Sep 2021 23:07:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB0A6600D4 for ; Wed, 15 Sep 2021 23:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232684AbhIOXIa (ORCPT ); Wed, 15 Sep 2021 19:08:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:59870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbhIOXI1 (ORCPT ); Wed, 15 Sep 2021 19:08:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C72F8600D4; Wed, 15 Sep 2021 23:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631747227; bh=R6EhXo9Iy/Ruzi0mxIqGA5uj+urplHq05EiyO7pdxv8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kHo1RfWvTvFhvw0pEyclmUByy0HjmJm7Zs1lsWLATaIOuMF+WA5anFyxJsoeT0uPf p2a9/z52BZia3UUhZSlmrB2Me5tXiPDZuuTiqrbOd6WlSUDmTin9iTdI9fPO88ljdr K7lu4uzwHcQHhiLT20RxmneVsL1E2WPcN9eYVTQxeurpTAesF0CPBetVwjaStSGtqV F/owgL2CQFRdHrmjRyKSI9gPS5thhLAz7zX7hMBOjPqF4UG9NgA7j7ky8K9yp2x30g 4x1xnwOqNWBHHe1h/DEoXnH2JjLXuz0EVBVAOQ5zS9MWVEvi5sRaEJn9jvggVQNrQq HhRiijVhhtHaw== Subject: [PATCH 06/61] xfs: Fix fall-through warnings for Clang From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: "Gustavo A. R. Silva" , linux-xfs@vger.kernel.org Date: Wed, 15 Sep 2021 16:07:07 -0700 Message-ID: <163174722755.350433.4462645030660733660.stgit@magnolia> In-Reply-To: <163174719429.350433.8562606396437219220.stgit@magnolia> References: <163174719429.350433.8562606396437219220.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Gustavo A. R. Silva Source kernel commit: 53004ee78d6273c994534ccf79d993098ac89769 In preparation to enable -Wimplicit-fallthrough for Clang, fix the following warnings by replacing /* fall through */ comments, and its variants, with the new pseudo-keyword macro fallthrough: fs/xfs/libxfs/xfs_alloc.c:3167:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/libxfs/xfs_da_btree.c:286:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/libxfs/xfs_ag_resv.c:346:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/libxfs/xfs_ag_resv.c:388:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_bmap_util.c:246:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_export.c:88:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_export.c:96:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_file.c:867:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_ioctl.c:562:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_ioctl.c:1548:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_iomap.c:1040:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_inode.c:852:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_log.c:2627:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/xfs_trans_buf.c:298:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/bmap.c:275:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/btree.c:48:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/common.c:85:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/common.c:138:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/common.c:698:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/dabtree.c:51:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/repair.c:951:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] fs/xfs/scrub/agheader.c:89:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings, so in order to globally enable -Wimplicit-fallthrough for Clang, these comments need to be replaced with fallthrough; in the whole codebase. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Darrick J. Wong --- include/linux.h | 17 +++++++++++++++++ libxfs/xfs_ag_resv.c | 4 ++-- libxfs/xfs_alloc.c | 2 +- libxfs/xfs_da_btree.c | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/linux.h b/include/linux.h index a22f7812..1b237d48 100644 --- a/include/linux.h +++ b/include/linux.h @@ -359,4 +359,21 @@ fsmap_advance( #include #endif /* HAVE_MAP_SYNC */ +/* + * Add the pseudo keyword 'fallthrough' so case statement blocks + * must end with any of these keywords: + * break; + * fallthrough; + * continue; + * goto