From: Chandan Rajendra <chandan@linux.ibm.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Chandan Rajendra <chandanrlinux@gmail.com>,
linux-xfs@vger.kernel.org, darrick.wong@oracle.com,
bfoster@redhat.com
Subject: Re: [PATCH 1/2] xfs: Fix log reservation calculation for xattr insert operation
Date: Wed, 08 Apr 2020 14:17:34 +0530 [thread overview]
Message-ID: <2566441.lnnSxWHcxk@localhost.localdomain> (raw)
In-Reply-To: <20200407004955.GE21885@dread.disaster.area>
On Tuesday, April 7, 2020 6:19 AM Dave Chinner wrote:
> [chopped bits out of the diff to get the whole reservation in one
> obvious piece of code.]
>
> On Sat, Apr 04, 2020 at 02:22:02PM +0530, Chandan Rajendra wrote:
> > @@ -698,42 +699,36 @@ xfs_calc_attrinval_reservation(
> > }
> >
> > /*
> > + * Setting an attribute.
> > * the inode getting the attribute
> > * the superblock for allocations
> > + * the agf extents are allocated from
> > * the attribute btree * max depth
> > + * the bmbt entries for da btree blocks
> > + * the bmbt entries for remote blocks (if any)
> > + * the allocation btrees.
> > */
> > STATIC uint
> > -xfs_calc_attrsetm_reservation(
> > +xfs_calc_attrset_reservation(
> > struct xfs_mount *mp)
> > {
> > + int max_rmt_blks;
> > + int da_blks;
> > + int bmbt_blks;
> > +
> > + da_blks = XFS_DAENTER_BLOCKS(mp, XFS_ATTR_FORK);
>
> #define XFS_DAENTER_BLOCKS(mp,w) \
> (XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
> #define XFS_DAENTER_1B(mp,w) \
> ((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
> #define XFS_DAENTER_DBS(mp,w) \
> (XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
>
> So, da_blks contains the full da btree split depth * 1 block. i.e.
>
> da_blks = XFS_DA_NODE_MAXDEPTH;
>
> > + bmbt_blks = XFS_DAENTER_BMAPS(mp, XFS_ATTR_FORK);
>
> #define XFS_DAENTER_BMAPS(mp,w) \
> (XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w))
>
> #define XFS_DAENTER_BMAP1B(mp,w) \
> XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w)
>
> So, bmbt_blks contains the full da btree split depth * the BMBT
> overhead for a single block allocation:
>
> #define XFS_EXTENTADD_SPACE_RES(mp,w) (XFS_BM_MAXLEVELS(mp,w) - 1)
> #define XFS_NEXTENTADD_SPACE_RES(mp,b,w)\
> (((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
> XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
> XFS_EXTENTADD_SPACE_RES(mp,w))
>
> XFS_NEXTENTADD_SPACE_RES(1) = ((1 + N - 1) / N) * (XFS_BM_MAXLEVELS - 1)
> = (XFS_BM_MAXLEVELS - 1)
>
> So, bmbt_blks = XFS_DA_NODE_MAXDEPTH * (XFS_BM_MAXLEVELS - 1)
>
> IOWs, this bmbt reservation is assuming a full height BMBT
> modification on *every* dabtree node allocation. IOWs, we're
> reserving multiple times the log space for potential bmbt
> modifications than we are for the entire dabtree modification.
> That's why the individual dabtree reservations are so big....
>
> > + max_rmt_blks = xfs_attr3_rmt_blocks(mp, XATTR_SIZE_MAX);
> > + bmbt_blks += XFS_NEXTENTADD_SPACE_RES(mp, max_rmt_blks, XFS_ATTR_FORK);
>
> And this assumes we are going to log at least another full bmbt
> modification.
>
> IT seems to me that the worst case here is one full split and then
> every other allocation inserts at the start of an existing block and
> so updates pointers all the way up to the root. The impact is
> limited, though, because XFS_DA_NODE_MAXDEPTH = 5 and so the attr
> fork BMBT tree is not likely to reach anywhere near it's max depth
> on large filesystems.....
>
> > return XFS_DQUOT_LOGRES(mp) +
> > xfs_calc_inode_res(mp, 1) +
> > xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
> > + xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
> > + xfs_calc_buf_res(da_blks, XFS_FSB_TO_B(mp, 1)) +
> > + xfs_calc_buf_res(bmbt_blks, XFS_FSB_TO_B(mp, 1)) +
> > + xfs_calc_buf_res(xfs_allocfree_log_count(mp, da_blks),
> > XFS_FSB_TO_B(mp, 1));
>
> Given the above, this looks OK. Worst case BMBT usage looks
> excessive, but there is a chance it could be required...
>
> > diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h
> > index 88221c7a04ccf..6a22ad11b3825 100644
> > --- a/fs/xfs/libxfs/xfs_trans_space.h
> > +++ b/fs/xfs/libxfs/xfs_trans_space.h
> > @@ -38,8 +38,14 @@
> >
> > #define XFS_DAENTER_1B(mp,w) \
> > ((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
> > +/*
> > + * xattr set operation can cause the da btree to split twice in the
> > + * worst case. The double split is actually an extra leaf node rather
> > + * than a complete split of blocks in the path from root to a
> > + * leaf. The '1' in the macro below accounts for the extra leaf node.
>
> It's not a double tree split, so don't describe it that way and then
> have to explain that it's not a double tree split!
>
> /*
> * When inserting a large local record into the dabtree leaf, we may
> * need to split the leaf twice to make room to fit the new record
> * into the new leaf. This double leaf split still only requires a
> * single datree path update as the inserted leaves are at adjacent
> * indexes. Hence we only need to account for an the extra leaf
> * block in the attribute fork here.
> */
Sure. I will change the comment. Thanks for the review.
--
chandan
next prev parent reply other threads:[~2020-04-08 8:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-04 8:52 [PATCH 0/2] Extend xattr extent counter to 32-bits Chandan Rajendra
2020-04-04 8:52 ` [PATCH 1/2] xfs: Fix log reservation calculation for xattr insert operation Chandan Rajendra
2020-04-06 15:25 ` Brian Foster
2020-04-06 22:57 ` Dave Chinner
2020-04-07 5:11 ` Chandan Rajendra
2020-04-07 12:59 ` Brian Foster
2020-04-07 0:49 ` Dave Chinner
2020-04-08 8:47 ` Chandan Rajendra [this message]
2020-04-04 8:52 ` [PATCH 2/2] xfs: Extend xattr extent counter to 32-bits Chandan Rajendra
2020-04-06 16:45 ` Brian Foster
2020-04-08 12:40 ` Chandan Rajendra
2020-04-06 17:06 ` Darrick J. Wong
2020-04-06 23:30 ` Dave Chinner
2020-04-08 12:43 ` Chandan Rajendra
2020-04-08 15:38 ` Darrick J. Wong
2020-04-08 22:43 ` Dave Chinner
2020-04-08 15:45 ` Darrick J. Wong
2020-04-08 22:45 ` Dave Chinner
2020-04-08 12:42 ` Chandan Rajendra
2020-04-07 1:20 ` Dave Chinner
2020-04-08 12:45 ` Chandan Rajendra
2020-04-10 7:46 ` Chandan Rajendra
2020-04-12 6:34 ` Chandan Rajendra
2020-04-13 18:55 ` Darrick J. Wong
2020-04-20 4:38 ` Chandan Rajendra
2020-04-22 9:38 ` Chandan Rajendra
2020-04-22 22:30 ` Dave Chinner
2020-04-25 12:07 ` Chandan Rajendra
2020-04-26 22:08 ` Dave Chinner
2020-04-29 15:35 ` Chandan Rajendra
2020-05-01 7:08 ` Chandan Rajendra
2020-05-12 23:53 ` Darrick J. Wong
2020-05-13 12:19 ` Chandan Rajendra
2020-04-22 22:51 ` Darrick J. Wong
2020-04-27 7:42 ` Christoph Hellwig
2020-04-27 7:39 ` Christoph Hellwig
2020-04-30 2:29 ` Chandan Rajendra
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=2566441.lnnSxWHcxk@localhost.localdomain \
--to=chandan@linux.ibm.com \
--cc=bfoster@redhat.com \
--cc=chandanrlinux@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.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).