Skip to contentSkip to conversation

fs/ntfs3: Use new mount api and change some opts

PATCH Superseded Kari Argillander 4 participants 18 messages Aug 29, 2021 – Sep 8, 2021 1 message not in the archive

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover fs/ntfs3: Use new mount api and change some opts

See V2 if you want:
lore.kernel.org/ntfs3/[email protected]

NLS change is now blocked when remounting. Christoph also suggest that we block all other mount options, but I have tested a couple and they seem to work. I wish that we do not block any other than NLS because in theory they should work. Also Konstantin can comment about this.

I have not include reviewed/acked to patch "Use new api for mounting" because it change so much. I have also included three new patch to this series:
- Convert mount options to pointer in sbi
So that we do not need to initiliaze whole spi in remount.
- Init spi more in init_fs_context than fill_super This is just refactoring. (Series does not depend on this)
- Show uid/gid always in show_options()
Christian Brauner kinda ask this. (Series does not depend on this)

Series is ones again tested with kvm-xfstests. Every commit is build tested.

v3:
- Add patch "Convert mount options to pointer in sbi"
- Add patch "Init spi more in init_fs_context than fill_super"
- Add patch "Show uid/gid always in show_options"
- Patch "Use new api for mounting" has make over
- NLS loading is not anymore possible when remounting
- show_options() iocharset printing is fixed
- Delete comment that testing should be done with other mount options.
- Add reviewed/acked-tags to 1,2,6,8
- Rewrite this cover
v2:
- Rewrite this cover leter
- Reorder noatime to first patch
- NLS loading with string
- Delete default_options function
- Remove remount flags
- Rename no_acl_rules mount option
- Making code cleaner
- Add comment that mount options should be tested

Kari Argillander (9):
fs/ntfs3: Remove unnecesarry mount option noatime fs/ntfs3: Remove unnecesarry remount flag handling fs/ntfs3: Convert mount options to pointer in sbi fs/ntfs3: Use new api for mounting
fs/ntfs3: Init spi more in init_fs_context than fill_super fs/ntfs3: Make mount option nohidden more universal fs/ntfs3: Add iocharset= mount option as alias for nls= fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules fs/ntfs3: Show uid/gid always in show_options()

 Documentation/filesystems/ntfs3.rst |  10 +-
 fs/ntfs3/attrib.c                   |   2 +-
 fs/ntfs3/dir.c                      |   8 +-
 fs/ntfs3/file.c                     |   4 +-
 fs/ntfs3/inode.c                    |  12 +-
 fs/ntfs3/ntfs_fs.h                  |  26 +-
 fs/ntfs3/super.c                    | 486 +++++++++++++++-------------
 fs/ntfs3/xattr.c                    |   2 +-
 8 files changed, 284 insertions(+), 266 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/9 fs/ntfs3: Remove unnecesarry mount option noatime

Remove unnecesarry mount option noatime because this will be handled by VFS. Our option parser will never get opt like this.

---
 Documentation/filesystems/ntfs3.rst | 4 ----
 fs/ntfs3/super.c                    | 7 -------
 2 files changed, 11 deletions(-)
Documentation/filesystems/ntfs3.rst +0 -4
index ffe9ea0c1499..af7158de6fde 100644
@@ -85,10 +85,6 @@ acl			Support POSIX ACLs (Access Control Lists). Effective if
 			supported by Kernel. Not to be confused with NTFS ACLs.
 			The option specified as acl enables support for POSIX ACLs.
 
-noatime			All files and directories will not update their last access
-			time attribute if a partition is mounted with this parameter.
-			This option can speed up file system operation.
-
 ===============================================================================
 
 ToDo list
fs/ntfs3/super.c +0 -7
index 17ee715ab539..267f123b0109 100644
@@ -216,7 +216,6 @@ enum Opt {
 	Opt_nohidden,
 	Opt_showmeta,
 	Opt_acl,
-	Opt_noatime,
 	Opt_nls,
 	Opt_prealloc,
 	Opt_no_acs_rules,
@@ -235,7 +234,6 @@ static const match_table_t ntfs_tokens = {
 	{ Opt_sparse, "sparse" },
 	{ Opt_nohidden, "nohidden" },
 	{ Opt_acl, "acl" },
-	{ Opt_noatime, "noatime" },
 	{ Opt_showmeta, "showmeta" },
 	{ Opt_nls, "nls=%s" },
 	{ Opt_prealloc, "prealloc" },
@@ -326,9 +324,6 @@ static noinline int ntfs_parse_options(struct super_block *sb, char *options,
 			ntfs_err(sb, "support for ACL not compiled in!");
 			return -EINVAL;
 #endif
-		case Opt_noatime:
-			sb->s_flags |= SB_NOATIME;
-			break;
 		case Opt_showmeta:
 			opts->showmeta = 1;
 			break;
@@ -575,8 +570,6 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 		seq_puts(m, ",prealloc");
 	if (sb->s_flags & SB_POSIXACL)
 		seq_puts(m, ",acl");
-	if (sb->s_flags & SB_NOATIME)
-		seq_puts(m, ",noatime");
 
 	return 0;
 }
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 2/9 fs/ntfs3: Remove unnecesarry remount flag handling

In reply to Kari Argillander

Remove unnecesarry remount flag handling. This does not do anything for this driver. We have already set SB_NODIRATIME when we fill super. Also noatime should be set from mount option. Now for some reson we try to set it when remounting.

Lazytime part looks like it is copied from f2fs and there is own mount parameter for it. That is why they use it. We do not set lazytime anywhere in our code. So basically this just blocks lazytime when remounting.

---
 fs/ntfs3/super.c | 2 --
 1 file changed, 2 deletions(-)
fs/ntfs3/super.c +0 -2
index 267f123b0109..c590872070e1 100644
@@ -407,8 +407,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data)
 
 	clear_mount_options(&old_opts);
 
-	*flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME) |
-		 SB_NODIRATIME | SB_NOATIME;
 	ntfs_info(sb, "re-mounted. Opts: %s", orig_data);
 	err = 0;
 	goto out;
Signature · 1 line
2.25.1
#3 lore raw

PATCH v3 3/9 fs/ntfs3: Convert mount options to pointer in sbi

In reply to Kari Argillander

Use pointer to mount options. We want to do this because we will use new mount api which will benefit that we have spi and mount options in different allocations. When we remount we do not have to make whole new spi it is enough that we will allocate just mount options.

Please note that we can do example remount lot cleaner but things will change in next patch so this should be just functional.

---
 fs/ntfs3/attrib.c  |  2 +-
 fs/ntfs3/dir.c     |  8 ++++----
 fs/ntfs3/file.c    |  4 ++--
 fs/ntfs3/inode.c   | 12 ++++++------
 fs/ntfs3/ntfs_fs.h |  2 +-
 fs/ntfs3/super.c   | 31 +++++++++++++++++++------------
 fs/ntfs3/xattr.c   |  2 +-
 7 files changed, 34 insertions(+), 27 deletions(-)
fs/ntfs3/attrib.c +1 -1
index 4eae9886e27d..7eb366a1b7c7 100644
@@ -538,7 +538,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
 		} else if (pre_alloc == -1) {
 			pre_alloc = 0;
 			if (type == ATTR_DATA && !name_len &&
-			    sbi->options.prealloc) {
+			    sbi->options->prealloc) {
 				CLST new_alen2 = bytes_to_cluster(
 					sbi, get_pre_allocated(new_size));
 				pre_alloc = new_alen2 - new_alen;
fs/ntfs3/dir.c +4 -4
index d36d7fbc2b1d..e41e5a259be7 100644
@@ -25,7 +25,7 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
 	int ret, uni_len, warn;
 	const __le16 *ip;
 	u8 *op;
-	struct nls_table *nls = sbi->options.nls;
+	struct nls_table *nls = sbi->options->nls;
 
 	static_assert(sizeof(wchar_t) == sizeof(__le16));
 
@@ -183,7 +183,7 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
 {
 	int ret, slen;
 	const u8 *end;
-	struct nls_table *nls = sbi->options.nls;
+	struct nls_table *nls = sbi->options->nls;
 	u16 *uname = uni->name;
 
 	static_assert(sizeof(wchar_t) == sizeof(u16));
@@ -296,10 +296,10 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,
 		return 0;
 
 	/* Skip meta files ( unless option to show metafiles is set ) */
-	if (!sbi->options.showmeta && ntfs_is_meta_file(sbi, ino))
+	if (!sbi->options->showmeta && ntfs_is_meta_file(sbi, ino))
 		return 0;
 
-	if (sbi->options.nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
+	if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
 		return 0;
 
 	name_len = ntfs_utf16_to_nls(sbi, (struct le_str *)&fname->name_len,
fs/ntfs3/file.c +2 -2
index a959f6197c99..c79e4aff7a19 100644
@@ -743,7 +743,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 	umode_t mode = inode->i_mode;
 	int err;
 
-	if (sbi->options.no_acs_rules) {
+	if (sbi->options->no_acs_rules) {
 		/* "no access rules" - force any changes of time etc. */
 		attr->ia_valid |= ATTR_FORCE;
 		/* and disable for editing some attributes */
@@ -1189,7 +1189,7 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
 	int err = 0;
 
 	/* if we are the last writer on the inode, drop the block reservation */
-	if (sbi->options.prealloc && ((file->f_mode & FMODE_WRITE) &&
+	if (sbi->options->prealloc && ((file->f_mode & FMODE_WRITE) &&
 				      atomic_read(&inode->i_writecount) == 1)) {
 		ni_lock(ni);
 		down_write(&ni->file.run_lock);
fs/ntfs3/inode.c +6 -6
index 520471f35e29..b28dd111e6cf 100644
@@ -51,8 +51,8 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
 	inode->i_op = NULL;
 	/* Setup 'uid' and 'gid' */
-	inode->i_uid = sbi->options.fs_uid;
-	inode->i_gid = sbi->options.fs_gid;
+	inode->i_uid = sbi->options->fs_uid;
+	inode->i_gid = sbi->options->fs_gid;
 
 	err = mi_init(&ni->mi, sbi, ino);
 	if (err)
@@ -231,7 +231,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 			t32 = le16_to_cpu(attr->nres.run_off);
 		}
 
-		mode = S_IFREG | (0777 & sbi->options.fs_fmask_inv);
+		mode = S_IFREG | (0777 & sbi->options->fs_fmask_inv);
 
 		if (!attr->non_res) {
 			ni->ni_flags |= NI_FLAG_RESIDENT;
@@ -274,7 +274,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 			goto out;
 
 		mode = sb->s_root
-			       ? (S_IFDIR | (0777 & sbi->options.fs_dmask_inv))
+			       ? (S_IFDIR | (0777 & sbi->options->fs_dmask_inv))
 			       : (S_IFDIR | 0777);
 		goto next_attr;
 
@@ -439,7 +439,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 		goto out;
 	}
 
-	if ((sbi->options.sys_immutable &&
+	if ((sbi->options->sys_immutable &&
 	     (std5->fa & FILE_ATTRIBUTE_SYSTEM)) &&
 	    !S_ISFIFO(mode) && !S_ISSOCK(mode) && !S_ISLNK(mode)) {
 		inode->i_flags |= S_IMMUTABLE;
@@ -1228,7 +1228,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
 		 *	}
 		 */
 	} else if (S_ISREG(mode)) {
-		if (sbi->options.sparse) {
+		if (sbi->options->sparse) {
 			/* sparsed regular file, cause option 'sparse' */
 			fa = FILE_ATTRIBUTE_SPARSE_FILE |
 			     FILE_ATTRIBUTE_ARCHIVE;
fs/ntfs3/ntfs_fs.h +1 -1
index e3a667e9838f..43b177280f39 100644
@@ -279,7 +279,7 @@ struct ntfs_sb_info {
 #endif
 	} compress;
 
-	struct ntfs_mount_options options;
+	struct ntfs_mount_options *options;
 	struct ratelimit_state msg_ratelimit;
 };
 
fs/ntfs3/super.c +19 -12
index c590872070e1..e9dfe274b558 100644
@@ -379,11 +379,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data)
 		return -ENOMEM;
 
 	/* Store  original options */
-	memcpy(&old_opts, &sbi->options, sizeof(old_opts));
-	clear_mount_options(&sbi->options);
-	memset(&sbi->options, 0, sizeof(sbi->options));
+	memcpy(&old_opts, sbi->options, sizeof(old_opts));
+	clear_mount_options(sbi->options);
+	memset(sbi->options, 0, sizeof(old_opts));
 
-	err = ntfs_parse_options(sb, data, 0, &sbi->options);
+	err = ntfs_parse_options(sb, data, 0, sbi->options);
 	if (err)
 		goto restore_opts;
 
@@ -399,7 +399,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data)
 	sync_filesystem(sb);
 
 	if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) &&
-	    !sbi->options.force) {
+	    !sbi->options->force) {
 		ntfs_warn(sb, "volume is dirty and \"force\" flag is not set!");
 		err = -EINVAL;
 		goto restore_opts;
@@ -412,8 +412,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data)
 	goto out;
 
 restore_opts:
-	clear_mount_options(&sbi->options);
-	memcpy(&sbi->options, &old_opts, sizeof(old_opts));
+	clear_mount_options(sbi->options);
+	memcpy(sbi->options, &old_opts, sizeof(old_opts));
 
 out:
 	kfree(orig_data);
@@ -494,7 +494,8 @@ static noinline void put_ntfs(struct ntfs_sb_info *sbi)
 	xpress_free_decompressor(sbi->compress.xpress);
 	lzx_free_decompressor(sbi->compress.lzx);
 #endif
-	clear_mount_options(&sbi->options);
+	clear_mount_options(sbi->options);
+	kfree(sbi->options);
 
 	kfree(sbi);
 }
@@ -533,7 +534,7 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 {
 	struct super_block *sb = root->d_sb;
 	struct ntfs_sb_info *sbi = sb->s_fs_info;
-	struct ntfs_mount_options *opts = &sbi->options;
+	struct ntfs_mount_options *opts = sbi->options;
 	struct user_namespace *user_ns = seq_user_ns(m);
 
 	if (opts->uid)
@@ -910,6 +911,12 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 	if (!sbi)
 		return -ENOMEM;
 
+	sbi->options = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS);
+	if (!sbi->options) {
+		kfree(sbi);
+		return -ENOMEM;
+	}
+
 	sb->s_fs_info = sbi;
 	sbi->sb = sb;
 	sb->s_flags |= SB_NODIRATIME;
@@ -922,7 +929,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 	ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
 			     DEFAULT_RATELIMIT_BURST);
 
-	err = ntfs_parse_options(sb, data, silent, &sbi->options);
+	err = ntfs_parse_options(sb, data, silent, sbi->options);
 	if (err)
 		goto out;
 
@@ -1054,7 +1061,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 			goto out;
 		}
 	} else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) {
-		if (!is_ro && !sbi->options.force) {
+		if (!is_ro && !sbi->options->force) {
 			ntfs_warn(
 				sb,
 				"volume is dirty and \"force\" flag is not set!");
@@ -1376,7 +1383,7 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len)
 	if (sbi->flags & NTFS_FLAGS_NODISCARD)
 		return -EOPNOTSUPP;
 
-	if (!sbi->options.discard)
+	if (!sbi->options->discard)
 		return -EOPNOTSUPP;
 
 	lbo = (u64)lcn << sbi->cluster_bits;
fs/ntfs3/xattr.c +1 -1
index d3d5b9d331d1..a17d48735b99 100644
@@ -774,7 +774,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
 		    int mask)
 {
-	if (ntfs_sb(inode->i_sb)->options.no_acs_rules) {
+	if (ntfs_sb(inode->i_sb)->options->no_acs_rules) {
 		/* "no access rules" mode - allow all changes */
 		return 0;
 	}
Signature · 1 line
2.25.1
#4 lore raw

PATCH v3 4/9 fs/ntfs3: Use new api for mounting

In reply to Kari Argillander

We have now new mount api as described in Documentation/filesystems. We
should use it as it gives us some benefits which are desribed here lore.kernel.org/linux-fsdevel/159646178122.1784947.11705396571718464082.stgit@warthog.procyon.org.uk/

Nls loading is changed a to load with string. This did make code also little cleaner.

Also try to use fsparam_flag_no as much as possible. This is just nice little touch and is not mandatory but it should not make any harm. It is just convenient that we can use example acl/noacl mount options.

---
 fs/ntfs3/ntfs_fs.h |   1 +
 fs/ntfs3/super.c   | 426 ++++++++++++++++++++++++---------------------
 2 files changed, 225 insertions(+), 202 deletions(-)
fs/ntfs3/ntfs_fs.h +1 -0
index 43b177280f39..45d6f4f91222 100644
@@ -52,6 +52,7 @@
 // clang-format on
 
 struct ntfs_mount_options {
+	char *nls_name;
 	struct nls_table *nls;
 
 	kuid_t fs_uid;
fs/ntfs3/super.c +224 -202

539 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH v3 5/9 fs/ntfs3: Init spi more in init_fs_context than fill_super

In reply to Kari Argillander

init_fs_context() is meant to initialize s_fs_info (spi). Move spi initializing code there which we can initialize before fill_super().

---
 fs/ntfs3/super.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
fs/ntfs3/super.c +22 -19
index 99102a146cf5..b2a3f947542b 100644
@@ -870,7 +870,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	const struct VOLUME_INFO *info;
 	u32 idx, done, bytes;
 	struct ATTR_DEF_ENTRY *t;
-	u16 *upcase = NULL;
+	u16 *upcase;
 	u16 *shared;
 	bool is_ro;
 	struct MFT_REF ref;
@@ -885,9 +885,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
 	sb->s_xattr = ntfs_xattr_handlers;
 
-	ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
-			     DEFAULT_RATELIMIT_BURST);
-
 	sbi->options->nls = ntfs_load_nls(sbi->options->nls_name);
 	if (IS_ERR(sbi->options->nls)) {
 		sbi->options->nls = NULL;
@@ -917,12 +914,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
 #endif
 
-	mutex_init(&sbi->compress.mtx_lznt);
-#ifdef CONFIG_NTFS3_LZX_XPRESS
-	mutex_init(&sbi->compress.mtx_xpress);
-	mutex_init(&sbi->compress.mtx_lzx);
-#endif
-
 	/*
 	 * Load $Volume. This should be done before LogFile
 	 * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'
@@ -1207,11 +1198,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 		goto out;
 	}
 
-	sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
-	if (!upcase) {
-		err = -ENOMEM;
-		goto out;
-	}
+	upcase = sbi->upcase;
 
 	for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
 		const __le16 *src;
@@ -1421,10 +1408,21 @@ static int ntfs_init_fs_context(struct fs_context *fc)
 		goto ok;
 
 	sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
-	if (!sbi) {
-		kfree(opts);
-		return -ENOMEM;
-	}
+	if (!sbi)
+		goto free_opts;
+
+	sbi->upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
+	if (!sbi->upcase)
+		goto free_sbi;
+
+	ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
+			     DEFAULT_RATELIMIT_BURST);
+
+	mutex_init(&sbi->compress.mtx_lznt);
+#ifdef CONFIG_NTFS3_LZX_XPRESS
+	mutex_init(&sbi->compress.mtx_xpress);
+	mutex_init(&sbi->compress.mtx_lzx);
+#endif
 
 	sbi->options = opts;
 	fc->s_fs_info = sbi;
@@ -1433,6 +1431,11 @@ static int ntfs_init_fs_context(struct fs_context *fc)
 	fc->ops = &ntfs_context_ops;
 
 	return 0;
+free_opts:
+	kfree(opts);
+free_sbi:
+	kfree(sbi);
+	return -ENOMEM;
 }
 
 // clang-format off
Signature · 1 line
2.25.1
#6 lore raw

PATCH v3 6/9 fs/ntfs3: Make mount option nohidden more universal

In reply to Kari Argillander

If we call Opt_nohidden with just keyword hidden, then we can use hidden/nohidden when mounting. We already use this method for almoust all other parameters so it is just logical that this will use same method.

---
 fs/ntfs3/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/super.c +2 -2
index b2a3f947542b..52e0dc45e060 100644
@@ -235,7 +235,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
 	fsparam_flag_no("discard",		Opt_discard),
 	fsparam_flag_no("force",		Opt_force),
 	fsparam_flag_no("sparse",		Opt_sparse),
-	fsparam_flag("nohidden",		Opt_nohidden),
+	fsparam_flag_no("hidden",		Opt_nohidden),
 	fsparam_flag_no("acl",			Opt_acl),
 	fsparam_flag_no("showmeta",		Opt_showmeta),
 	fsparam_string("nls",			Opt_nls),
@@ -324,7 +324,7 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 		opts->sparse = result.negated ? 0 : 1;
 		break;
 	case Opt_nohidden:
-		opts->nohidden = 1;
+		opts->nohidden = result.negated ? 1 : 0;
 		break;
 	case Opt_acl:
 		if (!result.negated)
Signature · 1 line
2.25.1
#7 lore raw

PATCH v3 7/9 fs/ntfs3: Add iocharset= mount option as alias for nls=

In reply to Kari Argillander

Other fs drivers are using iocharset= mount option for specifying charset. So add it also for ntfs3 and mark old nls= mount option as deprecated.

---
 Documentation/filesystems/ntfs3.rst |  4 ++--
 fs/ntfs3/super.c                    | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)
Documentation/filesystems/ntfs3.rst +2 -2
index af7158de6fde..ded706474825 100644
@@ -32,12 +32,12 @@ generic ones.
 
 ===============================================================================
 
-nls=name		This option informs the driver how to interpret path
+iocharset=name		This option informs the driver how to interpret path
 			strings and translate them to Unicode and back. If
 			this option is not set, the default codepage will be
 			used (CONFIG_NLS_DEFAULT).
 			Examples:
-				'nls=utf8'
+				'iocharset=utf8'
 
 uid=
 gid=
fs/ntfs3/super.c +11 -7
index 52e0dc45e060..e5c319604c4d 100644
@@ -219,7 +219,7 @@ enum Opt {
 	Opt_nohidden,
 	Opt_showmeta,
 	Opt_acl,
-	Opt_nls,
+	Opt_iocharset,
 	Opt_prealloc,
 	Opt_no_acs_rules,
 	Opt_err,
@@ -238,9 +238,13 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
 	fsparam_flag_no("hidden",		Opt_nohidden),
 	fsparam_flag_no("acl",			Opt_acl),
 	fsparam_flag_no("showmeta",		Opt_showmeta),
-	fsparam_string("nls",			Opt_nls),
 	fsparam_flag_no("prealloc",		Opt_prealloc),
 	fsparam_flag("no_acs_rules",		Opt_no_acs_rules),
+	fsparam_string("iocharset",		Opt_iocharset),
+
+	__fsparam(fs_param_is_string,
+		  "nls", Opt_iocharset,
+		  fs_param_deprecated, NULL),
 	{}
 };
 
@@ -339,7 +343,7 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 	case Opt_showmeta:
 		opts->showmeta = result.negated ? 0 : 1;
 		break;
-	case Opt_nls:
+	case Opt_iocharset:
 		kfree(opts->nls_name);
 		opts->nls_name = param->string;
 		param->string = NULL;
@@ -373,11 +377,11 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
 	new_opts->nls = ntfs_load_nls(new_opts->nls_name);
 	if (IS_ERR(new_opts->nls)) {
 		new_opts->nls = NULL;
-		errorf(fc, "ntfs3: Cannot load nls %s", new_opts->nls_name);
+		errorf(fc, "ntfs3: Cannot load iocharset %s", new_opts->nls_name);
 		return -EINVAL;
 	}
 	if (new_opts->nls != sbi->options->nls)
-		return invalf(fc, "ntfs3: Cannot use different nls when remounting!");
+		return invalf(fc, "ntfs3: Cannot use different iocharset when remounting!");
 
 	sync_filesystem(sb);
 
@@ -519,9 +523,9 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 	if (opts->dmask)
 		seq_printf(m, ",dmask=%04o", ~opts->fs_dmask_inv);
 	if (opts->nls)
-		seq_printf(m, ",nls=%s", opts->nls->charset);
+		seq_printf(m, ",iocharset=%s", opts->nls->charset);
 	else
-		seq_puts(m, ",nls=utf8");
+		seq_puts(m, ",iocharset=utf8");
 	if (opts->sys_immutable)
 		seq_puts(m, ",sys_immutable");
 	if (opts->discard)
Signature · 1 line
2.25.1
#8 lore raw

PATCH v3 8/9 fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules

In reply to Kari Argillander

Rename mount option no_acl_rules to noacl_rules. This allow us to use possibility to mount with options noacl_rules or acl_rules.

---
 Documentation/filesystems/ntfs3.rst |  2 +-
 fs/ntfs3/file.c                     |  2 +-
 fs/ntfs3/ntfs_fs.h                  |  2 +-
 fs/ntfs3/super.c                    | 12 ++++++------
 fs/ntfs3/xattr.c                    |  2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)
Documentation/filesystems/ntfs3.rst +1 -1
index ded706474825..bdc9dd5a9185 100644
@@ -73,7 +73,7 @@ prealloc		Preallocate space for files excessively when file size is
 			increasing on writes. Decreases fragmentation in case of
 			parallel write operations to different files.
 
-no_acs_rules		"No access rules" mount option sets access rights for
+noacs_rules		"No access rules" mount option sets access rights for
 			files/folders to 777 and owner/group to root. This mount
 			option absorbs all other permissions:
 			- permissions change for files/folders will be reported
fs/ntfs3/file.c +1 -1
index c79e4aff7a19..4c9ff7fcf0b1 100644
@@ -743,7 +743,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 	umode_t mode = inode->i_mode;
 	int err;
 
-	if (sbi->options->no_acs_rules) {
+	if (sbi->options->noacs_rules) {
 		/* "no access rules" - force any changes of time etc. */
 		attr->ia_valid |= ATTR_FORCE;
 		/* and disable for editing some attributes */
fs/ntfs3/ntfs_fs.h +1 -1
index 45d6f4f91222..5df55bc733bd 100644
@@ -70,7 +70,7 @@ struct ntfs_mount_options {
 		showmeta : 1, /*show meta files*/
 		nohidden : 1, /*do not show hidden files*/
 		force : 1, /*rw mount dirty volume*/
-		no_acs_rules : 1, /*exclude acs rules*/
+		noacs_rules : 1, /*exclude acs rules*/
 		prealloc : 1 /*preallocate space when file is growing*/
 		;
 };
fs/ntfs3/super.c +6 -6
index e5c319604c4d..d7408b4f6813 100644
@@ -221,7 +221,7 @@ enum Opt {
 	Opt_acl,
 	Opt_iocharset,
 	Opt_prealloc,
-	Opt_no_acs_rules,
+	Opt_noacs_rules,
 	Opt_err,
 };
 
@@ -239,7 +239,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
 	fsparam_flag_no("acl",			Opt_acl),
 	fsparam_flag_no("showmeta",		Opt_showmeta),
 	fsparam_flag_no("prealloc",		Opt_prealloc),
-	fsparam_flag("no_acs_rules",		Opt_no_acs_rules),
+	fsparam_flag_no("acs_rules",		Opt_noacs_rules),
 	fsparam_string("iocharset",		Opt_iocharset),
 
 	__fsparam(fs_param_is_string,
@@ -351,8 +351,8 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 	case Opt_prealloc:
 		opts->prealloc = result.negated ? 0 : 1;
 		break;
-	case Opt_no_acs_rules:
-		opts->no_acs_rules = 1;
+	case Opt_noacs_rules:
+		opts->noacs_rules = result.negated ? 1 : 0;
 		break;
 	default:
 		/* Should not be here unless we forget add case. */
@@ -538,8 +538,8 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 		seq_puts(m, ",nohidden");
 	if (opts->force)
 		seq_puts(m, ",force");
-	if (opts->no_acs_rules)
-		seq_puts(m, ",no_acs_rules");
+	if (opts->noacs_rules)
+		seq_puts(m, ",noacs_rules");
 	if (opts->prealloc)
 		seq_puts(m, ",prealloc");
 	if (sb->s_flags & SB_POSIXACL)
fs/ntfs3/xattr.c +1 -1
index a17d48735b99..4b37ed239579 100644
@@ -774,7 +774,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
 		    int mask)
 {
-	if (ntfs_sb(inode->i_sb)->options->no_acs_rules) {
+	if (ntfs_sb(inode->i_sb)->options->noacs_rules) {
 		/* "no access rules" mode - allow all changes */
 		return 0;
 	}
Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH v3 8/9] fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules

Hello!

Quoted 2 lines · On Sunday 29 August 2021 12:56:13 Kari Argillander wrote:

Rename mount option no_acl_rules to noacl_rules. This allow us to use possibility to mount with options noacl_rules or acl_rules.

$commit_message =~ s/acl/acs/g;

Anyway, for me "noacs_rules" name looks strange. Underline is used as a word separator and so original name "no_acs_rules" looks better. But if you are going to remove first underline, why not then remove also the second one? So name would be "noacsrules" and better matches naming convention?

And I see that other filesystems have option 'mode' (e.g. iso9660, udf) whicha is basically superset of this no_acs_rules as it supports to set permission to also any other mode than 0777.

Maybe this could be a good thing to unify across all filesystems in future...

Quoted 110 lines
---
 Documentation/filesystems/ntfs3.rst |  2 +-
 fs/ntfs3/file.c                     |  2 +-
 fs/ntfs3/ntfs_fs.h                  |  2 +-
 fs/ntfs3/super.c                    | 12 ++++++------
 fs/ntfs3/xattr.c                    |  2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)
Documentation/filesystems/ntfs3.rst +1 -1
index ded706474825..bdc9dd5a9185 100644
@@ -73,7 +73,7 @@ prealloc		Preallocate space for files excessively when file size is
 			increasing on writes. Decreases fragmentation in case of
 			parallel write operations to different files.
 
-no_acs_rules		"No access rules" mount option sets access rights for
+noacs_rules		"No access rules" mount option sets access rights for
 			files/folders to 777 and owner/group to root. This mount
 			option absorbs all other permissions:
 			- permissions change for files/folders will be reported
fs/ntfs3/file.c +1 -1
index c79e4aff7a19..4c9ff7fcf0b1 100644
@@ -743,7 +743,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 	umode_t mode = inode->i_mode;
 	int err;
 
-	if (sbi->options->no_acs_rules) {
+	if (sbi->options->noacs_rules) {
 		/* "no access rules" - force any changes of time etc. */
 		attr->ia_valid |= ATTR_FORCE;
 		/* and disable for editing some attributes */
fs/ntfs3/ntfs_fs.h +1 -1
index 45d6f4f91222..5df55bc733bd 100644
@@ -70,7 +70,7 @@ struct ntfs_mount_options {
 		showmeta : 1, /*show meta files*/
 		nohidden : 1, /*do not show hidden files*/
 		force : 1, /*rw mount dirty volume*/
-		no_acs_rules : 1, /*exclude acs rules*/
+		noacs_rules : 1, /*exclude acs rules*/
 		prealloc : 1 /*preallocate space when file is growing*/
 		;
 };
fs/ntfs3/super.c +6 -6
index e5c319604c4d..d7408b4f6813 100644
@@ -221,7 +221,7 @@ enum Opt {
 	Opt_acl,
 	Opt_iocharset,
 	Opt_prealloc,
-	Opt_no_acs_rules,
+	Opt_noacs_rules,
 	Opt_err,
 };
 
@@ -239,7 +239,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
 	fsparam_flag_no("acl",			Opt_acl),
 	fsparam_flag_no("showmeta",		Opt_showmeta),
 	fsparam_flag_no("prealloc",		Opt_prealloc),
-	fsparam_flag("no_acs_rules",		Opt_no_acs_rules),
+	fsparam_flag_no("acs_rules",		Opt_noacs_rules),
 	fsparam_string("iocharset",		Opt_iocharset),
 
 	__fsparam(fs_param_is_string,
@@ -351,8 +351,8 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 	case Opt_prealloc:
 		opts->prealloc = result.negated ? 0 : 1;
 		break;
-	case Opt_no_acs_rules:
-		opts->no_acs_rules = 1;
+	case Opt_noacs_rules:
+		opts->noacs_rules = result.negated ? 1 : 0;
 		break;
 	default:
 		/* Should not be here unless we forget add case. */
@@ -538,8 +538,8 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 		seq_puts(m, ",nohidden");
 	if (opts->force)
 		seq_puts(m, ",force");
-	if (opts->no_acs_rules)
-		seq_puts(m, ",no_acs_rules");
+	if (opts->noacs_rules)
+		seq_puts(m, ",noacs_rules");
 	if (opts->prealloc)
 		seq_puts(m, ",prealloc");
 	if (sb->s_flags & SB_POSIXACL)
fs/ntfs3/xattr.c +1 -1
index a17d48735b99..4b37ed239579 100644
@@ -774,7 +774,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
 		    int mask)
 {
-	if (ntfs_sb(inode->i_sb)->options->no_acs_rules) {
+	if (ntfs_sb(inode->i_sb)->options->noacs_rules) {
 		/* "no access rules" mode - allow all changes */
 		return 0;
 	}
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v3 8/9] fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules

Quoted 7 lines · Pali Rohár

Hello!

Quoted 2 lines · On Sunday 29 August 2021 12:56:13 Kari Argillander wrote:

Rename mount option no_acl_rules to noacl_rules. This allow us to use possibility to mount with options noacl_rules or acl_rules.

$commit_message =~ s/acl/acs/g;

Thanks.

Quoted 6 lines

Anyway, for me "noacs_rules" name looks strange. Underline is used as a word separator and so original name "no_acs_rules" looks better. But if you are going to remove first underline, why not then remove also the second one? So name would be "noacsrules" and better matches naming convention?

I agree. Now that you wrote it like that I see that is definitely better.

Quoted 3 lines

And I see that other filesystems have option 'mode' (e.g. iso9660, udf) whicha is basically superset of this no_acs_rules as it supports to set permission to also any other mode than 0777.

We also have umask, fmask and dmask. Isn't fmask=mode and dmask=dmode?

I have not tested these really, but my impression is that noacsrules will kinda overwrite everything else. It can also lie to user because user can change file permission, but it will not change in reality.

I'm not even sure when do we need this option. Konstantin can probably enlighten us or at least me.

Quoted 2 lines

Maybe this could be a good thing to unify across all filesystems in future...

Hopefully.

Quoted 112 lines
Quoted 111 lines
---
 Documentation/filesystems/ntfs3.rst |  2 +-
 fs/ntfs3/file.c                     |  2 +-
 fs/ntfs3/ntfs_fs.h                  |  2 +-
 fs/ntfs3/super.c                    | 12 ++++++------
 fs/ntfs3/xattr.c                    |  2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)
Documentation/filesystems/ntfs3.rst +1 -1
index ded706474825..bdc9dd5a9185 100644
@@ -73,7 +73,7 @@ prealloc		Preallocate space for files excessively when file size is
 			increasing on writes. Decreases fragmentation in case of
 			parallel write operations to different files.
 
-no_acs_rules		"No access rules" mount option sets access rights for
+noacs_rules		"No access rules" mount option sets access rights for
 			files/folders to 777 and owner/group to root. This mount
 			option absorbs all other permissions:
 			- permissions change for files/folders will be reported
fs/ntfs3/file.c +1 -1
index c79e4aff7a19..4c9ff7fcf0b1 100644
@@ -743,7 +743,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 	umode_t mode = inode->i_mode;
 	int err;
 
-	if (sbi->options->no_acs_rules) {
+	if (sbi->options->noacs_rules) {
 		/* "no access rules" - force any changes of time etc. */
 		attr->ia_valid |= ATTR_FORCE;
 		/* and disable for editing some attributes */
fs/ntfs3/ntfs_fs.h +1 -1
index 45d6f4f91222..5df55bc733bd 100644
@@ -70,7 +70,7 @@ struct ntfs_mount_options {
 		showmeta : 1, /*show meta files*/
 		nohidden : 1, /*do not show hidden files*/
 		force : 1, /*rw mount dirty volume*/
-		no_acs_rules : 1, /*exclude acs rules*/
+		noacs_rules : 1, /*exclude acs rules*/
 		prealloc : 1 /*preallocate space when file is growing*/
 		;
 };
fs/ntfs3/super.c +6 -6
index e5c319604c4d..d7408b4f6813 100644
@@ -221,7 +221,7 @@ enum Opt {
 	Opt_acl,
 	Opt_iocharset,
 	Opt_prealloc,
-	Opt_no_acs_rules,
+	Opt_noacs_rules,
 	Opt_err,
 };
 
@@ -239,7 +239,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
 	fsparam_flag_no("acl",			Opt_acl),
 	fsparam_flag_no("showmeta",		Opt_showmeta),
 	fsparam_flag_no("prealloc",		Opt_prealloc),
-	fsparam_flag("no_acs_rules",		Opt_no_acs_rules),
+	fsparam_flag_no("acs_rules",		Opt_noacs_rules),
 	fsparam_string("iocharset",		Opt_iocharset),
 
 	__fsparam(fs_param_is_string,
@@ -351,8 +351,8 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 	case Opt_prealloc:
 		opts->prealloc = result.negated ? 0 : 1;
 		break;
-	case Opt_no_acs_rules:
-		opts->no_acs_rules = 1;
+	case Opt_noacs_rules:
+		opts->noacs_rules = result.negated ? 1 : 0;
 		break;
 	default:
 		/* Should not be here unless we forget add case. */
@@ -538,8 +538,8 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 		seq_puts(m, ",nohidden");
 	if (opts->force)
 		seq_puts(m, ",force");
-	if (opts->no_acs_rules)
-		seq_puts(m, ",no_acs_rules");
+	if (opts->noacs_rules)
+		seq_puts(m, ",noacs_rules");
 	if (opts->prealloc)
 		seq_puts(m, ",prealloc");
 	if (sb->s_flags & SB_POSIXACL)
fs/ntfs3/xattr.c +1 -1
index a17d48735b99..4b37ed239579 100644
@@ -774,7 +774,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
 		    int mask)
 {
-	if (ntfs_sb(inode->i_sb)->options->no_acs_rules) {
+	if (ntfs_sb(inode->i_sb)->options->noacs_rules) {
 		/* "no access rules" mode - allow all changes */
 		return 0;
 	}
Signature · 1 line
2.25.1
#11 lore raw

PATCH v3 9/9 fs/ntfs3: Show uid/gid always in show_options()

In reply to Kari Argillander

Show options should show option according documentation when some value is not default or when ever coder wants. Uid/gid are problematic because it is hard to know which are defaults. In file system there is many different implementation for this problem.

Some file systems show uid/gid when they are different than root, some when user has set them and some show them always. There is also problem that what if root uid/gid change. This code just choose to show them always. This way we do not need to think this any more.

---
 fs/ntfs3/ntfs_fs.h | 23 ++++++++++-------------
 fs/ntfs3/super.c   | 12 ++++--------
 2 files changed, 14 insertions(+), 21 deletions(-)
fs/ntfs3/ntfs_fs.h +10 -13
index 5df55bc733bd..a3a7d10de7cb 100644
@@ -60,19 +60,16 @@ struct ntfs_mount_options {
 	u16 fs_fmask_inv;
 	u16 fs_dmask_inv;
 
-	unsigned uid : 1, /* uid was set */
-		gid : 1, /* gid was set */
-		fmask : 1, /* fmask was set */
-		dmask : 1, /*dmask was set*/
-		sys_immutable : 1, /* immutable system files */
-		discard : 1, /* issue discard requests on deletions */
-		sparse : 1, /*create sparse files*/
-		showmeta : 1, /*show meta files*/
-		nohidden : 1, /*do not show hidden files*/
-		force : 1, /*rw mount dirty volume*/
-		noacs_rules : 1, /*exclude acs rules*/
-		prealloc : 1 /*preallocate space when file is growing*/
-		;
+	unsigned fmask : 1; /* fmask was set */
+	unsigned dmask : 1; /*dmask was set*/
+	unsigned sys_immutable : 1; /* immutable system files */
+	unsigned discard : 1; /* issue discard requests on deletions */
+	unsigned sparse : 1; /*create sparse files*/
+	unsigned showmeta : 1; /*show meta files*/
+	unsigned nohidden : 1; /*do not show hidden files*/
+	unsigned force : 1; /*rw mount dirty volume*/
+	unsigned noacs_rules : 1; /*exclude acs rules*/
+	unsigned prealloc : 1; /*preallocate space when file is growing*/
 };
 
 /* special value to unpack and deallocate*/
fs/ntfs3/super.c +4 -8
index d7408b4f6813..d28fab6c2297 100644
@@ -287,13 +287,11 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 		opts->fs_uid = make_kuid(current_user_ns(), result.uint_32);
 		if (!uid_valid(opts->fs_uid))
 			return invalf(fc, "ntfs3: Invalid value for uid.");
-		opts->uid = 1;
 		break;
 	case Opt_gid:
 		opts->fs_gid = make_kgid(current_user_ns(), result.uint_32);
 		if (!gid_valid(opts->fs_gid))
 			return invalf(fc, "ntfs3: Invalid value for gid.");
-		opts->gid = 1;
 		break;
 	case Opt_umask:
 		if (result.uint_32 & ~07777)
@@ -512,12 +510,10 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 	struct ntfs_mount_options *opts = sbi->options;
 	struct user_namespace *user_ns = seq_user_ns(m);
 
-	if (opts->uid)
-		seq_printf(m, ",uid=%u",
-			   from_kuid_munged(user_ns, opts->fs_uid));
-	if (opts->gid)
-		seq_printf(m, ",gid=%u",
-			   from_kgid_munged(user_ns, opts->fs_gid));
+	seq_printf(m, ",uid=%u",
+		  from_kuid_munged(user_ns, opts->fs_uid));
+	seq_printf(m, ",gid=%u",
+		  from_kgid_munged(user_ns, opts->fs_gid));
 	if (opts->fmask)
 		seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv);
 	if (opts->dmask)
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH v3 9/9] fs/ntfs3: Show uid/gid always in show_options()

Quoted 9 lines · On Sunday 29 August 2021 12:56:14 Kari Argillander wrote:

Show options should show option according documentation when some value is not default or when ever coder wants. Uid/gid are problematic because it is hard to know which are defaults. In file system there is many different implementation for this problem.

Some file systems show uid/gid when they are different than root, some when user has set them and some show them always. There is also problem that what if root uid/gid change. This code just choose to show them always. This way we do not need to think this any more.

Hello! IIRC ntfs disk storage supports POSIX permissions and uid/gid for files and directories. But from ntfs3 documentation it is not clear if this ntfs3 implementation supports it or not.

Currently ntfs3 documentation says:

Quoted 3 lines

https://github.com/Paragon-Software-Group/linux-ntfs3/blob/master/Documentation/filesystems/ntfs3.rst
uid= gid= umask= Controls the default permissions for files/directories created after the NTFS volume is mounted.

(and looks that rst formatting is broken)

And from this description I'm not really sure what these option controls.

For example udf filesystem also supports storing POSIX uid/gid and supports also additional extension per file to "do not store uid" and "do not store gid". Moreover kernel implementation has mount option (uid= and gid=) which overrides disk's uid/gid to mount option value. And also has mount option to allow storing new files "without uid/gid". So there does not have to be any default for uid=/gid= like it is for "native" POSIX filesystems (e.g. ext4).

And so interpretation of uid/gid options is not always easy; specially if filesystem has extensions to POSIX permissions. And NTFS has it too as it by default has in its storage (only?) NT permissions and NT SIDs.

Quoted 78 lines
---
 fs/ntfs3/ntfs_fs.h | 23 ++++++++++-------------
 fs/ntfs3/super.c   | 12 ++++--------
 2 files changed, 14 insertions(+), 21 deletions(-)
fs/ntfs3/ntfs_fs.h +10 -13
index 5df55bc733bd..a3a7d10de7cb 100644
@@ -60,19 +60,16 @@ struct ntfs_mount_options {
 	u16 fs_fmask_inv;
 	u16 fs_dmask_inv;
 
-	unsigned uid : 1, /* uid was set */
-		gid : 1, /* gid was set */
-		fmask : 1, /* fmask was set */
-		dmask : 1, /*dmask was set*/
-		sys_immutable : 1, /* immutable system files */
-		discard : 1, /* issue discard requests on deletions */
-		sparse : 1, /*create sparse files*/
-		showmeta : 1, /*show meta files*/
-		nohidden : 1, /*do not show hidden files*/
-		force : 1, /*rw mount dirty volume*/
-		noacs_rules : 1, /*exclude acs rules*/
-		prealloc : 1 /*preallocate space when file is growing*/
-		;
+	unsigned fmask : 1; /* fmask was set */
+	unsigned dmask : 1; /*dmask was set*/
+	unsigned sys_immutable : 1; /* immutable system files */
+	unsigned discard : 1; /* issue discard requests on deletions */
+	unsigned sparse : 1; /*create sparse files*/
+	unsigned showmeta : 1; /*show meta files*/
+	unsigned nohidden : 1; /*do not show hidden files*/
+	unsigned force : 1; /*rw mount dirty volume*/
+	unsigned noacs_rules : 1; /*exclude acs rules*/
+	unsigned prealloc : 1; /*preallocate space when file is growing*/
 };
 
 /* special value to unpack and deallocate*/
fs/ntfs3/super.c +4 -8
index d7408b4f6813..d28fab6c2297 100644
@@ -287,13 +287,11 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
 		opts->fs_uid = make_kuid(current_user_ns(), result.uint_32);
 		if (!uid_valid(opts->fs_uid))
 			return invalf(fc, "ntfs3: Invalid value for uid.");
-		opts->uid = 1;
 		break;
 	case Opt_gid:
 		opts->fs_gid = make_kgid(current_user_ns(), result.uint_32);
 		if (!gid_valid(opts->fs_gid))
 			return invalf(fc, "ntfs3: Invalid value for gid.");
-		opts->gid = 1;
 		break;
 	case Opt_umask:
 		if (result.uint_32 & ~07777)
@@ -512,12 +510,10 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 	struct ntfs_mount_options *opts = sbi->options;
 	struct user_namespace *user_ns = seq_user_ns(m);
 
-	if (opts->uid)
-		seq_printf(m, ",uid=%u",
-			   from_kuid_munged(user_ns, opts->fs_uid));
-	if (opts->gid)
-		seq_printf(m, ",gid=%u",
-			   from_kgid_munged(user_ns, opts->fs_gid));
+	seq_printf(m, ",uid=%u",
+		  from_kuid_munged(user_ns, opts->fs_uid));
+	seq_printf(m, ",gid=%u",
+		  from_kgid_munged(user_ns, opts->fs_gid));
 	if (opts->fmask)
 		seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv);
 	if (opts->dmask)
Signature · 1 line
2.25.1
#13 lore raw
In reply to Kari Argillander
Quoted 20 lines · Kari Argillander

See V2 if you want:
lore.kernel.org/ntfs3/[email protected]

NLS change is now blocked when remounting. Christoph also suggest that we block all other mount options, but I have tested a couple and they seem to work. I wish that we do not block any other than NLS because in theory they should work. Also Konstantin can comment about this.

I have not include reviewed/acked to patch "Use new api for mounting" because it change so much. I have also included three new patch to this series:
- Convert mount options to pointer in sbi
So that we do not need to initiliaze whole spi in remount.
- Init spi more in init_fs_context than fill_super This is just refactoring. (Series does not depend on this)
- Show uid/gid always in show_options()
Christian Brauner kinda ask this. (Series does not depend on this)

Quoted 2 lines

Series is ones again tested with kvm-xfstests. Every commit is build tested.

I will send v4 within couple of days. It will address issues what Pali says in patch 8/9. Everything else should be same at least for now. Is everything else looking ok?

Quoted 47 lines

v3:
- Add patch "Convert mount options to pointer in sbi"
- Add patch "Init spi more in init_fs_context than fill_super"
- Add patch "Show uid/gid always in show_options"
- Patch "Use new api for mounting" has make over
- NLS loading is not anymore possible when remounting
- show_options() iocharset printing is fixed
- Delete comment that testing should be done with other mount options.
- Add reviewed/acked-tags to 1,2,6,8
- Rewrite this cover
v2:
- Rewrite this cover leter
- Reorder noatime to first patch
- NLS loading with string
- Delete default_options function
- Remove remount flags
- Rename no_acl_rules mount option
- Making code cleaner
- Add comment that mount options should be tested

Kari Argillander (9):
fs/ntfs3: Remove unnecesarry mount option noatime fs/ntfs3: Remove unnecesarry remount flag handling fs/ntfs3: Convert mount options to pointer in sbi fs/ntfs3: Use new api for mounting
fs/ntfs3: Init spi more in init_fs_context than fill_super fs/ntfs3: Make mount option nohidden more universal fs/ntfs3: Add iocharset= mount option as alias for nls= fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules fs/ntfs3: Show uid/gid always in show_options()

 Documentation/filesystems/ntfs3.rst |  10 +-
 fs/ntfs3/attrib.c                   |   2 +-
 fs/ntfs3/dir.c                      |   8 +-
 fs/ntfs3/file.c                     |   4 +-
 fs/ntfs3/inode.c                    |  12 +-
 fs/ntfs3/ntfs_fs.h                  |  26 +-
 fs/ntfs3/super.c                    | 486 +++++++++++++++-------------
 fs/ntfs3/xattr.c                    |   2 +-
 8 files changed, 284 insertions(+), 266 deletions(-)
Signature · 1 line
2.25.1
#14 lore raw
Quoted 21 lines · Kari Argillander
Quoted 20 lines · Kari Argillander

See V2 if you want:
lore.kernel.org/ntfs3/[email protected]

NLS change is now blocked when remounting. Christoph also suggest that we block all other mount options, but I have tested a couple and they seem to work. I wish that we do not block any other than NLS because in theory they should work. Also Konstantin can comment about this.

I have not include reviewed/acked to patch "Use new api for mounting" because it change so much. I have also included three new patch to this series:
- Convert mount options to pointer in sbi
So that we do not need to initiliaze whole spi in remount.
- Init spi more in init_fs_context than fill_super This is just refactoring. (Series does not depend on this)
- Show uid/gid always in show_options()
Christian Brauner kinda ask this. (Series does not depend on this)

Quoted 7 lines
Quoted 2 lines

Series is ones again tested with kvm-xfstests. Every commit is build tested.

I will send v4 within couple of days. It will address issues what Pali says in patch 8/9. Everything else should be same at least for now. Is everything else looking ok?

Yes, everything else seems good.
We tested patches locally - no regression was found.

Quoted 47 lines
Quoted 47 lines

v3:
- Add patch "Convert mount options to pointer in sbi"
- Add patch "Init spi more in init_fs_context than fill_super"
- Add patch "Show uid/gid always in show_options"
- Patch "Use new api for mounting" has make over
- NLS loading is not anymore possible when remounting
- show_options() iocharset printing is fixed
- Delete comment that testing should be done with other mount options.
- Add reviewed/acked-tags to 1,2,6,8
- Rewrite this cover
v2:
- Rewrite this cover leter
- Reorder noatime to first patch
- NLS loading with string
- Delete default_options function
- Remove remount flags
- Rename no_acl_rules mount option
- Making code cleaner
- Add comment that mount options should be tested

Kari Argillander (9):
fs/ntfs3: Remove unnecesarry mount option noatime fs/ntfs3: Remove unnecesarry remount flag handling fs/ntfs3: Convert mount options to pointer in sbi fs/ntfs3: Use new api for mounting
fs/ntfs3: Init spi more in init_fs_context than fill_super fs/ntfs3: Make mount option nohidden more universal fs/ntfs3: Add iocharset= mount option as alias for nls= fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules fs/ntfs3: Show uid/gid always in show_options()

 Documentation/filesystems/ntfs3.rst |  10 +-
 fs/ntfs3/attrib.c                   |   2 +-
 fs/ntfs3/dir.c                      |   8 +-
 fs/ntfs3/file.c                     |   4 +-
 fs/ntfs3/inode.c                    |  12 +-
 fs/ntfs3/ntfs_fs.h                  |  26 +-
 fs/ntfs3/super.c                    | 486 +++++++++++++++-------------
 fs/ntfs3/xattr.c                    |   2 +-
 8 files changed, 284 insertions(+), 266 deletions(-)
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): CAHp75Vd==Dm1s=WK9p2q3iEBSHxN-1spHmmtZ21eRNoqyJ5v=Q@mail.gmail.com

#16 lore raw
Quoted 31 lines · Andy Shevchenko
Quoted 30 lines · Konstantin Komarov
Quoted 28 lines · Kari Argillander
Quoted 20 lines · Kari Argillander

See V2 if you want:
lore.kernel.org/ntfs3/[email protected]

NLS change is now blocked when remounting. Christoph also suggest that we block all other mount options, but I have tested a couple and they seem to work. I wish that we do not block any other than NLS because in theory they should work. Also Konstantin can comment about this.

I have not include reviewed/acked to patch "Use new api for mounting" because it change so much. I have also included three new patch to this series:
- Convert mount options to pointer in sbi
So that we do not need to initiliaze whole spi in remount.
- Init spi more in init_fs_context than fill_super
This is just refactoring. (Series does not depend on this)
- Show uid/gid always in show_options()
Christian Brauner kinda ask this. (Series does not depend on this)

Quoted 2 lines

Series is ones again tested with kvm-xfstests. Every commit is build tested.

I will send v4 within couple of days. It will address issues what Pali says in patch 8/9. Everything else should be same at least for now. Is everything else looking ok?

Quoted 4 lines
Quoted 2 lines

Yes, everything else seems good.
We tested patches locally - no regression was

The formal answer in such case should also contain the Tested-by tag. I would suggest you to read the Submitting Patches document (available in the Linux kernel source tree).

He is a maintainer so he can add tags when he picks this up. This is not really relevant here. Yes it should be good to include that but I have already sended v4 which he has not tested. So I really cannot put this tag for him. So at the end he really should not even put it here.

Also usually the maintainers will always make their own tests and usually they will not even bother with a tested-by tag. Or do you say to me that I should go read Submitting Patches document as I'm the one who submit this?

Argillander

Quoted 55 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines

v3:
- Add patch "Convert mount options to pointer in sbi"
- Add patch "Init spi more in init_fs_context than fill_super"
- Add patch "Show uid/gid always in show_options"
- Patch "Use new api for mounting" has make over
- NLS loading is not anymore possible when remounting
- show_options() iocharset printing is fixed
- Delete comment that testing should be done with other mount options.
- Add reviewed/acked-tags to 1,2,6,8
- Rewrite this cover
v2:
- Rewrite this cover leter
- Reorder noatime to first patch
- NLS loading with string
- Delete default_options function
- Remove remount flags
- Rename no_acl_rules mount option
- Making code cleaner
- Add comment that mount options should be tested

Kari Argillander (9):
fs/ntfs3: Remove unnecesarry mount option noatime fs/ntfs3: Remove unnecesarry remount flag handling fs/ntfs3: Convert mount options to pointer in sbi fs/ntfs3: Use new api for mounting
fs/ntfs3: Init spi more in init_fs_context than fill_super fs/ntfs3: Make mount option nohidden more universal fs/ntfs3: Add iocharset= mount option as alias for nls= fs/ntfs3: Rename mount option no_acl_rules > (no)acl_rules fs/ntfs3: Show uid/gid always in show_options()

 Documentation/filesystems/ntfs3.rst |  10 +-
 fs/ntfs3/attrib.c                   |   2 +-
 fs/ntfs3/dir.c                      |   8 +-
 fs/ntfs3/file.c                     |   4 +-
 fs/ntfs3/inode.c                    |  12 +-
 fs/ntfs3/ntfs_fs.h                  |  26 +-
 fs/ntfs3/super.c                    | 486 +++++++++++++++-------------
 fs/ntfs3/xattr.c                    |   2 +-
 8 files changed, 284 insertions(+), 266 deletions(-)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

--
2.25.1

--
With Best Regards,
Andy Shevchenko

#17 lore raw
Quoted 4 lines · Kari Argillander
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Konstantin Komarov

On 07.09.2021 10:36, Kari Argillander wrote:

...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yes, everything else seems good.
We tested patches locally - no regression was

The formal answer in such case should also contain the Tested-by tag. I would suggest you to read the Submitting Patches document (available in the Linux kernel source tree).

He is a maintainer so he can add tags when he picks this up.

It's a good practice to do so. Moreover, it's better to do it patch-by-patch, so tools like b4 can cope with tags for *anybody* who will use it in automated way.

Quoted 2 lines

This is not
really relevant here.

Why not?

Quoted 3 lines

Yes it should be good to include that but I have already
sended v4 which he has not tested. So I really cannot put this tag for him. So at the end he really should not even put it here.

For v4 I agree with you.

Quoted 2 lines

Also usually the maintainers will always make their own tests and usually they will not even bother with a tested-by tag.

If it's their own code, yes, if it's others', why not? See above as well.

Quoted 3 lines

Or do you say to me that I
should go read Submitting Patches document as I'm the one who submit this?

It's always good to refresh memory, so why not? :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#18 lore raw
Quoted 23 lines · Andy Shevchenko
Quoted 4 lines · Kari Argillander
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Konstantin Komarov

On 07.09.2021 10:36, Kari Argillander wrote:

...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yes, everything else seems good.
We tested patches locally - no regression was

The formal answer in such case should also contain the Tested-by tag. I would suggest you to read the Submitting Patches document (available in the Linux kernel source tree).

He is a maintainer so he can add tags when he picks this up.

It's a good practice to do so. Moreover, it's better to do it patch-by-patch, so tools like b4 can cope with tags for *anybody* who will use it in automated way.

Quoted 2 lines

This is not
really relevant here.

Quoted 7 lines

Why not?

Quoted 3 lines

Yes it should be good to include that but I have already
sended v4 which he has not tested. So I really cannot put this tag for him. So at the end he really should not even put it here.

For v4 I agree with you.

My answer doesn't contain Tested-by tag because author of patch already said that there will be next version of patch.
Thanks for Submitting Patches document suggestion.

Quoted 12 lines
Quoted 3 lines

Also usually the maintainers will always make their own tests and usually they will not even bother with a tested-by tag.

If it's their own code, yes, if it's others', why not? See above as well.

Quoted 3 lines

Or do you say to me that I
should go read Submitting Patches document as I'm the one who submit this?

It's always good to refresh memory, so why not? :-)