From: John Garry <john.g.garry@oracle.com>
To: dchinner@redhat.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org,
linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, gfs2@lists.linux.dev,
linux-xfs@vger.kernel.org, catherine.hoang@oracle.com,
ritesh.list@gmail.com, mcgrof@kernel.org,
mikulas@artax.karlin.mff.cuni.cz, agruenba@redhat.com,
miklos@szeredi.hu, martin.petersen@oracle.com, axboe@kernel.dk,
tytso@mit.edu, viro@zeniv.linux.org.uk, brauner@kernel.org,
jack@suse.com, chandan.babu@oracle.com, hch@lst.de,
djwong@kernel.org
Subject: Re: [PATCH v4 13/22] xfs: Unmap blocks according to forcealign
Date: Tue, 11 Jun 2024 11:08:13 +0100 [thread overview]
Message-ID: <4c6da37f-c5ea-4008-8250-a75f3b65427e@oracle.com> (raw)
In-Reply-To: <20240607143919.2622319-14-john.g.garry@oracle.com>
On 07/06/2024 15:39, John Garry wrote:
> For when forcealign is enabled, blocks in an inode need to be unmapped
> according to extent alignment, like what is already done for rtvol.
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 33 ++++++++++++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index c9cf138e13c4..2b6d5ebd8b4f 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5380,6 +5380,20 @@ xfs_bmap_del_extent_real(
> return 0;
> }
>
> +static xfs_extlen_t
> +xfs_bunmapi_align(
> + struct xfs_inode *ip,
> + xfs_fsblock_t bno)
> +{
> + if (xfs_inode_has_forcealign(ip)) {
> + if (is_power_of_2(ip->i_extsize))
> + return bno & (ip->i_extsize - 1);
> + return do_div(bno, ip->i_extsize);
> + }
> + ASSERT(XFS_IS_REALTIME_INODE(ip));
> + return xfs_rtb_to_rtxoff(ip->i_mount, bno);
> +}
This following updated version of xfs_bunmapi_align() seems to fix the
issue reported in
https://lore.kernel.org/linux-xfs/d96c6e91-44f0-41c5-bebc-a092dc8a8406@oracle.com/
static xfs_extlen_t
xfs_bunmapi_align(
struct xfs_inode *ip,
xfs_fsblock_t fsbno)
{
if (xfs_inode_has_forcealign(ip)) {
struct xfs_mount *mp = ip->i_mount;
xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp,
fsbno);
if (is_power_of_2(ip->i_extsize))
return agbno & (ip->i_extsize - 1);
return do_div(agbno, ip->i_extsize);
}
ASSERT(XFS_IS_REALTIME_INODE(ip));
return xfs_rtb_to_rtxoff(ip->i_mount, fsbno);
}
> +
> /*
> * Unmap (remove) blocks from a file.
> * If nexts is nonzero then the number of extents to remove is limited to
> @@ -5402,6 +5416,7 @@ __xfs_bunmapi(
> struct xfs_bmbt_irec got; /* current extent record */
> struct xfs_ifork *ifp; /* inode fork pointer */
> int isrt; /* freeing in rt area */
> + int isforcealign; /* freeing for inode with forcealign */
> int logflags; /* transaction logging flags */
> xfs_extlen_t mod; /* rt extent offset */
> struct xfs_mount *mp = ip->i_mount;
> @@ -5439,6 +5454,8 @@ __xfs_bunmapi(
> }
> XFS_STATS_INC(mp, xs_blk_unmap);
> isrt = xfs_ifork_is_realtime(ip, whichfork);
> + isforcealign = (whichfork != XFS_ATTR_FORK) &&
> + xfs_inode_has_forcealign(ip);
> end = start + len;
>
> if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) {
> @@ -5490,11 +5507,10 @@ __xfs_bunmapi(
> if (del.br_startoff + del.br_blockcount > end + 1)
> del.br_blockcount = end + 1 - del.br_startoff;
>
> - if (!isrt || (flags & XFS_BMAPI_REMAP))
> + if ((!isrt && !isforcealign) || (flags & XFS_BMAPI_REMAP))
> goto delete;
>
> - mod = xfs_rtb_to_rtxoff(mp,
> - del.br_startblock + del.br_blockcount);
> + mod = xfs_bunmapi_align(ip, del.br_startblock + del.br_blockcount);
> if (mod) {
> /*
> * Realtime extent not lined up at the end.
> @@ -5542,9 +5558,16 @@ __xfs_bunmapi(
> goto nodelete;
> }
>
> - mod = xfs_rtb_to_rtxoff(mp, del.br_startblock);
> + mod = xfs_bunmapi_align(ip, del.br_startblock);
> if (mod) {
> - xfs_extlen_t off = mp->m_sb.sb_rextsize - mod;
> + xfs_extlen_t off;
> +
> + if (isforcealign) {
> + off = ip->i_extsize - mod;
> + } else {
> + ASSERT(isrt);
> + off = mp->m_sb.sb_rextsize - mod;
> + }
>
> /*
> * Realtime extent is lined up at the end but not
next prev parent reply other threads:[~2024-06-11 10:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 14:38 [PATCH v4 00/22] block atomic writes for xfs John Garry
2024-06-07 14:38 ` [PATCH v4 01/22] fs: Add generic_atomic_write_valid_size() John Garry
2024-06-12 21:10 ` Darrick J. Wong
2024-06-13 7:35 ` John Garry
2024-06-20 21:24 ` Darrick J. Wong
2024-06-07 14:38 ` [PATCH v4 02/22] iomap: Allow filesystems set IO block zeroing size John Garry
2024-06-12 21:32 ` Darrick J. Wong
2024-06-13 10:31 ` John Garry
2024-06-21 21:18 ` Darrick J. Wong
2024-06-24 13:58 ` John Garry
2024-06-07 14:39 ` [PATCH v4 03/22] xfs: Use extent size granularity for iomap->io_block_size John Garry
2024-06-12 21:47 ` Darrick J. Wong
2024-06-13 11:13 ` John Garry
2024-06-07 14:39 ` [PATCH v4 04/22] xfs: only allow minlen allocations when near ENOSPC John Garry
2024-06-07 14:39 ` [PATCH v4 05/22] xfs: always tail align maxlen allocations John Garry
2024-06-07 14:39 ` [PATCH v4 06/22] xfs: simplify extent allocation alignment John Garry
2024-06-07 14:39 ` [PATCH v4 07/22] xfs: make EOF allocation simpler John Garry
2024-06-07 14:39 ` [PATCH v4 08/22] xfs: introduce forced allocation alignment John Garry
2024-06-07 14:39 ` [PATCH v4 09/22] xfs: align args->minlen for " John Garry
2024-06-07 14:39 ` [PATCH v4 10/22] xfs: Introduce FORCEALIGN inode flag John Garry
2024-06-07 14:39 ` [PATCH v4 11/22] xfs: Do not free EOF blocks for forcealign John Garry
2024-06-07 14:39 ` [PATCH v4 12/22] xfs: Update xfs_inode_alloc_unitsize_fsb() " John Garry
2024-06-07 14:39 ` [PATCH v4 13/22] xfs: Unmap blocks according to forcealign John Garry
2024-06-11 10:08 ` John Garry [this message]
2024-06-07 14:39 ` [PATCH v4 14/22] xfs: Only free full extents for forcealign John Garry
2024-06-07 14:39 ` [PATCH v4 15/22] xfs: Don't revert allocated offset " John Garry
2024-06-07 14:39 ` [PATCH v4 16/22] xfs: Enable file data forcealign feature John Garry
2024-06-07 14:39 ` [PATCH v4 17/22] fs: Add FS_XFLAG_ATOMICWRITES flag John Garry
2024-06-07 14:39 ` [PATCH v4 18/22] iomap: Atomic write support John Garry
2024-06-07 14:39 ` [PATCH v4 19/22] xfs: Support FS_XFLAG_ATOMICWRITES for forcealign John Garry
2024-06-07 14:39 ` [PATCH v4 20/22] xfs: Support atomic write for statx John Garry
2024-06-07 14:39 ` [PATCH v4 21/22] xfs: Validate atomic writes John Garry
2024-06-07 14:39 ` [PATCH v4 22/22] xfs: Support setting FMODE_CAN_ATOMIC_WRITE John Garry
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=4c6da37f-c5ea-4008-8250-a75f3b65427e@oracle.com \
--to=john.g.garry@oracle.com \
--cc=agruenba@redhat.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=catherine.hoang@oracle.com \
--cc=chandan.babu@oracle.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=hch@lst.de \
--cc=jack@suse.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mcgrof@kernel.org \
--cc=miklos@szeredi.hu \
--cc=mikulas@artax.karlin.mff.cuni.cz \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).