linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Amir Goldstein <amir73il@gmail.com>
Cc: zhangyi <yi.zhang@huawei.com>, overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: [PATCH] ovl: take lower dir inode mutex outside upper sb_writers lock
Date: Wed, 22 Nov 2017 10:34:35 +0100	[thread overview]
Message-ID: <CAJfpegvFutFyP_o4LPxopCGe6LD0fs-Y4mAsUjnPO+f9Y3Sgow@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxh-=vEQaW96_ZR1GcnOpbjy==k_zVsGy_Bt9kcdrdD-1w@mail.gmail.com>

On Wed, Nov 22, 2017 at 6:46 AM, Amir Goldstein <amir73il@gmail.com> wrote:
> On Fri, Nov 10, 2017 at 1:18 PM, Amir Goldstein <amir73il@gmail.com> wrote:
>> The functions ovl_lower_positive() and ovl_check_empty_dir() both take
>> inode mutex on the real lower dir under ovl_want_write() which takes
>> the upper_mnt sb_writers lock.
>>
>> While this is not a clear locking order or layering violation, it creates
>> an undesired lock dependency between two unrelated layers for no good
>> reason.
>>
>> This lock dependency materializes to a false(?) positive lockdep warning
>> when calling rmdir() on a nested overlayfs, where both nested and
>> underlying overlayfs both use the same fs type as upper layer.
>>
>> rmdir() on the nested overlayfs creates the lock chain:
>>   sb_writers of upper_mnt (e.g. tmpfs) in ovl_do_remove()
>>   ovl_i_mutex_dir_key[] of lower overlay dir in ovl_lower_positive()
>>
>> rmdir() on the underlying overlayfs creates the lock chain in
>> reverse order:
>>   ovl_i_mutex_dir_key[] of lower overlay dir in vfs_rmdir()
>>   sb_writers of nested upper_mnt (e.g. tmpfs) in ovl_do_remove()
>>
>> To rid of the unneeded locking dependency, move both ovl_lower_positive()
>> and ovl_check_empty_dir() to before ovl_want_write() in rmdir() and
>> rename() implementation.
>>
>> This change spreads the pieces of ovl_check_empty_and_clear() directly
>> inside the rmdir()/rename() implementations so the helper is no longer
>> needed and removed.
>>
>> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>> ---
>>
>> Miklos,
>>
>> Please consider this patch for v4.15.
>>
>> I bumped into the lockdep warning while testing file handles on nested
>> overlay and had to work around it by using different type of fs for the
>> lower-upper(xfs) and the upper-upper(tmpfs).
>>
>> The workaround doesn't suffice if there is another test mounting an overlay
>> with the same fs type used for upper-upper (e.g. unionmount-testsuite)
>> at the same machine boot, which happens on my automated testing.
>>
>> So fixing this removes a false positive from my automated testing.
>>
>
> Miklos,
>
> Any objections to this change?
>
> Thanks,
> Amir.

No objection, just need time to review.  Will do.

Thanks,
Miklos

      reply	other threads:[~2017-11-22  9:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 11:18 [PATCH] ovl: take lower dir inode mutex outside upper sb_writers lock Amir Goldstein
2017-11-22  5:46 ` Amir Goldstein
2017-11-22  9:34   ` Miklos Szeredi [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=CAJfpegvFutFyP_o4LPxopCGe6LD0fs-Y4mAsUjnPO+f9Y3Sgow@mail.gmail.com \
    --to=miklos@szeredi.hu \
    --cc=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=yi.zhang@huawei.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;
as well as URLs for NNTP newsgroup(s).