LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts
@ 2021-09-07 15:35 Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Kari Argillander
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

v3 link:
lore.kernel.org/ntfs3/20210829095614.50021-1-kari.argillander@gmail.com

This series will delete unnecessary mount options and rename some.
Also this will convert ntfs3 to use new mount api. In my opinion we
should get this in 5.15 because after that basically we have to have
deprecated flag with new mount options. Let's try to avoid that if
possible.

v4:
	- Rebased top of the current ntfs3/master
	- Rename mount option (no)acs_rules -> (no)acsrules
	- Fix acs commit message acl -> acs (Thank Pali)
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_acs_rules > (no)acsrules
  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                    | 498 +++++++++++++++-------------
 fs/ntfs3/xattr.c                    |   2 +-
 8 files changed, 290 insertions(+), 272 deletions(-)


base-commit: 2e3a51b59ea26544303e168de8a0479915f09aa3
-- 
2.25.1


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

* [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-08 19:10   ` Pali Rohár
  2021-09-07 15:35 ` [PATCH v4 2/9] fs/ntfs3: Remove unnecesarry remount flag handling Kari Argillander
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 Documentation/filesystems/ntfs3.rst | 4 ----
 fs/ntfs3/super.c                    | 7 -------
 2 files changed, 11 deletions(-)

diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
index ffe9ea0c1499..af7158de6fde 100644
--- a/Documentation/filesystems/ntfs3.rst
+++ b/Documentation/filesystems/ntfs3.rst
@@ -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
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 55bbc9200a10..a18b99a3e3b5 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -223,7 +223,6 @@ enum Opt {
 	Opt_nohidden,
 	Opt_showmeta,
 	Opt_acl,
-	Opt_noatime,
 	Opt_nls,
 	Opt_prealloc,
 	Opt_no_acs_rules,
@@ -242,7 +241,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" },
@@ -333,9 +331,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;
@@ -587,8 +582,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;
 }
-- 
2.25.1


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

* [PATCH v4 2/9] fs/ntfs3: Remove unnecesarry remount flag handling
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 3/9] fs/ntfs3: Convert mount options to pointer in sbi Kari Argillander
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/super.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index a18b99a3e3b5..6cb689605089 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -417,8 +417,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;
-- 
2.25.1


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

* [PATCH v4 3/9] fs/ntfs3: Convert mount options to pointer in sbi
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 2/9] fs/ntfs3: Remove unnecesarry remount flag handling Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 4/9] fs/ntfs3: Use new api for mounting Kari Argillander
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 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(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 34c4cbf7e29b..b1055b284c60 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -529,7 +529,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;
diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c
index 93f6d485564e..40440df021ef 100644
--- a/fs/ntfs3/dir.c
+++ b/fs/ntfs3/dir.c
@@ -24,7 +24,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));
 
@@ -186,7 +186,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));
@@ -301,10 +301,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,
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 424450e77ad5..fef57141b161 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -737,7 +737,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. */
@@ -1185,7 +1185,7 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
 	int err = 0;
 
 	/* If we are 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);
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index db2a5a4c38e4..9f740fd301b2 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -49,8 +49,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)
@@ -229,7 +229,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;
@@ -272,7 +272,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;
 
@@ -443,7 +443,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;
@@ -1244,7 +1244,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;
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 97e682ebcfb9..98c90c399ee2 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -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;
 };
 
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 6cb689605089..0f3820342051 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -389,11 +389,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;
 
@@ -409,7 +409,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;
@@ -422,8 +422,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);
@@ -506,7 +506,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);
 }
@@ -545,7 +546,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)
@@ -930,6 +931,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;
@@ -942,7 +949,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;
 
@@ -1074,7 +1081,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!");
@@ -1394,7 +1401,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;
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index b15d532e4a17..ac4b37bf8832 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -769,7 +769,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;
 	}
-- 
2.25.1


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

* [PATCH v4 4/9] fs/ntfs3: Use new api for mounting
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (2 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 3/9] fs/ntfs3: Convert mount options to pointer in sbi Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 5/9] fs/ntfs3: Init spi more in init_fs_context than fill_super Kari Argillander
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/ntfs_fs.h |   1 +
 fs/ntfs3/super.c   | 433 ++++++++++++++++++++++++---------------------
 2 files changed, 229 insertions(+), 205 deletions(-)

diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 98c90c399ee2..aa18f12b7096 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -52,6 +52,7 @@
 // clang-format on
 
 struct ntfs_mount_options {
+	char *nls_name;
 	struct nls_table *nls;
 
 	kuid_t fs_uid;
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 0f3820342051..befa78d3cb26 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -28,11 +28,12 @@
 #include <linux/buffer_head.h>
 #include <linux/exportfs.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 #include <linux/iversion.h>
 #include <linux/log2.h>
 #include <linux/module.h>
 #include <linux/nls.h>
-#include <linux/parser.h>
 #include <linux/seq_file.h>
 #include <linux/statfs.h>
 
@@ -205,9 +206,11 @@ void *ntfs_put_shared(void *ptr)
 	return ret;
 }
 
-static inline void clear_mount_options(struct ntfs_mount_options *options)
+static inline void put_mount_options(struct ntfs_mount_options *options)
 {
+	kfree(options->nls_name);
 	unload_nls(options->nls);
+	kfree(options);
 }
 
 enum Opt {
@@ -229,205 +232,171 @@ enum Opt {
 	Opt_err,
 };
 
-static const match_table_t ntfs_tokens = {
-	{ Opt_uid, "uid=%u" },
-	{ Opt_gid, "gid=%u" },
-	{ Opt_umask, "umask=%o" },
-	{ Opt_dmask, "dmask=%o" },
-	{ Opt_fmask, "fmask=%o" },
-	{ Opt_immutable, "sys_immutable" },
-	{ Opt_discard, "discard" },
-	{ Opt_force, "force" },
-	{ Opt_sparse, "sparse" },
-	{ Opt_nohidden, "nohidden" },
-	{ Opt_acl, "acl" },
-	{ Opt_showmeta, "showmeta" },
-	{ Opt_nls, "nls=%s" },
-	{ Opt_prealloc, "prealloc" },
-	{ Opt_no_acs_rules, "no_acs_rules" },
-	{ Opt_err, NULL },
+static const struct fs_parameter_spec ntfs_fs_parameters[] = {
+	fsparam_u32("uid",			Opt_uid),
+	fsparam_u32("gid",			Opt_gid),
+	fsparam_u32oct("umask",			Opt_umask),
+	fsparam_u32oct("dmask",			Opt_dmask),
+	fsparam_u32oct("fmask",			Opt_fmask),
+	fsparam_flag_no("sys_immutable",	Opt_immutable),
+	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("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),
+	{}
 };
 
-static noinline int ntfs_parse_options(struct super_block *sb, char *options,
-				       int silent,
-				       struct ntfs_mount_options *opts)
+/*
+ * Load nls table or if @nls is utf8 then return NULL.
+ */
+static struct nls_table *ntfs_load_nls(char *nls)
 {
-	char *p;
-	substring_t args[MAX_OPT_ARGS];
-	int option;
-	char nls_name[30];
-	struct nls_table *nls;
+	struct nls_table *ret;
 
-	opts->fs_uid = current_uid();
-	opts->fs_gid = current_gid();
-	opts->fs_fmask_inv = opts->fs_dmask_inv = ~current_umask();
-	nls_name[0] = 0;
+	if (!nls)
+		nls = CONFIG_NLS_DEFAULT;
 
-	if (!options)
-		goto out;
+	if (strcmp(nls, "utf8") == 0)
+		return NULL;
 
-	while ((p = strsep(&options, ","))) {
-		int token;
+	if (strcmp(nls, CONFIG_NLS_DEFAULT) == 0)
+		return load_nls_default();
 
-		if (!*p)
-			continue;
+	ret = load_nls(nls);
+	if (ret)
+		return ret;
 
-		token = match_token(p, ntfs_tokens, args);
-		switch (token) {
-		case Opt_immutable:
-			opts->sys_immutable = 1;
-			break;
-		case Opt_uid:
-			if (match_int(&args[0], &option))
-				return -EINVAL;
-			opts->fs_uid = make_kuid(current_user_ns(), option);
-			if (!uid_valid(opts->fs_uid))
-				return -EINVAL;
-			opts->uid = 1;
-			break;
-		case Opt_gid:
-			if (match_int(&args[0], &option))
-				return -EINVAL;
-			opts->fs_gid = make_kgid(current_user_ns(), option);
-			if (!gid_valid(opts->fs_gid))
-				return -EINVAL;
-			opts->gid = 1;
-			break;
-		case Opt_umask:
-			if (match_octal(&args[0], &option))
-				return -EINVAL;
-			opts->fs_fmask_inv = opts->fs_dmask_inv = ~option;
-			opts->fmask = opts->dmask = 1;
-			break;
-		case Opt_dmask:
-			if (match_octal(&args[0], &option))
-				return -EINVAL;
-			opts->fs_dmask_inv = ~option;
-			opts->dmask = 1;
-			break;
-		case Opt_fmask:
-			if (match_octal(&args[0], &option))
-				return -EINVAL;
-			opts->fs_fmask_inv = ~option;
-			opts->fmask = 1;
-			break;
-		case Opt_discard:
-			opts->discard = 1;
-			break;
-		case Opt_force:
-			opts->force = 1;
-			break;
-		case Opt_sparse:
-			opts->sparse = 1;
-			break;
-		case Opt_nohidden:
-			opts->nohidden = 1;
-			break;
-		case Opt_acl:
+	return ERR_PTR(-EINVAL);
+}
+
+static int ntfs_fs_parse_param(struct fs_context *fc,
+			       struct fs_parameter *param)
+{
+	struct ntfs_mount_options *opts = fc->fs_private;
+	struct fs_parse_result result;
+	int opt;
+
+	opt = fs_parse(fc, ntfs_fs_parameters, param, &result);
+	if (opt < 0)
+		return opt;
+
+	switch (opt) {
+	case Opt_uid:
+		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)
+			return invalf(fc, "ntfs3: Invalid value for umask.");
+		opts->fs_fmask_inv = ~result.uint_32;
+		opts->fs_dmask_inv = ~result.uint_32;
+		opts->fmask = 1;
+		opts->dmask = 1;
+		break;
+	case Opt_dmask:
+		if (result.uint_32 & ~07777)
+			return invalf(fc, "ntfs3: Invalid value for dmask.");
+		opts->fs_dmask_inv = ~result.uint_32;
+		opts->dmask = 1;
+		break;
+	case Opt_fmask:
+		if (result.uint_32 & ~07777)
+			return invalf(fc, "ntfs3: Invalid value for fmask.");
+		opts->fs_fmask_inv = ~result.uint_32;
+		opts->fmask = 1;
+		break;
+	case Opt_immutable:
+		opts->sys_immutable = result.negated ? 0 : 1;
+		break;
+	case Opt_discard:
+		opts->discard = result.negated ? 0 : 1;
+		break;
+	case Opt_force:
+		opts->force = result.negated ? 0 : 1;
+		break;
+	case Opt_sparse:
+		opts->sparse = result.negated ? 0 : 1;
+		break;
+	case Opt_nohidden:
+		opts->nohidden = 1;
+		break;
+	case Opt_acl:
+		if (!result.negated)
 #ifdef CONFIG_NTFS3_FS_POSIX_ACL
-			sb->s_flags |= SB_POSIXACL;
-			break;
+			fc->sb_flags |= SB_POSIXACL;
 #else
-			ntfs_err(sb, "support for ACL not compiled in!");
-			return -EINVAL;
+			return invalf(fc, "ntfs3: Support for ACL not compiled in!");
 #endif
-		case Opt_showmeta:
-			opts->showmeta = 1;
-			break;
-		case Opt_nls:
-			match_strlcpy(nls_name, &args[0], sizeof(nls_name));
-			break;
-		case Opt_prealloc:
-			opts->prealloc = 1;
-			break;
-		case Opt_no_acs_rules:
-			opts->no_acs_rules = 1;
-			break;
-		default:
-			if (!silent)
-				ntfs_err(
-					sb,
-					"Unrecognized mount option \"%s\" or missing value",
-					p);
-			//return -EINVAL;
-		}
-	}
-
-out:
-	if (!strcmp(nls_name[0] ? nls_name : CONFIG_NLS_DEFAULT, "utf8")) {
-		/*
-		 * For UTF-8 use utf16s_to_utf8s()/utf8s_to_utf16s()
-		 * instead of NLS.
-		 */
-		nls = NULL;
-	} else if (nls_name[0]) {
-		nls = load_nls(nls_name);
-		if (!nls) {
-			ntfs_err(sb, "failed to load \"%s\"", nls_name);
-			return -EINVAL;
-		}
-	} else {
-		nls = load_nls_default();
-		if (!nls) {
-			ntfs_err(sb, "failed to load default nls");
-			return -EINVAL;
-		}
+		else
+			fc->sb_flags &= ~SB_POSIXACL;
+		break;
+	case Opt_showmeta:
+		opts->showmeta = result.negated ? 0 : 1;
+		break;
+	case Opt_nls:
+		kfree(opts->nls_name);
+		opts->nls_name = param->string;
+		param->string = NULL;
+		break;
+	case Opt_prealloc:
+		opts->prealloc = result.negated ? 0 : 1;
+		break;
+	case Opt_no_acs_rules:
+		opts->no_acs_rules = 1;
+		break;
+	default:
+		/* Should not be here unless we forget add case. */
+		return -EINVAL;
 	}
-	opts->nls = nls;
-
 	return 0;
 }
 
-static int ntfs_remount(struct super_block *sb, int *flags, char *data)
+static int ntfs_fs_reconfigure(struct fs_context *fc)
 {
-	int err, ro_rw;
+	struct super_block *sb = fc->root->d_sb;
 	struct ntfs_sb_info *sbi = sb->s_fs_info;
-	struct ntfs_mount_options old_opts;
-	char *orig_data = kstrdup(data, GFP_KERNEL);
-
-	if (data && !orig_data)
-		return -ENOMEM;
-
-	/* Store  original 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);
-	if (err)
-		goto restore_opts;
+	struct ntfs_mount_options *new_opts = fc->fs_private;
+	int ro_rw;
 
-	ro_rw = sb_rdonly(sb) && !(*flags & SB_RDONLY);
+	ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY);
 	if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY)) {
-		ntfs_warn(
-			sb,
-			"Couldn't remount rw because journal is not replayed. Please umount/remount instead\n");
-		err = -EINVAL;
-		goto restore_opts;
+		errorf(fc, "ntfs3: Couldn't remount rw because journal is not replayed. Please umount/remount instead\n");
+		return -EINVAL;
+	}
+
+	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);
+		return -EINVAL;
 	}
+	if (new_opts->nls != sbi->options->nls)
+		return invalf(fc, "ntfs3: Cannot use different nls when remounting!");
 
 	sync_filesystem(sb);
 
 	if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) &&
-	    !sbi->options->force) {
-		ntfs_warn(sb, "volume is dirty and \"force\" flag is not set!");
-		err = -EINVAL;
-		goto restore_opts;
+	    !new_opts->force) {
+		errorf(fc, "ntfs3: Volume is dirty and \"force\" flag is not set!");
+		return -EINVAL;
 	}
 
-	clear_mount_options(&old_opts);
-
-	ntfs_info(sb, "re-mounted. Opts: %s", orig_data);
-	err = 0;
-	goto out;
-
-restore_opts:
-	clear_mount_options(sbi->options);
-	memcpy(sbi->options, &old_opts, sizeof(old_opts));
+	memcpy(sbi->options, new_opts, sizeof(*new_opts));
 
-out:
-	kfree(orig_data);
-	return err;
+	return 0;
 }
 
 static struct kmem_cache *ntfs_inode_cachep;
@@ -506,9 +475,6 @@ 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);
-	kfree(sbi->options);
-
 	kfree(sbi);
 }
 
@@ -519,7 +485,9 @@ static void ntfs_put_super(struct super_block *sb)
 	/* Mark rw ntfs as clear, if possible. */
 	ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
 
+	put_mount_options(sbi->options);
 	put_ntfs(sbi);
+	sb->s_fs_info = NULL;
 
 	sync_blockdev(sb->s_bdev);
 }
@@ -635,7 +603,6 @@ static const struct super_operations ntfs_sops = {
 	.statfs = ntfs_statfs,
 	.show_options = ntfs_show_options,
 	.sync_fs = ntfs_sync_fs,
-	.remount_fs = ntfs_remount,
 	.write_inode = ntfs3_write_inode,
 };
 
@@ -905,10 +872,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
 /*
  * ntfs_fill_super - Try to mount.
  */
-static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
+static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	int err;
-	struct ntfs_sb_info *sbi;
+	struct ntfs_sb_info *sbi = sb->s_fs_info;
 	struct block_device *bdev = sb->s_bdev;
 	struct inode *bd_inode = bdev->bd_inode;
 	struct request_queue *rq = bdev_get_queue(bdev);
@@ -927,17 +894,6 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
 	ref.high = 0;
 
-	sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
-	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;
 	sb->s_magic = 0x7366746e; // "ntfs"
@@ -949,9 +905,12 @@ 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);
-	if (err)
-		goto out;
+	sbi->options->nls = ntfs_load_nls(sbi->options->nls_name);
+	if (IS_ERR(sbi->options->nls)) {
+		sbi->options->nls = NULL;
+		errorf(fc, "Cannot load nls %s", sbi->options->nls_name);
+		return -EINVAL;
+	}
 
 	if (!rq || !blk_queue_discard(rq) || !rq->limits.discard_granularity) {
 		;
@@ -1344,6 +1303,9 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 		goto out;
 	}
 
+	fc->fs_private = NULL;
+	fc->s_fs_info = NULL;
+
 	return 0;
 
 out:
@@ -1354,9 +1316,6 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 		sb->s_root = NULL;
 	}
 
-	put_ntfs(sbi);
-
-	sb->s_fs_info = NULL;
 	return err;
 }
 
@@ -1426,19 +1385,83 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len)
 	return err;
 }
 
-static struct dentry *ntfs_mount(struct file_system_type *fs_type, int flags,
-				 const char *dev_name, void *data)
+static int ntfs_fs_get_tree(struct fs_context *fc)
+{
+	return get_tree_bdev(fc, ntfs_fill_super);
+}
+
+/*
+ * ntfs_fs_free - Free fs_context.
+ *
+ * Note that this will be called after fill_super and reconfigure
+ * even when they pass. So they have to take pointers if they pass.
+ */
+static void ntfs_fs_free(struct fs_context *fc)
+{
+	struct ntfs_mount_options *opts = fc->fs_private;
+	struct ntfs_sb_info *sbi = fc->s_fs_info;
+
+	if (sbi)
+		put_ntfs(sbi);
+
+	if (opts)
+		put_mount_options(opts);
+}
+
+static const struct fs_context_operations ntfs_context_ops = {
+	.parse_param	= ntfs_fs_parse_param,
+	.get_tree	= ntfs_fs_get_tree,
+	.reconfigure	= ntfs_fs_reconfigure,
+	.free		= ntfs_fs_free,
+};
+
+/*
+ * ntfs_init_fs_context - Initialize spi and opts
+ *
+ * This will called when mount/remount. We will first initiliaze
+ * options so that if remount we can use just that.
+ */
+static int ntfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_bdev(fs_type, flags, dev_name, data, ntfs_fill_super);
+	struct ntfs_mount_options *opts;
+	struct ntfs_sb_info *sbi;
+
+	opts = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS);
+	if (!opts)
+		return -ENOMEM;
+
+	/* Default options. */
+	opts->fs_uid = current_uid();
+	opts->fs_gid = current_gid();
+	opts->fs_fmask_inv = ~current_umask();
+	opts->fs_dmask_inv = ~current_umask();
+
+	if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
+		goto ok;
+
+	sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
+	if (!sbi) {
+		kfree(opts);
+		return -ENOMEM;
+	}
+
+	sbi->options = opts;
+	fc->s_fs_info = sbi;
+ok:
+	fc->fs_private = opts;
+	fc->ops = &ntfs_context_ops;
+
+	return 0;
 }
 
 // clang-format off
 static struct file_system_type ntfs_fs_type = {
-	.owner		= THIS_MODULE,
-	.name		= "ntfs3",
-	.mount		= ntfs_mount,
-	.kill_sb	= kill_block_super,
-	.fs_flags	= FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
+	.owner			= THIS_MODULE,
+	.name			= "ntfs3",
+	.init_fs_context	= ntfs_init_fs_context,
+	.parameters		= ntfs_fs_parameters,
+	.kill_sb		= kill_block_super,
+	.fs_flags		= FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
 };
 // clang-format on
 
-- 
2.25.1


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

* [PATCH v4 5/9] fs/ntfs3: Init spi more in init_fs_context than fill_super
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (3 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 4/9] fs/ntfs3: Use new api for mounting Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal Kari Argillander
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/super.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index befa78d3cb26..420cd1409170 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -887,7 +887,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;
@@ -902,9 +902,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;
@@ -934,12 +931,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'.
@@ -1224,11 +1215,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;
@@ -1440,10 +1427,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;
@@ -1452,6 +1450,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
-- 
2.25.1


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

* [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (4 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 5/9] fs/ntfs3: Init spi more in init_fs_context than fill_super Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-08 19:11   ` Pali Rohár
  2021-09-07 15:35 ` [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls= Kari Argillander
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 420cd1409170..729ead6f2fac 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -242,7 +242,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),
@@ -331,7 +331,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)
-- 
2.25.1


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

* [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (5 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-08 19:09   ` Pali Rohár
  2021-09-07 15:35 ` [PATCH v4 8/9] fs/ntfs3: Rename mount option no_acs_rules > (no)acsrules Kari Argillander
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 Documentation/filesystems/ntfs3.rst |  4 ++--
 fs/ntfs3/super.c                    | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
index af7158de6fde..ded706474825 100644
--- a/Documentation/filesystems/ntfs3.rst
+++ b/Documentation/filesystems/ntfs3.rst
@@ -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=
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 729ead6f2fac..503e2e23f711 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -226,7 +226,7 @@ enum Opt {
 	Opt_nohidden,
 	Opt_showmeta,
 	Opt_acl,
-	Opt_nls,
+	Opt_iocharset,
 	Opt_prealloc,
 	Opt_no_acs_rules,
 	Opt_err,
@@ -245,9 +245,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),
 	{}
 };
 
@@ -346,7 +350,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;
@@ -380,11 +384,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);
 
@@ -528,9 +532,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)
-- 
2.25.1


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

* [PATCH v4 8/9] fs/ntfs3: Rename mount option no_acs_rules > (no)acsrules
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (6 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls= Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-07 15:35 ` [PATCH v4 9/9] fs/ntfs3: Show uid/gid always in show_options() Kari Argillander
  2021-09-09 16:39 ` [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Konstantin Komarov
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

Rename mount option no_acs_rules to (no)acsrules. This allow us to use
possibility to mount with options noaclrules or aclrules.

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 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(-)

diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
index ded706474825..7b6afe452197 100644
--- a/Documentation/filesystems/ntfs3.rst
+++ b/Documentation/filesystems/ntfs3.rst
@@ -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
+noacsrules		"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
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index fef57141b161..0743d806c567 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -737,7 +737,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->noacsrules) {
 		/* "No access rules" - Force any changes of time etc. */
 		attr->ia_valid |= ATTR_FORCE;
 		/* and disable for editing some attributes. */
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index aa18f12b7096..15bab48bc1ad 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -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. */
+		noacsrules : 1, /*Exclude acs rules. */
 		prealloc : 1 /* Preallocate space when file is growing. */
 		;
 };
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 503e2e23f711..0690e7e4f00d 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -228,7 +228,7 @@ enum Opt {
 	Opt_acl,
 	Opt_iocharset,
 	Opt_prealloc,
-	Opt_no_acs_rules,
+	Opt_noacsrules,
 	Opt_err,
 };
 
@@ -246,7 +246,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("acsrules",		Opt_noacsrules),
 	fsparam_string("iocharset",		Opt_iocharset),
 
 	__fsparam(fs_param_is_string,
@@ -358,8 +358,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_noacsrules:
+		opts->noacsrules = result.negated ? 1 : 0;
 		break;
 	default:
 		/* Should not be here unless we forget add case. */
@@ -547,8 +547,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->noacsrules)
+		seq_puts(m, ",noacsrules");
 	if (opts->prealloc)
 		seq_puts(m, ",prealloc");
 	if (sb->s_flags & SB_POSIXACL)
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index ac4b37bf8832..6f88cb77a17f 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -769,7 +769,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->noacsrules) {
 		/* "No access rules" mode - Allow all changes. */
 		return 0;
 	}
-- 
2.25.1


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

* [PATCH v4 9/9] fs/ntfs3: Show uid/gid always in show_options()
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (7 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 8/9] fs/ntfs3: Rename mount option no_acs_rules > (no)acsrules Kari Argillander
@ 2021-09-07 15:35 ` Kari Argillander
  2021-09-09 16:39 ` [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Konstantin Komarov
  9 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-09-07 15:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3
  Cc: Kari Argillander, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Pali Rohár, Matthew Wilcox, Christian Brauner

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.

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/ntfs_fs.h | 23 ++++++++++-------------
 fs/ntfs3/super.c   | 12 ++++--------
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 15bab48bc1ad..372cda697dd4 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -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. */
-		noacsrules : 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 noacsrules : 1; /* Exclude acs rules. */
+	unsigned prealloc : 1; /* Preallocate space when file is growing. */
 };
 
 /* Special value to unpack and deallocate. */
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 0690e7e4f00d..3cba0b5e7ac7 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -294,13 +294,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)
@@ -521,12 +519,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)
-- 
2.25.1


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

* Re: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-09-07 15:35 ` [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls= Kari Argillander
@ 2021-09-08 19:09   ` Pali Rohár
  2021-10-09 11:42     ` Pali Rohár
  0 siblings, 1 reply; 18+ messages in thread
From: Pali Rohár @ 2021-09-08 19:09 UTC (permalink / raw)
  To: Kari Argillander
  Cc: Konstantin Komarov, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner

On Tuesday 07 September 2021 18:35:55 Kari Argillander wrote:
> 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.
> 
> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  Documentation/filesystems/ntfs3.rst |  4 ++--
>  fs/ntfs3/super.c                    | 18 +++++++++++-------
>  2 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
> index af7158de6fde..ded706474825 100644
> --- a/Documentation/filesystems/ntfs3.rst
> +++ b/Documentation/filesystems/ntfs3.rst
> @@ -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=
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 729ead6f2fac..503e2e23f711 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -226,7 +226,7 @@ enum Opt {
>  	Opt_nohidden,
>  	Opt_showmeta,
>  	Opt_acl,
> -	Opt_nls,
> +	Opt_iocharset,
>  	Opt_prealloc,
>  	Opt_no_acs_rules,
>  	Opt_err,
> @@ -245,9 +245,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),
>  	{}
>  };
>  
> @@ -346,7 +350,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;
> @@ -380,11 +384,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);
>  
> @@ -528,9 +532,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)
> -- 
> 2.25.1
> 

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

* Re: [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime
  2021-09-07 15:35 ` [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Kari Argillander
@ 2021-09-08 19:10   ` Pali Rohár
  0 siblings, 0 replies; 18+ messages in thread
From: Pali Rohár @ 2021-09-08 19:10 UTC (permalink / raw)
  To: Kari Argillander
  Cc: Konstantin Komarov, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner

On Tuesday 07 September 2021 18:35:49 Kari Argillander wrote:
> Remove unnecesarry mount option noatime because this will be handled
> by VFS. Our option parser will never get opt like this.
> 
> Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  Documentation/filesystems/ntfs3.rst | 4 ----
>  fs/ntfs3/super.c                    | 7 -------
>  2 files changed, 11 deletions(-)
> 
> diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
> index ffe9ea0c1499..af7158de6fde 100644
> --- a/Documentation/filesystems/ntfs3.rst
> +++ b/Documentation/filesystems/ntfs3.rst
> @@ -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
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 55bbc9200a10..a18b99a3e3b5 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -223,7 +223,6 @@ enum Opt {
>  	Opt_nohidden,
>  	Opt_showmeta,
>  	Opt_acl,
> -	Opt_noatime,
>  	Opt_nls,
>  	Opt_prealloc,
>  	Opt_no_acs_rules,
> @@ -242,7 +241,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" },
> @@ -333,9 +331,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;
> @@ -587,8 +582,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;
>  }
> -- 
> 2.25.1
> 

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

* Re: [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal
  2021-09-07 15:35 ` [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal Kari Argillander
@ 2021-09-08 19:11   ` Pali Rohár
  0 siblings, 0 replies; 18+ messages in thread
From: Pali Rohár @ 2021-09-08 19:11 UTC (permalink / raw)
  To: Kari Argillander
  Cc: Konstantin Komarov, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner

On Tuesday 07 September 2021 18:35:54 Kari Argillander wrote:
> 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.
> 
> Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  fs/ntfs3/super.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 420cd1409170..729ead6f2fac 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -242,7 +242,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),
> @@ -331,7 +331,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)
> -- 
> 2.25.1
> 

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

* Re: [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts
  2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
                   ` (8 preceding siblings ...)
  2021-09-07 15:35 ` [PATCH v4 9/9] fs/ntfs3: Show uid/gid always in show_options() Kari Argillander
@ 2021-09-09 16:39 ` Konstantin Komarov
  9 siblings, 0 replies; 18+ messages in thread
From: Konstantin Komarov @ 2021-09-09 16:39 UTC (permalink / raw)
  To: Kari Argillander, ntfs3
  Cc: Christoph Hellwig, linux-kernel, linux-fsdevel, Pali Rohár,
	Matthew Wilcox, Christian Brauner



On 07.09.2021 18:35, Kari Argillander wrote:
> v3 link:
> lore.kernel.org/ntfs3/20210829095614.50021-1-kari.argillander@gmail.com
> 
> This series will delete unnecessary mount options and rename some.
> Also this will convert ntfs3 to use new mount api. In my opinion we
> should get this in 5.15 because after that basically we have to have
> deprecated flag with new mount options. Let's try to avoid that if
> possible.
> 
> v4:
> 	- Rebased top of the current ntfs3/master
> 	- Rename mount option (no)acs_rules -> (no)acsrules
> 	- Fix acs commit message acl -> acs (Thank Pali)
> 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_acs_rules > (no)acsrules
>   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                    | 498 +++++++++++++++-------------
>  fs/ntfs3/xattr.c                    |   2 +-
>  8 files changed, 290 insertions(+), 272 deletions(-)
> 
> 
> base-commit: 2e3a51b59ea26544303e168de8a0479915f09aa3
> 

Applied, thanks for patches and review!

Best regards,
Konstantin

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

* Re: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-09-08 19:09   ` Pali Rohár
@ 2021-10-09 11:42     ` Pali Rohár
  2021-10-09 14:33       ` Kari Argillander
  0 siblings, 1 reply; 18+ messages in thread
From: Pali Rohár @ 2021-10-09 11:42 UTC (permalink / raw)
  To: Kari Argillander
  Cc: Konstantin Komarov, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner

Hello!

This patch have not been applied yet:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ntfs3/super.c#n247

What happened that in upstream tree is still only nls= option and not
this iocharset=?

On Wednesday 08 September 2021 21:09:38 Pali Rohár wrote:
> On Tuesday 07 September 2021 18:35:55 Kari Argillander wrote:
> > 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.
> > 
> > Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
> 
> Reviewed-by: Pali Rohár <pali@kernel.org>
> 
> > ---
> >  Documentation/filesystems/ntfs3.rst |  4 ++--
> >  fs/ntfs3/super.c                    | 18 +++++++++++-------
> >  2 files changed, 13 insertions(+), 9 deletions(-)
> > 
> > diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
> > index af7158de6fde..ded706474825 100644
> > --- a/Documentation/filesystems/ntfs3.rst
> > +++ b/Documentation/filesystems/ntfs3.rst
> > @@ -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=
> > diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> > index 729ead6f2fac..503e2e23f711 100644
> > --- a/fs/ntfs3/super.c
> > +++ b/fs/ntfs3/super.c
> > @@ -226,7 +226,7 @@ enum Opt {
> >  	Opt_nohidden,
> >  	Opt_showmeta,
> >  	Opt_acl,
> > -	Opt_nls,
> > +	Opt_iocharset,
> >  	Opt_prealloc,
> >  	Opt_no_acs_rules,
> >  	Opt_err,
> > @@ -245,9 +245,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),
> >  	{}
> >  };
> >  
> > @@ -346,7 +350,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;
> > @@ -380,11 +384,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);
> >  
> > @@ -528,9 +532,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)
> > -- 
> > 2.25.1
> > 

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

* Re: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-10-09 11:42     ` Pali Rohár
@ 2021-10-09 14:33       ` Kari Argillander
  2021-10-11 17:14         ` Konstantin Komarov
  0 siblings, 1 reply; 18+ messages in thread
From: Kari Argillander @ 2021-10-09 14:33 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Konstantin Komarov, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner, torvalds

Choose to add Linus to CC so that he also knows whats coming.

On Sat, Oct 09, 2021 at 01:42:52PM +0200, Pali Rohár wrote:
> Hello!
> 
> This patch have not been applied yet:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ntfs3/super.c#n247
> 
> What happened that in upstream tree is still only nls= option and not
> this iocharset=?

Very valid question. For some reason Konstantin has not sended pr to
Linus. I have also address my concern that pr is not yet sended and he
will make very massive "patch dumb" to rc6/rc7. See thread [1]. There is
about 50-70 patch already which he will send to rc6/rc7. I have get also
impression that patches which are not yet even applied to ntfs3 tree [2]
will be also sended to rc6/rc7. There is lot of refactoring and new
algorithms which imo are not rc material. I have sended many message to
Konstantin about this topic, but basically ignored.

Basically we do not have anything for next merge window and every patch
will be sended for 5.15.

[1] lore.kernel.org/lkml/20210925082823.fo2wm62xlcexhwvi@kari-VirtualBox
[2] https://github.com/Paragon-Software-Group/linux-ntfs3/commits/master

  Argillander

> 
> On Wednesday 08 September 2021 21:09:38 Pali Rohár wrote:
> > On Tuesday 07 September 2021 18:35:55 Kari Argillander wrote:
> > > 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.
> > > 
> > > Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
> > 
> > Reviewed-by: Pali Rohár <pali@kernel.org>
> > 
> > > ---
> > >  Documentation/filesystems/ntfs3.rst |  4 ++--
> > >  fs/ntfs3/super.c                    | 18 +++++++++++-------
> > >  2 files changed, 13 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
> > > index af7158de6fde..ded706474825 100644
> > > --- a/Documentation/filesystems/ntfs3.rst
> > > +++ b/Documentation/filesystems/ntfs3.rst
> > > @@ -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=
> > > diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> > > index 729ead6f2fac..503e2e23f711 100644
> > > --- a/fs/ntfs3/super.c
> > > +++ b/fs/ntfs3/super.c
> > > @@ -226,7 +226,7 @@ enum Opt {
> > >  	Opt_nohidden,
> > >  	Opt_showmeta,
> > >  	Opt_acl,
> > > -	Opt_nls,
> > > +	Opt_iocharset,
> > >  	Opt_prealloc,
> > >  	Opt_no_acs_rules,
> > >  	Opt_err,
> > > @@ -245,9 +245,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),
> > >  	{}
> > >  };
> > >  
> > > @@ -346,7 +350,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;
> > > @@ -380,11 +384,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);
> > >  
> > > @@ -528,9 +532,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)
> > > -- 
> > > 2.25.1
> > > 

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

* Re: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-10-09 14:33       ` Kari Argillander
@ 2021-10-11 17:14         ` Konstantin Komarov
  2021-10-11 22:05           ` Kari Argillander
  0 siblings, 1 reply; 18+ messages in thread
From: Konstantin Komarov @ 2021-10-11 17:14 UTC (permalink / raw)
  To: Kari Argillander, Pali Rohár
  Cc: ntfs3, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Matthew Wilcox, Christian Brauner, torvalds



On 09.10.2021 17:33, Kari Argillander wrote:
> Choose to add Linus to CC so that he also knows whats coming.
> 
> On Sat, Oct 09, 2021 at 01:42:52PM +0200, Pali Rohár wrote:
>> Hello!
>>
>> This patch have not been applied yet:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ntfs3/super.c#n247
>>
>> What happened that in upstream tree is still only nls= option and not
>> this iocharset=?
> 
> Very valid question. For some reason Konstantin has not sended pr to
> Linus. I have also address my concern that pr is not yet sended and he
> will make very massive "patch dumb" to rc6/rc7. See thread [1]. There is
> about 50-70 patch already which he will send to rc6/rc7. I have get also
> impression that patches which are not yet even applied to ntfs3 tree [2]
> will be also sended to rc6/rc7. There is lot of refactoring and new
> algorithms which imo are not rc material. I have sended many message to
> Konstantin about this topic, but basically ignored.
> 
> Basically we do not have anything for next merge window and every patch
> will be sended for 5.15.
> 
> [1] lore.kernel.org/lkml/20210925082823.fo2wm62xlcexhwvi@kari-VirtualBox
> [2] https://github.com/Paragon-Software-Group/linux-ntfs3/commits/master
> 
>   Argillander
> 

Hello.

I was planning to send pull request on Friday 08.10.
But there is still one panic, that wasn't resolved [1].
It seems to be tricky, so I'll be content even with quick band-aid [2].
After confirming, that it works, I plan on sending pull request.
I don't want for this panic to remain in 5.15.

[1]: https://lore.kernel.org/ntfs3/f9de5807-2311-7374-afb0-bc5dffb522c0@gmail.com/
[2]: https://lore.kernel.org/ntfs3/7e5b8dc9-9989-0e8a-9e8d-ae26b6e74df4@paragon-software.com/

>>
>> On Wednesday 08 September 2021 21:09:38 Pali Rohár wrote:
>>> On Tuesday 07 September 2021 18:35:55 Kari Argillander wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
>>>
>>> Reviewed-by: Pali Rohár <pali@kernel.org>
>>>
>>>> ---
>>>>  Documentation/filesystems/ntfs3.rst |  4 ++--
>>>>  fs/ntfs3/super.c                    | 18 +++++++++++-------
>>>>  2 files changed, 13 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
>>>> index af7158de6fde..ded706474825 100644
>>>> --- a/Documentation/filesystems/ntfs3.rst
>>>> +++ b/Documentation/filesystems/ntfs3.rst
>>>> @@ -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=
>>>> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
>>>> index 729ead6f2fac..503e2e23f711 100644
>>>> --- a/fs/ntfs3/super.c
>>>> +++ b/fs/ntfs3/super.c
>>>> @@ -226,7 +226,7 @@ enum Opt {
>>>>  	Opt_nohidden,
>>>>  	Opt_showmeta,
>>>>  	Opt_acl,
>>>> -	Opt_nls,
>>>> +	Opt_iocharset,
>>>>  	Opt_prealloc,
>>>>  	Opt_no_acs_rules,
>>>>  	Opt_err,
>>>> @@ -245,9 +245,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),
>>>>  	{}
>>>>  };
>>>>  
>>>> @@ -346,7 +350,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;
>>>> @@ -380,11 +384,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);
>>>>  
>>>> @@ -528,9 +532,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)
>>>> -- 
>>>> 2.25.1
>>>>

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

* Re: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls=
  2021-10-11 17:14         ` Konstantin Komarov
@ 2021-10-11 22:05           ` Kari Argillander
  0 siblings, 0 replies; 18+ messages in thread
From: Kari Argillander @ 2021-10-11 22:05 UTC (permalink / raw)
  To: Konstantin Komarov
  Cc: Pali Rohár, ntfs3, Christoph Hellwig, linux-kernel,
	linux-fsdevel, Matthew Wilcox, Christian Brauner, torvalds

On Mon, Oct 11, 2021 at 08:14:28PM +0300, Konstantin Komarov wrote:
> 
> 
> On 09.10.2021 17:33, Kari Argillander wrote:
> > Choose to add Linus to CC so that he also knows whats coming.
> > 
> > On Sat, Oct 09, 2021 at 01:42:52PM +0200, Pali Rohár wrote:
> >> Hello!
> >>
> >> This patch have not been applied yet:
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ntfs3/super.c#n247
> >>
> >> What happened that in upstream tree is still only nls= option and not
> >> this iocharset=?
> > 
> > Very valid question. For some reason Konstantin has not sended pr to
> > Linus. I have also address my concern that pr is not yet sended and he
> > will make very massive "patch dumb" to rc6/rc7. See thread [1]. There is
> > about 50-70 patch already which he will send to rc6/rc7. I have get also
> > impression that patches which are not yet even applied to ntfs3 tree [2]
> > will be also sended to rc6/rc7. There is lot of refactoring and new
> > algorithms which imo are not rc material. I have sended many message to
> > Konstantin about this topic, but basically ignored.
> > 
> > Basically we do not have anything for next merge window and every patch
> > will be sended for 5.15.
> > 
> > [1] lore.kernel.org/lkml/20210925082823.fo2wm62xlcexhwvi@kari-VirtualBox
> > [2] https://github.com/Paragon-Software-Group/linux-ntfs3/commits/master
> > 
> >   Argillander
> > 
> 
> Hello.
> 
> I was planning to send pull request on Friday 08.10.
> But there is still one panic, that wasn't resolved [1].
> It seems to be tricky, so I'll be content even with quick band-aid [2].
> After confirming, that it works, I plan on sending pull request.
> I don't want for this panic to remain in 5.15.

Of course we won't want panic to remain 5.15, but that does not mean you
can't send pr for other patches. You can still send other pr later for
other rc's. If you will send pr late it might be that Linus will not
apply any of them because it will be too big pr for late rc. I'm sure he
will be resonable in first time because ntfs3 is new driver and will
accept pr in this case, but this cannot come habbit.

Normally rc cycle is for this kind of things. We fix things we broke
during merge window, but right now it is real danger that we introduce
many bugs because people cannot test ntfs3 because you hold on patches.
They belong to also to Linus tree not just to linux-next. Many user use
Linus tree and there are many who send good bug reports.

But do not take this too harsh. I'm just personally worried here. Also I
think you as maintainer had improved well in short time.

> [1]: https://lore.kernel.org/ntfs3/f9de5807-2311-7374-afb0-bc5dffb522c0@gmail.com/
> [2]: https://lore.kernel.org/ntfs3/7e5b8dc9-9989-0e8a-9e8d-ae26b6e74df4@paragon-software.com/
> 
> >>
> >> On Wednesday 08 September 2021 21:09:38 Pali Rohár wrote:
> >>> On Tuesday 07 September 2021 18:35:55 Kari Argillander wrote:
> >>>> 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.
> >>>>
> >>>> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
> >>>
> >>> Reviewed-by: Pali Rohár <pali@kernel.org>
> >>>
> >>>> ---
> >>>>  Documentation/filesystems/ntfs3.rst |  4 ++--
> >>>>  fs/ntfs3/super.c                    | 18 +++++++++++-------
> >>>>  2 files changed, 13 insertions(+), 9 deletions(-)
> >>>>
> >>>> diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst
> >>>> index af7158de6fde..ded706474825 100644
> >>>> --- a/Documentation/filesystems/ntfs3.rst
> >>>> +++ b/Documentation/filesystems/ntfs3.rst
> >>>> @@ -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=
> >>>> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> >>>> index 729ead6f2fac..503e2e23f711 100644
> >>>> --- a/fs/ntfs3/super.c
> >>>> +++ b/fs/ntfs3/super.c
> >>>> @@ -226,7 +226,7 @@ enum Opt {
> >>>>  	Opt_nohidden,
> >>>>  	Opt_showmeta,
> >>>>  	Opt_acl,
> >>>> -	Opt_nls,
> >>>> +	Opt_iocharset,
> >>>>  	Opt_prealloc,
> >>>>  	Opt_no_acs_rules,
> >>>>  	Opt_err,
> >>>> @@ -245,9 +245,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),
> >>>>  	{}
> >>>>  };
> >>>>  
> >>>> @@ -346,7 +350,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;
> >>>> @@ -380,11 +384,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);
> >>>>  
> >>>> @@ -528,9 +532,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)
> >>>> -- 
> >>>> 2.25.1
> >>>>

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

end of thread, other threads:[~2021-10-11 22:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 15:35 [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Kari Argillander
2021-09-07 15:35 ` [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Kari Argillander
2021-09-08 19:10   ` Pali Rohár
2021-09-07 15:35 ` [PATCH v4 2/9] fs/ntfs3: Remove unnecesarry remount flag handling Kari Argillander
2021-09-07 15:35 ` [PATCH v4 3/9] fs/ntfs3: Convert mount options to pointer in sbi Kari Argillander
2021-09-07 15:35 ` [PATCH v4 4/9] fs/ntfs3: Use new api for mounting Kari Argillander
2021-09-07 15:35 ` [PATCH v4 5/9] fs/ntfs3: Init spi more in init_fs_context than fill_super Kari Argillander
2021-09-07 15:35 ` [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal Kari Argillander
2021-09-08 19:11   ` Pali Rohár
2021-09-07 15:35 ` [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls= Kari Argillander
2021-09-08 19:09   ` Pali Rohár
2021-10-09 11:42     ` Pali Rohár
2021-10-09 14:33       ` Kari Argillander
2021-10-11 17:14         ` Konstantin Komarov
2021-10-11 22:05           ` Kari Argillander
2021-09-07 15:35 ` [PATCH v4 8/9] fs/ntfs3: Rename mount option no_acs_rules > (no)acsrules Kari Argillander
2021-09-07 15:35 ` [PATCH v4 9/9] fs/ntfs3: Show uid/gid always in show_options() Kari Argillander
2021-09-09 16:39 ` [PATCH v4 0/9] fs/ntfs3: Use new mount api and change some opts Konstantin Komarov

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