All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>, Ian Campbell <ian.campbell@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	xen-devel <xen-devel@lists.xen.org>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH 1/2 linux-next] Revert "ufs: fix deadlocks introduced by sb mutex merge"
Date: Sat, 6 Jun 2015 10:04:15 +0200 (CEST)	[thread overview]
Message-ID: <1470229945.639558.1433577855169.open-xchange@webmail.nmp.proximus.be> (raw)
In-Reply-To: <20150605185018.GX7232@ZenIV.linux.org.uk>



> On 05 June 2015 at 20:50 Al Viro <viro@ZenIV.linux.org.uk> wrote:
>
>
> On Fri, Jun 05, 2015 at 06:27:01PM +0200, Fabian Frederick wrote:
>
> > You're asking to remove lock_ufs() in allocation and replace it by
> > truncate_mutex. I guess you're talking about doing that on current rc
> > (without s_lock restored).
> >
> > I tried a quick patch on rc trying to convert lock_ufs()/unlock_ufs()
> > with per inode truncate_mutex (see attachment).
> > Is it going the right direction ?
>
> Nope.  First of all, allocation should be protected by fs-wide mutex, for
> obvious reasons.  What ->truncate_mutex is protecting (outside of that
> one) is modifications of block pointers in inode and in indirect blocks.
>
> Check what ext2 is doing.  It tries to follow pointers without taking
> a lock.  If it succeeds, fine, no allocation is needed, just map it.
> If it fails, it grabs ->truncate_mutex, follows pointers again (checking
> the chain it followed before grabbing the lock first, in hope it has
> remained valid) and does allocations and block pointer modifications,
> with ->truncate_mutex making sure that nobody else would touch those
> under it.  And on truncate side it deals with the page into which EOF
> will fall, then (still holding ->i_mutex) does setting ->i_size and
> eviction of pages beyond EOF (by truncate_setsize()), then does freeing
> the blocks past the new EOF.  Which is where it grabs ->truncate_mutex
> (inside __ext2_truncate_blocks()).  And it doesn't need to do those
> insane retries - on get_block side we need to redo the pointer chasing
> after having taken ->truncate_mutex (when it decides that it might need
> to do allocation, after all), but that's done once; truncate side just
> grabs ->truncate_mutex as soon as it gets to __ext2_truncate_blocks(),
> which means that nobody can change anything under it.
>
> Actual allocation/freeing of blocks (as well as that of inodes) is done
> under fs-wide mutex, nesting inside the rest.
>
> Basically, we have
>       i_mutex: file size changes, contents-affecting syscalls.  Per-inode.
>       truncate_mutex: block pointers changes.  Per-inode.
>       s_lock: block and inode bitmaps changes.  Per-filesystem.
>
> For UFS it's slightly more complicated due to tail packing they are doing for
> short files, but most of that complexity is due to having that stuff handled
> way too deep in call chain.

In your two explanations, there's only a place for one sb mutex:
"
i_mutex: file size changes, contents-affecting syscalls.  Per-inode.
truncate_mutex: block pointers changes.  Per-inode.
s_lock: block and inode bitmaps changes.  Per-filesystem.
"
"
per-page exclusion for reallocation time (normal page locks are doing that)
per-fs exclusion for block and fragment allocations (->s_lock?)
per-fs exclusion for inode allocations (->s_lock?)
per-inode exclusion for mapping changes (a-la ext2 truncate_mutex)
per-directory exclusion for contents access (->i_mutex gives that)       
"

Meanwhile current linux-next has 2 in fs/ufs/ufs.h: struct ufs_sb_info

struct mutex mutex
struct mutex s_lock

So commit 0244756edc4b98c129e "ufs: sb mutex merge + mutex_destroy")
was finally not a bad thing but maybe it removed the bad one ?

Regards,
Fabian

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

      parent reply	other threads:[~2015-06-06  8:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1432754131-27425-1-git-send-email-fabf@skynet.be>
     [not found] ` <20150527145735.e3d1913bc66426038d53be32@linux-foundation.org>
2015-06-04  5:01   ` [PATCH 1/2 linux-next] Revert "ufs: fix deadlocks introduced by sb mutex merge" Al Viro
2015-06-04 22:22     ` Al Viro
2015-06-04 22:22     ` Al Viro
2015-06-05 16:27     ` Fabian Frederick
2015-06-05 18:50       ` Al Viro
2015-06-05 22:03         ` Al Viro
2015-06-17  8:57           ` Jan Kara
2015-06-17  8:57           ` Jan Kara
2015-06-17 20:31             ` Al Viro
2015-06-17 20:31             ` Al Viro
2015-06-19 23:07               ` Al Viro
2015-06-19 23:07               ` Al Viro
2015-06-23 16:46                 ` Jan Kara
2015-06-23 16:46                 ` Jan Kara
2015-06-23 21:56                   ` Al Viro
2015-06-23 21:56                   ` Al Viro
2015-06-05 22:03         ` Al Viro
2015-06-06  8:04         ` Fabian Frederick [this message]

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=1470229945.639558.1433577855169.open-xchange@webmail.nmp.proximus.be \
    --to=fabf@skynet.be \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=akpm@linux-foundation.org \
    --cc=dushistov@mail.ru \
    --cc=ian.campbell@citrix.com \
    --cc=jack@suse.cz \
    --cc=khoroshilov@ispras.ru \
    --cc=roger.pau@citrix.com \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.