From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] xfs: skip dquot reservations if quota is inactive
Date: Wed, 7 Oct 2020 15:09:45 -0700 [thread overview]
Message-ID: <20201007220945.GE6540@magnolia> (raw)
In-Reply-To: <20201001150310.141467-2-bfoster@redhat.com>
On Thu, Oct 01, 2020 at 11:03:08AM -0400, Brian Foster wrote:
> The dquot reservation helper currently performs the associated
> reservation for any provided dquots. The dquots could have been
> acquired from inode references or explicit dquot allocation
> requests. Some reservation callers may have already checked that the
> associated quota subsystem is active (xfs_qm_dqget() returns an
> error otherwise), while others might not have checked at all
> (xfs_trans_reserve_quota_nblks() passes the inode references).
> Further, subsequent dquot modifications do actually check that the
> associated quota is active before making transactional changes
> (xfs_trans_mod_dquot_byino()).
>
> Given all of that, the behavior to unconditionally perform
> reservation on any provided dquots is somewhat ad hoc. While it is
> currently harmless, it is not without side effect. If the quota is
> inactive by the time a transaction attempts a quota reservation, the
> dquot will be attached to the transaction and subsequently logged,
> even though no dquot modifications are ultimately made.
>
> This is a problem for upcoming quotaoff changes that intend to
> implement a strict transactional barrier for logging dquots during a
> quotaoff operation. If a dquot is logged after the subsystem
> deactivated and the barrier released, a subsequent log recovery can
> incorrectly replay dquot changes into the filesystem.
>
> Therefore, update the dquot reservation path to also check that a
> particular quota mode is active before associating a dquot with a
> transaction. This should have no noticeable impact on the current
> code that already accommodates checking active quota state at points
> before and after quota reservations are made.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
Seems reasonable not to bother with the dqresv step if the quota type
isn't enabled.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_trans_dquot.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index 133fc6fc3edd..547ba824542e 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -39,14 +39,12 @@ xfs_trans_dqjoin(
> }
>
> /*
> - * This is called to mark the dquot as needing
> - * to be logged when the transaction is committed. The dquot must
> - * already be associated with the given transaction.
> - * Note that it marks the entire transaction as dirty. In the ordinary
> - * case, this gets called via xfs_trans_commit, after the transaction
> - * is already dirty. However, there's nothing stop this from getting
> - * called directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY
> - * flag.
> + * This is called to mark the dquot as needing to be logged when the transaction
> + * is committed. The dquot must already be associated with the given
> + * transaction. Note that it marks the entire transaction as dirty. In the
> + * ordinary case, this gets called via xfs_trans_commit, after the transaction
> + * is already dirty. However, there's nothing stop this from getting called
> + * directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY flag.
> */
> void
> xfs_trans_log_dquot(
> @@ -770,19 +768,19 @@ xfs_trans_reserve_quota_bydquots(
>
> ASSERT(flags & XFS_QMOPT_RESBLK_MASK);
>
> - if (udqp) {
> + if (XFS_IS_UQUOTA_ON(mp) && udqp) {
> error = xfs_trans_dqresv(tp, mp, udqp, nblks, ninos, flags);
> if (error)
> return error;
> }
>
> - if (gdqp) {
> + if (XFS_IS_GQUOTA_ON(mp) && gdqp) {
> error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags);
> if (error)
> goto unwind_usr;
> }
>
> - if (pdqp) {
> + if (XFS_IS_PQUOTA_ON(mp) && pdqp) {
> error = xfs_trans_dqresv(tp, mp, pdqp, nblks, ninos, flags);
> if (error)
> goto unwind_grp;
> --
> 2.25.4
>
next prev parent reply other threads:[~2020-10-07 22:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 15:03 [PATCH 0/3] xfs: rework quotaoff to avoid log deadlock Brian Foster
2020-10-01 15:03 ` [PATCH 1/3] xfs: skip dquot reservations if quota is inactive Brian Foster
2020-10-07 22:09 ` Darrick J. Wong [this message]
2020-10-01 15:03 ` [PATCH 2/3] xfs: transaction subsystem quiesce mechanism Brian Foster
2020-10-07 22:13 ` Darrick J. Wong
2020-10-08 11:26 ` Brian Foster
2020-10-08 18:27 ` Brian Foster
2020-10-01 15:03 ` [PATCH 3/3] xfs: rework quotaoff logging to avoid log deadlock on active fs Brian Foster
2020-10-07 22:24 ` Darrick J. Wong
2020-10-08 11:29 ` Brian Foster
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=20201007220945.GE6540@magnolia \
--to=darrick.wong@oracle.com \
--cc=bfoster@redhat.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).