All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 06/17] ext4: move quota configuration out of handle_mount_opt()
@ 2020-05-09  0:57 kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2020-05-09  0:57 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6724 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200428164536.462-7-lczerner@redhat.com>
References: <20200428164536.462-7-lczerner@redhat.com>
TO: Lukas Czerner <lczerner@redhat.com>
TO: linux-ext4(a)vger.kernel.org
CC: dhowells(a)redhat.com
CC: viro(a)zeniv.linux.org.uk

Hi Lukas,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linus/master v5.7-rc4 next-20200508]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Lukas-Czerner/ext4-new-mount-API-conversion/20200429-050951
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
reproduce:
        # apt-get install sparse
        # sparse version: 
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
:::::: branch date: 10 days ago
:::::: commit date: 10 days ago

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

   fs/ext4/super.c:2364:51: sparse: warning: incorrect type in argument 1 (different address spaces)
>> fs/ext4/super.c:2364:51: sparse:    expected char const *cs
   fs/ext4/super.c:2364:51: sparse:    got char [noderef] <asn:4> *
   fs/ext4/super.c:2332:38: sparse: warning: incorrect type in argument 1 (different address spaces)
   fs/ext4/super.c:2332:38: sparse:    expected void const *
   fs/ext4/super.c:2332:38: sparse:    got char [noderef] <asn:4> *

# https://github.com/0day-ci/linux/commit/9c038e70e9f6fa282da120a8796f43eed7be1384
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 9c038e70e9f6fa282da120a8796f43eed7be1384
vim +2364 fs/ext4/super.c

9c038e70e9f6fa Lukas Czerner 2020-04-28  2338  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2339  /*
9c038e70e9f6fa Lukas Czerner 2020-04-28  2340   * Check quota settings consistency.
9c038e70e9f6fa Lukas Czerner 2020-04-28  2341   */
9c038e70e9f6fa Lukas Czerner 2020-04-28  2342  static int ext4_check_quota_consistency(struct fs_context *fc,
9c038e70e9f6fa Lukas Czerner 2020-04-28  2343  					struct super_block *sb)
9c038e70e9f6fa Lukas Czerner 2020-04-28  2344  {
9c038e70e9f6fa Lukas Czerner 2020-04-28  2345  #ifdef CONFIG_QUOTA
9c038e70e9f6fa Lukas Czerner 2020-04-28  2346  	struct ext4_fs_context *ctx = fc->fs_private;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2347  	struct ext4_sb_info *sbi = EXT4_SB(sb);
9c038e70e9f6fa Lukas Czerner 2020-04-28  2348  	bool quota_feature = ext4_has_feature_quota(sb);
9c038e70e9f6fa Lukas Czerner 2020-04-28  2349  	bool quota_loaded = sb_any_quota_loaded(sb);
9c038e70e9f6fa Lukas Czerner 2020-04-28  2350  	int i;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2351  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2352  	if (ctx->qname_spec && quota_loaded) {
9c038e70e9f6fa Lukas Czerner 2020-04-28  2353  		if (quota_feature)
9c038e70e9f6fa Lukas Czerner 2020-04-28  2354  			goto err_feature;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2355  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2356  		for (i = 0; i < EXT4_MAXQUOTAS; i++) {
9c038e70e9f6fa Lukas Czerner 2020-04-28  2357  			if (!(ctx->qname_spec & (1 << i)))
9c038e70e9f6fa Lukas Czerner 2020-04-28  2358  				continue;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2359  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2360  			if (!!sbi->s_qf_names[i] != !!ctx->s_qf_names[i])
9c038e70e9f6fa Lukas Czerner 2020-04-28  2361  				goto err_jquota_change;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2362  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2363  			if (sbi->s_qf_names[i] && ctx->s_qf_names[i] &&
9c038e70e9f6fa Lukas Czerner 2020-04-28 @2364  			    strcmp(sbi->s_qf_names[i],
9c038e70e9f6fa Lukas Czerner 2020-04-28  2365  				   ctx->s_qf_names[i]) != 0)
9c038e70e9f6fa Lukas Czerner 2020-04-28  2366  				goto err_jquota_specified;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2367  		}
9c038e70e9f6fa Lukas Czerner 2020-04-28  2368  	}
9c038e70e9f6fa Lukas Czerner 2020-04-28  2369  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2370  	if (ctx->s_jquota_fmt) {
9c038e70e9f6fa Lukas Czerner 2020-04-28  2371  		if (sbi->s_jquota_fmt != ctx->s_jquota_fmt && quota_loaded)
9c038e70e9f6fa Lukas Czerner 2020-04-28  2372  			goto err_quota_change;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2373  		if (quota_feature) {
9c038e70e9f6fa Lukas Czerner 2020-04-28  2374  			ext4_msg(NULL, KERN_INFO, "Quota format mount options "
9c038e70e9f6fa Lukas Czerner 2020-04-28  2375  				 "ignored when QUOTA feature is enabled");
9c038e70e9f6fa Lukas Czerner 2020-04-28  2376  			return 0;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2377  		}
9c038e70e9f6fa Lukas Czerner 2020-04-28  2378  	}
9c038e70e9f6fa Lukas Czerner 2020-04-28  2379  	return 0;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2380  
9c038e70e9f6fa Lukas Czerner 2020-04-28  2381  err_quota_change:
9c038e70e9f6fa Lukas Czerner 2020-04-28  2382  	ext4_msg(NULL, KERN_ERR,
9c038e70e9f6fa Lukas Czerner 2020-04-28  2383  		 "Ext4: Cannot change quota options when quota turned on");
9c038e70e9f6fa Lukas Czerner 2020-04-28  2384  	return -EINVAL;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2385  err_jquota_change:
9c038e70e9f6fa Lukas Czerner 2020-04-28  2386  	ext4_msg(NULL, KERN_ERR, "Ext4: Cannot change journaled quota "
9c038e70e9f6fa Lukas Czerner 2020-04-28  2387  		 "options when quota turned on");
9c038e70e9f6fa Lukas Czerner 2020-04-28  2388  	return -EINVAL;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2389  err_jquota_specified:
9c038e70e9f6fa Lukas Czerner 2020-04-28  2390  	ext4_msg(NULL, KERN_ERR, "Ext4: Quota file already specified");
9c038e70e9f6fa Lukas Czerner 2020-04-28  2391  	return -EINVAL;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2392  err_feature:
9c038e70e9f6fa Lukas Czerner 2020-04-28  2393  	ext4_msg(NULL, KERN_ERR, "Ext4: Journaled quota options ignored "
9c038e70e9f6fa Lukas Czerner 2020-04-28  2394  		 "when QUOTA feature is enabled");
9c038e70e9f6fa Lukas Czerner 2020-04-28  2395  	return 0;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2396  #else
9c038e70e9f6fa Lukas Czerner 2020-04-28  2397  	return 0;
9c038e70e9f6fa Lukas Czerner 2020-04-28  2398  #endif
9c038e70e9f6fa Lukas Czerner 2020-04-28  2399  }
9c038e70e9f6fa Lukas Czerner 2020-04-28  2400  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* [PATCH v2 06/17] ext4: move quota configuration out of handle_mount_opt()
  2020-04-28 16:45 [PATCH v2 00/17] ext4: new mount API conversion Lukas Czerner
@ 2020-04-28 16:45 ` Lukas Czerner
  0 siblings, 0 replies; 2+ messages in thread
From: Lukas Czerner @ 2020-04-28 16:45 UTC (permalink / raw)
  To: linux-ext4; +Cc: dhowells, viro

At the parsing phase of mount in the new mount api sb will not be
available so move quota confiquration out of handle_mount_opt() by
noting the quota file names in the ext4_fs_context structure to be
able to apply it later.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/super.c | 248 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 159 insertions(+), 89 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2f7e49bfbf71..ae0ef04b3be4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -89,6 +89,10 @@ static void ext4_clear_request_list(void);
 static struct inode *ext4_get_journal_inode(struct super_block *sb,
 					    unsigned int journal_inum);
 static int ext4_validate_options(struct fs_context *fc);
+static int ext4_check_quota_consistency(struct fs_context *fc,
+					struct super_block *sb);
+static void ext4_apply_quota_options(struct fs_context *fc,
+				     struct super_block *sb);
 
 /*
  * Lock ordering
@@ -1778,71 +1782,6 @@ static const char deprecated_msg[] =
 	"Mount option \"%s\" will be removed by %s\n"
 	"Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
 
-#ifdef CONFIG_QUOTA
-static int set_qf_name(struct super_block *sb, int qtype,
-		       struct fs_parameter *param)
-{
-	struct ext4_sb_info *sbi = EXT4_SB(sb);
-	char *qname, *old_qname = get_qf_name(sb, sbi, qtype);
-	int ret = -1;
-
-	if (sb_any_quota_loaded(sb) && !old_qname) {
-		ext4_msg(sb, KERN_ERR,
-			"Cannot change journaled "
-			"quota options when quota turned on");
-		return -1;
-	}
-	if (ext4_has_feature_quota(sb)) {
-		ext4_msg(sb, KERN_INFO, "Journaled quota options "
-			 "ignored when QUOTA feature is enabled");
-		return 1;
-	}
-	qname = kmemdup_nul(param->string, param->size, GFP_KERNEL);
-	if (!qname) {
-		ext4_msg(sb, KERN_ERR,
-			"Not enough memory for storing quotafile name");
-		return -1;
-	}
-	if (old_qname) {
-		if (strcmp(old_qname, qname) == 0)
-			ret = 1;
-		else
-			ext4_msg(sb, KERN_ERR,
-				 "%s quota file already specified",
-				 QTYPE2NAME(qtype));
-		goto errout;
-	}
-	if (strchr(qname, '/')) {
-		ext4_msg(sb, KERN_ERR,
-			"quotafile must be on filesystem root");
-		goto errout;
-	}
-	rcu_assign_pointer(sbi->s_qf_names[qtype], qname);
-	set_opt(sb, QUOTA);
-	return 1;
-errout:
-	kfree(qname);
-	return ret;
-}
-
-static int clear_qf_name(struct super_block *sb, int qtype)
-{
-
-	struct ext4_sb_info *sbi = EXT4_SB(sb);
-	char *old_qname = get_qf_name(sb, sbi, qtype);
-
-	if (sb_any_quota_loaded(sb) && old_qname) {
-		ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options"
-			" when quota turned on");
-		return -1;
-	}
-	rcu_assign_pointer(sbi->s_qf_names[qtype], NULL);
-	synchronize_rcu();
-	kfree(old_qname);
-	return 1;
-}
-#endif
-
 #define MOPT_SET	0x0001
 #define MOPT_CLEAR	0x0002
 #define MOPT_NOSUPPORT	0x0004
@@ -1987,10 +1926,68 @@ static int ext4_sb_read_encoding(const struct ext4_super_block *es,
 #endif
 
 struct ext4_fs_context {
-	unsigned long journal_devnum;
-	unsigned int journal_ioprio;
+	char		*s_qf_names[EXT4_MAXQUOTAS];
+	int		s_jquota_fmt;	/* Format of quota to use */
+	unsigned short	qname_spec;
+	unsigned long	journal_devnum;
+	unsigned int	journal_ioprio;
 };
 
+#ifdef CONFIG_QUOTA
+/*
+ * Note the name of the specified quota file.
+ */
+static int note_qf_name(struct fs_context *fc, int qtype,
+		       struct fs_parameter *param)
+{
+	struct ext4_fs_context *ctx = fc->fs_private;
+	char *qname;
+
+	if (param->size < 1) {
+		ext4_msg(NULL, KERN_ERR, "EXT4-fs: Missing quota name");
+		return -EINVAL;
+	}
+	if (strchr(param->string, '/')) {
+		ext4_msg(NULL, KERN_ERR,
+			 "quotafile must be on filesystem root");
+		return -EINVAL;
+	}
+	if (ctx->s_qf_names[qtype]) {
+		if (strcmp(ctx->s_qf_names[qtype], param->string) != 0) {
+			ext4_msg(NULL, KERN_ERR,
+				 "EXT4-fs: Quota file already specified");
+			return -EINVAL;
+		}
+		return 0;
+	}
+
+	qname = kmemdup_nul(param->string, param->size, GFP_KERNEL);
+	if (!qname) {
+		ext4_msg(NULL, KERN_ERR,
+			 "Not enough memory for storing quotafile name");
+		return -ENOMEM;
+	}
+	ctx->s_qf_names[qtype] = qname;
+	ctx->qname_spec |= 1 << qtype;
+	return 0;
+}
+
+/*
+ * Clear the name of the specified quota file.
+ */
+static int unnote_qf_name(struct fs_context *fc, int qtype)
+{
+	struct ext4_fs_context *ctx = fc->fs_private;
+
+	if (ctx->s_qf_names[qtype])
+		kfree(ctx->s_qf_names[qtype]);
+
+	ctx->s_qf_names[qtype] = NULL;
+	ctx->qname_spec |= 1 << qtype;
+	return 0;
+}
+#endif
+
 static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
 {
 	struct ext4_fs_context *ctx = fc->fs_private;
@@ -2009,14 +2006,14 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
 #ifdef CONFIG_QUOTA
 	if (token == Opt_usrjquota) {
 		if (!*param->string)
-			return clear_qf_name(sb, USRQUOTA);
+			return unnote_qf_name(fc, USRQUOTA);
 		else
-			return set_qf_name(sb, USRQUOTA, param);
+			return note_qf_name(fc, USRQUOTA, param);
 	} else if (token == Opt_grpjquota) {
 		if (!*param->string)
-			return clear_qf_name(sb, GRPQUOTA);
+			return unnote_qf_name(fc, GRPQUOTA);
 		else
-			return set_qf_name(sb, GRPQUOTA, param);
+			return note_qf_name(fc, GRPQUOTA, param);
 	}
 #endif
 	switch (token) {
@@ -2082,11 +2079,6 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
 	}
 	if (m->flags & MOPT_CLEAR_ERR)
 		clear_opt(sb, ERRORS_MASK);
-	if (token == Opt_noquota && sb_any_quota_loaded(sb)) {
-		ext4_msg(NULL, KERN_ERR, "Cannot change quota "
-			 "options when quota turned on");
-		return -EINVAL;
-	}
 
 	if (m->flags & MOPT_NOSUPPORT) {
 		ext4_msg(NULL, KERN_ERR, "%s option not supported",
@@ -2211,19 +2203,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
 		}
 #ifdef CONFIG_QUOTA
 	} else if (m->flags & MOPT_QFMT) {
-		if (sb_any_quota_loaded(sb) &&
-		    sbi->s_jquota_fmt != m->mount_opt) {
-			ext4_msg(NULL, KERN_ERR, "Cannot change journaled "
-				 "quota options when quota turned on");
-			return -EINVAL;
-		}
-		if (ext4_has_feature_quota(sb)) {
-			ext4_msg(NULL, KERN_INFO,
-				 "Quota format mount options ignored "
-				 "when QUOTA feature is enabled");
-			return 1;
-		}
-		sbi->s_jquota_fmt = m->mount_opt;
+		ctx->s_jquota_fmt = m->mount_opt;
 #endif
 	} else if (token == Opt_dax) {
 #ifdef CONFIG_FS_DAX
@@ -2325,9 +2305,99 @@ static int parse_options(char *options, struct super_block *sb,
 	if (ret < 0)
 		return 0;
 
+	ret = ext4_check_quota_consistency(&fc, sb);
+	if (ret < 0)
+		return 0;
+
+	if (ctx.qname_spec)
+		ext4_apply_quota_options(&fc, sb);
+
 	return 1;
 }
 
+static void ext4_apply_quota_options(struct fs_context *fc,
+				     struct super_block *sb)
+{
+#ifdef CONFIG_QUOTA
+	struct ext4_fs_context *ctx = fc->fs_private;
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	char *qname;
+	int i;
+
+	for (i = 0; i < EXT4_MAXQUOTAS; i++) {
+		if (!(ctx->qname_spec & (1 << i)))
+			continue;
+		qname = ctx->s_qf_names[i]; /* May be NULL */
+		ctx->s_qf_names[i] = NULL;
+		kfree(sbi->s_qf_names[i]);
+		rcu_assign_pointer(sbi->s_qf_names[i], qname);
+		set_opt(sb, QUOTA);
+	}
+#endif
+}
+
+/*
+ * Check quota settings consistency.
+ */
+static int ext4_check_quota_consistency(struct fs_context *fc,
+					struct super_block *sb)
+{
+#ifdef CONFIG_QUOTA
+	struct ext4_fs_context *ctx = fc->fs_private;
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	bool quota_feature = ext4_has_feature_quota(sb);
+	bool quota_loaded = sb_any_quota_loaded(sb);
+	int i;
+
+	if (ctx->qname_spec && quota_loaded) {
+		if (quota_feature)
+			goto err_feature;
+
+		for (i = 0; i < EXT4_MAXQUOTAS; i++) {
+			if (!(ctx->qname_spec & (1 << i)))
+				continue;
+
+			if (!!sbi->s_qf_names[i] != !!ctx->s_qf_names[i])
+				goto err_jquota_change;
+
+			if (sbi->s_qf_names[i] && ctx->s_qf_names[i] &&
+			    strcmp(sbi->s_qf_names[i],
+				   ctx->s_qf_names[i]) != 0)
+				goto err_jquota_specified;
+		}
+	}
+
+	if (ctx->s_jquota_fmt) {
+		if (sbi->s_jquota_fmt != ctx->s_jquota_fmt && quota_loaded)
+			goto err_quota_change;
+		if (quota_feature) {
+			ext4_msg(NULL, KERN_INFO, "Quota format mount options "
+				 "ignored when QUOTA feature is enabled");
+			return 0;
+		}
+	}
+	return 0;
+
+err_quota_change:
+	ext4_msg(NULL, KERN_ERR,
+		 "Ext4: Cannot change quota options when quota turned on");
+	return -EINVAL;
+err_jquota_change:
+	ext4_msg(NULL, KERN_ERR, "Ext4: Cannot change journaled quota "
+		 "options when quota turned on");
+	return -EINVAL;
+err_jquota_specified:
+	ext4_msg(NULL, KERN_ERR, "Ext4: Quota file already specified");
+	return -EINVAL;
+err_feature:
+	ext4_msg(NULL, KERN_ERR, "Ext4: Journaled quota options ignored "
+		 "when QUOTA feature is enabled");
+	return 0;
+#else
+	return 0;
+#endif
+}
+
 static int ext4_validate_options(struct fs_context *fc)
 {
 	struct ext4_sb_info *sbi = fc->s_fs_info;
-- 
2.21.1


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

end of thread, other threads:[~2020-05-09  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09  0:57 [PATCH v2 06/17] ext4: move quota configuration out of handle_mount_opt() kbuild test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-04-28 16:45 [PATCH v2 00/17] ext4: new mount API conversion Lukas Czerner
2020-04-28 16:45 ` [PATCH v2 06/17] ext4: move quota configuration out of handle_mount_opt() Lukas Czerner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.