* zoned fixes
@ 2025-03-17 5:44 Christoph Hellwig
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-03-17 5:44 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
Hi all,
this is a small set of zoned fixes, one reported by Dan through smatch,
and reported and draft fixed by Darrick, and a little cleanup I noticed
while going through the report from Dan.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data
2025-03-17 5:44 zoned fixes Christoph Hellwig
@ 2025-03-17 5:44 ` Christoph Hellwig
2025-03-18 11:54 ` Carlos Maiolino
2025-03-24 8:52 ` Carlos Maiolino
2025-03-17 5:44 ` [PATCH 2/3] xfs: don't increment m_generation for all errors " Christoph Hellwig
2025-03-17 5:44 ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Christoph Hellwig
2 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-03-17 5:44 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
The newly added check for the internal RT device needs to unlock
m_growlock just like all ther other error cases.
Fixes: bdc03eb5f98f ("xfs: allow internal RT devices for zoned mode")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_fsops.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index ee2cefbd5df8..d7658b7dcdbd 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -301,7 +301,7 @@ xfs_growfs_data(
struct xfs_mount *mp,
struct xfs_growfs_data *in)
{
- int error = 0;
+ int error;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -309,8 +309,10 @@ xfs_growfs_data(
return -EWOULDBLOCK;
/* we can't grow the data section when an internal RT section exists */
- if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart)
- return -EINVAL;
+ if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
+ error = -EINVAL;
+ goto out_error;
+ }
/* update imaxpct separately to the physical grow of the filesystem */
if (in->imaxpct != mp->m_sb.sb_imax_pct) {
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] xfs: don't increment m_generation for all errors in xfs_growfs_data
2025-03-17 5:44 zoned fixes Christoph Hellwig
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
@ 2025-03-17 5:44 ` Christoph Hellwig
2025-03-18 12:01 ` Carlos Maiolino
2025-03-17 5:44 ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Christoph Hellwig
2 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2025-03-17 5:44 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
xfs_growfs_data needs to increment m_generation as soon as the primary
superblock has been updated. As the update of the secondary superblocks
was part of xfs_growfs_data_private that mean the incremented had to be
done unconditionally once that was called. Later, commit 83a7f86e39ff
("xfs: separate secondary sb update in growfs") split the secondary
superblock update into a separate helper, so now the increment on error
can be limited to failed calls to xfs_update_secondary_sbs.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_fsops.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index d7658b7dcdbd..b6f3d7abdae5 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -311,20 +311,20 @@ xfs_growfs_data(
/* we can't grow the data section when an internal RT section exists */
if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
error = -EINVAL;
- goto out_error;
+ goto out_unlock;
}
/* update imaxpct separately to the physical grow of the filesystem */
if (in->imaxpct != mp->m_sb.sb_imax_pct) {
error = xfs_growfs_imaxpct(mp, in->imaxpct);
if (error)
- goto out_error;
+ goto out_unlock;
}
if (in->newblocks != mp->m_sb.sb_dblocks) {
error = xfs_growfs_data_private(mp, in);
if (error)
- goto out_error;
+ goto out_unlock;
}
/* Post growfs calculations needed to reflect new state in operations */
@@ -338,13 +338,12 @@ xfs_growfs_data(
/* Update secondary superblocks now the physical grow has completed */
error = xfs_update_secondary_sbs(mp);
-out_error:
/*
- * Increment the generation unconditionally, the error could be from
- * updating the secondary superblocks, in which case the new size
- * is live already.
+ * Increment the generation unconditionally, after trying to update the
+ * secondary superblocks, as the new size is live already at this point.
*/
mp->m_generation++;
+out_unlock:
mutex_unlock(&mp->m_growlock);
return error;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info
2025-03-17 5:44 zoned fixes Christoph Hellwig
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
2025-03-17 5:44 ` [PATCH 2/3] xfs: don't increment m_generation for all errors " Christoph Hellwig
@ 2025-03-17 5:44 ` Christoph Hellwig
2025-03-17 14:46 ` Hans Holmberg
2025-03-18 12:04 ` Carlos Maiolino
2 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-03-17 5:44 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
From: "Darrick J. Wong" <djwong@kernel.org>
xfs_zoned_wake_all checks SB_ACTIVE to make sure it does the right thing
when a shutdown happens during unmount, but it fails to account for the
log recovery special case that sets SB_ACTIVE temporarily. Add a NULL
check to cover both cases.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[hch: added a commit log and comment]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_zone_alloc.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index fd4c60a050e6..52af234936a2 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -853,13 +853,22 @@ xfs_zone_alloc_and_submit(
bio_io_error(&ioend->io_bio);
}
+/*
+ * Wake up all threads waiting for a zoned space allocation when the file system
+ * is shut down.
+ */
void
xfs_zoned_wake_all(
struct xfs_mount *mp)
{
- if (!(mp->m_super->s_flags & SB_ACTIVE))
- return; /* can happen during log recovery */
- wake_up_all(&mp->m_zone_info->zi_zone_wait);
+ /*
+ * Don't wake up if there is no m_zone_info. This is complicated by the
+ * fact that unmount can't atomically clear m_zone_info and thus we need
+ * to check SB_ACTIVE for that, but mount temporarily enables SB_ACTIVE
+ * during log recovery so we can't entirely rely on that either.
+ */
+ if ((mp->m_super->s_flags & SB_ACTIVE) && mp->m_zone_info)
+ wake_up_all(&mp->m_zone_info->zi_zone_wait);
}
/*
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info
2025-03-17 5:44 ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Christoph Hellwig
@ 2025-03-17 14:46 ` Hans Holmberg
2025-03-18 12:04 ` Carlos Maiolino
1 sibling, 0 replies; 9+ messages in thread
From: Hans Holmberg @ 2025-03-17 14:46 UTC (permalink / raw)
To: hch, Carlos Maiolino
Cc: Darrick J. Wong, Dan Carpenter, linux-xfs@vger.kernel.org
On 17/03/2025 06:45, Christoph Hellwig wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
>
> xfs_zoned_wake_all checks SB_ACTIVE to make sure it does the right thing
> when a shutdown happens during unmount, but it fails to account for the
> log recovery special case that sets SB_ACTIVE temporarily. Add a NULL
> check to cover both cases.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> [hch: added a commit log and comment]
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_zone_alloc.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index fd4c60a050e6..52af234936a2 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -853,13 +853,22 @@ xfs_zone_alloc_and_submit(
> bio_io_error(&ioend->io_bio);
> }
>
> +/*
> + * Wake up all threads waiting for a zoned space allocation when the file system
> + * is shut down.
> + */
> void
> xfs_zoned_wake_all(
> struct xfs_mount *mp)
> {
> - if (!(mp->m_super->s_flags & SB_ACTIVE))
> - return; /* can happen during log recovery */
> - wake_up_all(&mp->m_zone_info->zi_zone_wait);
> + /*
> + * Don't wake up if there is no m_zone_info. This is complicated by the
> + * fact that unmount can't atomically clear m_zone_info and thus we need
> + * to check SB_ACTIVE for that, but mount temporarily enables SB_ACTIVE
> + * during log recovery so we can't entirely rely on that either.
> + */
> + if ((mp->m_super->s_flags & SB_ACTIVE) && mp->m_zone_info)
> + wake_up_all(&mp->m_zone_info->zi_zone_wait);
> }
>
> /*
Looks good,
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
@ 2025-03-18 11:54 ` Carlos Maiolino
2025-03-24 8:52 ` Carlos Maiolino
1 sibling, 0 replies; 9+ messages in thread
From: Carlos Maiolino @ 2025-03-18 11:54 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
On Mon, Mar 17, 2025 at 06:44:52AM +0100, Christoph Hellwig wrote:
> The newly added check for the internal RT device needs to unlock
> m_growlock just like all ther other error cases.
>
> Fixes: bdc03eb5f98f ("xfs: allow internal RT devices for zoned mode")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/xfs_fsops.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index ee2cefbd5df8..d7658b7dcdbd 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -301,7 +301,7 @@ xfs_growfs_data(
> struct xfs_mount *mp,
> struct xfs_growfs_data *in)
> {
> - int error = 0;
> + int error;
>
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
> @@ -309,8 +309,10 @@ xfs_growfs_data(
> return -EWOULDBLOCK;
>
> /* we can't grow the data section when an internal RT section exists */
> - if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart)
> - return -EINVAL;
> + if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
> + error = -EINVAL;
> + goto out_error;
> + }
>
> /* update imaxpct separately to the physical grow of the filesystem */
> if (in->imaxpct != mp->m_sb.sb_imax_pct) {
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] xfs: don't increment m_generation for all errors in xfs_growfs_data
2025-03-17 5:44 ` [PATCH 2/3] xfs: don't increment m_generation for all errors " Christoph Hellwig
@ 2025-03-18 12:01 ` Carlos Maiolino
0 siblings, 0 replies; 9+ messages in thread
From: Carlos Maiolino @ 2025-03-18 12:01 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
On Mon, Mar 17, 2025 at 06:44:53AM +0100, Christoph Hellwig wrote:
> xfs_growfs_data needs to increment m_generation as soon as the primary
> superblock has been updated. As the update of the secondary superblocks
> was part of xfs_growfs_data_private that mean the incremented had to be
> done unconditionally once that was called. Later, commit 83a7f86e39ff
> ("xfs: separate secondary sb update in growfs") split the secondary
> superblock update into a separate helper, so now the increment on error
> can be limited to failed calls to xfs_update_secondary_sbs.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/xfs_fsops.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index d7658b7dcdbd..b6f3d7abdae5 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -311,20 +311,20 @@ xfs_growfs_data(
> /* we can't grow the data section when an internal RT section exists */
> if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
> error = -EINVAL;
> - goto out_error;
> + goto out_unlock;
> }
>
> /* update imaxpct separately to the physical grow of the filesystem */
> if (in->imaxpct != mp->m_sb.sb_imax_pct) {
> error = xfs_growfs_imaxpct(mp, in->imaxpct);
> if (error)
> - goto out_error;
> + goto out_unlock;
> }
>
> if (in->newblocks != mp->m_sb.sb_dblocks) {
> error = xfs_growfs_data_private(mp, in);
> if (error)
> - goto out_error;
> + goto out_unlock;
> }
>
> /* Post growfs calculations needed to reflect new state in operations */
> @@ -338,13 +338,12 @@ xfs_growfs_data(
> /* Update secondary superblocks now the physical grow has completed */
> error = xfs_update_secondary_sbs(mp);
>
> -out_error:
> /*
> - * Increment the generation unconditionally, the error could be from
> - * updating the secondary superblocks, in which case the new size
> - * is live already.
> + * Increment the generation unconditionally, after trying to update the
> + * secondary superblocks, as the new size is live already at this point.
> */
> mp->m_generation++;
> +out_unlock:
> mutex_unlock(&mp->m_growlock);
> return error;
> }
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info
2025-03-17 5:44 ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Christoph Hellwig
2025-03-17 14:46 ` Hans Holmberg
@ 2025-03-18 12:04 ` Carlos Maiolino
1 sibling, 0 replies; 9+ messages in thread
From: Carlos Maiolino @ 2025-03-18 12:04 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
On Mon, Mar 17, 2025 at 06:44:54AM +0100, Christoph Hellwig wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
>
> xfs_zoned_wake_all checks SB_ACTIVE to make sure it does the right thing
> when a shutdown happens during unmount, but it fails to account for the
> log recovery special case that sets SB_ACTIVE temporarily. Add a NULL
> check to cover both cases.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> [hch: added a commit log and comment]
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/xfs_zone_alloc.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index fd4c60a050e6..52af234936a2 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -853,13 +853,22 @@ xfs_zone_alloc_and_submit(
> bio_io_error(&ioend->io_bio);
> }
>
> +/*
> + * Wake up all threads waiting for a zoned space allocation when the file system
> + * is shut down.
> + */
> void
> xfs_zoned_wake_all(
> struct xfs_mount *mp)
> {
> - if (!(mp->m_super->s_flags & SB_ACTIVE))
> - return; /* can happen during log recovery */
> - wake_up_all(&mp->m_zone_info->zi_zone_wait);
> + /*
> + * Don't wake up if there is no m_zone_info. This is complicated by the
> + * fact that unmount can't atomically clear m_zone_info and thus we need
> + * to check SB_ACTIVE for that, but mount temporarily enables SB_ACTIVE
> + * during log recovery so we can't entirely rely on that either.
> + */
> + if ((mp->m_super->s_flags & SB_ACTIVE) && mp->m_zone_info)
> + wake_up_all(&mp->m_zone_info->zi_zone_wait);
> }
>
> /*
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
2025-03-18 11:54 ` Carlos Maiolino
@ 2025-03-24 8:52 ` Carlos Maiolino
1 sibling, 0 replies; 9+ messages in thread
From: Carlos Maiolino @ 2025-03-24 8:52 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J. Wong, Dan Carpenter, Hans Holmberg, linux-xfs
On Mon, 17 Mar 2025 06:44:52 +0100, Christoph Hellwig wrote:
> The newly added check for the internal RT device needs to unlock
> m_growlock just like all ther other error cases.
>
>
Applied to for-next, thanks!
[1/3] xfs: fix a missing unlock in xfs_growfs_data
commit: beba9487138151c17dec17105364b35935f21562
[2/3] xfs: don't increment m_generation for all errors in xfs_growfs_data
commit: 9ec3f7977a32f2045ef14445f165bcd96e596344
[3/3] xfs: don't wake zone space waiters without m_zone_info
commit: f56f73ebf8bb13d72b93e490c1f175a0a2c836f2
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-03-24 8:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 5:44 zoned fixes Christoph Hellwig
2025-03-17 5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
2025-03-18 11:54 ` Carlos Maiolino
2025-03-24 8:52 ` Carlos Maiolino
2025-03-17 5:44 ` [PATCH 2/3] xfs: don't increment m_generation for all errors " Christoph Hellwig
2025-03-18 12:01 ` Carlos Maiolino
2025-03-17 5:44 ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Christoph Hellwig
2025-03-17 14:46 ` Hans Holmberg
2025-03-18 12:04 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox