public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 9/9] xfs: add in-memory iunlink log item
Date: Wed, 29 Jun 2022 14:49:46 -0700	[thread overview]
Message-ID: <YrzI+vbHY4eOjh/N@magnolia> (raw)
In-Reply-To: <20220629214458.GZ227878@dread.disaster.area>

On Thu, Jun 30, 2022 at 07:44:58AM +1000, Dave Chinner wrote:
> On Wed, Jun 29, 2022 at 02:21:30PM -0700, Darrick J. Wong wrote:
> > On Mon, Jun 27, 2022 at 10:43:36AM +1000, Dave Chinner wrote:
> > > diff --git a/fs/xfs/xfs_iunlink_item.c b/fs/xfs/xfs_iunlink_item.c
> > > new file mode 100644
> > > index 000000000000..fe38fc61f79e
> > > --- /dev/null
> > > +++ b/fs/xfs/xfs_iunlink_item.c
> > > @@ -0,0 +1,180 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * Copyright (c) 2020, Red Hat, Inc.
> > 
> > 2022?
> 
> 2020 is correct - that's when I originally wrote this and first published it.
> 
> > > + * All Rights Reserved.
> > > + */
> > > +#include "xfs.h"
> > > +#include "xfs_fs.h"
> > > +#include "xfs_shared.h"
> > > +#include "xfs_format.h"
> > > +#include "xfs_log_format.h"
> > > +#include "xfs_trans_resv.h"
> > > +#include "xfs_mount.h"
> > > +#include "xfs_inode.h"
> > > +#include "xfs_trans.h"
> > > +#include "xfs_trans_priv.h"
> > > +#include "xfs_ag.h"
> > > +#include "xfs_iunlink_item.h"
> > > +#include "xfs_trace.h"
> > > +#include "xfs_error.h"
> > > +
> > > +struct kmem_cache	*xfs_iunlink_cache;
> > > +
> > > +static inline struct xfs_iunlink_item *IUL_ITEM(struct xfs_log_item *lip)
> > > +{
> > > +	return container_of(lip, struct xfs_iunlink_item, item);
> > > +}
> > > +
> > > +static void
> > > +xfs_iunlink_item_release(
> > > +	struct xfs_log_item	*lip)
> > > +{
> > > +	struct xfs_iunlink_item	*iup = IUL_ITEM(lip);
> > > +
> > > +	xfs_perag_put(iup->pag);
> > > +	kmem_cache_free(xfs_iunlink_cache, IUL_ITEM(lip));
> > > +}
> > > +
> > > +
> > > +static uint64_t
> > > +xfs_iunlink_item_sort(
> > > +	struct xfs_log_item	*lip)
> > > +{
> > > +	return IUL_ITEM(lip)->ip->i_ino;
> > > +}
> > 
> > Since you mentioned in-memory log items for dquots -- how should
> > iunlinks and dquot log items be sorted?
> 
> ip->i_ino is the physical location of the inode - I'd use the
> physical location of the dquot buffer if that was being logged.
> 
> > (On the off chance the dquot comment was made off the cuff and you don't
> > have a patchset ready to go in your dev tree -- I probably wouldn't have
> > said anything if this looked like the usual comparator function.)
> 
> No, there's nothing coming down the line for dquots right now.

Ok.

> > > +/*
> > > + * On precommit, we grab the inode cluster buffer for the inode number we were
> > > + * passed, then update the next unlinked field for that inode in the buffer and
> > > + * log the buffer. This ensures that the inode cluster buffer was logged in the
> > > + * correct order w.r.t. other inode cluster buffers. We can then remove the
> > > + * iunlink item from the transaction and release it as it is has now served it's
> > > + * purpose.
> > > + */
> > > +static int
> > > +xfs_iunlink_item_precommit(
> > > +	struct xfs_trans	*tp,
> > > +	struct xfs_log_item	*lip)
> > > +{
> > > +	struct xfs_iunlink_item	*iup = IUL_ITEM(lip);
> > > +	int			error;
> > > +
> > > +	error = xfs_iunlink_log_dinode(tp, iup);
> > 
> > Hmm, so does this imply that log items can create new log items now?
> 
> Yup, now it's been sorted, we can lock the buffer, modify the
> unlinked list and log the buffer, adding the new buffer log item to
> the transaction.
> 
> That's the whole point of the in-memory log item - it records the
> change to be made, then delays the physical change until it is safe
> to lock the object we need to change.

Wheeee :)

> This minimises the length of time we have to hold the object locked
> during a transaction by dissociating the in-memory change from the
> on-disk format changes. I plan to use this technique a lot more in
> future...

Cool.  All I can think of is matrixpeople transmogrifying into Agent
Smiths :P

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com

  reply	other threads:[~2022-06-29 21:49 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27  0:43 [PATCH 0/9 v3] xfs: in-memory iunlink items Dave Chinner
2022-06-27  0:43 ` [PATCH 1/9] xfs: factor the xfs_iunlink functions Dave Chinner
2022-06-29  7:05   ` Christoph Hellwig
2022-06-29 20:48   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 2/9] xfs: track the iunlink list pointer in the xfs_inode Dave Chinner
2022-06-29  7:08   ` Christoph Hellwig
2022-06-29 20:50   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 3/9] xfs: refactor xlog_recover_process_iunlinks() Dave Chinner
2022-06-29  7:12   ` Christoph Hellwig
2022-06-29 20:56   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 4/9] xfs: introduce xfs_iunlink_lookup Dave Chinner
2022-06-29  7:17   ` Christoph Hellwig
2022-06-29 21:01   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 5/9] xfs: double link the unlinked inode list Dave Chinner
2022-06-29  7:20   ` Christoph Hellwig
2022-06-29 20:02     ` Darrick J. Wong
2022-06-29 21:06   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 6/9] xfs: clean up xfs_iunlink_update_inode() Dave Chinner
2022-06-29  7:21   ` Christoph Hellwig
2022-06-29 21:07   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 7/9] xfs: combine iunlink inode update functions Dave Chinner
2022-06-29  7:21   ` Christoph Hellwig
2022-06-29 21:07   ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 8/9] xfs: add log item precommit operation Dave Chinner
2022-06-29 21:16   ` Darrick J. Wong
2022-06-29 21:34     ` Dave Chinner
2022-06-29 21:42       ` Darrick J. Wong
2022-06-29 21:48         ` Dave Chinner
2022-07-07  2:34           ` Darrick J. Wong
2022-06-27  0:43 ` [PATCH 9/9] xfs: add in-memory iunlink log item Dave Chinner
2022-06-29  7:25   ` Christoph Hellwig
2022-06-29 21:37     ` Dave Chinner
2022-06-29 21:21   ` Darrick J. Wong
2022-06-29 21:44     ` Dave Chinner
2022-06-29 21:49       ` Darrick J. Wong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-07 23:43 [PATCH 0/9 v4] xfs: introduce in-memory inode unlink log items Dave Chinner
2022-07-07 23:43 ` [PATCH 9/9] xfs: add in-memory iunlink log item Dave Chinner
2022-07-11  5:24   ` 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=YrzI+vbHY4eOjh/N@magnolia \
    --to=djwong@kernel.org \
    --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