linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: Miao Xie <miaoxie@huawei.com>, Al Viro <viro@ZenIV.linux.org.uk>
Cc: <linux-btrfs@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH RESEND v4 6/8] vfs: Add get_vfsmount_sb() function to get vfsmount from a given sb.
Date: Fri, 30 Jan 2015 13:30:47 +0800	[thread overview]
Message-ID: <54CB1707.2030202@cn.fujitsu.com> (raw)
In-Reply-To: <54CB0520.2070008@huawei.com>


-------- Original Message --------
Subject: Re: [PATCH RESEND v4 6/8] vfs: Add get_vfsmount_sb() function 
to get vfsmount from a given sb.
From: Miao Xie <miaoxie@huawei.com>
To: Al Viro <viro@ZenIV.linux.org.uk>, Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015年01月30日 12:14
> On Fri, 30 Jan 2015 02:14:45 +0000, Al Viro wrote:
>> On Fri, Jan 30, 2015 at 09:44:03AM +0800, Qu Wenruo wrote:
>>
>>> This shouldn't happen. If someone is ro, the whole fs should be ro, right?
>> Wrong.  Individual vfsmounts over an r/w superblock might very well be r/o.
>> As for that trylock...  What for?  It invites transient failures for no
>> good reason.  Removal of sysfs entry will block while write(2) to that sucker
>> is in progress, so btrfs shutdown will block at that point in ctree_close().
>> It won't go away under you.
> could you explain the race condition? I think the deadlock won't happen, during
> the btrfs shutdown, we hold s_umount, the write operation will fail to lock it,
> and quit quickly, and then umount will continue.
>
> I think sb_want_write() is similar to trylock(s_umount), the difference is that
> sb_want_write() is more complex.
How?
sb_want_write() should be much like mnt_want_write(), except no need to 
increase vfsmout ref count things
and no need to check per mount ro/rw things.

Thanks,
Qu
>
>> Now, you might want to move those sysfs entry removals to the very beginning
>> of btrfs_kill_super(), but that's a different story - you need only to make
>> sure that they are removed not later than the destruction of the data
>> structures they need (IOW, the current location might very well be OK - I
>> hadn't checked the details).
> Yes, we need move those sysfs entry removals, but needn't move to the very
> beginning of btrfs_kill_super(), just at the beginning of close_ctree();
>
> The current location is not right, it will introduce the use-after-free
> problem. because we remove the sysfs entry after we release
> transaction_kthread, use-after-free problem might happen in this case
> 	Task1				Task2
> 	change Label by sysfs
> 					close_ctree
> 					  kthread_stop(transaction_kthread);
> 	  change label
> 	  wake_up(transaction_kthread)
>
>
> Thanks
> Miao
>
>> As for "it won't go r/o under us" - sb_want_write() will do that just fine.
>> .
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2015-01-30  5:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1422498281-20493-1-git-send-email-quwenruo@cn.fujitsu.com>
2015-01-29  2:24 ` [PATCH RESEND v4 6/8] vfs: Add get_vfsmount_sb() function to get vfsmount from a given sb Qu Wenruo
2015-01-29 12:37   ` David Sterba
2015-01-29 15:23     ` Al Viro
2015-01-30  1:11       ` Qu Wenruo
2015-01-30  2:09         ` Al Viro
2015-01-30  2:20           ` Qu Wenruo
2015-01-30  0:52   ` Miao Xie
2015-01-30  1:44     ` Qu Wenruo
2015-01-30  2:02       ` Qu Wenruo
2015-01-30  3:22         ` Miao Xie
2015-01-30  3:30           ` Qu Wenruo
2015-01-30  2:14       ` Al Viro
2015-01-30  4:14         ` Miao Xie
2015-01-30  4:37           ` Al Viro
2015-01-30  5:34             ` Miao Xie
2015-01-30  6:15               ` Al Viro
2015-01-30  5:30           ` Qu Wenruo [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=54CB1707.2030202@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=viro@ZenIV.linux.org.uk \
    /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).