FAILED: patch "[PATCH] xfs: add a flag to convert unwritten extents without allocating blocks" failed to apply to 5.10-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x f3ca3498dfe624f9b604c934263538a3acd55af5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From f3ca3498dfe624f9b604c934263538a3acd55af5 Mon Sep 17 00:00:00 2001
From: Daejun Park <[email protected]>
Date: Thu, 29 Oct 2026 11:22:59 +0900
Subject: [PATCH] xfs: add a flag to convert unwritten extents without
allocating blocks
xfs_bmapi_write() with XFS_BMAPI_CONVERT also allocates blocks for holes and delalloc extents in the range. Add XFS_BMAPI_CONVERT_ONLY for callers that may only convert already allocated blocks. It stops at a hole or delalloc extent, and returns -ENOSR if it stops before mapping anything.
Marked for stable because "xfs: refuse a pNFS LAYOUTCOMMIT of a range without blocks" needs it.
--- fs/xfs/libxfs/xfs_bmap.c | 14 ++++++++++++-- fs/xfs/libxfs/xfs_bmap.h | 10 +++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +12 -2
@@ -4130,6 +4130,8 @@ xfs_bmapi_finish(* Returns a negative error code on failure, including -ENOSPC when it could not * allocate any blocks and -ENOSR when it did allocate blocks to convert a * delalloc range, but those blocks were before the passed in range. +* With XFS_BMAPI_CONVERT_ONLY, it stops at a hole or a delalloc extent instead +* of allocating blocks, and returns -ENOSR if it stops before mapping anything. */ int xfs_bmapi_write(
@@ -4189,6 +4191,8 @@ xfs_bmapi_write(*/ ASSERT ((flags & (XFS_BMAPI_PREALLOC |XFS_BMAPI_ZERO )) != (XFS_BMAPI_PREALLOC |XFS_BMAPI_ZERO )); +ASSERT (!(flags &XFS_BMAPI_CONVERT_ONLY ) || + (flags &XFS_BMAPI_CONVERT ));if (XFS_IS_CORRUPT (mp, !xfs_ifork_has_extents (ifp)) ||XFS_TEST_ERROR (mp,XFS_ERRTAG_BMAPIFORMAT )) {
@@ -4237,6 +4241,9 @@ xfs_bmapi_write(* that we found, if any. */ if (need_alloc || wasdelay) { +if (flags &XFS_BMAPI_CONVERT_ONLY ) +break ; + bma.eof = eof; bma.conv = !!(flags &XFS_BMAPI_CONVERT ); bma.wasdel = wasdelay;
@@ -4332,10 +4339,13 @@ xfs_bmapi_write(* * To avoid a successful return with *nmap set to 0, return the magic * -ENOSR error code for this particular case so that the caller can -* handle it. +* handle it. The same goes for XFS_BMAPI_CONVERT_ONLY stopping at a +* hole or a delalloc extent at the start of the range, in which case +* nothing has been changed. */ if (!n) { -ASSERT (bma.nallocs >= *nmap); +ASSERT ((flags &XFS_BMAPI_CONVERT_ONLY ) ? bma.nallocs ==0 : + bma.nallocs >= *nmap);return -ENOSR ; } *nmap = n;
fs/xfs/libxfs/xfs_bmap.h +9 -1
@@ -90,6 +90,13 @@ struct xfs_bmalloca {/* Try to align allocations to the extent size hint */ #define XFS_BMAPI_EXTSZALIGN (1u << 11) +/* +* Use with XFS_BMAPI_CONVERT to convert unwritten extents without allocating +* blocks. Stop at a hole or a delalloc extent: return the mappings found so +* far, or -ENOSR if there are none. +*/ +#define XFS_BMAPI_CONVERT_ONLY (1u << 12) +#define XFS_BMAPI_FLAGS \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \
@@ -102,7 +109,8 @@ struct xfs_bmalloca { { XFS_BMAPI_COWFORK, "COWFORK" }, \ { XFS_BMAPI_NODISCARD, "NODISCARD" }, \ { XFS_BMAPI_NORMAP, "NORMAP" },\ - { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" } + { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" }, \ + { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" } static inline int xfs_bmapi_aflag(int w)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 xfs: add a flag to convert unwritten extents without allocating blocks
From: Daejun Park <[email protected]>
[ Upstream commit f3ca3498dfe624f9b604c934263538a3acd55af5 ]
xfs_bmapi_write() with XFS_BMAPI_CONVERT also allocates blocks for holes and delalloc extents in the range. Add XFS_BMAPI_CONVERT_ONLY for callers that may only convert already allocated blocks. It stops at a hole or delalloc extent, and returns -ENOSR if it stops before mapping anything.
Marked for stable because "xfs: refuse a pNFS LAYOUTCOMMIT of a range without blocks" needs it.
--- fs/xfs/libxfs/xfs_bmap.c | 12 ++++++++++++ fs/xfs/libxfs/xfs_bmap.h | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_bmap.c +12 -0
@@ -4304,6 +4304,8 @@ xfs_bmapi_finish(* extent state if necessary. Details behaviour is controlled by the flags * parameter. Only allocates blocks from a single allocation group, to avoid * locking problems. +* With XFS_BMAPI_CONVERT_ONLY, it stops at a hole or a delalloc extent instead +* of allocating blocks, and returns -ENOSR if it stops before mapping anything. */ int xfs_bmapi_write(
@@ -4363,6 +4365,8 @@ xfs_bmapi_write(*/ ASSERT ((flags & (XFS_BMAPI_PREALLOC |XFS_BMAPI_ZERO )) != (XFS_BMAPI_PREALLOC |XFS_BMAPI_ZERO )); +ASSERT (!(flags &XFS_BMAPI_CONVERT_ONLY ) || + (flags &XFS_BMAPI_CONVERT ));if (XFS_IS_CORRUPT (mp, !xfs_ifork_has_extents (ifp)) ||XFS_TEST_ERROR (false, mp,XFS_ERRTAG_BMAPIFORMAT )) {
@@ -4412,6 +4416,9 @@ xfs_bmapi_write(* that we found, if any. */ if (need_alloc || wasdelay) { +if (flags &XFS_BMAPI_CONVERT_ONLY ) +break ; + bma.eof = eof; bma.conv = !!(flags &XFS_BMAPI_CONVERT ); bma.wasdel = wasdelay;
@@ -4486,6 +4493,11 @@ xfs_bmapi_write(xfs_bmapi_finish (&bma, whichfork,0 );xfs_bmap_validate_ret (orig_bno, orig_len, orig_flags, orig_mval, orig_nmap, *nmap); + +if (!n && (flags &XFS_BMAPI_CONVERT_ONLY )) { +ASSERT (bma.nallocs ==0 ); +return -ENOSR ; + }return 0 ; error0:xfs_bmapi_finish (&bma, whichfork, error);
fs/xfs/libxfs/xfs_bmap.h +9 -1
@@ -101,6 +101,13 @@ struct xfs_extent_free_item/* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */ #define XFS_BMAPI_NORMAP 0x2000 +/* +* Use with XFS_BMAPI_CONVERT to convert unwritten extents without allocating +* blocks. Stop at a hole or a delalloc extent: return the mappings found so +* far, or -ENOSR if there are none. +*/ +#define XFS_BMAPI_CONVERT_ONLY 0x4000 +#define XFS_BMAPI_FLAGS \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \
@@ -112,7 +119,8 @@ struct xfs_extent_free_item { XFS_BMAPI_REMAP, "REMAP" }, \ { XFS_BMAPI_COWFORK, "COWFORK" }, \ { XFS_BMAPI_NODISCARD, "NODISCARD" }, \ - { XFS_BMAPI_NORMAP, "NORMAP" } + { XFS_BMAPI_NORMAP, "NORMAP" }, \ + { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" } static inline int xfs_bmapi_aflag(int w)
Signature · 1 line
2.53.0