Skip to contentSkip to conversation

POSIX ACL config and mount option changes

PATCH New Jan Kara 3 participants 10 messages Oct 15, 2009 – Oct 29, 2009 OCFS2

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

cover POSIX ACL config and mount option changes

Hi,

we've discussed with Joel and Mark how to improve user experience
with ACL mount options. In the end we'va agreed on the following:

1) Rip out CONFIG_OCFS2_POSIX_ACL. The code is always built in.
2) Always enable acls if a filesystem has xattrs. This is a noop if no one ever calls setacl.
3) If a user explicitly puts -oacl on the mount command line, but the filesystem doesn't have xattrs, fail the mount. This is a safe place to catch people changing kernels, as a too-old kernel driver likely doesn't have xattrs anyway.
4) If a user explicitly puts -onoacl on the mount command line, they get

This patch series implements the changes. The last patch also fixes
a bug when acls are enabled only on remount.

Honza

author
#1 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

To become consistent with filesystems such as XFS or BTRFS, make posix ACLs always compiled into the kernel. This also reduces possibility of misconfiguration on admin's side.

---
 fs/ocfs2/Kconfig  |   10 +---------
 fs/ocfs2/Makefile |    7 ++-----
 fs/ocfs2/acl.h    |   22 ----------------------
 fs/ocfs2/super.c  |    9 ---------
 fs/ocfs2/xattr.c  |    4 ----
 fs/ocfs2/xattr.h  |    2 --
 6 files changed, 3 insertions(+), 51 deletions(-)
fs/ocfs2/Kconfig +1 -9
index 701b7a3..0d84066 100644
@@ -6,6 +6,7 @@ config OCFS2_FS
 	select CRC32
 	select QUOTA
 	select QUOTA_TREE
+	select FS_POSIX_ACL
 	help
 	  OCFS2 is a general purpose extent based shared disk cluster file
 	  system with many similarities to ext3. It supports 64 bit inode
@@ -74,12 +75,3 @@ config OCFS2_DEBUG_FS
 	  This option will enable expensive consistency checks. Enable
 	  this option for debugging only as it is likely to decrease
 	  performance of the filesystem.
-
-config OCFS2_FS_POSIX_ACL
-	bool "OCFS2 POSIX Access Control Lists"
-	depends on OCFS2_FS
-	select FS_POSIX_ACL
-	default n
-	help
-	  Posix Access Control Lists (ACLs) support permissions for users and
-	  groups beyond the owner/group/world scheme.
fs/ocfs2/Makefile +2 -5
index 31f25ce..600d2d2 100644
@@ -39,11 +39,8 @@ ocfs2-objs := \
 	ver.o			\
 	quota_local.o		\
 	quota_global.o		\
-	xattr.o
-
-ifeq ($(CONFIG_OCFS2_FS_POSIX_ACL),y)
-ocfs2-objs += acl.o
-endif
+	xattr.o			\
+	acl.o
 
 ocfs2_stackglue-objs := stackglue.o
 ocfs2_stack_o2cb-objs := stack_o2cb.o
fs/ocfs2/acl.h +0 -22
index 8f6389e..5c5d31f 100644
@@ -26,8 +26,6 @@ struct ocfs2_acl_entry {
 	__le32 e_id;
 };
 
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
-
 extern int ocfs2_check_acl(struct inode *, int);
 extern int ocfs2_acl_chmod(struct inode *);
 extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
@@ -35,24 +33,4 @@ extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
 			  struct ocfs2_alloc_context *,
 			  struct ocfs2_alloc_context *);
 
-#else /* CONFIG_OCFS2_FS_POSIX_ACL*/
-
-#define ocfs2_check_acl NULL
-static inline int ocfs2_acl_chmod(struct inode *inode)
-{
-	return 0;
-}
-static inline int ocfs2_init_acl(handle_t *handle,
-				 struct inode *inode,
-				 struct inode *dir,
-				 struct buffer_head *di_bh,
-				 struct buffer_head *dir_bh,
-				 struct ocfs2_alloc_context *meta_ac,
-				 struct ocfs2_alloc_context *data_ac)
-{
-	return 0;
-}
-
-#endif /* CONFIG_OCFS2_FS_POSIX_ACL*/
-
 #endif /* OCFS2_ACL_H */
fs/ocfs2/super.c +0 -9
index 154e625..f2413f8 100644
@@ -1412,19 +1412,12 @@ static int ocfs2_parse_options(struct super_block *sb,
 			}
 			mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA;
 			break;
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 		case Opt_acl:
 			mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL;
 			break;
 		case Opt_noacl:
 			mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
 			break;
-#else
-		case Opt_acl:
-		case Opt_noacl:
-			printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
-			break;
-#endif
 		default:
 			mlog(ML_ERROR,
 			     "Unrecognized mount option \"%s\" "
@@ -1501,12 +1494,10 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
 	if (opts & OCFS2_MOUNT_INODE64)
 		seq_printf(s, ",inode64");
 
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif
 
 	return 0;
 }
fs/ocfs2/xattr.c +0 -4
index fe34190..923e950 100644
@@ -98,10 +98,8 @@ static struct ocfs2_xattr_def_value_root def_xv = {
 
 struct xattr_handler *ocfs2_xattr_handlers[] = {
 	&ocfs2_xattr_user_handler,
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	&ocfs2_xattr_acl_access_handler,
 	&ocfs2_xattr_acl_default_handler,
-#endif
 	&ocfs2_xattr_trusted_handler,
 	&ocfs2_xattr_security_handler,
 	NULL
@@ -109,12 +107,10 @@ struct xattr_handler *ocfs2_xattr_handlers[] = {
 
 static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
 	[OCFS2_XATTR_INDEX_USER]	= &ocfs2_xattr_user_handler,
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	[OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS]
 					= &ocfs2_xattr_acl_access_handler,
 	[OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT]
 					= &ocfs2_xattr_acl_default_handler,
-#endif
 	[OCFS2_XATTR_INDEX_TRUSTED]	= &ocfs2_xattr_trusted_handler,
 	[OCFS2_XATTR_INDEX_SECURITY]	= &ocfs2_xattr_security_handler,
 };
fs/ocfs2/xattr.h +0 -2
index 08e3638..abd72a4 100644
@@ -40,10 +40,8 @@ struct ocfs2_security_xattr_info {
 extern struct xattr_handler ocfs2_xattr_user_handler;
 extern struct xattr_handler ocfs2_xattr_trusted_handler;
 extern struct xattr_handler ocfs2_xattr_security_handler;
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 extern struct xattr_handler ocfs2_xattr_acl_access_handler;
 extern struct xattr_handler ocfs2_xattr_acl_default_handler;
-#endif
 extern struct xattr_handler *ocfs2_xattr_handlers[];
 
 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

Quoted 3 lines · Jan Kara

To become consistent with filesystems such as XFS or BTRFS, make posix ACLs always compiled into the kernel. This also reduces possibility of misconfiguration on admin's side.

Actually both XFS and btrfs have options for the acl code. We don't have options for xattrs.

These days I probably wouldn't make acls optional anymore, though - there's very little code in the fs needed only for ACLs.

fs/ocfs2/super.c static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) · line 1509

Quoted 6 lines
fs/ocfs2/super.c +0 -2
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif

It might be a good idea to always print acl here for backwards compatiblity.

author
#3 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Jan Kara

To become consistent with filesystems such as XFS or BTRFS, make posix ACLs always compiled into the kernel. This also reduces possibility of misconfiguration on admin's side.

Actually both XFS and btrfs have options for the acl code. We don't have options for xattrs.

These days I probably wouldn't make acls optional anymore, though - there's very little code in the fs needed only for ACLs.

Exactly, that's what we thought as well.

Quoted 9 lines

fs/ocfs2/super.c static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) · line 1509

Quoted 6 lines
fs/ocfs2/super.c +0 -2
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif

It might be a good idea to always print acl here for backwards compatiblity.

I don't understand here - why would printing 'acl' even if acls are
disabled be more backward compatible?
Thanks for your comments.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

Quoted 11 lines · Jan Kara
Quoted 10 lines · Christoph Hellwig

fs/ocfs2/super.c static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) · line 1509

Quoted 6 lines · Jan Kara
fs/ocfs2/super.c +0 -2
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif

It might be a good idea to always print acl here for backwards compatiblity.

Quoted 2 lines

I don't understand here - why would printing 'acl' even if acls are
disabled be more backward compatible?

I think he's saying "if you don't provide any acl option at all,
they will default to enabled but you will not print 'acl'.
I think the correct solution is to start mount_op with
OCFS2_MOUNT_POSIX_ACL set. This correctly describes the behavior. Then 'case Opt_acl' only does the check for xattrs and 'case Opt_noacl' does the clearing of the option.

Joel

Signature · 7 lines
"People with narrow minds usually have broad tongues."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#5 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

Quoted 12 lines · Joel Becker
Quoted 11 lines · Jan Kara
Quoted 10 lines · Christoph Hellwig

fs/ocfs2/super.c static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) · line 1509

Quoted 6 lines · Jan Kara
fs/ocfs2/super.c +0 -2
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif

It might be a good idea to always print acl here for backwards compatiblity.

Quoted 5 lines
Quoted 2 lines

I don't understand here - why would printing 'acl' even if acls are
disabled be more backward compatible?

I think he's saying "if you don't provide any acl option at all,
they will default to enabled but you will not print 'acl'.

We will print 'acl' - what the code does is that
ocfs2_check_set_options() sets OCFS2_MOUNT_POSIX_ACL in case 'noacl' hasn't been specified.

Quoted 4 lines

I think the correct solution is to start mount_op with
OCFS2_MOUNT_POSIX_ACL set. This correctly describes the behavior. Then 'case Opt_acl' only does the check for xattrs and 'case Opt_noacl' does the clearing of the option.

This won't quite work because at the time parse_options is called during
mount, we don't have filesystem features available yet. That's why I go through the hoops described above.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#6 lore raw

PATCH 1/3 ocfs2: Make ACLs always compiled into the kernel

In reply to Jan Kara
Quoted 11 lines · Jan Kara
Quoted 9 lines

fs/ocfs2/super.c static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) · line 1509

Quoted 6 lines
fs/ocfs2/super.c +0 -2
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 	if (opts & OCFS2_MOUNT_POSIX_ACL)
 		seq_printf(s, ",acl");
 	else
 		seq_printf(s, ",noacl");
-#endif

It might be a good idea to always print acl here for backwards compatiblity.

I don't understand here - why would printing 'acl' even if acls are
disabled be more backward compatible?

Sorry. misparsed the patch - ignore this comment.

author
#7 lore raw

PATCH 2/3 ocfs2: Change acl mount option handling

In reply to Jan Kara

Change acl mount options handling to match the one of XFS and BTRFS and hopefully it is also easier to use now. When admin does not specify any acl mount option, acls are enabled if and only if the filesystem has xattr feature enabled. If admin specifies 'acl' mount option, we fail the mount if the filesystem does not have xattr feature and thus acls cannot be enabled.

---
 fs/ocfs2/ocfs2.h |    8 +++--
 fs/ocfs2/super.c |   82 +++++++++++++++++++++++++++++-------------------------
 2 files changed, 49 insertions(+), 41 deletions(-)
fs/ocfs2/ocfs2.h +5 -3
index eae4046..35ad46c 100644
@@ -250,9 +250,11 @@ enum ocfs2_mount_options
 	OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
 	OCFS2_MOUNT_NOUSERXATTR = 1 << 6, /* No user xattr */
 	OCFS2_MOUNT_INODE64 = 1 << 7,	/* Allow inode numbers > 2^32 */
-	OCFS2_MOUNT_POSIX_ACL = 1 << 8,	/* POSIX access control lists */
-	OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
-	OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
+	OCFS2_MOUNT_POSIX_ACL = 1 << 8,	/* Force POSIX access control lists */
+	OCFS2_MOUNT_NO_POSIX_ACL = 1 << 9,	/* Disable POSIX access
+						   control lists */
+	OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
+	OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
 };
 
 #define OCFS2_OSB_SOFT_RO			0x0001
fs/ocfs2/super.c +44 -38

133 lines not on this page · raw message

Signature · 1 line
1.6.0.2
author
#8 lore raw

PATCH 3/3 ocfs2: Set MS_POSIXACL on remount

In reply to Jan Kara

We have to set MS_POSIXACL on remount as well. Otherwise VFS would not know we started supporting ACLs after remount and thus ACLs would not work.

---
 fs/ocfs2/super.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/super.c +4 -0
index d6a0d6a..8118043 100644
@@ -703,6 +703,10 @@ unlock_osb:
 
 		if (!ocfs2_is_hard_readonly(osb))
 			ocfs2_set_journal_params(osb);
+
+		sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
+			((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ?
+							MS_POSIXACL : 0);
 	}
 out:
 	unlock_kernel();
Signature · 1 line
1.6.0.2
#9 lore raw

cover POSIX ACL config and mount option changes

In reply to Jan Kara
Quoted 2 lines · Jan Kara

we've discussed with Joel and Mark how to improve user experience
with ACL mount options. In the end we'va agreed on the following:

These patches are now part of the merge-window branch of
ocfs2.git.

Joel

Signature · 9 lines
"If the human brain were so simple we could understand it, we would
 be so simple that we could not."
	- W. A. Clouston

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127