From: Shida Zhang <starzhangzsd@gmail.com>
To: djwong@kernel.org, dchinner@redhat.com
Cc: zhangshida@kylinos.cn, starzhangzsd@gmail.com,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH v2] xfs: add check before calling xfs_mod_fdblocks
Date: Tue, 21 Jun 2022 15:02:24 +0800 [thread overview]
Message-ID: <20220621070224.1231039-1-zhangshida@kylinos.cn> (raw)
Checks are missing when delta equals 0 in __xfs_ag_resv_free() and
__xfs_ag_resv_init().
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
Changes from v1:
-Add checks before calling xfs_mod_fdblocks instead.
fs/xfs/libxfs/xfs_ag_resv.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index fe94058d4e9e..c8fa032e4b00 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -149,7 +149,12 @@ __xfs_ag_resv_free(
oldresv = resv->ar_orig_reserved;
else
oldresv = resv->ar_reserved;
- error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
+
+ if (oldresv)
+ error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
+ else
+ error = 0;
+
resv->ar_reserved = 0;
resv->ar_asked = 0;
resv->ar_orig_reserved = 0;
@@ -215,8 +220,13 @@ __xfs_ag_resv_init(
if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
error = -ENOSPC;
- else
- error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true);
+ else {
+ error = 0;
+ if (hidden_space)
+ error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space,
+ true);
+ }
+
if (error) {
trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
error, _RET_IP_);
--
2.25.1
next reply other threads:[~2022-06-21 7:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 7:02 Shida Zhang [this message]
2022-06-21 7:12 ` [PATCH v2] xfs: add check before calling xfs_mod_fdblocks Stephen Zhang
2022-06-21 7:39 ` Dave Chinner
2022-06-21 8:39 ` Stephen Zhang
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=20220621070224.1231039-1-zhangshida@kylinos.cn \
--to=starzhangzsd@gmail.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zhangshida@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.