All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs: remove erofs_dev_context->rwsem
@ 2026-08-16  2:00 Bingwu Zhang
  2026-08-16  3:06 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Bingwu Zhang @ 2026-08-16  2:00 UTC (permalink / raw)
  To: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale, Hongbo Li,
	Chunhai Guo
  Cc: linux-erofs, linux-kernel, Bingwu Zhang

From: Bingwu Zhang <xtex@astrafall.org>

devs->tree is only modified in initialization and
destruction code paths and will never be concurrent
with data reading. Thus there is no need to guard
idr_alloc/idr_find with a rwsem.

Signed-off-by: Bingwu Zhang <xtex@astrafall.org>
---
 fs/erofs/data.c     | 9 +--------
 fs/erofs/internal.h | 1 -
 fs/erofs/super.c    | 5 -----
 3 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 9aa48c8d67d1..49d62eac6eb4 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -216,21 +216,15 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
 	erofs_fill_from_devinfo(map, sb, &EROFS_SB(sb)->dif0);
 	map->m_bdev = sb->s_bdev;	/* use s_bdev for the primary device */
 	if (map->m_deviceid) {
-		down_read(&devs->rwsem);
 		dif = idr_find(&devs->tree, map->m_deviceid - 1);
-		if (!dif) {
-			up_read(&devs->rwsem);
+		if (!dif)
 			return -ENODEV;
-		}
 		if (devs->flatdev) {
 			map->m_pa += erofs_pos(sb, dif->uniaddr);
-			up_read(&devs->rwsem);
 			return 0;
 		}
 		erofs_fill_from_devinfo(map, sb, dif);
-		up_read(&devs->rwsem);
 	} else if (devs->extra_devices && !devs->flatdev) {
-		down_read(&devs->rwsem);
 		idr_for_each_entry(&devs->tree, dif, id) {
 			if (!dif->uniaddr)
 				continue;
@@ -243,7 +237,6 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
 				break;
 			}
 		}
-		up_read(&devs->rwsem);
 	}
 	return 0;
 }
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 57bd21859c65..811c160035ce 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -65,7 +65,6 @@ struct erofs_mount_opts {
 
 struct erofs_dev_context {
 	struct idr tree;
-	struct rw_semaphore rwsem;
 
 	unsigned int extra_devices;
 	bool flatdev;
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 9d8f862f309f..12ecdd4b85ac 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -215,7 +215,6 @@ static int erofs_scan_devices(struct super_block *sb,
 
 	sbi->device_id_mask = roundup_pow_of_two(ondisk_extradevs + 1) - 1;
 	pos = le16_to_cpu(dsb->devt_slotoff) * EROFS_DEVT_SLOT_SIZE;
-	down_read(&sbi->devs->rwsem);
 	if (sbi->devs->extra_devices) {
 		idr_for_each_entry(&sbi->devs->tree, dif, id) {
 			err = erofs_init_device(&buf, sb, dif, &pos);
@@ -242,7 +241,6 @@ static int erofs_scan_devices(struct super_block *sb,
 				break;
 		}
 	}
-	up_read(&sbi->devs->rwsem);
 	erofs_put_metabuf(&buf);
 	return err;
 }
@@ -489,9 +487,7 @@ static int erofs_fc_parse_param(struct fs_context *fc,
 			kfree(dif);
 			return -ENOMEM;
 		}
-		down_write(&sbi->devs->rwsem);
 		ret = idr_alloc(&sbi->devs->tree, dif, 0, 0, GFP_KERNEL);
-		up_write(&sbi->devs->rwsem);
 		if (ret < 0) {
 			kfree(dif->path);
 			kfree(dif);
@@ -850,7 +846,6 @@ static int erofs_init_fs_context(struct fs_context *fc)
 	fc->s_fs_info = sbi;
 
 	idr_init(&sbi->devs->tree);
-	init_rwsem(&sbi->devs->rwsem);
 	erofs_default_options(sbi);
 	fc->ops = &erofs_context_ops;
 	return 0;

---
base-commit: 3eb40771c00a8488fa6ed2cc1fe203477908bf38
change-id: 20260814-erofs-remove-rwsem-5a0982d5da80

Best regards,
--  
Bingwu Zhang <xtex@astrafall.org>



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

end of thread, other threads:[~2026-08-16  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16  2:00 [PATCH] erofs: remove erofs_dev_context->rwsem Bingwu Zhang
2026-08-16  3:06 ` Gao Xiang
2026-08-16  3:11   ` xtex

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.