public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/20] xfs: split iop_unlock
Date: Mon, 20 May 2019 07:38:14 -0400	[thread overview]
Message-ID: <20190520113811.GA31317@bfoster> (raw)
In-Reply-To: <20190520061043.GG31977@lst.de>

On Mon, May 20, 2019 at 08:10:43AM +0200, Christoph Hellwig wrote:
> On Fri, May 17, 2019 at 01:49:16PM -0400, Brian Foster wrote:
> > Refactoring aside, I see that the majority of this patch is focused on
> > intent log item implementations. I don't think an item leak is possible
> > here because we intentionally dirty transactions when either an intent
> > or done item is logged. See xfs_extent_free_log_item() and
> > xfs_trans_free_extent() for examples associated with the EFI/EFD items.
> 
> That's why I said theoretical.
> 

The current commit log says it's either rare or doesn't occur in
practice, which leaves the question open. I'm pointing out that for the
codepaths affected by this patch, I don't think it can occur.

I agree that it's still a theoretical possibility based on the current
log item interface and intent item implementations...

> > On one hand this logic supports the current item reference counting
> > logic (for example, so we know whether to drop the log's reference to an
> > EFI on transaction abort or wait until physical log commit time). On the
> > other hand, the items themselves must be logged to disk so we have to
> > mark them dirty (along with the transaction on behalf of the item) for
> > that reason as well. FWIW, I do think the current approach of adding the
> > intent item and dirtying it separately is slightly confusing,
> > particularly since I'm not sure we have any valid use case to have a
> > clean intent/done item in a transaction.
> 
> Indeed.  I think there is plenty of opportunity for futher wok here.
> 
> > I suppose this kind of refactoring might still make sense on its own if
> > the resulting code is more clear or streamlined. I.e., perhaps there's
> > no need for the separate ->iop_committing() and ->iop_unlock() callbacks
> > invoked one after the other. That said, I think the commit log should
> > probably be updated to focus on that (unless I'm missing something about
> > the potential leak). Hm?
> 
> The streamlining was the the point.  I just noticed that if we were
> every to about a clean intent item we'd leak it while doing that.

Ok, then I'd just suggest to update the commit log. I guess it's easier
for me to just suggest one, so for example (feel free to use, modify or
replace):

---

iop_unlock() is called when comitting or cancelling a transaction. In
the latter case, the transaction may or may not be aborted. While there
is no known problem with the current code in practice, this
implementation is limited in that any log item implementation that might
want to differentiate between a commit and a cancel must rely on the
aborted state. The aborted bit is only set when the cancelled
transaction is dirty, however. This means that there is no way to
distinguish between a commit and a clean transaction cancel.

For example, intent log items currently rely on this distinction. The
log item is either transferred to the CIL on commit or released on
transaction cancel. There is currently no possibility for a clean intent
log item in a transaction, but if that state is ever introduced a cancel
of such a transaction will immediately result in memory leaks of the
associated log item(s). This is an interface deficiency and landmine.

To clean this up, replace ->iop_unlock() with an ->iop_release()
callback that is specific to transaction cancel. The existing
->iop_committing() callback occurs at the same time as ->iop_unlock() in
the commit path and there is no need for two separate callbacks here.
Overload ->iop_committing() with the current commit time ->iop_unlock()
implementations to eliminate the need for the latter and further
simplify the interface.

---

I'll try to get through the rest of this series today..

Brian

  reply	other threads:[~2019-05-20 11:38 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
2019-05-17 14:04   ` Brian Foster
2019-05-20 22:08   ` Darrick J. Wong
2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
2019-05-17 14:04   ` Brian Foster
2019-05-20  6:03     ` Christoph Hellwig
2019-05-17 14:10   ` Eric Sandeen
2019-05-20  6:05     ` Christoph Hellwig
2019-05-20 22:08   ` Darrick J. Wong
2019-06-11  8:46     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 03/20] xfs: don't require log items to implement optional methods Christoph Hellwig
2019-05-17 14:06   ` Brian Foster
2019-05-20  6:06     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items Christoph Hellwig
2019-05-17 14:07   ` Brian Foster
2019-05-17  7:31 ` [PATCH 05/20] xfs: remove the iop_push implementation for quota off items Christoph Hellwig
2019-05-17 14:08   ` Brian Foster
2019-05-20  6:09     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path Christoph Hellwig
2019-05-17 14:08   ` Brian Foster
2019-05-17  7:31 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
2019-05-17 17:49   ` Brian Foster
2019-05-20  6:10     ` Christoph Hellwig
2019-05-20 11:38       ` Brian Foster [this message]
2019-05-17  7:31 ` [PATCH 08/20] xfs: add a flag to release log items on commit Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-20  6:11     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-17  7:31 ` [PATCH 10/20] xfs: remove the xfs_log_item_t typedef Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-17  7:31 ` [PATCH 11/20] xfs: use a list_head for iclog callbacks Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-20 13:19     ` Christoph Hellwig
2019-05-20 13:25       ` Brian Foster
2019-05-20 13:27       ` Bryan Gurney
2019-05-20 13:31         ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
2019-05-17  8:16   ` Nikolay Borisov
2019-05-17  8:27     ` Christoph Hellwig
2019-05-17 18:26   ` Eric Sandeen
2019-05-20  6:03     ` Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-17  7:31 ` [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster
2019-05-17  7:31 ` [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster
2019-05-17  7:31 ` [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster
  -- strict thread matches above, loose matches on Subject: below --
2019-06-13 18:02 misc log item related cleanups v2 Christoph Hellwig
2019-06-13 18:02 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
2019-06-14 14:43   ` 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=20190520113811.GA31317@bfoster \
    --to=bfoster@redhat.com \
    --cc=hch@lst.de \
    --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