Message ID | 20250317054512.1131950-4-hch@lst.de (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/3] xfs: fix a missing unlock in xfs_growfs_data | expand |
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>
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 >
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); } /*