From patchwork Fri May 26 01:16:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13256027 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ACFDC77B7A for ; Fri, 26 May 2023 01:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231344AbjEZBQy (ORCPT ); Thu, 25 May 2023 21:16:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjEZBQw (ORCPT ); Thu, 25 May 2023 21:16:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A17125; Thu, 25 May 2023 18:16:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 810DC64C2D; Fri, 26 May 2023 01:16:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB07AC433D2; Fri, 26 May 2023 01:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685063809; bh=PlMVkZW9e+dM/1tKhpzC9MxYCmOyWhPI1zpCRon4FgU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=tdqd875pFaDiiOnDQoPtR2zgx30SInGt6+Png0upbH6nCBJrl9wgBeXzSxnD5EOkc hsKk+gkqaP1yUB21zlzCPKRy4TcOo6oSGyFyIFOebapi+8hCsAPlMu/wJmEdGRMK0B z+ZuE42KRCQuzCZgRFX8P7wgDpjgq7YYEaoeo7u4dmvXtFKOMKtDh2L3gnVWopFo4A 6rpqhZyAZn2LOeOcrX2/p0CXL8gqCRLvoE1bAUQ6oEFG5hTe6lqO5zzLQW2J8rPoiT ldFpOrVBOHeUp/dbDctr4/+dNSaT6czZX3s7ZXACs7sOQ796aIveIHXUawAf90OpOt CLLzDm5ol+bUQ== Date: Thu, 25 May 2023 18:16:49 -0700 Subject: [PATCH 09/25] xfs: create a log incompat flag for atomic extent swapping From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org Message-ID: <168506065109.3734442.16171377728027428590.stgit@frogsfrogsfrogs> In-Reply-To: <168506064947.3734442.7654653738998941813.stgit@frogsfrogsfrogs> References: <168506064947.3734442.7654653738998941813.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Darrick J. Wong Create a log incompat flag so that we only attempt to process swap extent log items if the filesystem supports it, and a geometry flag to advertise support if it's present. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_format.h | 1 + fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 3 +++ fs/xfs/libxfs/xfs_swapext.h | 24 ++++++++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 fs/xfs/libxfs/xfs_swapext.h diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 817adb36cb1e..1424976ec955 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -391,6 +391,7 @@ xfs_sb_has_incompat_feature( } #define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_SWAPEXT (1U << 31) /* file extent swap */ #define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 29857b0f87df..cf909dbeed86 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -239,6 +239,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */ +#define XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP (1U << 31) /* atomic file extent swap */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 1cfa7bf276a9..bb2d97e95933 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -25,6 +25,7 @@ #include "xfs_da_format.h" #include "xfs_health.h" #include "xfs_ag.h" +#include "xfs_swapext.h" /* * Physical superblock buffer manipulations. Shared with libxfs in userspace. @@ -1199,6 +1200,8 @@ xfs_fs_geometry( } if (xfs_has_large_extent_counts(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_NREXT64; + if (xfs_swapext_supported(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP; geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp); diff --git a/fs/xfs/libxfs/xfs_swapext.h b/fs/xfs/libxfs/xfs_swapext.h new file mode 100644 index 000000000000..6d17657cf1f6 --- /dev/null +++ b/fs/xfs/libxfs/xfs_swapext.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2020-2023 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_SWAPEXT_H_ +#define __XFS_SWAPEXT_H_ 1 + +/* + * Decide if this filesystem supports using log items to swap file extents and + * restart the operation if the system fails before the operation completes. + * + * This can be done to individual file extents by using the block mapping log + * intent items introduced with reflink and rmap; or to entire file ranges + * using swapext log intent items to track the overall progress across multiple + * extent mappings. Realtime is not supported yet. + */ +static inline bool xfs_swapext_supported(struct xfs_mount *mp) +{ + return (xfs_has_reflink(mp) || xfs_has_rmapbt(mp)) && + !xfs_has_realtime(mp); +} + +#endif /* __XFS_SWAPEXT_H_ */