All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, osandov@osandov.com, hch@lst.de
Subject: [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents
Date: Wed, 11 Oct 2023 11:04:55 -0700	[thread overview]
Message-ID: <169704721209.1773611.10988808692731283385.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <169704721170.1773611.12311239321983752854.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

Create a helper to compute the misalignment between a file extent
(xfs_extlen_t) and a realtime extent.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_bmap.c        |    4 ++--
 fs/xfs/libxfs/xfs_rtbitmap.h    |    9 +++++++++
 fs/xfs/libxfs/xfs_trans_inode.c |    1 +
 fs/xfs/scrub/inode.c            |    3 ++-
 fs/xfs/scrub/inode_repair.c     |    3 ++-
 fs/xfs/xfs_bmap_util.c          |    2 +-
 fs/xfs/xfs_inode_item.c         |    3 ++-
 fs/xfs/xfs_ioctl.c              |    5 +++--
 8 files changed, 22 insertions(+), 8 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index fd083a3c554e0..82dc95944374e 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3038,7 +3038,7 @@ xfs_bmap_extsize_align(
 	 * If realtime, and the result isn't a multiple of the realtime
 	 * extent size we need to remove blocks until it is.
 	 */
-	if (rt && (temp = (align_alen % mp->m_sb.sb_rextsize))) {
+	if (rt && (temp = xfs_extlen_to_rtxmod(mp, align_alen))) {
 		/*
 		 * We're not covering the original request, or
 		 * we won't be able to once we fix the length.
@@ -3065,7 +3065,7 @@ xfs_bmap_extsize_align(
 		else {
 			align_alen -= orig_off - align_off;
 			align_off = orig_off;
-			align_alen -= align_alen % mp->m_sb.sb_rextsize;
+			align_alen -= xfs_extlen_to_rtxmod(mp, align_alen);
 		}
 		/*
 		 * Result doesn't cover the request, fail it.
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h
index 099ea8902aaaf..b6a4c46bddc0a 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.h
+++ b/fs/xfs/libxfs/xfs_rtbitmap.h
@@ -22,6 +22,15 @@ xfs_rtxlen_to_extlen(
 	return rtxlen * mp->m_sb.sb_rextsize;
 }
 
+/* Compute the misalignment between an extent length and a realtime extent .*/
+static inline unsigned int
+xfs_extlen_to_rtxmod(
+	struct xfs_mount	*mp,
+	xfs_extlen_t		len)
+{
+	return len % mp->m_sb.sb_rextsize;
+}
+
 /*
  * Functions for walking free space rtextents in the realtime bitmap.
  */
diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
index 3e07e7c6a5d53..29f1aa290ce6d 100644
--- a/fs/xfs/libxfs/xfs_trans_inode.c
+++ b/fs/xfs/libxfs/xfs_trans_inode.c
@@ -14,6 +14,7 @@
 #include "xfs_trans.h"
 #include "xfs_trans_priv.h"
 #include "xfs_inode_item.h"
+#include "xfs_rtbitmap.h"
 
 #include <linux/iversion.h>
 
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index 3cb75c559a32f..e8da1ae3c5c01 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -20,6 +20,7 @@
 #include "xfs_reflink.h"
 #include "xfs_rmap.h"
 #include "xfs_bmap_util.h"
+#include "xfs_rtbitmap.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 #include "scrub/btree.h"
@@ -254,7 +255,7 @@ xchk_inode_extsize(
 	 */
 	if ((flags & XFS_DIFLAG_RTINHERIT) &&
 	    (flags & XFS_DIFLAG_EXTSZINHERIT) &&
-	    value % sc->mp->m_sb.sb_rextsize > 0)
+	    xfs_extlen_to_rtxmod(sc->mp, value) > 0)
 		xchk_ino_set_warning(sc, ino);
 }
 
diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c
index 6787abbc6d6ff..7f1f7cec822a2 100644
--- a/fs/xfs/scrub/inode_repair.c
+++ b/fs/xfs/scrub/inode_repair.c
@@ -36,6 +36,7 @@
 #include "xfs_attr_leaf.h"
 #include "xfs_log_priv.h"
 #include "xfs_symlink_remote.h"
+#include "xfs_rtbitmap.h"
 #include "scrub/xfs_scrub.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
@@ -1599,7 +1600,7 @@ xrep_inode_extsize(
 	/* Fix misaligned extent size hints on a directory. */
 	if ((sc->ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
 	    (sc->ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) &&
-	    sc->ip->i_extsize % sc->mp->m_sb.sb_rextsize > 0) {
+	    xfs_extlen_to_rtxmod(sc->mp, sc->ip->i_extsize) > 0) {
 		sc->ip->i_extsize = 0;
 		sc->ip->i_diflags &= ~XFS_DIFLAG_EXTSZINHERIT;
 	}
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index cd4136b2b39c4..0590d55cd88f6 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -98,7 +98,7 @@ xfs_bmap_rtalloc(
 	if (error)
 		return error;
 	ASSERT(ap->length);
-	ASSERT(ap->length % mp->m_sb.sb_rextsize == 0);
+	ASSERT(xfs_extlen_to_rtxmod(mp, ap->length) == 0);
 
 	/*
 	 * If we shifted the file offset downward to satisfy an extent size
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 127b2410eb206..3183d0b03e0bc 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -19,6 +19,7 @@
 #include "xfs_log.h"
 #include "xfs_log_priv.h"
 #include "xfs_error.h"
+#include "xfs_rtbitmap.h"
 
 #include <linux/iversion.h>
 
@@ -107,7 +108,7 @@ xfs_inode_item_precommit(
 	 */
 	if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
 	    (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) &&
-	    (ip->i_extsize % ip->i_mount->m_sb.sb_rextsize) > 0) {
+	    xfs_extlen_to_rtxmod(ip->i_mount, ip->i_extsize) > 0) {
 		ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |
 				   XFS_DIFLAG_EXTSZINHERIT);
 		ip->i_extsize = 0;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index a2c7508527f8c..cbfa8500e2354 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -41,6 +41,7 @@
 #include "xfs_xattr.h"
 #include "xfs_xchgrange.h"
 #include "xfs_file.h"
+#include "xfs_rtbitmap.h"
 
 #include <linux/mount.h>
 #include <linux/namei.h>
@@ -1017,7 +1018,7 @@ xfs_fill_fsxattr(
 		 * later.
 		 */
 		if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
-		    ip->i_extsize % mp->m_sb.sb_rextsize > 0) {
+		    xfs_extlen_to_rtxmod(mp, ip->i_extsize) > 0) {
 			fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |
 					    FS_XFLAG_EXTSZINHERIT);
 			fa->fsx_extsize = 0;
@@ -1083,7 +1084,7 @@ xfs_ioctl_setattr_xflags(
 	/* If realtime flag is set then must have realtime device */
 	if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
 		if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
-		    (ip->i_extsize % mp->m_sb.sb_rextsize))
+		    xfs_extlen_to_rtxmod(mp, ip->i_extsize))
 			return -EINVAL;
 	}
 


  parent reply	other threads:[~2023-10-11 18:05 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 17:57 [PATCHBOMB RFC]: xfs: realtime units cleanups Darrick J. Wong
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/3] xfs: minor bugfixes for rt stuff Darrick J. Wong
2023-10-11 18:02   ` [PATCH 1/3] xfs: bump max fsgeom struct version Darrick J. Wong
2023-10-12  4:51     ` Christoph Hellwig
2023-10-12 17:34       ` Darrick J. Wong
2023-10-11 18:02   ` [PATCH 2/3] xfs: prevent rt growfs when quota is enabled Darrick J. Wong
2023-10-12  4:51     ` Christoph Hellwig
2023-10-11 18:02   ` [PATCH 3/3] xfs: rt stubs should return negative errnos when rt disabled Darrick J. Wong
2023-10-12  4:52     ` Christoph Hellwig
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/7] xfs: clean up realtime type usage Darrick J. Wong
2023-10-11 18:02   ` [PATCH 1/7] xfs: make sure maxlen is still congruent with prod when rounding down Darrick J. Wong
2023-10-12  4:59     ` Christoph Hellwig
2023-10-12 17:31       ` Darrick J. Wong
2023-10-13  4:22         ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 2/7] xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h Darrick J. Wong
2023-10-12  6:33     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 3/7] xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator Darrick J. Wong
2023-10-12  5:00     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 4/7] xfs: convert rt bitmap/summary block numbers to xfs_fileoff_t Darrick J. Wong
2023-10-12  5:01     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 5/7] xfs: convert rt bitmap extent lengths to xfs_rtbxlen_t Darrick J. Wong
2023-10-12  5:01     ` Christoph Hellwig
2023-10-11 18:04   ` [PATCH 6/7] xfs: rename xfs_verify_rtext to xfs_verify_rtbext Darrick J. Wong
2023-10-12  5:02     ` Christoph Hellwig
2023-10-11 18:04   ` [PATCH 7/7] xfs: convert rt extent numbers to xfs_rtxnum_t Darrick J. Wong
2023-10-12  5:03     ` Christoph Hellwig
2023-10-12  5:05   ` [PATCHSET RFC v1.0 0/7] xfs: clean up realtime type usage Christoph Hellwig
2023-10-12 22:30     ` Darrick J. Wong
2023-10-13  4:24       ` Christoph Hellwig
2023-10-17  0:48         ` Darrick J. Wong
2023-10-17  4:05           ` Christoph Hellwig
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-11 18:04   ` [PATCH 1/7] xfs: create a helper to convert rtextents to rtblocks Darrick J. Wong
2023-10-12  5:10     ` Christoph Hellwig
2023-10-11 18:04   ` Darrick J. Wong [this message]
2023-10-12  5:11     ` [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents Christoph Hellwig
2023-10-12 17:40       ` Darrick J. Wong
2023-10-11 18:05   ` [PATCH 3/7] " Darrick J. Wong
2023-10-12  6:34     ` Christoph Hellwig
2023-10-11 18:05   ` [PATCH 4/7] xfs: create helpers to convert rt block numbers to rt extent numbers Darrick J. Wong
2023-10-12  5:17     ` Christoph Hellwig
2023-10-12 17:58       ` Darrick J. Wong
2023-10-13  4:25         ` Christoph Hellwig
2023-10-11 18:05   ` [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Darrick J. Wong
2023-10-12  5:22     ` Christoph Hellwig
2023-10-12 18:10       ` Darrick J. Wong
2023-10-11 18:05   ` [PATCH 6/7] xfs: create rt extent rounding helpers for realtime extent blocks Darrick J. Wong
2023-10-12  5:22     ` Christoph Hellwig
2023-10-11 18:06   ` [PATCH 7/7] xfs: use shifting and masking when converting rt extents, if possible Darrick J. Wong
2023-10-12  5:25     ` Christoph Hellwig
2023-10-12 18:19       ` Darrick J. Wong
2023-10-16 17:19         ` Omar Sandoval
2023-10-17  0:51           ` Darrick J. Wong
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/8] xfs: refactor rtbitmap/summary macros Darrick J. Wong
2023-10-11 18:06   ` [PATCH 1/8] xfs: convert the rtbitmap block and bit macros to static inline functions Darrick J. Wong
2023-10-12  6:34     ` Christoph Hellwig
2023-10-11 18:06   ` [PATCH 2/8] xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macros Darrick J. Wong
2023-10-12  5:33     ` Christoph Hellwig
2023-10-12 18:20       ` Darrick J. Wong
2023-10-13  5:53         ` Christoph Hellwig
2023-10-17  0:49           ` Darrick J. Wong
2023-10-11 18:07   ` [PATCH 3/8] xfs: convert open-coded xfs_rtword_t pointer accesses to helper Darrick J. Wong
2023-10-12  5:39     ` Christoph Hellwig
2023-10-12 18:26       ` Darrick J. Wong
2023-10-11 18:07   ` [PATCH 4/8] xfs: convert rt summary macros to helpers Darrick J. Wong
2023-10-12  5:41     ` Christoph Hellwig
2023-10-11 18:07   ` [PATCH 5/8] xfs: create helpers for rtbitmap block/wordcount computations Darrick J. Wong
2023-10-12  5:44     ` Christoph Hellwig
2023-10-12 21:55       ` Darrick J. Wong
2023-10-13  4:26         ` Christoph Hellwig
2023-10-11 18:07   ` [PATCH 6/8] xfs: use accessor functions for bitmap words Darrick J. Wong
2023-10-12  6:19     ` Christoph Hellwig
2023-10-12 22:11       ` Darrick J. Wong
2023-10-13  4:28         ` Christoph Hellwig
2023-10-13 16:58           ` Darrick J. Wong
2023-10-11 18:08   ` [PATCH 7/8] xfs: create helpers for rtsummary block/wordcount computations Darrick J. Wong
2023-10-12  6:25     ` Christoph Hellwig
2023-10-12 22:18       ` Darrick J. Wong
2023-10-13  4:29         ` Christoph Hellwig
2023-10-13 17:11           ` Darrick J. Wong
2023-10-11 18:08   ` [PATCH 8/8] xfs: use accessor functions for summary info words Darrick J. Wong
2023-10-12  6:26     ` Christoph Hellwig
2023-10-12 22:21       ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2023-10-19 16:20 [PATCHSET v1.1 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-19 16:24 ` [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents Darrick J. Wong
2023-10-17 15:46 [PATCHSET RFC v1.1 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-17 15:50 ` [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents Darrick J. Wong
2022-12-30 22:17 [PATCHSET v1.0 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2022-12-30 22:17 ` [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=169704721209.1773611.10988808692731283385.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=osandov@osandov.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.