From: Pranay Srivastava <pranjas@gmail.com>
To: "Lukáš Czerner" <lczerner@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
kzak@redhat.com, Dexuan Cui <decui@microsoft.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: Can one file system be R/W mounted multiple times in Linux?
Date: Sat, 10 Jan 2015 01:01:19 +0530 [thread overview]
Message-ID: <CA+aCy1Esm-2NGvJFG4_22rNaXiOqx1f2beCPpSCcovrXFf07+A@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1501091646400.24821@localhost.localdomain>
Hi
On Fri, Jan 9, 2015 at 9:22 PM, Lukáš Czerner <lczerner@redhat.com> wrote:
> On Fri, 9 Jan 2015, Stefan Hajnoczi wrote:
>
>> Date: Fri, 9 Jan 2015 12:01:59 +0000
>> From: Stefan Hajnoczi <stefanha@redhat.com>
>> To: Al Viro <viro@ZenIV.linux.org.uk>
>> Cc: Dexuan Cui <decui@microsoft.com>,
>> "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
>> 'linux-ext4' <linux-ext4@vger.kernel.org>
>> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
>>
>> On Fri, Jan 09, 2015 at 03:51:23AM +0000, Al Viro wrote:
>> > On Fri, Jan 09, 2015 at 03:44:16AM +0000, Dexuan Cui wrote:
>> > > The 'mount' utility allows me to mount 1 file systems multiple times at different
>> > > mount points, like "mount /dev/sdb1 /a; mount /dev/sdb1 /b".
>> > >
>> > > I tried to write from /a and /b at the same time and it seems everything is OK
>> > > and no data corruption happens.
>> > > I tried only ext4 only.
>> > >
>> > > Can somebody please tell me if this usage is safe?
>> >
>> > Yes.
>>
>> Can you explain under what conditions mounting the same file system
>> twice will work?
>>
>> I guess the kernel is looking up the block device and then sharing the
>> superblock if the file system is already mounted on this block device?
>>
>> If I use two loop devices for the same underlying storage it does not
>> work:
>>
>> # mount -o loop /var/tmp/ext4.img /tmp/a
>> # mount -o loop /var/tmp/ext4.img /tmp/b
>
> Because now you have two block devices backed by the same file.
> Which as Christoph pointed out is equivalent of accessing it from
> two different systems.
>
> What you probably want to do is this:
>
> # losetup --show -f /var/tmp/ext4.img
> /dev/loop0
>
> mount /dev/loop0 /tmp/a
> mount /dev/loop0 /tmp/b
>
> Now the question is, whether 'mount' can be a bit smarter than that
> and just mount the already existing block device instead of creating
> new one ? Karel ?
It's not the mount. If you see mount_bdev it checks for this and uses
the existing super block from the first mount
for all subsequent mounts of that block device.
When block devices differ, as in with 2 loop devices they have
different bdev and that's why it doesn't work with 2
loop devices.
>
> -Lukas
>
>
>> # touch /tmp/a/a
>> # ls /tmp/b
>> lost+found
>> # umount /tmp/a
>> # umount /tmp/b
>> # mount -o loop /var/tmp/ext4.img /tmp/a
>> [1078357.297245] EXT4-fs error (device loop0): ext4_lookup:1441: inode #2: comm ls: deleted inode referenced: 12
>>
>> Stefan
>>
> --
> 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
--
---P.K.S
--
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-09 19:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-09 3:44 Can one file system be R/W mounted multiple times in Linux? Dexuan Cui
2015-01-09 3:51 ` Al Viro
2015-01-09 4:58 ` Dexuan Cui
2015-01-09 6:04 ` Eric Sandeen
2015-01-09 6:48 ` Dexuan Cui
2015-01-09 13:25 ` Bob Peterson
2015-01-09 12:01 ` Stefan Hajnoczi
2015-01-09 14:55 ` Christoph Hellwig
2015-01-09 15:52 ` Lukáš Czerner
2015-01-09 19:31 ` Pranay Srivastava [this message]
2015-01-09 20:37 ` Al Viro
2015-01-10 3:52 ` Dexuan Cui
2015-01-12 13:00 ` Karel Zak
2015-01-12 14:20 ` Lukáš Czerner
2015-01-12 16:47 ` Karel Zak
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=CA+aCy1Esm-2NGvJFG4_22rNaXiOqx1f2beCPpSCcovrXFf07+A@mail.gmail.com \
--to=pranjas@gmail.com \
--cc=decui@microsoft.com \
--cc=kzak@redhat.com \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stefanha@redhat.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).