From: Chunhai Guo via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: xiang@kernel.org
Cc: Chunhai Guo <guochunhai@vivo.com>,
linux-erofs@lists.ozlabs.org, huyue2@coolpad.com
Subject: [PATCH 1/2] erofs: rename utils.c to zutil.c
Date: Mon, 1 Apr 2024 07:55:50 -0600 [thread overview]
Message-ID: <20240401135550.2550043-1-guochunhai@vivo.com> (raw)
Currently, utils.c is only useful if CONFIG_EROFS_FS_ZIP is on.
So let's rename as zutil.c as well as avoid its inclusion if
CONFIG_EROFS_FS_ZIP is explicitly disabled.
Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
Suggested-by: Gao Xiang <xiang@kernel.org>
---
fs/erofs/Makefile | 4 ++--
fs/erofs/{utils.c => zutil.c} | 30 +++++++++++-------------------
2 files changed, 13 insertions(+), 21 deletions(-)
rename fs/erofs/{utils.c => zutil.c} (96%)
diff --git a/fs/erofs/Makefile b/fs/erofs/Makefile
index 994d0b9deddf..845eafdcee4a 100644
--- a/fs/erofs/Makefile
+++ b/fs/erofs/Makefile
@@ -1,9 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_EROFS_FS) += erofs.o
-erofs-objs := super.o inode.o data.o namei.o dir.o utils.o sysfs.o
+erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o
erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o
-erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o pcpubuf.o
+erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o pcpubuf.o zutil.o
erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o
erofs-$(CONFIG_EROFS_FS_ZIP_DEFLATE) += decompressor_deflate.o
erofs-$(CONFIG_EROFS_FS_ONDEMAND) += fscache.o
diff --git a/fs/erofs/utils.c b/fs/erofs/zutil.c
similarity index 96%
rename from fs/erofs/utils.c
rename to fs/erofs/zutil.c
index 518bdd69c823..8cd30ac2091f 100644
--- a/fs/erofs/utils.c
+++ b/fs/erofs/zutil.c
@@ -5,6 +5,15 @@
*/
#include "internal.h"
+static atomic_long_t erofs_global_shrink_cnt; /* for all mounted instances */
+/* protected by 'erofs_sb_list_lock' */
+static unsigned int shrinker_run_no;
+
+/* protects the mounted 'erofs_sb_list' */
+static DEFINE_SPINLOCK(erofs_sb_list_lock);
+static LIST_HEAD(erofs_sb_list);
+static struct shrinker *erofs_shrinker_info;
+
struct page *erofs_allocpage(struct page **pagepool, gfp_t gfp)
{
struct page *page = *pagepool;
@@ -12,10 +21,9 @@ struct page *erofs_allocpage(struct page **pagepool, gfp_t gfp)
if (page) {
DBG_BUGON(page_ref_count(page) != 1);
*pagepool = (struct page *)page_private(page);
- } else {
- page = alloc_page(gfp);
+ return page;
}
- return page;
+ return alloc_page(gfp);
}
void erofs_release_pages(struct page **pagepool)
@@ -28,10 +36,6 @@ void erofs_release_pages(struct page **pagepool)
}
}
-#ifdef CONFIG_EROFS_FS_ZIP
-/* global shrink count (for all mounted EROFS instances) */
-static atomic_long_t erofs_global_shrink_cnt;
-
static bool erofs_workgroup_get(struct erofs_workgroup *grp)
{
if (lockref_get_not_zero(&grp->lockref))
@@ -171,13 +175,6 @@ static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
return freed;
}
-/* protected by 'erofs_sb_list_lock' */
-static unsigned int shrinker_run_no;
-
-/* protects the mounted 'erofs_sb_list' */
-static DEFINE_SPINLOCK(erofs_sb_list_lock);
-static LIST_HEAD(erofs_sb_list);
-
void erofs_shrinker_register(struct super_block *sb)
{
struct erofs_sb_info *sbi = EROFS_SB(sb);
@@ -264,8 +261,6 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink,
return freed;
}
-static struct shrinker *erofs_shrinker_info;
-
int __init erofs_init_shrinker(void)
{
erofs_shrinker_info = shrinker_alloc(0, "erofs-shrinker");
@@ -274,9 +269,7 @@ int __init erofs_init_shrinker(void)
erofs_shrinker_info->count_objects = erofs_shrink_count;
erofs_shrinker_info->scan_objects = erofs_shrink_scan;
-
shrinker_register(erofs_shrinker_info);
-
return 0;
}
@@ -284,4 +277,3 @@ void erofs_exit_shrinker(void)
{
shrinker_free(erofs_shrinker_info);
}
-#endif /* !CONFIG_EROFS_FS_ZIP */
--
2.25.1
next reply other threads:[~2024-04-01 13:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 13:55 Chunhai Guo via Linux-erofs [this message]
2024-04-02 0:46 ` [PATCH 1/2] erofs: rename utils.c to zutil.c Gao Xiang
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=20240401135550.2550043-1-guochunhai@vivo.com \
--to=linux-erofs@lists.ozlabs.org \
--cc=guochunhai@vivo.com \
--cc=huyue2@coolpad.com \
--cc=xiang@kernel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).