Re: [PATCH 3/9] VFS: Introduce a mount context

From: Karel Zak
Date: Wed May 10 2017 - 08:41:41 EST


On Tue, May 09, 2017 at 10:03:43AM +0200, Miklos Szeredi wrote:
> On Tue, May 9, 2017 at 12:57 AM, David Howells <dhowells@xxxxxxxxxx> wrote:
> > Miklos Szeredi <mszeredi@xxxxxxxxxx> wrote:
> >
> >> > + (3) Validate and pre-process the mount context.
> >>
> >> (3.5) Create super block
> >>
> >> I think this need to be triggered by something like a "commit" command
> >> from userspace. Basically this is where the options are atomically
> >> set on the new (create) or existing (reconfigure) superblock.
> >
> > Why do you need to expose this step to userspace? Assuming in the "new" case
> > you do, say:
> >
> > fd = fsopen("nfs");
> > write(fd, "s foo.bar:/bar", ...);
> > write(fd, "o intr", ...);
> > write(fd, "o fsc", ...);
> > ...
> > write(fd, "c", ...); /* commit operation to get a superblock */
> > fsmount(fd, AT_FDCWD, "/mnt"); /* mount the superblock we just got */
> >
> > Then the "commit" op is dissimilar to "mount -o remount" since remount may
> > alter the superblock parameters *and* the mountpoint parameters, but commit
> > can only affect the superblock.
>
> Forget remount, it's a historical remnant. We need fsreconfig(sb) and
> setmntattr(mnt). They are changing properties of different objects.

I agree and I'd like to highlight another issue we have with the
current mount(2). The problem is non-atomic work with more
propagation flags if you want to mount a filesystem. For example:

mount /dev/sda1 /A -o private,unbindable,ro

this is supported by mount(8), but it's implemented by three
independent mount(2) calls

- 1st mounts /dev/sda1 with MS_RDONLY
- 2nd sets MS_PRIVATE flag
- 3rd sets MS_UNBINDABLE flag.

it would be nice set all the VFS flags and then as atomic operation attach
the context to the tree.

Karel

--
Karel Zak <kzak@xxxxxxxxxx>
http://karelzak.blogspot.com