All of lore.kernel.org
 help / color / mirror / Atom feed
* Can one file system be R/W mounted multiple times in Linux?
@ 2015-01-09  3:44 Dexuan Cui
  2015-01-09  3:51 ` Al Viro
  0 siblings, 1 reply; 15+ messages in thread
From: Dexuan Cui @ 2015-01-09  3:44 UTC (permalink / raw)
  To: linux-fsdevel, 'linux-ext4'; +Cc: stefanha

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?

I'm not familiar with the internals of fs.
googling can't find an affirmative answer, I think.

Thanks,
-- Dexuan


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  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 12:01   ` Stefan Hajnoczi
  0 siblings, 2 replies; 15+ messages in thread
From: Al Viro @ 2015-01-09  3:51 UTC (permalink / raw)
  To: Dexuan Cui; +Cc: linux-fsdevel, 'linux-ext4', stefanha

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09  3:51 ` Al Viro
@ 2015-01-09  4:58   ` Dexuan Cui
  2015-01-09  6:04     ` Eric Sandeen
  2015-01-09 12:01   ` Stefan Hajnoczi
  1 sibling, 1 reply; 15+ messages in thread
From: Dexuan Cui @ 2015-01-09  4:58 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, 'linux-ext4', stefanha

> -----Original Message-----
> From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro
> Sent: Friday, January 9, 2015 11:51 AM
> To: Dexuan Cui
> Cc: linux-fsdevel@vger.kernel.org; 'linux-ext4'; stefanha@redhat.com
> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
> 
> 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.

Thanks for the confirmation!

-- Dexuan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09  4:58   ` Dexuan Cui
@ 2015-01-09  6:04     ` Eric Sandeen
  2015-01-09  6:48       ` Dexuan Cui
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Sandeen @ 2015-01-09  6:04 UTC (permalink / raw)
  To: Dexuan Cui; +Cc: Al Viro, linux-fsdevel, linux-ext4, stefanha

On Jan 8, 2015, at 10:59 PM, Dexuan Cui <decui@microsoft.com> wrote:

>> -----Original Message-----
>> From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro
>> Sent: Friday, January 9, 2015 11:51 AM
>> To: Dexuan Cui
>> Cc: linux-fsdevel@vger.kernel.org; 'linux-ext4'; stefanha@redhat.com
>> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
>> 
>>> 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.
> 
> Thanks for the confirmation!
> 
> -- Dexuan

But to be clear, just in case - this is completely different from, say, mounting the same ext4 fs on two different nodes on a SAN, which is quite certainly not safe...

-Eric

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09  6:04     ` Eric Sandeen
@ 2015-01-09  6:48       ` Dexuan Cui
  2015-01-09 13:25         ` Bob Peterson
  0 siblings, 1 reply; 15+ messages in thread
From: Dexuan Cui @ 2015-01-09  6:48 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Al Viro, linux-fsdevel, linux-ext4, stefanha

> -----Original Message-----
> From: Eric Sandeen [mailto:esandeen@redhat.com]
> Sent: Friday, January 9, 2015 14:05 PM
> To: Dexuan Cui
> Cc: Al Viro; linux-fsdevel@vger.kernel.org; linux-ext4; stefanha@redhat.com
> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
> 
> On Jan 8, 2015, at 10:59 PM, Dexuan Cui <decui@microsoft.com> wrote:
> 
> >> -----Original Message-----
> >> From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro
> >> Sent: Friday, January 9, 2015 11:51 AM
> >> To: Dexuan Cui
> >> Cc: linux-fsdevel@vger.kernel.org; 'linux-ext4'; stefanha@redhat.com
> >> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
> >>
> >>> 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.
> >
> > Thanks for the confirmation!
> >
> > -- Dexuan
> 
> But to be clear, just in case - this is completely different from, say, mounting the
> same ext4 fs on two different nodes on a SAN, which is quite certainly not safe...
> 
> -Eric

Thank Eric for pointing this out!
Can you please explain this?  I didn't use SAN... 

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09  3:51 ` Al Viro
  2015-01-09  4:58   ` Dexuan Cui
@ 2015-01-09 12:01   ` Stefan Hajnoczi
  2015-01-09 14:55     ` Christoph Hellwig
  2015-01-09 15:52     ` Lukáš Czerner
  1 sibling, 2 replies; 15+ messages in thread
From: Stefan Hajnoczi @ 2015-01-09 12:01 UTC (permalink / raw)
  To: Al Viro; +Cc: Dexuan Cui, linux-fsdevel, 'linux-ext4'

[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]

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
  # 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

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09  6:48       ` Dexuan Cui
@ 2015-01-09 13:25         ` Bob Peterson
  0 siblings, 0 replies; 15+ messages in thread
From: Bob Peterson @ 2015-01-09 13:25 UTC (permalink / raw)
  To: Dexuan Cui; +Cc: Eric Sandeen, Al Viro, linux-fsdevel, linux-ext4, stefanha

> > >>> Can somebody please tell me if this usage is safe?
> > >>
> > >> Yes.
> > But to be clear, just in case - this is completely different from, say,
> > mounting the
> > same ext4 fs on two different nodes on a SAN, which is quite certainly not
> > safe...
> > 
> > -Eric
> 
> Thank Eric for pointing this out!
> Can you please explain this?  I didn't use SAN...
> 
> Thanks,
> -- Dexuan

Hi Dexuan,

I think Eric means mounting the same physical device from two different
machines (whether they be VMs or nodes in a cluster, etc.) where shared
storage is involved (like SAN or iSCSI). If one system has no knowledge
of what the other is changing, the file system will likely be corrupted.
It sounds like you're probably not doing that.

However, shared file systems like gfs2 and ocfs2 are designed to allow
simultaneous R/W access from multiple nodes, and the file system metadata
is kept in sync and coherent across the cluster.
I don't know if gfs2 allows multiple mounts from the same machine to
different mount points, due to how its inter-node locking and journal
recovery are coordinated. (I haven't tried it in recent years).

Regards,

Bob Peterson
Red Hat File Systems

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09 12:01   ` Stefan Hajnoczi
@ 2015-01-09 14:55     ` Christoph Hellwig
  2015-01-09 15:52     ` Lukáš Czerner
  1 sibling, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2015-01-09 14:55 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Al Viro, Dexuan Cui, linux-fsdevel, 'linux-ext4'

On Fri, Jan 09, 2015 at 12:01:59PM +0000, Stefan Hajnoczi wrote:
> 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?

Exactly.

> 
> If I use two loop devices for the same underlying storage it does not
> work:

Because that's very much the same situation as two different systems
trying to mount it.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  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
  2015-01-12 13:00       ` Karel Zak
  1 sibling, 2 replies; 15+ messages in thread
From: Lukáš Czerner @ 2015-01-09 15:52 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Al Viro, kzak, Dexuan Cui, linux-fsdevel, 'linux-ext4'

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 ?

-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
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09 15:52     ` Lukáš Czerner
@ 2015-01-09 19:31       ` Pranay Srivastava
  2015-01-09 20:37         ` Al Viro
  2015-01-12 13:00       ` Karel Zak
  1 sibling, 1 reply; 15+ messages in thread
From: Pranay Srivastava @ 2015-01-09 19:31 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Stefan Hajnoczi, Al Viro, kzak, Dexuan Cui, linux-fsdevel, linux-ext4

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09 19:31       ` Pranay Srivastava
@ 2015-01-09 20:37         ` Al Viro
  2015-01-10  3:52           ` Dexuan Cui
  0 siblings, 1 reply; 15+ messages in thread
From: Al Viro @ 2015-01-09 20:37 UTC (permalink / raw)
  To: Pranay Srivastava
  Cc: Lukáš Czerner, Stefan Hajnoczi, kzak, Dexuan Cui,
	linux-fsdevel, linux-ext4

On Sat, Jan 10, 2015 at 01:01:19AM +0530, Pranay Srivastava wrote:

> 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.

What Lukas is suggesting is for mount(8) to spot an existing loop device with
the desired backing store and reuse it, rather than try and set the new one
up.  That's where -o loop is handled - it's gone before mount(2) might see
it.  The problem is in races...

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09 20:37         ` Al Viro
@ 2015-01-10  3:52           ` Dexuan Cui
  0 siblings, 0 replies; 15+ messages in thread
From: Dexuan Cui @ 2015-01-10  3:52 UTC (permalink / raw)
  To: Al Viro, Pranay Srivastava
  Cc: Lukáš Czerner, Stefan Hajnoczi, kzak, linux-fsdevel,
	linux-ext4

> -----Original Message-----
> From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro
> Sent: Saturday, January 10, 2015 4:37 AM
> To: Pranay Srivastava
> Cc: Lukáš Czerner; Stefan Hajnoczi; kzak@redhat.com; Dexuan Cui; linux-
> fsdevel@vger.kernel.org; linux-ext4
> Subject: Re: Can one file system be R/W mounted multiple times in Linux?
> 
> On Sat, Jan 10, 2015 at 01:01:19AM +0530, Pranay Srivastava wrote:
> 
> > 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.
> 
> What Lukas is suggesting is for mount(8) to spot an existing loop device with
> the desired backing store and reuse it, rather than try and set the new one
> up.  That's where -o loop is handled - it's gone before mount(2) might see
> it.  The problem is in races...

Thank you all for the pretty informative discussion!

I think now I know when it's safe and when it's unsafe... :-)

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-09 15:52     ` Lukáš Czerner
  2015-01-09 19:31       ` Pranay Srivastava
@ 2015-01-12 13:00       ` Karel Zak
  2015-01-12 14:20         ` Lukáš Czerner
  1 sibling, 1 reply; 15+ messages in thread
From: Karel Zak @ 2015-01-12 13:00 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Stefan Hajnoczi, Al Viro, Dexuan Cui, linux-fsdevel,
	'linux-ext4'

On Fri, Jan 09, 2015 at 04:52:11PM +0100, Lukáš Czerner wrote:
> 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 ?

Well, the question is how smart is too smart :-) And Al is right, problem
is in races.

Anyway, I'd like to avoid complex FS specific code in mount(8). IMHO
it's FS driver responsibility to avoid (or support) FS sharing between
more block devices.

BTW, for ext4 you can enable ETX4_FEATURE_INCOMPAT_MMP to protect
against multi-mount.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com
--
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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-12 13:00       ` Karel Zak
@ 2015-01-12 14:20         ` Lukáš Czerner
  2015-01-12 16:47           ` Karel Zak
  0 siblings, 1 reply; 15+ messages in thread
From: Lukáš Czerner @ 2015-01-12 14:20 UTC (permalink / raw)
  To: Karel Zak
  Cc: Stefan Hajnoczi, Al Viro, Dexuan Cui, linux-fsdevel,
	'linux-ext4'

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1493 bytes --]

On Mon, 12 Jan 2015, Karel Zak wrote:

> Date: Mon, 12 Jan 2015 14:00:58 +0100
> From: Karel Zak <kzak@redhat.com>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>, Al Viro <viro@ZenIV.linux.org.uk>,
>     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 04:52:11PM +0100, Lukáš Czerner wrote:
> > 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 ?
> 
> Well, the question is how smart is too smart :-) And Al is right, problem
> is in races.
> 
> Anyway, I'd like to avoid complex FS specific code in mount(8). IMHO
> it's FS driver responsibility to avoid (or support) FS sharing between
> more block devices.
> 
> BTW, for ext4 you can enable ETX4_FEATURE_INCOMPAT_MMP to protect
> against multi-mount.
> 
>     Karel

Hi Karel,

that's not what I meant at all. Yes, things like MMP should help.
But what I was suggesting was not FS specific.

mount(8) could in case of '-o loop' look whether there is already a
block device associated with the file and if so use it instead of
creating new one.

However this might race with device removal among other things and I
am not sure whether there is any easy solution.

Thanks!
-Lukas

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Can one file system be R/W mounted multiple times in Linux?
  2015-01-12 14:20         ` Lukáš Czerner
@ 2015-01-12 16:47           ` Karel Zak
  0 siblings, 0 replies; 15+ messages in thread
From: Karel Zak @ 2015-01-12 16:47 UTC (permalink / raw)
  To: Lukáš Czerner
  Cc: Stefan Hajnoczi, Al Viro, Dexuan Cui, linux-fsdevel,
	'linux-ext4'

On Mon, Jan 12, 2015 at 03:20:19PM +0100, Lukáš Czerner wrote:
> that's not what I meant at all. Yes, things like MMP should help.
> But what I was suggesting was not FS specific.

And what do you want to do when somebody will implement any
cluster-like or multi-root filesystem where share the same FS image
between two loop devices is expected and supported feature?

I don't think there is any such generic VFS restriction, it's about FS
driver(s).

> mount(8) could in case of '-o loop' look whether there is already a
> block device associated with the file and if so use it instead of
> creating new one.
 
mount(8) already checks if the same backing file is not mounted on the
same mountpoint

 # mount -o loop fs.img /mnt/A
 # mount -o loop fs.img /mnt/A
 mount: fs.img is already mounted

but I don't want to make decision about anything else in userspace.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com
--
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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-01-12 16:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.