linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kemeng Shi <shikemeng@huaweicloud.com>
To: hughd@google.com, baolin.wang@linux.alibaba.com,
	willy@infradead.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH 5/7] mm: shmem: wrap additional shmem quota related code with CONFIG_TMPFS_QUOTA
Date: Fri,  6 Jun 2025 06:10:35 +0800	[thread overview]
Message-ID: <20250605221037.7872-6-shikemeng@huaweicloud.com> (raw)
In-Reply-To: <20250605221037.7872-1-shikemeng@huaweicloud.com>

Some code routines and structure members are unreachable when
CONFIG_TMPFS_QUOTA is off. Wrap additional shmem quota related code to
eliniate these unreachable sections.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 include/linux/shmem_fs.h |  4 ++++
 mm/shmem.c               | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 0b273a7b9f01..4873359a5442 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -47,12 +47,14 @@ struct shmem_inode_info {
 	(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL)
 #define SHMEM_FL_INHERITED		(FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL)
 
+#ifdef CONFIG_TMPFS_QUOTA
 struct shmem_quota_limits {
 	qsize_t usrquota_bhardlimit; /* Default user quota block hard limit */
 	qsize_t usrquota_ihardlimit; /* Default user quota inode hard limit */
 	qsize_t grpquota_bhardlimit; /* Default group quota block hard limit */
 	qsize_t grpquota_ihardlimit; /* Default group quota inode hard limit */
 };
+#endif
 
 struct shmem_sb_info {
 	unsigned long max_blocks;   /* How many blocks are allowed */
@@ -72,7 +74,9 @@ struct shmem_sb_info {
 	spinlock_t shrinklist_lock;   /* Protects shrinklist */
 	struct list_head shrinklist;  /* List of shinkable inodes */
 	unsigned long shrinklist_len; /* Length of shrinklist */
+#ifdef CONFIG_TMPFS_QUOTA
 	struct shmem_quota_limits qlimits; /* Default quota limits */
+#endif
 };
 
 static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
diff --git a/mm/shmem.c b/mm/shmem.c
index 9f5e1eccaacb..e3e05bbb6db2 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -121,8 +121,10 @@ struct shmem_options {
 	int huge;
 	int seen;
 	bool noswap;
+#ifdef CONFIG_TMPFS_QUOTA
 	unsigned short quota_types;
 	struct shmem_quota_limits qlimits;
+#endif
 #if IS_ENABLED(CONFIG_UNICODE)
 	struct unicode_map *encoding;
 	bool strict_encoding;
@@ -132,7 +134,9 @@ struct shmem_options {
 #define SHMEM_SEEN_HUGE 4
 #define SHMEM_SEEN_INUMS 8
 #define SHMEM_SEEN_NOSWAP 16
+#ifdef CONFIG_TMPFS_QUOTA
 #define SHMEM_SEEN_QUOTA 32
+#endif
 };
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -4549,6 +4553,7 @@ enum shmem_param {
 	Opt_inode32,
 	Opt_inode64,
 	Opt_noswap,
+#ifdef CONFIG_TMPFS_QUOTA
 	Opt_quota,
 	Opt_usrquota,
 	Opt_grpquota,
@@ -4556,6 +4561,7 @@ enum shmem_param {
 	Opt_usrquota_inode_hardlimit,
 	Opt_grpquota_block_hardlimit,
 	Opt_grpquota_inode_hardlimit,
+#endif
 	Opt_casefold_version,
 	Opt_casefold,
 	Opt_strict_encoding,
@@ -4742,6 +4748,7 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param)
 		ctx->noswap = true;
 		ctx->seen |= SHMEM_SEEN_NOSWAP;
 		break;
+#ifdef CONFIG_TMPFS_QUOTA
 	case Opt_quota:
 		if (fc->user_ns != &init_user_ns)
 			return invalfc(fc, "Quotas in unprivileged tmpfs mounts are unsupported");
@@ -4796,6 +4803,7 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param)
 				       "Group quota inode hardlimit too large.");
 		ctx->qlimits.grpquota_ihardlimit = size;
 		break;
+#endif
 	case Opt_casefold_version:
 		return shmem_parse_opt_casefold(fc, param, false);
 	case Opt_casefold:
@@ -4899,13 +4907,13 @@ static int shmem_reconfigure(struct fs_context *fc)
 		goto out;
 	}
 
+#ifdef CONFIG_TMPFS_QUOTA
 	if (ctx->seen & SHMEM_SEEN_QUOTA &&
 	    !sb_any_quota_loaded(fc->root->d_sb)) {
 		err = "Cannot enable quota on remount";
 		goto out;
 	}
 
-#ifdef CONFIG_TMPFS_QUOTA
 #define CHANGED_LIMIT(name)						\
 	(ctx->qlimits.name## hardlimit &&				\
 	(ctx->qlimits.name## hardlimit != sbinfo->qlimits.name## hardlimit))
-- 
2.30.0



  parent reply	other threads:[~2025-06-05 13:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 22:10 [PATCH 0/7] Some random fixes and cleanups to shmem Kemeng Shi
2025-06-05 20:02 ` Andrew Morton
2025-06-05 22:10 ` [PATCH 1/7] mm: shmem: correctly pass alloced parameter to shmem_recalc_inode() to avoid WARN_ON() Kemeng Shi
2025-06-05 19:57   ` Andrew Morton
2025-06-06  1:11     ` Kemeng Shi
2025-06-06  1:28       ` Andrew Morton
2025-06-06  2:29         ` Kemeng Shi
2025-06-06  1:31       ` Kemeng Shi
2025-06-07  6:11   ` Baolin Wang
2025-06-09  0:46     ` Kemeng Shi
2025-06-10  1:02       ` Kemeng Shi
2025-06-11  7:29         ` Baolin Wang
2025-06-11  8:38           ` Kemeng Shi
2025-06-05 22:10 ` [PATCH 2/7] mm: shmem: avoid setting error on splited entries in shmem_set_folio_swapin_error() Kemeng Shi
2025-06-07  6:20   ` Baolin Wang
2025-06-09  1:19     ` Kemeng Shi
2025-06-11  7:41       ` Baolin Wang
2025-06-11  9:11         ` Kemeng Shi
2025-06-13  6:56           ` Baolin Wang
2025-06-05 22:10 ` [PATCH 3/7] mm: shmem: avoid missing entries in shmem_undo_range() when entries was splited concurrently Kemeng Shi
2025-06-05 22:10 ` [PATCH 4/7] mm: shmem: handle special case of shmem_recalc_inode() in it's caller Kemeng Shi
2025-06-05 22:10 ` Kemeng Shi [this message]
2025-06-05 22:10 ` [PATCH 6/7] mm: shmem: simplify error flow in thpsize_shmem_enabled_store() Kemeng Shi
2025-06-05 22:10 ` [PATCH 7/7] mm: shmem: eliminate unneeded page counting in shmem_unuse_swap_entries() Kemeng Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250605221037.7872-6-shikemeng@huaweicloud.com \
    --to=shikemeng@huaweicloud.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox