From: "Darrick J. Wong" <djwong@kernel.org>
To: Wengang Wang <wen.gang.wang@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: make sure sb_fdblocks is non-negative
Date: Fri, 31 May 2024 08:52:45 -0700 [thread overview]
Message-ID: <20240531155245.GP52987@frogsfrogsfrogs> (raw)
In-Reply-To: <20240511003426.13858-1-wen.gang.wang@oracle.com>
On Fri, May 10, 2024 at 05:34:26PM -0700, Wengang Wang wrote:
You might want to lead off with the origins of this fixpatch:
"A user with a completely full filesystem experienced an unexpected
shutdown when the filesystem tried to write the superblock during
runtime:"
<dmesg dump here>
"When xfs_log_sb writes a superblock to disk, sb_fdblocks is fetched..."
(or so I'm guessing from the other replies in this thread?)
((What was it doing? Adding the ATTR/ATTR2 feature to the filesystem?))
> when writting super block to disk (in xfs_log_sb), sb_fdblocks is fetched from
> m_fdblocks without any lock. As m_fdblocks can experience a positive -> negativ
"negative"
> -> positive changing when the FS reaches fullness (see xfs_mod_fdblocks)
> So there is a chance that sb_fdblocks is negative, and because sb_fdblocks is
> type of unsigned long long, it reads super big. And sb_fdblocks being bigger
> than sb_dblocks is a problem during log recovery, xfs_validate_sb_write()
> complains.
>
> Fix:
> As sb_fdblocks will be re-calculated during mount when lazysbcount is enabled,
> We just need to make xfs_validate_sb_write() happy -- make sure sb_fdblocks is
> not genative.
"negative".
This otherwise looks good to me.
--D
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
> ---
> fs/xfs/libxfs/xfs_sb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 73a4b895de67..199756970383 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -1037,7 +1037,7 @@ xfs_log_sb(
> mp->m_sb.sb_ifree = min_t(uint64_t,
> percpu_counter_sum(&mp->m_ifree),
> mp->m_sb.sb_icount);
> - mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks);
> + mp->m_sb.sb_fdblocks = percpu_counter_sum_positive(&mp->m_fdblocks);
> }
>
> xfs_sb_to_disk(bp->b_addr, &mp->m_sb);
> --
> 2.39.3 (Apple Git-146)
>
>
next prev parent reply other threads:[~2024-05-31 15:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 0:34 [PATCH] xfs: make sure sb_fdblocks is non-negative Wengang Wang
2024-05-11 1:17 ` Dave Chinner
2024-05-13 17:06 ` Wengang Wang
2024-05-31 15:44 ` Wengang Wang
2024-06-02 23:37 ` Dave Chinner
2024-06-03 17:23 ` Wengang Wang
2024-06-03 18:43 ` Darrick J. Wong
2024-06-04 4:06 ` Dave Chinner
2024-05-31 15:52 ` Darrick J. Wong [this message]
2024-05-31 18:03 ` Wengang Wang
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=20240531155245.GP52987@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=wen.gang.wang@oracle.com \
/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