mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ferry Meng <mengferry@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ferry Meng <mengferry@linux.alibaba.com>
Subject: [PATCH] erofs: avoid some unnecessary #ifdefs
Date: Mon,  2 Feb 2026 11:09:09 +0800	[thread overview]
Message-ID: <20260202030909.128365-1-mengferry@linux.alibaba.com> (raw)

They can either be removed or replaced with IS_ENABLED().

Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
---
 fs/erofs/data.c  | 20 ++++++++------------
 fs/erofs/super.c | 13 ++++---------
 fs/erofs/sysfs.c |  5 ++---
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 3a4eb0dececd..a2c796db4510 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -365,12 +365,10 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		 u64 start, u64 len)
 {
 	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
-#ifdef CONFIG_EROFS_FS_ZIP
+		if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP))
+			return -EOPNOTSUPP;
 		return iomap_fiemap(inode, fieinfo, start, len,
 				    &z_erofs_iomap_report_ops);
-#else
-		return -EOPNOTSUPP;
-#endif
 	}
 	return iomap_fiemap(inode, fieinfo, start, len, &erofs_iomap_ops);
 }
@@ -428,10 +426,9 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	if (!iov_iter_count(to))
 		return 0;
 
-#ifdef CONFIG_FS_DAX
-	if (IS_DAX(inode))
+	if (IS_ENABLED(CONFIG_FS_DAX) && IS_DAX(inode))
 		return dax_iomap_rw(iocb, to, &erofs_iomap_ops);
-#endif
+
 	if ((iocb->ki_flags & IOCB_DIRECT) && inode->i_sb->s_bdev) {
 		struct erofs_iomap_iter_ctx iter_ctx = {
 			.realinode = inode,
@@ -491,12 +488,11 @@ static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence)
 	struct inode *inode = file->f_mapping->host;
 	const struct iomap_ops *ops = &erofs_iomap_ops;
 
-	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout))
-#ifdef CONFIG_EROFS_FS_ZIP
+	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
+		if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP))
+			return generic_file_llseek(file, offset, whence);
 		ops = &z_erofs_iomap_report_ops;
-#else
-		return generic_file_llseek(file, offset, whence);
-#endif
+	}
 
 	if (whence == SEEK_HOLE)
 		offset = iomap_seek_hole(inode, offset, ops);
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index e52c2b528f86..7827e61424b7 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -381,12 +381,10 @@ static void erofs_default_options(struct erofs_sb_info *sbi)
 	sbi->opt.cache_strategy = EROFS_ZIP_CACHE_READAROUND;
 	sbi->sync_decompress = EROFS_SYNC_DECOMPRESS_AUTO;
 #endif
-#ifdef CONFIG_EROFS_FS_XATTR
-	set_opt(&sbi->opt, XATTR_USER);
-#endif
-#ifdef CONFIG_EROFS_FS_POSIX_ACL
-	set_opt(&sbi->opt, POSIX_ACL);
-#endif
+	if (IS_ENABLED(CONFIG_EROFS_FS_XATTR))
+		set_opt(&sbi->opt, XATTR_USER);
+	if (IS_ENABLED(CONFIG_EROFS_FS_POSIX_ACL))
+		set_opt(&sbi->opt, POSIX_ACL);
 }
 
 enum {
@@ -1125,11 +1123,8 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 
 static void erofs_evict_inode(struct inode *inode)
 {
-#ifdef CONFIG_FS_DAX
 	if (IS_DAX(inode))
 		dax_break_layout_final(inode);
-#endif
-
 	erofs_ishare_free_inode(inode);
 	truncate_inode_pages_final(&inode->i_data);
 	clear_inode(inode);
diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
index 3a9a5fa000ae..6734483a440f 100644
--- a/fs/erofs/sysfs.c
+++ b/fs/erofs/sysfs.c
@@ -168,11 +168,10 @@ static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
 			return ret;
 		if (t != (unsigned int)t)
 			return -ERANGE;
-#ifdef CONFIG_EROFS_FS_ZIP
-		if (!strcmp(a->attr.name, "sync_decompress") &&
+		if (IS_ENABLED(CONFIG_EROFS_FS_ZIP) &&
+		    !strcmp(a->attr.name, "sync_decompress") &&
 		    (t > EROFS_SYNC_DECOMPRESS_FORCE_OFF))
 			return -EINVAL;
-#endif
 		*(unsigned int *)ptr = t;
 		return len;
 	case attr_pointer_bool:
-- 
2.43.5


             reply	other threads:[~2026-02-02  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02  3:09 Ferry Meng [this message]
2026-02-03  3:07 ` 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=20260202030909.128365-1-mengferry@linux.alibaba.com \
    --to=mengferry@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.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

Powered by JetHome