From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs@vger.kernel.org, chandanbabu@kernel.org
Subject: Re: [PATCH 3/4] xfs: handle allocation failure in xfs_dquot_disk_alloc()
Date: Thu, 4 Apr 2024 08:49:13 +1100 [thread overview]
Message-ID: <Zg3O2d8GozDujblD@dread.disaster.area> (raw)
In-Reply-To: <Zg1ieA0NA9Bd_i3P@infradead.org>
On Wed, Apr 03, 2024 at 07:06:48AM -0700, Christoph Hellwig wrote:
> On Wed, Apr 03, 2024 at 08:38:18AM +1100, Dave Chinner wrote:
> > @@ -356,6 +356,23 @@ xfs_dquot_disk_alloc(
> > if (error)
> > goto err_cancel;
> >
> > + if (nmaps == 0) {
> > + /*
> > + * Unexpected ENOSPC - the transaction reservation should have
> > + * guaranteed that this allocation will succeed. We don't know
> > + * why this happened, so just back out gracefully.
>
> So looking at this code, xfs_dquot_disk_alloc allocates it's own
> transaction, and does so without a space reservation.
It does have a valid space reservation:
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc,
XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
The space reservation is XFS_QM_DQALLOC_SPACE_RES(mp):
#define XFS_QM_DQALLOC_SPACE_RES(mp) \
(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
XFS_DQUOT_CLUSTER_SIZE_FSB)
which is correct for allocating a single XFS_DQUOT_CLUSTER_SIZE_FSB
sized extent.
> In other words:
> an ENOSPC is entirely expected here in the current form.
I disagree with that assessment. :)
> The code, just
> like many other callers of xfs_bmapi_write, just fails to handle
> the weird 0 return value and zero nmaps convention properly.
Yes, that's exactly what this patch is fixing regardless of the
cause of the failure. It's the right thing to do - error handling by
assumption (i.e. ASSERT()) is simply poor code....
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-04-03 21:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 21:38 [PATCH 0/4] xfs: fixes for 6.9-rcX Dave Chinner
2024-04-02 21:38 ` [PATCH 1/4] xfs: use kvmalloc for xattr buffers Dave Chinner
2024-04-03 3:43 ` Darrick J. Wong
2024-04-03 4:39 ` Christoph Hellwig
2024-04-03 6:16 ` Dave Chinner
2024-04-03 6:19 ` Christoph Hellwig
2024-04-17 14:35 ` Pankaj Raghav (Samsung)
2024-04-02 21:38 ` [PATCH 2/4] xfs: xfs_alloc_file_space() fails to detect ENOSPC Dave Chinner
2024-04-03 3:46 ` Darrick J. Wong
2024-04-03 4:40 ` Christoph Hellwig
2024-04-03 6:34 ` Dave Chinner
2024-04-03 18:23 ` Christoph Hellwig
2024-04-02 21:38 ` [PATCH 3/4] xfs: handle allocation failure in xfs_dquot_disk_alloc() Dave Chinner
2024-04-03 3:48 ` Darrick J. Wong
2024-04-03 4:41 ` Christoph Hellwig
2024-04-03 4:54 ` Darrick J. Wong
2024-04-03 4:56 ` Christoph Hellwig
2024-04-03 5:04 ` Darrick J. Wong
2024-04-03 6:41 ` Dave Chinner
2024-04-03 14:06 ` Christoph Hellwig
2024-04-03 21:49 ` Dave Chinner [this message]
2024-04-02 21:38 ` [PATCH 4/4] xfs: validate block count for XFS_IOC_SET_RESBLKS Dave Chinner
2024-04-03 3:53 ` Darrick J. Wong
2024-04-03 6:55 ` Dave Chinner
2024-04-03 4:43 ` 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=Zg3O2d8GozDujblD@dread.disaster.area \
--to=david@fromorbit.com \
--cc=chandanbabu@kernel.org \
--cc=hch@infradead.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.