From: Christoph Hellwig <hch@lst.de>
To: darrick.wong@oracle.com
Cc: bfoster@redhat.com, linux-xfs@vger.kernel.org
Subject: [PATCH 1/2] xfs: only update mount/resv fields on success in __xfs_ag_resv_init
Date: Tue, 24 Jan 2017 21:16:19 +0100 [thread overview]
Message-ID: <1485288980-17075-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1485288980-17075-1-git-send-email-hch@lst.de>
Try to reserve the blocks first and only then update the fields in
or hanging off the mount structure. This way we can call __xfs_ag_resv_init
again after a previous failure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_ag_resv.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index d346d42..94234bf 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -200,22 +200,27 @@ __xfs_ag_resv_init(
struct xfs_mount *mp = pag->pag_mount;
struct xfs_ag_resv *resv;
int error;
+ xfs_extlen_t reserved;
- resv = xfs_perag_resv(pag, type);
if (used > ask)
ask = used;
- resv->ar_asked = ask;
- resv->ar_reserved = resv->ar_orig_reserved = ask - used;
- mp->m_ag_max_usable -= ask;
+ reserved = ask - used;
- trace_xfs_ag_resv_init(pag, type, ask);
-
- error = xfs_mod_fdblocks(mp, -(int64_t)resv->ar_reserved, true);
- if (error)
+ error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true);
+ if (error) {
trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
error, _RET_IP_);
+ return error;
+ }
- return error;
+ mp->m_ag_max_usable -= ask;
+
+ resv = xfs_perag_resv(pag, type);
+ resv->ar_asked = ask;
+ resv->ar_reserved = resv->ar_orig_reserved = reserved;
+
+ trace_xfs_ag_resv_init(pag, type, ask);
+ return 0;
}
/* Create a per-AG block reservation. */
--
2.1.4
next prev parent reply other threads:[~2017-01-24 20:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 20:16 avoid running out of space during finobt insertation Christoph Hellwig
2017-01-24 20:16 ` Christoph Hellwig [this message]
2017-01-24 20:33 ` [PATCH 1/2] xfs: only update mount/resv fields on success in __xfs_ag_resv_init Darrick J. Wong
2017-01-24 20:16 ` [PATCH 2/2] xfs: use per-AG reservations for the finobt Christoph Hellwig
2017-01-24 20:42 ` Darrick J. Wong
2017-01-25 9:13 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2017-01-25 9:14 avoid running out of space during finobt insertation Christoph Hellwig
2017-01-25 9:14 ` [PATCH 1/2] xfs: only update mount/resv fields on success in __xfs_ag_resv_init Christoph Hellwig
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=1485288980-17075-2-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).