* [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero
@ 2023-12-14 19:28 Eric Sandeen
2023-12-14 20:14 ` Darrick J. Wong
2023-12-15 4:19 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2023-12-14 19:28 UTC (permalink / raw)
To: linux-xfs@vger.kernel.org
Although xfs_growfs_data() doesn't call xfs_growfs_data_private()
if in->newblocks == mp->m_sb.sb_dblocks, xfs_growfs_data_private()
further massages the new block count so that we don't i.e. try
to create a too-small new AG.
This may lead to a delta of "0" in xfs_growfs_data_private(), so
we end up in the shrink case and emit the EXPERIMENTAL warning
even if we're not changing anything at all.
Fix this by returning straightaway if the block delta is zero.
(nb: in older kernels, the result of entering the shrink case
with delta == 0 may actually let an -ENOSPC escape to userspace,
which is confusing for users.)
Fixes: fb2fc1720185 ("xfs: support shrinking unused space in the last AG")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 7cb75cb6b8e9..80811d16dde0 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -134,6 +134,10 @@ xfs_growfs_data_private(
if (delta < 0 && nagcount < 2)
return -EINVAL;
+ /* No work to do */
+ if (delta == 0)
+ return 0;
+
oagcount = mp->m_sb.sb_agcount;
/* allocate the new per-ag structures */
if (nagcount > oagcount) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero
2023-12-14 19:28 [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero Eric Sandeen
@ 2023-12-14 20:14 ` Darrick J. Wong
2023-12-15 4:19 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2023-12-14 20:14 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs@vger.kernel.org
On Thu, Dec 14, 2023 at 01:28:08PM -0600, Eric Sandeen wrote:
> Although xfs_growfs_data() doesn't call xfs_growfs_data_private()
> if in->newblocks == mp->m_sb.sb_dblocks, xfs_growfs_data_private()
> further massages the new block count so that we don't i.e. try
> to create a too-small new AG.
>
> This may lead to a delta of "0" in xfs_growfs_data_private(), so
> we end up in the shrink case and emit the EXPERIMENTAL warning
> even if we're not changing anything at all.
>
> Fix this by returning straightaway if the block delta is zero.
>
> (nb: in older kernels, the result of entering the shrink case
> with delta == 0 may actually let an -ENOSPC escape to userspace,
> which is confusing for users.)
>
> Fixes: fb2fc1720185 ("xfs: support shrinking unused space in the last AG")
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Seems like a reasonable addition...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
>
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index 7cb75cb6b8e9..80811d16dde0 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -134,6 +134,10 @@ xfs_growfs_data_private(
> if (delta < 0 && nagcount < 2)
> return -EINVAL;
>
> + /* No work to do */
> + if (delta == 0)
> + return 0;
> +
> oagcount = mp->m_sb.sb_agcount;
> /* allocate the new per-ag structures */
> if (nagcount > oagcount) {
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero
2023-12-14 19:28 [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero Eric Sandeen
2023-12-14 20:14 ` Darrick J. Wong
@ 2023-12-15 4:19 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-12-15 4:19 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs@vger.kernel.org
On Thu, Dec 14, 2023 at 01:28:08PM -0600, Eric Sandeen wrote:
> Although xfs_growfs_data() doesn't call xfs_growfs_data_private()
> if in->newblocks == mp->m_sb.sb_dblocks, xfs_growfs_data_private()
> further massages the new block count so that we don't i.e. try
> to create a too-small new AG.
>
> This may lead to a delta of "0" in xfs_growfs_data_private(), so
> we end up in the shrink case and emit the EXPERIMENTAL warning
> even if we're not changing anything at all.
>
> Fix this by returning straightaway if the block delta is zero.
>
> (nb: in older kernels, the result of entering the shrink case
> with delta == 0 may actually let an -ENOSPC escape to userspace,
> which is confusing for users.)
>
> Fixes: fb2fc1720185 ("xfs: support shrinking unused space in the last AG")
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-15 4:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 19:28 [PATCH] xfs: short circuit xfs_growfs_data_private() if delta is zero Eric Sandeen
2023-12-14 20:14 ` Darrick J. Wong
2023-12-15 4:19 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox