From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 01/14] xfs: create a per-AG btree to track reference counts
Date: Thu, 2 Jul 2015 09:30:42 +1000 [thread overview]
Message-ID: <20150701233042.GU22807@dastard> (raw)
In-Reply-To: <20150701225213.GA10043@birch.djwong.org>
On Wed, Jul 01, 2015 at 03:52:13PM -0700, Darrick J. Wong wrote:
> On Wed, Jul 01, 2015 at 10:13:06AM +1000, Dave Chinner wrote:
> > On Thu, Jun 25, 2015 at 04:39:16PM -0700, Darrick J. Wong wrote:
> > > diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> > > index 9cff517..e4954ab 100644
> > > --- a/fs/xfs/libxfs/xfs_format.h
> > > +++ b/fs/xfs/libxfs/xfs_format.h
> > > @@ -446,9 +446,11 @@ xfs_sb_has_compat_feature(
> > >
> > > #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */
> > > #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */
> > > +#define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflink btree */
> > > #define XFS_SB_FEAT_RO_COMPAT_ALL \
> > > (XFS_SB_FEAT_RO_COMPAT_FINOBT | \
> > > - XFS_SB_FEAT_RO_COMPAT_RMAPBT)
> > > + XFS_SB_FEAT_RO_COMPAT_RMAPBT | \
> > > + XFS_SB_FEAT_RO_COMPAT_REFLINK)
> >
> > The XFS_SB_FEAT_RO_COMPAT_REFLINK flag shoul dbe added as a separate
> > patch and put last in the series so it is only enabled once
> > everything is complete.
>
> What if I define XFS_SB_FEAT_RO_COMPAT_REFLINK at the beginning but omit it
> from the XFS_SB_FEAT_RO_COMPAT_ALL definition until the final patch? That
> should prohibit anyone from using the half-baked feature during a bisect.
Yup, thats what I meant ;)
> > > + int *stat)
> > > +{
> > > + int error;
> > > + xfs_agblock_t bno;
> > > +
> > > + XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
> > > +
> > > + /* Allocate the new block from the freelist. If we can't, give up. */
> > > + error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
> > > + &bno, 1);
> > > + if (error) {
> > > + XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
> > > + return error;
> > > + }
> >
> > Why does the reflink btree use the free list? Why can't it use
> > block allocation like the BMBT tree?
>
> I'm confused about the intended usage of the AGFL -- the XFS FS structure doc
> says that it's for growing the free space btrees and can't be used for anything
> else, but the rmap btree uses it.
The rmap btree is a "freespace" btree in that it is modified at the
same time the two freespace btrees are modified. It's tracking used
space rather than free space, but from an architectural POV the rmap
btree sits at the same lowest layer as the freespace btree.
Think of it like this: when an extent is allocated, the freespace
btree removal needs ot be atomic with the rmap btree insertion so
they remain coherent at all times. Similarly we have the same
situation with extent freeing - removal from the rmap must be atomic
with addition to the freespace btree.
The reflink btree sits a layer above the freespace btrees,
equivalent to the BMBT. That is, when we remove an extent from the
BMBT, we also need to remove the reflink btree reference. Only if
the reference drops to zero does the extent then become free, and we
pass it off to xfs_free_extent()....
> Originally it /did/ use xfs_alloc_vextent(), though it won't be
> difficult to revert.
The way you use EFIs means that it can't be put inside
xfs_alloc_vextent()/xfs_free_extent() - EFIs track movement of
extents from the BMBT to the freespace tree, and so if we now have a
reflink btree in the way, the EFI tracks movement from the reflink
btree to the freespace trees. i.e. the reflink btree is modified
atomically with the BMBT, not the freespace trees.
Which, really, is a long way of saying that the allocation/freeing
model of reflink btree blocks shoul dbe the same as the BMBT, and
the transactional model integrates with the BMBT modifications, not
the freespace btree modifications...
> > > +/*
> > > + * Allocate a new reflink btree cursor.
> > > + */
> > > +struct xfs_btree_cur * /* new reflink btree cursor */
> > > +xfs_reflinkbt_init_cursor(
> > > + struct xfs_mount *mp, /* file system mount point */
> > > + struct xfs_trans *tp, /* transaction pointer */
> > > + struct xfs_buf *agbp, /* buffer for agf structure */
> > > + xfs_agnumber_t agno) /* allocation group number */
> >
> > No real need for these comments on the variables. They are redundant
> > as the code documents what they are just fine.
>
> I was playing monkey-see monkey-do. Some of the other functions had
> commented args. :)
Yup, that's the old code. For new code we write it in a way that
doesn't require comments like that ;)
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-07-01 23:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 23:39 [RFC(RAP) 00/14] xfs: add reflink and dedupe support Darrick J. Wong
2015-06-25 23:39 ` [PATCH 01/14] xfs: create a per-AG btree to track reference counts Darrick J. Wong
2015-07-01 0:13 ` Dave Chinner
2015-07-01 22:52 ` Darrick J. Wong
2015-07-01 23:30 ` Dave Chinner [this message]
2015-06-25 23:39 ` [PATCH 02/14] libxfs: adjust refcounts in reflink btree Darrick J. Wong
2015-07-01 1:06 ` Dave Chinner
2015-07-01 23:10 ` Darrick J. Wong
2015-07-01 23:32 ` Dave Chinner
2015-06-25 23:39 ` [PATCH 03/14] libxfs: support unmapping reflink blocks Darrick J. Wong
2015-07-01 1:26 ` Dave Chinner
2015-07-02 2:27 ` Darrick J. Wong
2015-06-25 23:39 ` [PATCH 04/14] libxfs: block-mapper changes to support reflink Darrick J. Wong
2015-06-25 23:39 ` [PATCH 05/14] xfs: add reflink functions and ioctl Darrick J. Wong
2015-06-25 23:39 ` [PATCH 06/14] xfs: implement copy-on-write for reflinked blocks Darrick J. Wong
2015-06-25 23:39 ` [PATCH 07/14] xfs: handle directio " Darrick J. Wong
2015-06-25 23:40 ` [PATCH 08/14] xfs: teach fiemap about reflink'd extents Darrick J. Wong
2015-06-25 23:40 ` [PATCH 09/14] xfs: copy-on-write reflinked blocks when zeroing ranges of blocks Darrick J. Wong
2015-06-25 23:40 ` [PATCH 10/14] xfs: minimize impact to non-reflink files via reflink per-inode flag Darrick J. Wong
2015-07-01 1:58 ` Dave Chinner
2015-07-01 22:59 ` Darrick J. Wong
2015-07-01 23:49 ` Dave Chinner
2015-07-02 2:32 ` Darrick J. Wong
2015-07-02 7:07 ` Dave Chinner
2015-06-25 23:40 ` [PATCH 11/14] xfs: emulate the btrfs dedupe extent same ioctl Darrick J. Wong
2015-06-25 23:40 ` [PATCH 12/14] xfs: support XFS_XFLAG_REFLINK (and FS_NOCOW_FL) on reflink filesystems Darrick J. Wong
2015-06-25 23:40 ` [PATCH 13/14] xfs: add reflink btree root when expanding the filesystem Darrick J. Wong
2015-06-25 23:40 ` [PATCH 14/14] xfs: add reflink btree block detection to log recovery Darrick J. Wong
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=20150701233042.GU22807@dastard \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.com \
--cc=xfs@oss.sgi.com \
/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