linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6 v1 resend] statfs: handle mount propagation
@ 2018-05-25 12:48 Christian Brauner
  2018-05-25 12:48 ` [PATCH 1/6 v1 resend] fs: use << for MS_* flags Christian Brauner
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

From: Christian Brauner <christian.brauner@ubuntu.com>

Hey,

This is v1 of this patchset. All changes from v0 to v1 are non-functional.
Specifically, the commit messages and justification have been extended as
requested by Linus and Al.

This little series does the following:

- unify the definition of constants in statfs.h and fs.h:
  The definitions for MS_* flags are currently a mixture between hex values
  and bit-shifts. All higher values are already initialized with bit-shifts
  for MS_* constants starting with (1<<16). This patch switches the
  definitions for MS_* constants over to uniformly use bit-shifts and
  alignes the definitions of ST_* flags too.
  Initializing them identically let's userspace easily detect when flags
  indicate the same property but use a different value in doing so.

- extend statfs to handle mount propagation:
  For all cases the only way to do this right now is by parsing
  /proc/<pid>/mountinfo. Yes, it is doable but still it is somewhat costly
  and annoying as e.g. those mount propagation fields are optional.
  1. prevent propagation from happening:
     From a userspace perspective we often run into the case where we
     simply want to know whether a given mountpoint is MS_SHARED or is
     MS_SLAVE. If it is we remount it as MS_PRIVATE to prevent any
     propagation from happening. We don't care about the peer
     relationship or how the propagation is exactly setup. We only want
     to prevent any propagation from happening.
     These mountpoints might be known in advance so parsing
     /proc/<pid>/mountinfo should not be needed.
  2. differentiate between MS_SLAVE and MS_SHARED mountpoints:
     Mountpoints that are MS_SLAVE are kept intact and mountpoints that
     are MS_SHARED are made MS_PRIVATE. These mountpoint might be known in
     advance so parsing /proc/<pid>/mountinfo should not be needed.
  3. retrieve propagation properties when procfs is not mounted:
     When the set of interesting mountpoints is known and /proc is not
     mounted calling statfs() is the only good way to reliably determine
     the propagation property of a mountpoint.
  4. inspecting file descriptors to mountpoints for propagation
     properties:
     When file descriptors to mountpoints are passed around between
     processes it is useful to have fstatvfs() handle mount propagation
     properties too.
  To this end the flags:
  - ST_UNBINDABLE
  - ST_SHARED
  - ST_PRIVATE
  - ST_SLAVE
  are added. They have the same value as their MS_* counterparts.

- Testing:
  I verified that now userspace can do e.g.

  int ret;
  char *s = "/some/path";
  struct statvfs sb;

  ret = statvfs(s, &sb);
  if (ret < 0)
          return false;

  if (sb.f_flag & ST_SHARED) {
          ret = mount("", s, NULL, MS_SLAVE | MS_REC, NULL);
          if (ret < 0)
                  return -1;
  }

Thanks!
Christian

Christian Brauner (6):
  fs: use << for MS_* flags
  statfs: use << to align with fs header
  statfs: add ST_UNBINDABLE
  statfs: add ST_SHARED
  statfs: add ST_SLAVE
  statfs: add ST_PRIVATE

 fs/statfs.c             | 16 +++++++++++++++-
 include/linux/statfs.h  | 30 +++++++++++++++++-------------
 include/uapi/linux/fs.h | 33 +++++++++++++++++----------------
 3 files changed, 49 insertions(+), 30 deletions(-)

-- 
2.17.0

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

* [PATCH 1/6 v1 resend] fs: use << for MS_* flags
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-05-25 12:48 ` [PATCH 2/6 v1 resend] statfs: use << to align with fs header Christian Brauner
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

The definitions for MS_* flags are currently a mixture between hex values
and bit-shifts. All higher values are already initialized with bit-shifts
for MS_* constants starting with (1<<16).
This patch switches the definitions for MS_* constants over to uniformly
use bit-shifts.
Note that the BIT() macro cannot be used as it is not exported to uapi
files as was pointed out by gregkh.

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 include/uapi/linux/fs.h | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index d2a8313fabd7..9662790a657c 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -105,22 +105,23 @@ struct inodes_stat_t {
 /*
  * These are the fs-independent mount-flags: up to 32 flags are supported
  */
-#define MS_RDONLY	 1	/* Mount read-only */
-#define MS_NOSUID	 2	/* Ignore suid and sgid bits */
-#define MS_NODEV	 4	/* Disallow access to device special files */
-#define MS_NOEXEC	 8	/* Disallow program execution */
-#define MS_SYNCHRONOUS	16	/* Writes are synced at once */
-#define MS_REMOUNT	32	/* Alter flags of a mounted FS */
-#define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */
-#define MS_DIRSYNC	128	/* Directory modifications are synchronous */
-#define MS_NOATIME	1024	/* Do not update access times. */
-#define MS_NODIRATIME	2048	/* Do not update directory access times */
-#define MS_BIND		4096
-#define MS_MOVE		8192
-#define MS_REC		16384
-#define MS_VERBOSE	32768	/* War is peace. Verbosity is silence.
-				   MS_VERBOSE is deprecated. */
-#define MS_SILENT	32768
+#define MS_RDONLY	(1<<0)	/* Mount read-only */
+#define MS_NOSUID	(1<<1)	/* Ignore suid and sgid bits */
+#define MS_NODEV	(1<<2)	/* Disallow access to device special files */
+#define MS_NOEXEC	(1<<3)	/* Disallow program execution */
+#define MS_SYNCHRONOUS	(1<<4)	/* Writes are synced at once */
+#define MS_REMOUNT	(1<<5)	/* Alter flags of a mounted FS */
+#define MS_MANDLOCK	(1<<6)	/* Allow mandatory locks on an FS */
+#define MS_DIRSYNC	(1<<7)	/* Directory modifications are synchronous */
+#define MS_NOATIME	(1<<10)	/* Do not update access times. */
+#define MS_NODIRATIME	(1<<11)	/* Do not update directory access times */
+#define MS_BIND		(1<<12)
+#define MS_MOVE		(1<<13)
+#define MS_REC		(1<<14)
+#define MS_VERBOSE	(1<<15)	/* War is peace. Verbosity is silence.
+				 * MS_VERBOSE is deprecated.
+				 */
+#define MS_SILENT	(1<<15)
 #define MS_POSIXACL	(1<<16)	/* VFS does not apply the umask */
 #define MS_UNBINDABLE	(1<<17)	/* change to unbindable */
 #define MS_PRIVATE	(1<<18)	/* change to private */
-- 
2.17.0

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

* [PATCH 2/6 v1 resend] statfs: use << to align with fs header
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
  2018-05-25 12:48 ` [PATCH 1/6 v1 resend] fs: use << for MS_* flags Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-05-25 12:48 ` [PATCH 3/6 v1 resend] statfs: add ST_UNBINDABLE Christian Brauner
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

After switching to using bit-shifts to define MS_* flags switch over ST_*
flags too. ST_* and MS_* flags generally have the exact same value.
Initializing them identically let's userspace easily detect when flags
indicate the same property but use a different value in doing so.

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 include/linux/statfs.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index 3142e98546ac..b336c04e793c 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -27,18 +27,18 @@ struct kstatfs {
  * ABI.  The exception is ST_VALID which has the same value as MS_REMOUNT
  * which doesn't make any sense for statfs.
  */
-#define ST_RDONLY	0x0001	/* mount read-only */
-#define ST_NOSUID	0x0002	/* ignore suid and sgid bits */
-#define ST_NODEV	0x0004	/* disallow access to device special files */
-#define ST_NOEXEC	0x0008	/* disallow program execution */
-#define ST_SYNCHRONOUS	0x0010	/* writes are synced at once */
-#define ST_VALID	0x0020	/* f_flags support is implemented */
-#define ST_MANDLOCK	0x0040	/* allow mandatory locks on an FS */
-/* 0x0080 used for ST_WRITE in glibc */
-/* 0x0100 used for ST_APPEND in glibc */
-/* 0x0200 used for ST_IMMUTABLE in glibc */
-#define ST_NOATIME	0x0400	/* do not update access times */
-#define ST_NODIRATIME	0x0800	/* do not update directory access times */
-#define ST_RELATIME	0x1000	/* update atime relative to mtime/ctime */
+#define ST_RDONLY	(1<<0) /* mount read-only */
+#define ST_NOSUID	(1<<1) /* ignore suid and sgid bits */
+#define ST_NODEV	(1<<2) /* disallow access to device special files */
+#define ST_NOEXEC	(1<<3) /* disallow program execution */
+#define ST_SYNCHRONOUS	(1<<4) /* writes are synced at once */
+#define ST_VALID	(1<<5) /* f_flags support is implemented */
+#define ST_MANDLOCK	(1<<6) /* allow mandatory locks on an FS */
+/* (1<<7) used for ST_WRITE in glibc */
+/* (1<<8) used for ST_APPEND in glibc */
+/* (1<<9) used for ST_IMMUTABLE in glibc */
+#define ST_NOATIME	(1<<10) /* do not update access times */
+#define ST_NODIRATIME	(1<<11) /* do not update directory access times */
+#define ST_RELATIME	(1<<12) /* update atime relative to mtime/ctime */
 
 #endif
-- 
2.17.0

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

* [PATCH 3/6 v1 resend] statfs: add ST_UNBINDABLE
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
  2018-05-25 12:48 ` [PATCH 1/6 v1 resend] fs: use << for MS_* flags Christian Brauner
  2018-05-25 12:48 ` [PATCH 2/6 v1 resend] statfs: use << to align with fs header Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-05-25 12:48 ` [PATCH 4/6 v1 resend] statfs: add ST_SHARED Christian Brauner
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

Currently userspace can only determine whether a mountpoint is unbindable
by parsing /proc/<pid>/mountinfo. It would be convenient to simply retrieve
this property with a statvfs() call.
This let's userspace avoid costly parsing, supports cases where /proc is
not mounted, and supports usecases where file descriptors to mountpoints
are passed between processes that are inspected via fstatvfs().

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 fs/statfs.c            | 2 ++
 include/linux/statfs.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/statfs.c b/fs/statfs.c
index 5b2a24f0f263..61b3063d3921 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -29,6 +29,8 @@ static int flags_by_mnt(int mnt_flags)
 		flags |= ST_NODIRATIME;
 	if (mnt_flags & MNT_RELATIME)
 		flags |= ST_RELATIME;
+	if (mnt_flags & MNT_UNBINDABLE)
+		flags |= ST_UNBINDABLE;
 	return flags;
 }
 
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index b336c04e793c..e1b84d0388c1 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -40,5 +40,6 @@ struct kstatfs {
 #define ST_NOATIME	(1<<10) /* do not update access times */
 #define ST_NODIRATIME	(1<<11) /* do not update directory access times */
 #define ST_RELATIME	(1<<12) /* update atime relative to mtime/ctime */
+#define ST_UNBINDABLE	(1<<17)	/* change to unbindable */
 
 #endif
-- 
2.17.0

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

* [PATCH 4/6 v1 resend] statfs: add ST_SHARED
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
                   ` (2 preceding siblings ...)
  2018-05-25 12:48 ` [PATCH 3/6 v1 resend] statfs: add ST_UNBINDABLE Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-05-25 12:48 ` [PATCH 5/6 v1 resend] statfs: add ST_SLAVE Christian Brauner
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

Currently userspace can only determine whether a mountpoint is shared
by parsing /proc/<pid>/mountinfo. It would be convenient to simply retrieve
this property with a statvfs() call.
This let's userspace avoid costly parsing, supports cases where /proc is
not mounted, and supports usecases where file descriptors to mountpoints
are passed between processes that are inspected via fstatvfs().
This is especially helpful in all cases where userspace is not interested
in specific propagation properties but rather just wants to either turn on
or turn off propagation for specific mountpoints.

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 fs/statfs.c            | 2 ++
 include/linux/statfs.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/statfs.c b/fs/statfs.c
index 61b3063d3921..2fc6f9c3793c 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -31,6 +31,8 @@ static int flags_by_mnt(int mnt_flags)
 		flags |= ST_RELATIME;
 	if (mnt_flags & MNT_UNBINDABLE)
 		flags |= ST_UNBINDABLE;
+	if (mnt_flags & MNT_SHARED)
+		flags |= ST_SHARED;
 	return flags;
 }
 
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index e1b84d0388c1..5416b2936dd9 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -41,5 +41,6 @@ struct kstatfs {
 #define ST_NODIRATIME	(1<<11) /* do not update directory access times */
 #define ST_RELATIME	(1<<12) /* update atime relative to mtime/ctime */
 #define ST_UNBINDABLE	(1<<17)	/* change to unbindable */
+#define ST_SHARED	(1<<20)	/* change to shared */
 
 #endif
-- 
2.17.0

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

* [PATCH 5/6 v1 resend] statfs: add ST_SLAVE
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
                   ` (3 preceding siblings ...)
  2018-05-25 12:48 ` [PATCH 4/6 v1 resend] statfs: add ST_SHARED Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-05-25 12:48 ` [PATCH 6/6 v1 resend] statfs: add ST_PRIVATE Christian Brauner
  2018-06-13 14:06 ` [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

Currently userspace can only determine whether a mountpoint is slave
by parsing /proc/<pid>/mountinfo. It would be convenient to simply retrieve
this property with a statvfs() call.
This let's userspace avoid costly parsing, supports cases where /proc is
not mounted, and supports usecases where file descriptors to mountpoints
are passed between processes that are inspected via fstatvfs().
This is especially helpful in all cases where userspace is not interested
in specific propagation properties our peer group layouts but rather just
wants to either turn on or turn off propagation for specific mountpoints.

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 fs/statfs.c            | 10 +++++++++-
 include/linux/statfs.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/statfs.c b/fs/statfs.c
index 2fc6f9c3793c..35ad0402c9a3 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -10,6 +10,7 @@
 #include <linux/uaccess.h>
 #include <linux/compat.h>
 #include "internal.h"
+#include "pnode.h"
 
 static int flags_by_mnt(int mnt_flags)
 {
@@ -50,8 +51,15 @@ static int flags_by_sb(int s_flags)
 
 static int calculate_f_flags(struct vfsmount *mnt)
 {
-	return ST_VALID | flags_by_mnt(mnt->mnt_flags) |
+	int flags = 0;
+
+	flags = ST_VALID | flags_by_mnt(mnt->mnt_flags) |
 		flags_by_sb(mnt->mnt_sb->s_flags);
+
+	if (IS_MNT_SLAVE(real_mount(mnt)))
+		flags |= ST_SLAVE;
+
+	return flags;
 }
 
 static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index 5416b2936dd9..048127effaad 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -41,6 +41,7 @@ struct kstatfs {
 #define ST_NODIRATIME	(1<<11) /* do not update directory access times */
 #define ST_RELATIME	(1<<12) /* update atime relative to mtime/ctime */
 #define ST_UNBINDABLE	(1<<17)	/* change to unbindable */
+#define ST_SLAVE	(1<<19)	/* change to slave */
 #define ST_SHARED	(1<<20)	/* change to shared */
 
 #endif
-- 
2.17.0

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

* [PATCH 6/6 v1 resend] statfs: add ST_PRIVATE
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
                   ` (4 preceding siblings ...)
  2018-05-25 12:48 ` [PATCH 5/6 v1 resend] statfs: add ST_SLAVE Christian Brauner
@ 2018-05-25 12:48 ` Christian Brauner
  2018-06-13 14:06 ` [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
  6 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-05-25 12:48 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro, Christian Brauner

Currently userspace can only determine whether a mountpoint is private
by parsing /proc/<pid>/mountinfo. It would be convenient to simply retrieve
this property with a statvfs() call.
This let's userspace avoid costly parsing, supports cases where /proc is
not mounted, and supports usecases where file descriptors to mountpoints are
passed between processes that are inspected via fstatvfs().
A mountpoint is considered ST_PRIVATE iff and it is neither ST_SLAVE nor
ST_SHARED.

Signed-off-by: Christian Brauner <christian@brauner.io>
---
v0->v1:
* non-functional changes: extend commit message
---
 fs/statfs.c            | 2 ++
 include/linux/statfs.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/statfs.c b/fs/statfs.c
index 35ad0402c9a3..899e899ee84c 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -58,6 +58,8 @@ static int calculate_f_flags(struct vfsmount *mnt)
 
 	if (IS_MNT_SLAVE(real_mount(mnt)))
 		flags |= ST_SLAVE;
+	else if (!(flags & ST_SHARED))
+		flags |= ST_PRIVATE;
 
 	return flags;
 }
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index 048127effaad..663fa5498a7d 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -41,6 +41,7 @@ struct kstatfs {
 #define ST_NODIRATIME	(1<<11) /* do not update directory access times */
 #define ST_RELATIME	(1<<12) /* update atime relative to mtime/ctime */
 #define ST_UNBINDABLE	(1<<17)	/* change to unbindable */
+#define ST_PRIVATE	(1<<18)	/* change to private */
 #define ST_SLAVE	(1<<19)	/* change to slave */
 #define ST_SHARED	(1<<20)	/* change to shared */
 
-- 
2.17.0

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

* Re: [PATCH 0/6 v1 resend] statfs: handle mount propagation
  2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
                   ` (5 preceding siblings ...)
  2018-05-25 12:48 ` [PATCH 6/6 v1 resend] statfs: add ST_PRIVATE Christian Brauner
@ 2018-06-13 14:06 ` Christian Brauner
  2018-06-13 14:24   ` Greg KH
  6 siblings, 1 reply; 11+ messages in thread
From: Christian Brauner @ 2018-06-13 14:06 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel
  Cc: torvalds, tglx, kstewart, gregkh, pombredanne, linux-api,
	ebiederm, seth.forshee, viro

On Fri, May 25, 2018 at 02:48:19PM +0200, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@ubuntu.com>
> 
> Hey,
> 
> This is v1 of this patchset. All changes from v0 to v1 are non-functional.
> Specifically, the commit messages and justification have been extended as
> requested by Linus and Al.

Hey everyone,

Just a ping whether the requested changes have made this series suitable
for inclusion. Would be excellent if someone could do another review. :)

Thanks!
Christian


> 
> This little series does the following:
> 
> - unify the definition of constants in statfs.h and fs.h:
>   The definitions for MS_* flags are currently a mixture between hex values
>   and bit-shifts. All higher values are already initialized with bit-shifts
>   for MS_* constants starting with (1<<16). This patch switches the
>   definitions for MS_* constants over to uniformly use bit-shifts and
>   alignes the definitions of ST_* flags too.
>   Initializing them identically let's userspace easily detect when flags
>   indicate the same property but use a different value in doing so.
> 
> - extend statfs to handle mount propagation:
>   For all cases the only way to do this right now is by parsing
>   /proc/<pid>/mountinfo. Yes, it is doable but still it is somewhat costly
>   and annoying as e.g. those mount propagation fields are optional.
>   1. prevent propagation from happening:
>      From a userspace perspective we often run into the case where we
>      simply want to know whether a given mountpoint is MS_SHARED or is
>      MS_SLAVE. If it is we remount it as MS_PRIVATE to prevent any
>      propagation from happening. We don't care about the peer
>      relationship or how the propagation is exactly setup. We only want
>      to prevent any propagation from happening.
>      These mountpoints might be known in advance so parsing
>      /proc/<pid>/mountinfo should not be needed.
>   2. differentiate between MS_SLAVE and MS_SHARED mountpoints:
>      Mountpoints that are MS_SLAVE are kept intact and mountpoints that
>      are MS_SHARED are made MS_PRIVATE. These mountpoint might be known in
>      advance so parsing /proc/<pid>/mountinfo should not be needed.
>   3. retrieve propagation properties when procfs is not mounted:
>      When the set of interesting mountpoints is known and /proc is not
>      mounted calling statfs() is the only good way to reliably determine
>      the propagation property of a mountpoint.
>   4. inspecting file descriptors to mountpoints for propagation
>      properties:
>      When file descriptors to mountpoints are passed around between
>      processes it is useful to have fstatvfs() handle mount propagation
>      properties too.
>   To this end the flags:
>   - ST_UNBINDABLE
>   - ST_SHARED
>   - ST_PRIVATE
>   - ST_SLAVE
>   are added. They have the same value as their MS_* counterparts.
> 
> - Testing:
>   I verified that now userspace can do e.g.
> 
>   int ret;
>   char *s = "/some/path";
>   struct statvfs sb;
> 
>   ret = statvfs(s, &sb);
>   if (ret < 0)
>           return false;
> 
>   if (sb.f_flag & ST_SHARED) {
>           ret = mount("", s, NULL, MS_SLAVE | MS_REC, NULL);
>           if (ret < 0)
>                   return -1;
>   }
> 
> Thanks!
> Christian
> 
> Christian Brauner (6):
>   fs: use << for MS_* flags
>   statfs: use << to align with fs header
>   statfs: add ST_UNBINDABLE
>   statfs: add ST_SHARED
>   statfs: add ST_SLAVE
>   statfs: add ST_PRIVATE
> 
>  fs/statfs.c             | 16 +++++++++++++++-
>  include/linux/statfs.h  | 30 +++++++++++++++++-------------
>  include/uapi/linux/fs.h | 33 +++++++++++++++++----------------
>  3 files changed, 49 insertions(+), 30 deletions(-)
> 
> -- 
> 2.17.0
> 

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

* Re: [PATCH 0/6 v1 resend] statfs: handle mount propagation
  2018-06-13 14:06 ` [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
@ 2018-06-13 14:24   ` Greg KH
  2018-06-13 15:07     ` Christian Brauner
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2018-06-13 14:24 UTC (permalink / raw)
  To: Christian Brauner
  Cc: linux-kernel, linux-fsdevel, torvalds, tglx, kstewart,
	pombredanne, linux-api, ebiederm, seth.forshee, viro

On Wed, Jun 13, 2018 at 04:06:25PM +0200, Christian Brauner wrote:
> On Fri, May 25, 2018 at 02:48:19PM +0200, Christian Brauner wrote:
> > From: Christian Brauner <christian.brauner@ubuntu.com>
> > 
> > Hey,
> > 
> > This is v1 of this patchset. All changes from v0 to v1 are non-functional.
> > Specifically, the commit messages and justification have been extended as
> > requested by Linus and Al.
> 
> Hey everyone,
> 
> Just a ping whether the requested changes have made this series suitable
> for inclusion. Would be excellent if someone could do another review. :)

It's the middle of the merge window, no new code gets accepted right
now, so just wait until next week at the _earliest_ before worrying
about someone reviewing this.

thanks,

greg k-h

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

* Re: [PATCH 0/6 v1 resend] statfs: handle mount propagation
  2018-06-13 14:24   ` Greg KH
@ 2018-06-13 15:07     ` Christian Brauner
  2018-07-19 15:30       ` Christian Brauner
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Brauner @ 2018-06-13 15:07 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-fsdevel, torvalds, tglx, kstewart,
	pombredanne, linux-api, ebiederm, seth.forshee, viro

On Wed, Jun 13, 2018 at 04:24:54PM +0200, Greg KH wrote:
> On Wed, Jun 13, 2018 at 04:06:25PM +0200, Christian Brauner wrote:
> > On Fri, May 25, 2018 at 02:48:19PM +0200, Christian Brauner wrote:
> > > From: Christian Brauner <christian.brauner@ubuntu.com>
> > > 
> > > Hey,
> > > 
> > > This is v1 of this patchset. All changes from v0 to v1 are non-functional.
> > > Specifically, the commit messages and justification have been extended as
> > > requested by Linus and Al.
> > 
> > Hey everyone,
> > 
> > Just a ping whether the requested changes have made this series suitable
> > for inclusion. Would be excellent if someone could do another review. :)
> 
> It's the middle of the merge window, no new code gets accepted right
> now, so just wait until next week at the _earliest_ before worrying

Ok, sorry. It was just that this was sent out before well over a month
ago and I was just worried that it had been overlooked.

Thanks!
Christian

> about someone reviewing this.
> 
> thanks,
> 
> greg k-h

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

* Re: [PATCH 0/6 v1 resend] statfs: handle mount propagation
  2018-06-13 15:07     ` Christian Brauner
@ 2018-07-19 15:30       ` Christian Brauner
  0 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2018-07-19 15:30 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-fsdevel, torvalds, tglx, kstewart,
	pombredanne, linux-api, ebiederm, seth.forshee, viro

On Wed, Jun 13, 2018 at 05:07:02PM +0200, Christian Brauner wrote:
> On Wed, Jun 13, 2018 at 04:24:54PM +0200, Greg KH wrote:
> > On Wed, Jun 13, 2018 at 04:06:25PM +0200, Christian Brauner wrote:
> > > On Fri, May 25, 2018 at 02:48:19PM +0200, Christian Brauner wrote:
> > > > From: Christian Brauner <christian.brauner@ubuntu.com>
> > > > 
> > > > Hey,
> > > > 
> > > > This is v1 of this patchset. All changes from v0 to v1 are non-functional.
> > > > Specifically, the commit messages and justification have been extended as
> > > > requested by Linus and Al.
> > > 
> > > Hey everyone,
> > > 
> > > Just a ping whether the requested changes have made this series suitable
> > > for inclusion. Would be excellent if someone could do another review. :)
> > 
> > It's the middle of the merge window, no new code gets accepted right
> > now, so just wait until next week at the _earliest_ before worrying
> 
> Ok, sorry. It was just that this was sent out before well over a month
> ago and I was just worried that it had been overlooked.

Hey everyone,

It's been a few weeks. I just wanted to check whether the changes made
to the series would make it suitable for inclusion. I checked against
current master and it should still apply cleanly.

Thanks!
Christian

> 
> Thanks!
> Christian
> 
> > about someone reviewing this.
> > 
> > thanks,
> > 
> > greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" 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] 11+ messages in thread

end of thread, other threads:[~2018-07-19 16:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-25 12:48 [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
2018-05-25 12:48 ` [PATCH 1/6 v1 resend] fs: use << for MS_* flags Christian Brauner
2018-05-25 12:48 ` [PATCH 2/6 v1 resend] statfs: use << to align with fs header Christian Brauner
2018-05-25 12:48 ` [PATCH 3/6 v1 resend] statfs: add ST_UNBINDABLE Christian Brauner
2018-05-25 12:48 ` [PATCH 4/6 v1 resend] statfs: add ST_SHARED Christian Brauner
2018-05-25 12:48 ` [PATCH 5/6 v1 resend] statfs: add ST_SLAVE Christian Brauner
2018-05-25 12:48 ` [PATCH 6/6 v1 resend] statfs: add ST_PRIVATE Christian Brauner
2018-06-13 14:06 ` [PATCH 0/6 v1 resend] statfs: handle mount propagation Christian Brauner
2018-06-13 14:24   ` Greg KH
2018-06-13 15:07     ` Christian Brauner
2018-07-19 15:30       ` Christian Brauner

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