From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 06/11] xfs: flush eof/cowblocks if we can't reserve quota for file blocks
Date: Tue, 19 Jan 2021 08:08:45 +0100 [thread overview]
Message-ID: <YAaFfUxZjXAabnoV@infradead.org> (raw)
In-Reply-To: <161100795124.88816.6644776235251695171.stgit@magnolia>
> @@ -351,13 +351,14 @@ xfs_reflink_allocate_cow(
> bool convert_now)
> {
> struct xfs_mount *mp = ip->i_mount;
> + struct xfs_trans *tp;
> xfs_fileoff_t offset_fsb = imap->br_startoff;
> xfs_filblks_t count_fsb = imap->br_blockcount;
> - struct xfs_trans *tp;
> - int nimaps, error = 0;
> - bool found;
> xfs_filblks_t resaligned;
> xfs_extlen_t resblks = 0;
> + bool found;
> + bool quota_retry = false;
> + int nimaps, error = 0;
Any good reason for reshuffling the declarations here?
> + if (error) {
> + /* This function must return with the ILOCK held. */
> + xfs_ilock(ip, *lockmode);
> + return error;
> + }
Ugg.
> + if (error) {
> + xfs_trans_cancel(*tpp);
> + *tpp = NULL;
> + xfs_iunlock(ip, XFS_ILOCK_EXCL);
> + }
> +
> + /* We only allow one retry for EDQUOT/ENOSPC. */
> + if (*retry || (error != -EDQUOT && error != -ENOSPC)) {
> + *retry = false;
> + return error;
> + }
Id really don't like the semantics where this wrapper unlocks the
ilock. Keeping all the locking at one layer, which is the callers
makes the code much easier to reason about
> +
> + /* Try to free some quota for this file's dquots. */
> + err2 = xfs_blockgc_free_quota(ip, 0, retry);
> + if (err2)
> + return err2;
> + return *retry ? 0 : error;
> }
Why not have a should_retry helper for the callers and let them call
xfs_blockgc_free_quota? That is a little more boilerplate code, but
a lot less obsfucated.
next prev parent reply other threads:[~2021-01-19 7:10 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 22:11 [PATCHSET v3 00/11] xfs: try harder to reclaim space when we run out Darrick J. Wong
2021-01-18 22:12 ` [PATCH 01/11] xfs: refactor messy xfs_inode_free_quota_* functions Darrick J. Wong
2021-01-18 22:12 ` [PATCH 02/11] xfs: don't stall cowblocks scan if we can't take locks Darrick J. Wong
2021-01-19 6:49 ` Christoph Hellwig
2021-01-18 22:12 ` [PATCH 03/11] xfs: xfs_inode_free_quota_blocks should scan project quota Darrick J. Wong
2021-01-18 22:12 ` [PATCH 04/11] xfs: move and rename xfs_inode_free_quota_blocks to avoid conflicts Darrick J. Wong
2021-01-19 6:53 ` Christoph Hellwig
2021-01-18 22:12 ` [PATCH 05/11] xfs: pass flags and return gc errors from xfs_blockgc_free_quota Darrick J. Wong
2021-01-19 6:59 ` Christoph Hellwig
2021-01-18 22:12 ` [PATCH 06/11] xfs: flush eof/cowblocks if we can't reserve quota for file blocks Darrick J. Wong
2021-01-19 3:56 ` Darrick J. Wong
2021-01-19 7:08 ` Christoph Hellwig [this message]
2021-01-19 19:43 ` Darrick J. Wong
2021-01-18 22:12 ` [PATCH 07/11] xfs: flush eof/cowblocks if we can't reserve quota for inode creation Darrick J. Wong
2021-01-18 22:12 ` [PATCH 08/11] xfs: flush eof/cowblocks if we can't reserve quota for chown Darrick J. Wong
2021-01-18 22:12 ` [PATCH 09/11] xfs: add a tracepoint for blockgc scans Darrick J. Wong
2021-01-19 7:11 ` Christoph Hellwig
2021-01-18 22:12 ` [PATCH 10/11] xfs: refactor xfs_icache_free_{eof,cow}blocks call sites Darrick J. Wong
2021-01-18 22:12 ` [PATCH 11/11] xfs: flush speculative space allocations when we run out of space Darrick J. Wong
2021-01-23 18:51 [PATCHSET v4 00/11] xfs: try harder to reclaim space when we run out Darrick J. Wong
2021-01-23 18:52 ` [PATCH 06/11] xfs: flush eof/cowblocks if we can't reserve quota for file blocks Darrick J. Wong
2021-01-24 9:39 ` Christoph Hellwig
2021-01-25 18:16 ` Brian Foster
2021-01-25 18:57 ` Darrick J. Wong
2021-01-26 13:26 ` Brian Foster
2021-01-26 21:12 ` Darrick J. Wong
2021-01-27 14:19 ` Brian Foster
2021-01-27 17:19 ` Darrick J. Wong
2021-01-28 6:02 [PATCHSET v5 00/11] xfs: try harder to reclaim space when we run out Darrick J. Wong
2021-01-28 6:02 ` [PATCH 06/11] xfs: flush eof/cowblocks if we can't reserve quota for file blocks Darrick J. Wong
2021-01-28 9:26 ` 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=YAaFfUxZjXAabnoV@infradead.org \
--to=hch@infradead.org \
--cc=djwong@kernel.org \
--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 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.