linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Duplicate network filesystems
@ 2019-02-11 17:58 Aurélien Aptel
  2019-02-15  3:40 ` NeilBrown
  0 siblings, 1 reply; 3+ messages in thread
From: Aurélien Aptel @ 2019-02-11 17:58 UTC (permalink / raw)
  To: linux-fsdevel

Hi,

In fs/namespace.c do_add_mount() we do this check:

	/* Refuse the same filesystem on the same mount point */
	err = -EBUSY;
	if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb &&
	    path->mnt->mnt_root == path->dentry)
		goto unlock;

So that mount fails with EBUSY. But for networked filesystems (at least
cifs and nfs) you can do this:

mount //foo /mnt -o A
mount //foo /mnt -o B # different options

Since the SB are different it works, fine.

But mounting a 3rd time with options A succeeds, where from a user POV I
would have expected to fail.

So to recap:

mount //foo /mnt -o A
mount //foo /mnt -o A
# EBUSY => expected behaviour

mount //foo /mnt -o A
mount //foo /mnt -o B
# ok => expected behaviour

mount //foo /mnt -o A
mount //foo /mnt -o B
mount //foo /mnt -o A
# ok => what?

Shouldn't we check the stack of filesystems mounted at the path instead of
just the last one?

Cheers,

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

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

* Re: Duplicate network filesystems
  2019-02-11 17:58 Duplicate network filesystems Aurélien Aptel
@ 2019-02-15  3:40 ` NeilBrown
  2019-02-15 10:18   ` Aurélien Aptel
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2019-02-15  3:40 UTC (permalink / raw)
  To: Aurélien Aptel, linux-fsdevel

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

On Mon, Feb 11 2019, Aurélien Aptel wrote:

> Hi,
>
> In fs/namespace.c do_add_mount() we do this check:
>
> 	/* Refuse the same filesystem on the same mount point */
> 	err = -EBUSY;
> 	if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb &&
> 	    path->mnt->mnt_root == path->dentry)
> 		goto unlock;
>
> So that mount fails with EBUSY. But for networked filesystems (at least
> cifs and nfs) you can do this:
>
> mount //foo /mnt -o A
> mount //foo /mnt -o B # different options
>
> Since the SB are different it works, fine.
>
> But mounting a 3rd time with options A succeeds, where from a user POV I
> would have expected to fail.

Why? 
>
> So to recap:
>
> mount //foo /mnt -o A
> mount //foo /mnt -o A
> # EBUSY => expected behaviour
>
> mount //foo /mnt -o A
> mount //foo /mnt -o B
> # ok => expected behaviour
>
> mount //foo /mnt -o A
> mount //foo /mnt -o B
> mount //foo /mnt -o A
> # ok => what?
>
> Shouldn't we check the stack of filesystems mounted at the path instead of
> just the last one?

Why?

I think that the main reason that -EBUSY is important is that people
often run "mount -a" and don't expect filesystems that are already
mounted to be mounted again.  The current behaviour achieves that.

What is your use-case for wanted -EBUSY in some other circumstance?

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: Duplicate network filesystems
  2019-02-15  3:40 ` NeilBrown
@ 2019-02-15 10:18   ` Aurélien Aptel
  0 siblings, 0 replies; 3+ messages in thread
From: Aurélien Aptel @ 2019-02-15 10:18 UTC (permalink / raw)
  To: NeilBrown, linux-fsdevel

NeilBrown <neilb@suse.com> writes:
>> mount //foo /mnt -o A
>> mount //foo /mnt -o B # different options
>>
>> Since the SB are different it works, fine.
>>
>> But mounting a 3rd time with options A succeeds, where from a user POV I
>> would have expected to fail.
>
> Why?

Because it's already mounted.

>> mount //foo /mnt -o A
>> mount //foo /mnt -o B
>> mount //foo /mnt -o A
>> # ok => what?
>>
>> Shouldn't we check the stack of filesystems mounted at the path instead of
>> just the last one?
>
> Why?
>
> I think that the main reason that -EBUSY is important is that people
> often run "mount -a" and don't expect filesystems that are already
> mounted to be mounted again.  The current behaviour achieves that.

A is already mounted and mouting again succeeds. The current behaviour is
different from what you described. This is exactly what I was saying
earlier "from a user POV".

Side-note:
mount from coreutils has some logic to deal with -a and network
filesystems, because there are some issues with the default behaviour. I
can't recall the details about that, would have to look at the code
again.

Cheers,
-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

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

end of thread, other threads:[~2019-02-15 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 17:58 Duplicate network filesystems Aurélien Aptel
2019-02-15  3:40 ` NeilBrown
2019-02-15 10:18   ` Aurélien Aptel

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