From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <xiang@kernel.org>
Subject: [PATCH v2 2/3] erofs-utils: mkfs: introduce ddev_id_def
Date: Wed, 2 Sep 2026 23:53:31 +0800 [thread overview]
Message-ID: <20260902155333.57247-2-xiang@kernel.org> (raw)
In-Reply-To: <20260902155333.57247-1-xiang@kernel.org>
It indicates the default blob device containing the inode data.
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
include/erofs/importer.h | 1 +
lib/blobchunk.c | 11 +++--------
lib/inode.c | 3 ++-
lib/liberofs_chunk.h | 5 ++---
mkfs/main.c | 3 ++-
5 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/include/erofs/importer.h b/include/erofs/importer.h
index c09b169..5141965 100644
--- a/include/erofs/importer.h
+++ b/include/erofs/importer.h
@@ -64,6 +64,7 @@ struct erofs_importer_params {
bool compress_dir;
char fragdedupe;
char chunkszbits_def;
+ u16 ddev_id_def; /* target device id for inode data */
};
struct erofs_importer {
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index dcb7dfe..5a90991 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -34,7 +34,6 @@ struct erofs_chunkitem erofs_holechunk = {
struct erofs_chunkmgr {
struct list_head chunks[65536];
struct list_head unhashed_chunks;
- int device_id;
};
#define EROFS_CHUNK_NR_BUCKETS \
@@ -49,7 +48,7 @@ struct erofs_chunkitem *erofs_get_unhashed_chunk(struct erofs_sb_info *sbi,
int ret;
if (__erofs_unlikely(!chunkmgr)) {
- ret = erofs_blob_init(sbi, 0, 0);
+ ret = erofs_blob_init(sbi, 0);
if (ret)
return ERR_PTR(ret);
chunkmgr = sbi->chunkmgr;
@@ -323,11 +322,9 @@ static bool erofs_blob_can_merge(struct erofs_sb_info *sbi,
}
int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd,
- erofs_off_t startoff)
+ erofs_off_t startoff, int device_id)
{
struct erofs_sb_info *sbi = inode->sbi;
- struct erofs_chunkmgr *cmgr = sbi->chunkmgr;
- int device_id = cmgr->device_id;
unsigned int chunkbits = inode->u.chunkbits;
unsigned int count, unit;
struct erofs_chunkitem *chunk, *lastch;
@@ -636,8 +633,7 @@ err_vf:
return ret;
}
-int erofs_blob_init(struct erofs_sb_info *sbi, int blobdev_id,
- unsigned int chunkbits_zero)
+int erofs_blob_init(struct erofs_sb_info *sbi, unsigned int chunkbits_zero)
{
struct erofs_chunkmgr *cmgr;
int i, ret;
@@ -656,7 +652,6 @@ int erofs_blob_init(struct erofs_sb_info *sbi, int blobdev_id,
if (ret)
goto err_out;
}
- cmgr->device_id = blobdev_id;
sbi->chunkmgr = cmgr;
}
return 0;
diff --git a/lib/inode.c b/lib/inode.c
index 728040a..a3fc181 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -709,6 +709,7 @@ static int erofs_write_unencoded_file(const struct erofs_importer *im,
{
struct erofs_vfile vf = { .fd = fd };
char chunkbits = im->params->chunkszbits_def;
+ int device_id = im->params->ddev_id_def;
if (chunkbits &&
inode->datasource != EROFS_INODE_DATA_SOURCE_REBUILD_BLOB) {
@@ -717,7 +718,7 @@ static int erofs_write_unencoded_file(const struct erofs_importer *im,
inode->u.chunkformat = 0;
if (cfg.c_force_chunkformat == FORCE_INODE_CHUNK_INDEXES)
inode->u.chunkformat = EROFS_CHUNK_FORMAT_INDEXES;
- return erofs_blob_write_chunked_file(inode, fd, fpos);
+ return erofs_blob_write_chunked_file(inode, fd, fpos, device_id);
}
if (inode->datasource == EROFS_INODE_DATA_SOURCE_REBUILD_BLOB) {
diff --git a/lib/liberofs_chunk.h b/lib/liberofs_chunk.h
index 3af88df..ff31891 100644
--- a/lib/liberofs_chunk.h
+++ b/lib/liberofs_chunk.h
@@ -21,12 +21,11 @@ void erofs_inode_fixup_chunkformat(struct erofs_inode *inode);
int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf,
erofs_off_t off);
int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd,
- erofs_off_t startoff);
+ erofs_off_t startoff, int device_id);
int erofs_write_zero_inode(struct erofs_inode *inode);
int tarerofs_write_chunkes(struct erofs_inode *inode, erofs_off_t data_offset);
int erofs_mkfs_dump_blobs(struct erofs_sb_info *sbi);
-int erofs_blob_init(struct erofs_sb_info *sbi, int blobdev_id,
- unsigned int chunkbits_def);
+int erofs_blob_init(struct erofs_sb_info *sbi, unsigned int chunkbits_zero);
int erofs_blob_init_device(struct erofs_sb_info *sbi, int device_id);
int erofs_chunkmgr_exit(struct erofs_sb_info *sbi);
diff --git a/mkfs/main.c b/mkfs/main.c
index ce29319..688e474 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1941,7 +1941,8 @@ int main(int argc, char **argv)
goto exit;
}
- err = erofs_blob_init(&g_sbi, mkfscfg.blobdev_path ? 1 : 0, mkfscfg.chunkbits);
+ importer_params.ddev_id_def = mkfscfg.blobdev_path ? 1 : 0;
+ err = erofs_blob_init(&g_sbi, mkfscfg.chunkbits);
if (err)
goto exit;
}
--
2.47.3
next prev parent reply other threads:[~2026-09-02 15:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 15:53 [PATCH v2 1/3] erofs-utils: lib: migrate `c_chunkbits` and `c_blobdev_path` Gao Xiang
2026-09-02 15:53 ` Gao Xiang [this message]
2026-09-02 15:53 ` [PATCH v2 3/3] erofs-utils: mkfs: enable `--blobdev` for flat inode layouts Gao Xiang
2026-09-03 7:57 ` [PATCH v3] " Yifan Zhao
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=20260902155333.57247-2-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.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