Skip to contentSkip to conversation

erofs: scan devices from device table

PATCH Superseded Jeffle Xu 2 participants 2 messages May 10, 2022 – May 12, 2022 EROFS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeffle Xu

author
#0 lore raw

PATCH 1/1 erofs: scan devices from device table

When "-o device" mount option is not specified, scan the device table and instantiate the devices if there's any in the device table. In this case, the tag field of each device slot uniquely specifies a device.

---
 fs/erofs/erofs_fs.h |   9 ++--
 fs/erofs/super.c    | 102 ++++++++++++++++++++++++++++++--------------
 2 files changed, 72 insertions(+), 39 deletions(-)
fs/erofs/erofs_fs.h +3 -6
index 1238ca104f09..1adde3a813b4 100644
@@ -37,12 +37,9 @@
 #define EROFS_SB_EXTSLOT_SIZE	16
 
 struct erofs_deviceslot {
-	union {
-		u8 uuid[16];		/* used for device manager later */
-		u8 userdata[64];	/* digest(sha256), etc. */
-	} u;
-	__le32 blocks;			/* total fs blocks of this device */
-	__le32 mapped_blkaddr;		/* map starting at mapped_blkaddr */
+	u8 tag[64];		/* digest(sha256), etc. */
+	__le32 blocks;		/* total fs blocks of this device */
+	__le32 mapped_blkaddr;	/* map starting at mapped_blkaddr */
 	u8 reserved[56];
 };
 #define EROFS_DEVT_SLOT_SIZE	sizeof(struct erofs_deviceslot)
fs/erofs/super.c +69 -33

137 lines not on this page · raw message

Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 46 lines · Jeffle Xu

When "-o device" mount option is not specified, scan the device table and instantiate the devices if there's any in the device table. In this case, the tag field of each device slot uniquely specifies a device.

---
 fs/erofs/erofs_fs.h |   9 ++--
 fs/erofs/super.c    | 102 ++++++++++++++++++++++++++++++--------------
 2 files changed, 72 insertions(+), 39 deletions(-)
fs/erofs/erofs_fs.h +3 -6
index 1238ca104f09..1adde3a813b4 100644
@@ -37,12 +37,9 @@
 #define EROFS_SB_EXTSLOT_SIZE	16
 
 struct erofs_deviceslot {
-	union {
-		u8 uuid[16];		/* used for device manager later */
-		u8 userdata[64];	/* digest(sha256), etc. */
-	} u;
-	__le32 blocks;			/* total fs blocks of this device */
-	__le32 mapped_blkaddr;		/* map starting at mapped_blkaddr */
+	u8 tag[64];		/* digest(sha256), etc. */
+	__le32 blocks;		/* total fs blocks of this device */
+	__le32 mapped_blkaddr;	/* map starting at mapped_blkaddr */
 	u8 reserved[56];
 };
 #define EROFS_DEVT_SLOT_SIZE	sizeof(struct erofs_deviceslot)
fs/erofs/super.c +7 -1
index 4a623630e1c4..3f19c2031e69 100644
@@ -219,7 +219,52 @@ static int erofs_load_compr_cfgs(struct super_block *sb,
 }
 #endif
 
-static int erofs_init_devices(struct super_block *sb,
+static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
+			     struct erofs_device_info *dif, erofs_off_t *pos)
+{
+	struct erofs_sb_info *sbi = EROFS_SB(sb);
+	struct erofs_deviceslot *dis;
+	struct block_device *bdev;
+	void *ptr;

fs/erofs/super.c static int erofs_load_compr_cfgs(struct super_block *sb, · line 238

Quoted 10 lines
fs/erofs/super.c +10 -0
+	int ret;
+
+	ptr = erofs_read_metabuf(buf, sb, erofs_blknr(*pos), EROFS_KMAP);
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
+	dis = ptr + erofs_blkoff(*pos);
+
+	if (!dif->path) {
+		if (!dis->tag[0]) {
+			erofs_err(sb, "Empty digest data (pos %llu)", *pos);
			erofs_err(sb, "empty tag @ pos %llu", *pos);

?

Otherwise it looks good to me,

Thanks,
Gao Xiang