From patchwork Fri Aug 25 22:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Rosenberg X-Patchwork-Id: 13366380 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DA82C83F04 for ; Fri, 25 Aug 2023 22:44:16 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qZfXK-0003NM-Ol; Fri, 25 Aug 2023 22:44:15 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <3uC7pZAYKAOcMaXbNWPXXPUN.LXV@flex--drosen.bounces.google.com>) id 1qZfXJ-0003NG-Qk for linux-f2fs-devel@lists.sourceforge.net; Fri, 25 Aug 2023 22:44:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hz2Du4gxfgtUmKF5Mvj7vndJqHDA1dVz464QcNbmjEE=; b=W2PlvHObtpCN7qvyi5FzAhxRqo mL7SbKyGHqM69kb4ic6mlyKLJTQBedUU4SVZpl9+OLN07Da3Uab0PtWlj0gCwep2jHH1QZUkFM8M3 nGoxafgM2D8vT/LPySzvubmhmqzaIW03BJCu2t2SgqsyGQoCES5+bYpdNkwFYSS70KRw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:From:Subject:Message-ID:Mime-Version:Date:Sender: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=hz2Du4gxfgtUmKF5Mvj7vndJqHDA1dVz464QcNbmjEE=; b=m Fymtrc8hAMXDaUh43Nz4o74CSPGUPCmkpE0HWmapu3kI/0XweHJO9S6fwAzQf6x//Qh+l/uXobChD cXopPcYOK4d7cxREy2CVGOPpm46M9T5L5WTNiLTQPLhc+CKvIrv2065iVeYMFeDFeUlTSP6tHs4P6 44SotUAH2xojGFSM=; Received: from mail-yw1-f202.google.com ([209.85.128.202]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qZfXK-0007Mw-01 for linux-f2fs-devel@lists.sourceforge.net; Fri, 25 Aug 2023 22:44:14 +0000 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-58fbc0e0c6dso20468297b3.0 for ; Fri, 25 Aug 2023 15:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1693003448; x=1693608248; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=hz2Du4gxfgtUmKF5Mvj7vndJqHDA1dVz464QcNbmjEE=; b=vUr/QcuZ9MCiYZil3Jim/aI+HevJ+cQS1nVWstlUqKdqCzMdcbRo2Y3aEvE4rDoMeA oi73S5WlKS5hVYYxajLmXwoLcRL3KXiab3BFTMpEPEOk3M6xjFbbAAGXuRDZH3T5TDzg 6Lmu7f6Q3u+aClAaRCEf/yDMwHIYph+O8n6q5lboKBTVIc3eHkeReWYRZdXh3IpKQSxe NbULMImTc14m1Ndb45nMMXmtA8Ws8flaZmh5upFnqDmZltiCTsa7MiVp4ZkZHJfRzbT2 2stthkosmt2jq+Xo6bZYHazPIXVP/R+FeC1ZK/mq9y0gYw7hpW7WjKA1Z27vqSIiba+o OXmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693003448; x=1693608248; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hz2Du4gxfgtUmKF5Mvj7vndJqHDA1dVz464QcNbmjEE=; b=CxmvN5/om6cVsf5p72SWjIfoLsdDPlfdNVZ7+d20jj9DTxR2OdRCnMoEF4EtHxemoZ 8whNwcihIb4flVVuaiNXKWarDNyjNfbmN4azCjeuaj2MtFSDY3u0+G5Ii9R+GrMxmqQM FKBDi89HZnc5Vwc6daAMQLr6pvAvu3dc0Z/IZerr+8iZDY7JCqA7yNvz0z2wOa5Jsoo8 xBbhzs/0AIO1TOiCMf83jfVvPlieyoGYMbkYhm4LC2R6+J5vgi6HhJ6WlUYBQjqDEcJZ VCd8QOL/ya+AOsp1+xN1DomIWbj9rghW2Vk9qkAjdrxJTnkRUisdlr0H9+63FeMQybHd icOA== X-Gm-Message-State: AOJu0YzOPS1+ttDdLSV0tstlBxijfurlKOEA5QT8T7/8af0icQH/l6Gf oavjKAI4xfDIZ1rw2Utorvllzdr/ObscYn63F5KWOimOqla1EvRoBp32g0KPMdhyBCfeCOaV62P 796d7oYjQQa216Xe5kXyJuQ096ioL5kZZDuhp7fucWpSKYzlquO9mxjLKO1yv9GvoMT0Efpkwh9 Zz2/qQS5Q= X-Google-Smtp-Source: AGHT+IGZgNuVy13ZjiOhW7ly8gbVGSdUolt2kQ8Nw5Vzz7GPjsLTkYa9zXl1hBzC6BTTiGdPc+OmdHL5IyE= X-Received: from drosen.mtv.corp.google.com ([2620:15c:211:201:ad1d:adc4:c021:b463]) (user=drosen job=sendgmr) by 2002:a81:af03:0:b0:583:9913:f293 with SMTP id n3-20020a81af03000000b005839913f293mr520930ywh.1.1693003448272; Fri, 25 Aug 2023 15:44:08 -0700 (PDT) Date: Fri, 25 Aug 2023 15:43:53 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.rc2.253.gd59a3bf2b4-goog Message-ID: <20230825224400.2206278-1-drosen@google.com> To: linux-f2fs-devel@lists.sourceforge.net X-Headers-End: 1qZfXK-0007Mw-01 Subject: [f2fs-dev] [PATCH v2 0/7] Add 16K Support for f2fs-tools X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Daniel Rosenberg via Linux-f2fs-devel From: Daniel Rosenberg Reply-To: Daniel Rosenberg Cc: Jaegeuk Kim , kernel-team@android.com, Daniel Rosenberg Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This adds support for different block sizes to f2fs-tools. The first patch redefines all block size based constants to be based on the block size. After this patch, you should be able to compile a version of f2fs-tools that works for a given blocksize by just setting F2FS_BLKSIZE_BITS in f2fs_fs.h. Running fsck on an f2fs filesystem of a different block size will fail early, and should leave the fs untouched. I was unsure how to handle things under tools/, so I've left them as is. The rest of the patches refactor the code to allow it to handle different block sizes with the same binary. The final patch puts this under a block size argument in make_f2fs. The refactor splits apart structs that have components with sizes derived from the blocksize in the middle. If the component is at the end, it's treated as a variable length array. This means that sizeof on affected structs will not work as expected, and should be replaced with F2FS_BLKSIZE where appropriate. The affected static_asserts are replaced with runtime asserts. It touches a lot of places, but I think it's probably with it to be able to use a single binary, particularly if we're ever going to be able to mount different blocksize f2fs filesystems using the same kernel. I was unable to get xfstests running on my 16k arm setup, so I wasn't able to test it as thoroughly as I'd like to have, but it behaved the same on a 4k x86_64 system, and fsck/mounted successfully on an arm64 system. --- changes in v2: Moved some 4096=>Block Size changes up to initial patch Fixed build error in initial patch Daniel Rosenberg (7): f2fs-tools: Define constants in terms of BLKSIZE f2fs-tools: Refactor Orphan Block struct f2fs-tools: Refactor f2fs_node struct and friends f2fs-tools: Refactor SIT/NAT block structs f2fs-tools: Refactor Summary block struct and friends f2fs-tools: Refactor f2fs_dentry_block struct f2fs-tools: Support different block sizes fsck/dir.c | 46 +++---- fsck/dump.c | 28 ++-- fsck/f2fs.h | 6 +- fsck/fsck.c | 72 +++++------ fsck/fsck.h | 5 +- fsck/main.c | 1 + fsck/mount.c | 93 ++++++++------ fsck/node.c | 12 +- fsck/node.h | 20 +-- fsck/resize.c | 2 +- include/f2fs_fs.h | 271 ++++++++++++++++++++++++++++----------- lib/libf2fs.c | 4 +- man/sload.f2fs.8 | 2 +- mkfs/f2fs_format.c | 90 ++++++------- mkfs/f2fs_format_main.c | 14 +- mkfs/f2fs_format_utils.c | 2 +- 16 files changed, 405 insertions(+), 263 deletions(-) base-commit: b15b6cc56ac7764be17acbdbf96448f388992adc