From: kaixuxia <xiakaixu1987@gmail.com>
To: Eric Sandeen <sandeen@sandeen.net>, linux-xfs@vger.kernel.org
Cc: darrick.wong@oracle.com, Kaixu Xia <kaixuxia@tencent.com>
Subject: Re: [PATCH v2 3/4] xfs: check tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag
Date: Fri, 2 Oct 2020 11:31:24 +0800 [thread overview]
Message-ID: <fdff45c9-82ac-c053-3c10-ca8d8996630e@gmail.com> (raw)
In-Reply-To: <50bf4338-490e-b98d-321b-26dd08af98a0@sandeen.net>
On 2020/9/26 23:36, Eric Sandeen wrote:
> On 9/26/20 8:14 AM, xiakaixu1987@gmail.com wrote:
>> From: Kaixu Xia <kaixuxia@tencent.com>
>>
>> Nowadays the only things that the XFS_TRANS_DQ_DIRTY flag seems to do
>> are indicates the tp->t_dqinfo->dqs[XFS_QM_TRANS_{USR,GRP,PRJ}] values
>> changed and check in xfs_trans_apply_dquot_deltas() and the unreserve
>> variant xfs_trans_unreserve_and_mod_dquots(). Actually, we also can
>> use the tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag, that
>> is to say, we allocate the new tp->t_dqinfo only when the qtrx values
>> changed, so the tp->t_dqinfo value isn't NULL equals the XFS_TRANS_DQ_DIRTY
>> flag is set, we only need to check if tp->t_dqinfo == NULL in
>> xfs_trans_apply_dquot_deltas() and its unreserve variant to determine
>> whether lock all of the dquots and join them to the transaction.
>>
>> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
>> ---
>> fs/xfs/libxfs/xfs_shared.h | 1 -
>> fs/xfs/xfs_inode.c | 8 +-------
>> fs/xfs/xfs_trans_dquot.c | 20 ++------------------
>> 3 files changed, 3 insertions(+), 26 deletions(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
>> index c795ae47b3c9..8c61a461bf7b 100644
>> --- a/fs/xfs/libxfs/xfs_shared.h
>> +++ b/fs/xfs/libxfs/xfs_shared.h
>> @@ -62,7 +62,6 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp,
>> #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
>> #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
>> #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
>> -#define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
>> #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
>> #define XFS_TRANS_NO_WRITECOUNT 0x40 /* do not elevate SB writecount */
>> #define XFS_TRANS_RES_FDBLKS 0x80 /* reserve newly freed blocks */
>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
>> index 49624973eecc..9108eed0ea45 100644
>> --- a/fs/xfs/xfs_inode.c
>> +++ b/fs/xfs/xfs_inode.c
>> @@ -941,7 +941,6 @@ xfs_dir_ialloc(
>> xfs_buf_t *ialloc_context = NULL;
>> int code;
>> void *dqinfo;
>> - uint tflags;
>>
>> tp = *tpp;
>> ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
>> @@ -1000,12 +999,9 @@ xfs_dir_ialloc(
>> * and attach it to the next transaction.
>> */
>> dqinfo = NULL;
>> - tflags = 0;
>> if (tp->t_dqinfo) {
>> dqinfo = (void *)tp->t_dqinfo;
>> tp->t_dqinfo = NULL;
>> - tflags = tp->t_flags & XFS_TRANS_DQ_DIRTY;
>> - tp->t_flags &= ~(XFS_TRANS_DQ_DIRTY);
>> }
>>
>> code = xfs_trans_roll(&tp);
>> @@ -1013,10 +1009,8 @@ xfs_dir_ialloc(
>> /*
>> * Re-attach the quota info that we detached from prev trx.
>> */
>> - if (dqinfo) {
>> + if (dqinfo)
>> tp->t_dqinfo = dqinfo;
>> - tp->t_flags |= tflags;
>> - }
>>
>> if (code) {
>> xfs_buf_relse(ialloc_context);
>> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
>> index fe45b0c3970c..0ebfd7930382 100644
>> --- a/fs/xfs/xfs_trans_dquot.c
>> +++ b/fs/xfs/xfs_trans_dquot.c
>> @@ -84,13 +84,6 @@ xfs_trans_dup_dqinfo(
>>
>> xfs_trans_alloc_dqinfo(ntp);
>>
>> - /*
>> - * Because the quota blk reservation is carried forward,
>> - * it is also necessary to carry forward the DQ_DIRTY flag.
>> - */
>> - if (otp->t_flags & XFS_TRANS_DQ_DIRTY)
>> - ntp->t_flags |= XFS_TRANS_DQ_DIRTY;
>> -
>> for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
>> oqa = otp->t_dqinfo->dqs[j];
>> nqa = ntp->t_dqinfo->dqs[j];
>> @@ -143,9 +136,6 @@ xfs_trans_mod_dquot_byino(
>> xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
>> return;
>>
>> - if (tp->t_dqinfo == NULL)
>> - xfs_trans_alloc_dqinfo(tp);
>> -
>
> I can't tell from the commit log or from a very quick read of the code why these
> allocations are being removed. Can we not get here with a NULL t_dqinfo?
> If not, why not? This seems like a change unrelated to the proposed
> "t_dqinfo set == XFS_TRANS_DQ_DIRTY" change.
Yeah, remove these allocations because I want to allocate the t_dqinfo only
when the tp->t_dqinfo->dqs[XFS_QM_TRANS_{USR,GRP,PRJ}] values changed, that
is to say, only do the allocation in xfs_trans_mod_dquot() function. Actually,
original these allocations are repeated, for example, the xfs_trans_mod_dquot_byino()
function call the xfs_trans_mod_dquot(), but both of them do the allocation,
so remove one of them may be reasonable.
>
> Also, while it seems clear to say that !t_dqinfo == !XFS_TRANS_DQ_DIRTY, is the
> converse true? Is it possible to have t_dqinfo set, but it's not dirty?>
> I think the answer is that when we free the transaction we set t_dqinfo to
> NULL again, but I'm not certain, and it's not obvious from the changelog...
Now we do the allocation in xfs_trans_mod_dquot() function and only have t_dqinfo
set when it is dirty.
Thanks,
Kaixu
>
> -Eric
>
--
kaixuxia
next prev parent reply other threads:[~2020-10-02 3:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-26 13:14 [PATCH v2 0/4] xfs: random fixes for disk quota xiakaixu1987
2020-09-26 13:14 ` [PATCH v2 1/4] xfs: do the ASSERT for the arguments O_{u,g,p}dqpp xiakaixu1987
2020-10-06 4:35 ` Darrick J. Wong
2020-09-26 13:14 ` [PATCH v2 2/4] xfs: fix the indent in xfs_trans_mod_dquot xiakaixu1987
2020-10-06 4:36 ` Darrick J. Wong
2020-09-26 13:14 ` [PATCH v2 3/4] xfs: check tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag xiakaixu1987
2020-09-26 15:36 ` Eric Sandeen
2020-10-02 3:31 ` kaixuxia [this message]
2020-10-06 4:42 ` Darrick J. Wong
2020-10-06 11:33 ` kaixuxia
2020-09-26 13:14 ` [PATCH v2 4/4] xfs: directly return if the delta equal to zero xiakaixu1987
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=fdff45c9-82ac-c053-3c10-ca8d8996630e@gmail.com \
--to=xiakaixu1987@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=kaixuxia@tencent.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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).