Re: nfs/cifs mountinfo differences (was: Re: [PATCH] libmount: Skip root comparison for cifs in mnt_table_is_fs_mounted())

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have looked a bit more into it.

Linux provides filesystems a way to show their own thing in the 4th
column (documented as "root of the mount within the filesystem"). The
presence of this mechanism makes me think this info wasn't made only to
be altered by bind-mounts.

The mechanism in question is the superblock operation 'show_path'. If a
filesystem doesn't provide one, linux default is to walk the dentry
connected to the mount points until it reaches the fs root and print
that. This is what happens in (recent) CIFS.

                                  +------------------+
                                  | cifs super_block |
+------------------+              +------------------+
|rootfs super_block|              |      s_root      |
+------------------+              +------------------+
|      s_root      |                       |
+------------------+                       v
         |                           [ dentry "/" ]
         |                                 |
         |                                 v
         v                           [ dentry "sub" ]
    [dentry "/"]                           |
         v                                 v
   [dentry "mnt"] -----magic------>  [ dentry "dir" ]
                                           |
                                          vvv
                               [ content of "/sub/dir/" ]


CIFS doesn't override the default show_path so mountinfo walks from
"dir" to "/" and prints "/sub/dir".

NFS on the other hand overides the show_path operation to:

int nfs_show_path(struct seq_file *m, struct dentry *dentry)
{
	seq_puts(m, "/");
	return 0;
}

ie. *always* prints "/".

Now correct me if I'm wrong (I really am not sure) but I think 'mount
-a' assumes only bind-mounts should print a subdir path instead of "/".

So either

(A) we make that assumption explicit and consider it the Truth:

- we update the kernel documentation of that column in
  Documentation/filesystems/proc.txt to read something like "path
  binded within the filesystem"
- like NFS, we override show_path to always return "/".
- leave mount utility unchanged.

or (B) we consider the current kernel doc as the Truth:

- we make NFS do like CIFS
- leave CIFS unchanged [1]
- figure out what to do with mount utility (back to initial problem I
  guess)

Personal opinion: the way the current doc is written and again, the fact
that linux lets you override the path on a per-filesystem basis makes me
think solution B is the way to go.

Also, I don't understand why

On Wed, 3 Aug 2016 19:23:06 +0200 Stanislav Brabec <sbrabec@xxxxxxx>
wrote:
> > Skipping root comparison in mnt_table_is_fs_mounted() makes things
> > better, however it still does not cover all possible setups.

and

> > diff --git a/libmount/src/tab.c b/libmount/src/tab.c
> > index 155c65e..aa9185a 100644
> > --- a/libmount/src/tab.c
> > +++ b/libmount/src/tab.c
> > @@ -1562,7 +1562,10 @@ int mnt_table_is_fs_mounted(struct
> > libmnt_table *tb, struct libmnt_fs *fstab_fs) #endif
> >  		}
> >
> > -		if (root) {
> > +		/* For cifs, root contains a relative path to the
> > exported volume,
> > +		 * i. e. something we cannot compare.
> > +		 */
> > +		if (root && strcmp(mnt_fs_get_fstype(fs), "cifs"))
> > { const char *r = mnt_fs_get_root(fs);
> >  			if (!r || strcmp(r, root) != 0)
> >  				continue;
> >

We can't we compare in this case? Isn't it just a matter of
concatenating the source with the subdir?

1: I believe we should still override show_path in CIFS
   to take recent flag CIFS_USE_PREFIX_PATH into account because the
   default show_path assumes a different dentry structure

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

Attachment: pgpJILmAxMa2e.pgp
Description: OpenPGP digital signature


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux