From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: <dsterba@suse.cz>, <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 10:20:51 +0800 [thread overview]
Message-ID: <54CAEA83.3080908@cn.fujitsu.com> (raw)
In-Reply-To: <20150130020902.GG29656@ZenIV.linux.org.uk>
-------- Original Message --------
Subject: Re: [PATCH RESEND v4 6/8] vfs: Add get_vfsmount_sb() function
to get vfsmount from a given sb.
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015年01月30日 10:09
> On Fri, Jan 30, 2015 at 09:11:26AM +0800, Qu Wenruo wrote:
>> For the mounted ro case, that's not a problem, since if one instance
>> is mounted ro,
>> other instances are also mounted ro, so that's not a problem.
> Not really.
>
> root@satch:~# cd /tmp/
> root@satch:~# mkdir /tm/a
> root@satch:~# mount --bind /tmp/ /tmp/a
> root@satch:~# mount --bind -o remount,ro /tmp/a
> root@satch:~# mkdir /tmp/b
> root@satch:~# mkdir /tmp/a/c
> mkdir: cannot create directory '/tmp/a/c': Read-only file system
> root@satch:~# stat /tmp/b /tmp/a/b
> File: '/tmp/b'
> Size: 4096 Blocks: 8 IO Block: 4096 directory
> Device: 806h/2054d Inode: 257537 Links: 2
> Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
> Access: 2015-01-29 21:03:35.000000000 -0500
> Modify: 2015-01-29 21:03:35.000000000 -0500
> Change: 2015-01-29 21:03:35.000000000 -0500
> Birth: -
> File: '/tmp/a/b'
> Size: 4096 Blocks: 8 IO Block: 4096 directory
> Device: 806h/2054d Inode: 257537 Links: 2
> Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
> Access: 2015-01-29 21:03:35.000000000 -0500
> Modify: 2015-01-29 21:03:35.000000000 -0500
> Change: 2015-01-29 21:03:35.000000000 -0500
> Birth: -
> root@satch:~#
>
> IOW, /tmp and /tmp/a bear the same filesystem (one from /dev/sda6), the former
> is mounted r/w, the latter - r/o.
Oh, bind mount.....
I was so stupid to forget bind.
>
>>> Assuming that your superblock is guaranteed to stay alive and usable for
>>> whatever work you are trying to do, what's wrong with sb_want_write()?
>> Did you mean change the function name and it's parameter to
>> sb_want_write(sb) and sb_drop_write(sb).
>> That looks much better.
>> But I'm a little worried about just using sb_start_write() and
>> s_readonly_remount/s_flags to do the protection,
>> will it be enough?
> Protection against what? If superblock is r/w, it will stay r/w until you
> do sb_drop_write(); if it's r/o, sb_want_write() will fail. There might be
> any number of vfsmounts over superblock; attempt to get write access via
> vfsmount will succeed only of both the vfsmount and superblock are r/w -
> mnt_want_write() does sb_want_write() and fails if that has failed.
Nice.
I'll add sb_want_write() and sb_drop_write().
Tons of thanks for all your advice!
Qu
WARNING: multiple messages have this Message-ID (diff)
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: <dsterba@suse.cz>, <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 10:20:51 +0800 [thread overview]
Message-ID: <54CAEA83.3080908@cn.fujitsu.com> (raw)
In-Reply-To: <20150130020902.GG29656@ZenIV.linux.org.uk>
-------- Original Message --------
Subject: Re: [PATCH RESEND v4 6/8] vfs: Add get_vfsmount_sb() function
to get vfsmount from a given sb.
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015年01月30日 10:09
> On Fri, Jan 30, 2015 at 09:11:26AM +0800, Qu Wenruo wrote:
>> For the mounted ro case, that's not a problem, since if one instance
>> is mounted ro,
>> other instances are also mounted ro, so that's not a problem.
> Not really.
>
> root@satch:~# cd /tmp/
> root@satch:~# mkdir /tm/a
> root@satch:~# mount --bind /tmp/ /tmp/a
> root@satch:~# mount --bind -o remount,ro /tmp/a
> root@satch:~# mkdir /tmp/b
> root@satch:~# mkdir /tmp/a/c
> mkdir: cannot create directory '/tmp/a/c': Read-only file system
> root@satch:~# stat /tmp/b /tmp/a/b
> File: '/tmp/b'
> Size: 4096 Blocks: 8 IO Block: 4096 directory
> Device: 806h/2054d Inode: 257537 Links: 2
> Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
> Access: 2015-01-29 21:03:35.000000000 -0500
> Modify: 2015-01-29 21:03:35.000000000 -0500
> Change: 2015-01-29 21:03:35.000000000 -0500
> Birth: -
> File: '/tmp/a/b'
> Size: 4096 Blocks: 8 IO Block: 4096 directory
> Device: 806h/2054d Inode: 257537 Links: 2
> Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
> Access: 2015-01-29 21:03:35.000000000 -0500
> Modify: 2015-01-29 21:03:35.000000000 -0500
> Change: 2015-01-29 21:03:35.000000000 -0500
> Birth: -
> root@satch:~#
>
> IOW, /tmp and /tmp/a bear the same filesystem (one from /dev/sda6), the former
> is mounted r/w, the latter - r/o.
Oh, bind mount.....
I was so stupid to forget bind.
>
>>> Assuming that your superblock is guaranteed to stay alive and usable for
>>> whatever work you are trying to do, what's wrong with sb_want_write()?
>> Did you mean change the function name and it's parameter to
>> sb_want_write(sb) and sb_drop_write(sb).
>> That looks much better.
>> But I'm a little worried about just using sb_start_write() and
>> s_readonly_remount/s_flags to do the protection,
>> will it be enough?
> Protection against what? If superblock is r/w, it will stay r/w until you
> do sb_drop_write(); if it's r/o, sb_want_write() will fail. There might be
> any number of vfsmounts over superblock; attempt to get write access via
> vfsmount will succeed only of both the vfsmount and superblock are r/w -
> mnt_want_write() does sb_want_write() and fails if that has failed.
Nice.
I'll add sb_want_write() and sb_drop_write().
Tons of thanks for all your advice!
Qu
--
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
next prev parent reply other threads:[~2015-01-30 2:20 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 2:24 [PATCH RESEND v4 0/8] Fix freeze/sysfs deadlock in better method Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 1/8] Revert "btrfs: add support for processing pending changes" related commits Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 2/8] btrfs: Make btrfs_parse_options() parse mount option in a atomic way Qu Wenruo
2015-01-30 0:31 ` Miao Xie
2015-01-30 1:20 ` Qu Wenruo
2015-01-30 1:29 ` Miao Xie
2015-01-30 1:33 ` Qu Wenruo
2015-01-30 2:06 ` Miao Xie
2015-01-30 2:51 ` Qu Wenruo
2015-01-30 3:21 ` Miao Xie
2015-01-30 3:25 ` Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 3/8] btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 4/8] btrfs: Use btrfs_test_trans_opt() to handle SPACE_CACHE if it's under transaction protect Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 5/8] btrfs: Use btrfs_test_trans_opt() to handle INODE_CACHE " Qu Wenruo
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 1:11 ` Qu Wenruo
2015-01-30 2:09 ` Al Viro
2015-01-30 2:20 ` Qu Wenruo [this message]
2015-01-30 2:20 ` Qu Wenruo
2015-01-30 0:52 ` Miao Xie
2015-01-30 1:44 ` Qu Wenruo
2015-01-30 1:44 ` Qu Wenruo
2015-01-30 2:02 ` Qu Wenruo
2015-01-30 2:02 ` Qu Wenruo
2015-01-30 3:22 ` Miao Xie
2015-01-30 3:22 ` Miao Xie
2015-01-30 3:30 ` Qu Wenruo
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
2015-01-30 5:30 ` Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 7/8] btrfs: Use mnt_want_write() to protect label change Qu Wenruo
2015-01-29 2:24 ` [PATCH RESEND v4 8/8] btrfs: Use mnt_want_write() to protect sysfs feature change Qu Wenruo
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=54CAEA83.3080908@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--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 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.