Skip to contentSkip to conversation

erofs-utils: remove global sbi in library

PATCH Superseded Jingbo Xu 2 participants 8 messages Jul 18, 2023 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

cover erofs-utils: remove global sbi in library

Later mkfs is going to be capable of converting multiple erofs images into one merged erofs image, in which case there are multiple device context and sbi instances.

In preparation for that, remove global device context and sbi in all libraries except buffer block library, as there's still only one output erofs image.

The device context is inlined into sbi. Each erofs_inode keeps a reference to corresponding sbi through vi->sbi. Global sbi is remained but only used by utils directly, e.g. mkfs/dump/fsck.

patch 1-3 are minor fix/cleanup patches preparing for patch 4.

Test cases in "-b experimental-tests" passed with both 'make check' and 'make check FSTYP=erofsfuse'.

This series is also in reference to [1].

[1] https://lore.kernel.org/linux-erofs/[email protected]/

Jingbo Xu (4):
erofs-utils: simplify iloc()
erofs-utils: lib: fix recursive erofs_iterate_dir()
erofs-utils: inline vle_compressmeta_capacity()
erofs-utils: remove global sbi in library

 dump/main.c                    |  30 +++---
 fsck/main.c                    |  41 ++++----
 fuse/main.c                    |  24 ++---
 include/erofs/blobchunk.h      |   4 +-
 include/erofs/cache.h          |   6 +-
 include/erofs/compress.h       |   8 +-
 include/erofs/compress_hints.h |   2 +-
 include/erofs/decompress.h     |   1 +
 include/erofs/dir.h            |   3 +-
 include/erofs/internal.h       |  59 ++++++-----
 include/erofs/io.h             |  38 +++----
 include/erofs/tar.h            |   4 +-
 include/erofs/xattr.h          |  16 +--
 lib/blobchunk.c                |  45 ++++-----
 lib/cache.c                    |  42 ++++----
 lib/compress.c                 | 175 +++++++++++++++++----------------
 lib/compress_hints.c           |  10 +-
 lib/compressor.c               |  15 +--
 lib/compressor.h               |   4 +-
 lib/compressor_lz4.c           |   2 +-
 lib/compressor_lz4hc.c         |   2 +-
 lib/data.c                     |  69 +++++++------
 lib/decompress.c               |  29 +++---
 lib/dir.c                      |  26 ++---
 lib/fragments.c                |   2 +-
 lib/inode.c                    | 118 ++++++++++++----------
 lib/io.c                       | 119 +++++++++++-----------
 lib/namei.c                    |  36 ++++---
 lib/super.c                    |  51 +++++-----
 lib/tar.c                      |  36 +++----
 lib/xattr.c                    |  75 +++++++-------
 lib/zmap.c                     |  43 ++++----
 mkfs/main.c                    |  62 ++++++------
 33 files changed, 632 insertions(+), 565 deletions(-)
Signature · 1 line
2.19.1.6.gb485710b
author
#1 lore raw

PATCH 1/4 erofs-utils: simplify iloc()

---
 fsck/main.c              |  2 +-
 include/erofs/internal.h | 10 +++++-----
 lib/data.c               |  4 ++--
 lib/namei.c              |  2 +-
 lib/xattr.c              |  8 ++++----
 lib/zmap.c               |  6 +++---
 6 files changed, 16 insertions(+), 16 deletions(-)
fsck/main.c +1 -1
index 608635e..498c646 100644
@@ -325,7 +325,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
 		}
 	}
 
-	addr = iloc(inode->nid) + inode->inode_isize;
+	addr = iloc(inode) + inode->inode_isize;
 	ret = dev_read(0, buf, addr, xattr_hdr_size);
 	if (ret < 0) {
 		erofs_err("failed to read xattr header @ nid %llu: %d",
include/erofs/internal.h +5 -5
index 46690f5..23f64b7 100644
@@ -103,11 +103,6 @@ struct erofs_sb_info {
 /* make sure that any user of the erofs headers has atleast 64bit off_t type */
 extern int erofs_assert_largefile[sizeof(off_t)-8];
 
-static inline erofs_off_t iloc(erofs_nid_t nid)
-{
-	return erofs_pos(sbi.meta_blkaddr) + (nid << sbi.islotbits);
-}
-
 #define EROFS_FEATURE_FUNCS(name, compat, feature) \
 static inline bool erofs_sb_has_##name(void) \
 { \
@@ -219,6 +214,11 @@ struct erofs_inode {
 	unsigned int fragment_size;
 };
 
+static inline erofs_off_t iloc(struct erofs_inode *inode)
+{
+	return erofs_pos(sbi.meta_blkaddr) + (inode->nid << sbi.islotbits);
+}
+
 static inline bool is_inode_layout_compression(struct erofs_inode *inode)
 {
 	return erofs_inode_is_data_compressed(inode->datalayout);
lib/data.c +2 -2
index 612112a..cc8ff2b 100644
@@ -33,7 +33,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,
 		map->m_plen = erofs_pos(lastblk) - offset;
 	} else if (tailendpacking) {
 		/* 2 - inode inline B: inode, [xattrs], inline last blk... */
-		map->m_pa = iloc(vi->nid) + vi->inode_isize +
+		map->m_pa = iloc(vi) + vi->inode_isize +
 			vi->xattr_isize + erofs_blkoff(map->m_la);
 		map->m_plen = inode->i_size - offset;
 
@@ -89,7 +89,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;	/* block map */
 
 	chunknr = map->m_la >> vi->u.chunkbits;
-	pos = roundup(iloc(vi->nid) + vi->inode_isize +
+	pos = roundup(iloc(vi) + vi->inode_isize +
 		      vi->xattr_isize, unit) + unit * chunknr;
 
 	err = blk_read(0, buf, erofs_blknr(pos), 1);
lib/namei.c +1 -1
index 3751741..4b7e3e4 100644
@@ -28,7 +28,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 	char buf[sizeof(struct erofs_inode_extended)];
 	struct erofs_inode_compact *dic;
 	struct erofs_inode_extended *die;
-	const erofs_off_t inode_loc = iloc(vi->nid);
+	const erofs_off_t inode_loc = iloc(vi);
 
 	ret = dev_read(0, buf, inode_loc, sizeof(*dic));
 	if (ret < 0)
lib/xattr.c +4 -4
index 87a95c7..5ad2d25 100644
@@ -871,8 +871,8 @@ static int init_inode_xattrs(struct erofs_inode *vi)
 		return -ENOATTR;
 	}
 
-	it.blkaddr = erofs_blknr(iloc(vi->nid) + vi->inode_isize);
-	it.ofs = erofs_blkoff(iloc(vi->nid) + vi->inode_isize);
+	it.blkaddr = erofs_blknr(iloc(vi) + vi->inode_isize);
+	it.ofs = erofs_blkoff(iloc(vi) + vi->inode_isize);
 
 	ret = blk_read(0, it.page, it.blkaddr, 1);
 	if (ret < 0)
@@ -962,8 +962,8 @@ static int inline_xattr_iter_pre(struct xattr_iter *it,
 
 	inline_xattr_ofs = vi->inode_isize + xattr_header_sz;
 
-	it->blkaddr = erofs_blknr(iloc(vi->nid) + inline_xattr_ofs);
-	it->ofs = erofs_blkoff(iloc(vi->nid) + inline_xattr_ofs);
+	it->blkaddr = erofs_blknr(iloc(vi) + inline_xattr_ofs);
+	it->ofs = erofs_blkoff(iloc(vi) + inline_xattr_ofs);
 
 	ret = blk_read(0, it->page, it->blkaddr, 1);
 	if (ret < 0)
lib/zmap.c +3 -3
index 209b5d7..b0ae88e 100644
@@ -39,7 +39,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi)
 	if (vi->flags & EROFS_I_Z_INITED)
 		return 0;
 
-	pos = round_up(iloc(vi->nid) + vi->inode_isize + vi->xattr_isize, 8);
+	pos = round_up(iloc(vi) + vi->inode_isize + vi->xattr_isize, 8);
 	ret = dev_read(0, buf, pos, sizeof(buf));
 	if (ret < 0)
 		return -EIO;
@@ -143,7 +143,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 					 unsigned long lcn)
 {
 	struct erofs_inode *const vi = m->inode;
-	const erofs_off_t ibase = iloc(vi->nid);
+	const erofs_off_t ibase = iloc(vi);
 	const erofs_off_t pos = Z_EROFS_FULL_INDEX_ALIGN(ibase +
 			vi->inode_isize + vi->xattr_isize) +
 		lcn * sizeof(struct z_erofs_lcluster_index);
@@ -342,7 +342,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 {
 	struct erofs_inode *const vi = m->inode;
 	const unsigned int lclusterbits = vi->z_logical_clusterbits;
-	const erofs_off_t ebase = round_up(iloc(vi->nid) + vi->inode_isize +
+	const erofs_off_t ebase = round_up(iloc(vi) + vi->inode_isize +
 					   vi->xattr_isize, 8) +
 		sizeof(struct z_erofs_map_header);
 	const unsigned int totalidx = BLK_ROUND_UP(vi->i_size);
Signature · 1 line
2.19.1.6.gb485710b
#2 lore raw

Re: [PATCH 1/4] erofs-utils: simplify iloc()

Quoted 1 line · Jingbo Xu

Could you please keep in sync with the kernel commit b780d3fc6107464dcc43631a6208c43b6421f1e6.

I mean, use the name "erofs_iloc()" instead.

Thanks,
Gao Xiang

Quoted 142 lines
---
  fsck/main.c              |  2 +-
  include/erofs/internal.h | 10 +++++-----
  lib/data.c               |  4 ++--
  lib/namei.c              |  2 +-
  lib/xattr.c              |  8 ++++----
  lib/zmap.c               |  6 +++---
  6 files changed, 16 insertions(+), 16 deletions(-)
fsck/main.c +1 -1
index 608635e..498c646 100644
@@ -325,7 +325,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
  		}
  	}
 
-	addr = iloc(inode->nid) + inode->inode_isize;
+	addr = iloc(inode) + inode->inode_isize;
  	ret = dev_read(0, buf, addr, xattr_hdr_size);
  	if (ret < 0) {
  		erofs_err("failed to read xattr header @ nid %llu: %d",
include/erofs/internal.h +5 -5
index 46690f5..23f64b7 100644
@@ -103,11 +103,6 @@ struct erofs_sb_info {
  /* make sure that any user of the erofs headers has atleast 64bit off_t type */
  extern int erofs_assert_largefile[sizeof(off_t)-8];
 
-static inline erofs_off_t iloc(erofs_nid_t nid)
-{
-	return erofs_pos(sbi.meta_blkaddr) + (nid << sbi.islotbits);
-}
-
  #define EROFS_FEATURE_FUNCS(name, compat, feature) \
  static inline bool erofs_sb_has_##name(void) \
  { \
@@ -219,6 +214,11 @@ struct erofs_inode {
  	unsigned int fragment_size;
  };
 
+static inline erofs_off_t iloc(struct erofs_inode *inode)
+{
+	return erofs_pos(sbi.meta_blkaddr) + (inode->nid << sbi.islotbits);
+}
+
  static inline bool is_inode_layout_compression(struct erofs_inode *inode)
  {
  	return erofs_inode_is_data_compressed(inode->datalayout);
lib/data.c +2 -2
index 612112a..cc8ff2b 100644
@@ -33,7 +33,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,
  		map->m_plen = erofs_pos(lastblk) - offset;
  	} else if (tailendpacking) {
  		/* 2 - inode inline B: inode, [xattrs], inline last blk... */
-		map->m_pa = iloc(vi->nid) + vi->inode_isize +
+		map->m_pa = iloc(vi) + vi->inode_isize +
  			vi->xattr_isize + erofs_blkoff(map->m_la);
  		map->m_plen = inode->i_size - offset;
 
@@ -89,7 +89,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
  		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;	/* block map */
 
  	chunknr = map->m_la >> vi->u.chunkbits;
-	pos = roundup(iloc(vi->nid) + vi->inode_isize +
+	pos = roundup(iloc(vi) + vi->inode_isize +
  		      vi->xattr_isize, unit) + unit * chunknr;
 
  	err = blk_read(0, buf, erofs_blknr(pos), 1);
lib/namei.c +1 -1
index 3751741..4b7e3e4 100644
@@ -28,7 +28,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
  	char buf[sizeof(struct erofs_inode_extended)];
  	struct erofs_inode_compact *dic;
  	struct erofs_inode_extended *die;
-	const erofs_off_t inode_loc = iloc(vi->nid);
+	const erofs_off_t inode_loc = iloc(vi);
 
  	ret = dev_read(0, buf, inode_loc, sizeof(*dic));
  	if (ret < 0)
lib/xattr.c +4 -4
index 87a95c7..5ad2d25 100644
@@ -871,8 +871,8 @@ static int init_inode_xattrs(struct erofs_inode *vi)
  		return -ENOATTR;
  	}
 
-	it.blkaddr = erofs_blknr(iloc(vi->nid) + vi->inode_isize);
-	it.ofs = erofs_blkoff(iloc(vi->nid) + vi->inode_isize);
+	it.blkaddr = erofs_blknr(iloc(vi) + vi->inode_isize);
+	it.ofs = erofs_blkoff(iloc(vi) + vi->inode_isize);
 
  	ret = blk_read(0, it.page, it.blkaddr, 1);
  	if (ret < 0)
@@ -962,8 +962,8 @@ static int inline_xattr_iter_pre(struct xattr_iter *it,
 
  	inline_xattr_ofs = vi->inode_isize + xattr_header_sz;
 
-	it->blkaddr = erofs_blknr(iloc(vi->nid) + inline_xattr_ofs);
-	it->ofs = erofs_blkoff(iloc(vi->nid) + inline_xattr_ofs);
+	it->blkaddr = erofs_blknr(iloc(vi) + inline_xattr_ofs);
+	it->ofs = erofs_blkoff(iloc(vi) + inline_xattr_ofs);
 
  	ret = blk_read(0, it->page, it->blkaddr, 1);
  	if (ret < 0)
lib/zmap.c +3 -3
index 209b5d7..b0ae88e 100644
@@ -39,7 +39,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi)
  	if (vi->flags & EROFS_I_Z_INITED)
  		return 0;
 
-	pos = round_up(iloc(vi->nid) + vi->inode_isize + vi->xattr_isize, 8);
+	pos = round_up(iloc(vi) + vi->inode_isize + vi->xattr_isize, 8);
  	ret = dev_read(0, buf, pos, sizeof(buf));
  	if (ret < 0)
  		return -EIO;
@@ -143,7 +143,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
  					 unsigned long lcn)
  {
  	struct erofs_inode *const vi = m->inode;
-	const erofs_off_t ibase = iloc(vi->nid);
+	const erofs_off_t ibase = iloc(vi);
  	const erofs_off_t pos = Z_EROFS_FULL_INDEX_ALIGN(ibase +
  			vi->inode_isize + vi->xattr_isize) +
  		lcn * sizeof(struct z_erofs_lcluster_index);
@@ -342,7 +342,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
  {
  	struct erofs_inode *const vi = m->inode;
  	const unsigned int lclusterbits = vi->z_logical_clusterbits;
-	const erofs_off_t ebase = round_up(iloc(vi->nid) + vi->inode_isize +
+	const erofs_off_t ebase = round_up(iloc(vi) + vi->inode_isize +
  					   vi->xattr_isize, 8) +
  		sizeof(struct z_erofs_map_header);
  	const unsigned int totalidx = BLK_ROUND_UP(vi->i_size);
author
#3 lore raw

PATCH 2/4 erofs-utils: lib: fix recursive erofs_iterate_dir()

In reply to Jingbo Xu

ctx->dir may have changed when ctx is reused along erofs_iterate_dir() recursion.

---
 lib/dir.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
lib/dir.c +4 -3
index abbf27a..6758b8d 100644
@@ -9,6 +9,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 			    unsigned int next_nameoff, unsigned int maxsize,
 			    bool fsck)
 {
+	struct erofs_inode *dir = ctx->dir;
 	struct erofs_dirent *de = dentry_blk;
 	const struct erofs_dirent *end = dentry_blk + next_nameoff;
 	const char *prev_name = NULL;
@@ -76,7 +77,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 					goto out;
 				}
 				ctx->flags |= EROFS_READDIR_DOTDOT_FOUND;
-				if (sbi.root_nid == ctx->dir->nid) {
+				if (sbi.root_nid == dir->nid) {
 					ctx->pnid = sbi.root_nid;
 					ctx->flags |= EROFS_READDIR_VALID_PNID;
 				}
@@ -95,7 +96,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 				}
 
 				ctx->flags |= EROFS_READDIR_DOT_FOUND;
-				if (fsck && ctx->de_nid != ctx->dir->nid) {
+				if (fsck && ctx->de_nid != dir->nid) {
 					errmsg = "corrupted `.' dirent";
 					goto out;
 				}
@@ -115,7 +116,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 out:
 	if (ret && !silent)
 		erofs_err("%s @ nid %llu, lblk %u, index %lu",
-			  errmsg, ctx->dir->nid | 0ULL, lblk,
+			  errmsg, dir->nid | 0ULL, lblk,
 			  (de - (struct erofs_dirent *)dentry_blk) | 0UL);
 	return ret;
 }
Signature · 1 line
2.19.1.6.gb485710b
author
#5 lore raw

PATCH 3/4 erofs-utils: inline vle_compressmeta_capacity()

In reply to Jingbo Xu
---
 lib/compress.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
lib/compress.c +3 -9
index 6fb63cb..a871322 100644
@@ -49,14 +49,6 @@ struct z_erofs_vle_compress_ctx {
 
 #define Z_EROFS_LEGACY_MAP_HEADER_SIZE	Z_EROFS_FULL_INDEX_ALIGN(0)
 
-static unsigned int vle_compressmeta_capacity(erofs_off_t filesize)
-{
-	const unsigned int indexsize = BLK_ROUND_UP(filesize) *
-		sizeof(struct z_erofs_lcluster_index);
-
-	return Z_EROFS_LEGACY_MAP_HEADER_SIZE + indexsize;
-}
-
 static void z_erofs_write_indexes_final(struct z_erofs_vle_compress_ctx *ctx)
 {
 	const unsigned int type = Z_EROFS_LCLUSTER_TYPE_PLAIN;
@@ -843,7 +835,9 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd)
 	erofs_blk_t blkaddr, compressed_blocks;
 	unsigned int legacymetasize;
 	int ret;
-	u8 *compressmeta = malloc(vle_compressmeta_capacity(inode->i_size));
+	u8 *compressmeta = malloc(BLK_ROUND_UP(inode->i_size) *
+				  sizeof(struct z_erofs_lcluster_index) +
+				  Z_EROFS_LEGACY_MAP_HEADER_SIZE);
 
 	if (!compressmeta)
 		return -ENOMEM;
Signature · 1 line
2.19.1.6.gb485710b
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] erofs-utils: inline vle_compressmeta_capacity()

Quoted 1 line · Jingbo Xu

Thanks,
Gao Xiang

Quoted 34 lines
---
  lib/compress.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
lib/compress.c +3 -9
index 6fb63cb..a871322 100644
@@ -49,14 +49,6 @@ struct z_erofs_vle_compress_ctx {
 
  #define Z_EROFS_LEGACY_MAP_HEADER_SIZE	Z_EROFS_FULL_INDEX_ALIGN(0)
 
-static unsigned int vle_compressmeta_capacity(erofs_off_t filesize)
-{
-	const unsigned int indexsize = BLK_ROUND_UP(filesize) *
-		sizeof(struct z_erofs_lcluster_index);
-
-	return Z_EROFS_LEGACY_MAP_HEADER_SIZE + indexsize;
-}
-
  static void z_erofs_write_indexes_final(struct z_erofs_vle_compress_ctx *ctx)
  {
  	const unsigned int type = Z_EROFS_LCLUSTER_TYPE_PLAIN;
@@ -843,7 +835,9 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd)
  	erofs_blk_t blkaddr, compressed_blocks;
  	unsigned int legacymetasize;
  	int ret;
-	u8 *compressmeta = malloc(vle_compressmeta_capacity(inode->i_size));
+	u8 *compressmeta = malloc(BLK_ROUND_UP(inode->i_size) *
+				  sizeof(struct z_erofs_lcluster_index) +
+				  Z_EROFS_LEGACY_MAP_HEADER_SIZE);
 
  	if (!compressmeta)
  		return -ENOMEM;
author
#7 lore raw

PATCH 4/4 erofs-utils: remove global sbi in library

In reply to Jingbo Xu

Later mkfs is going to be capable of converting multiple erofs images into one merged erofs image, in which case there are multiple device context and sbi instances.

In preparation for that, remove global device context and sbi in all libraries except buffer block library, as there's still only one output erofs image.

The device context is inlined into sbi. Global sbi is remained but only used by utils directly, e.g. mkfs/dump/fsck.

---
 dump/main.c                    |  30 +++---
 fsck/main.c                    |  39 ++++----
 fuse/main.c                    |  24 ++---
 include/erofs/blobchunk.h      |   4 +-
 include/erofs/cache.h          |   6 +-
 include/erofs/compress.h       |   8 +-
 include/erofs/compress_hints.h |   2 +-
 include/erofs/decompress.h     |   1 +
 include/erofs/dir.h            |   3 +-
 include/erofs/internal.h       |  51 +++++-----
 include/erofs/io.h             |  38 ++++----
 include/erofs/tar.h            |   4 +-
 include/erofs/xattr.h          |  16 ++--
 lib/blobchunk.c                |  45 ++++-----
 lib/cache.c                    |  42 ++++-----
 lib/compress.c                 | 165 ++++++++++++++++++---------------
 lib/compress_hints.c           |  10 +-
 lib/compressor.c               |  15 +--
 lib/compressor.h               |   4 +-
 lib/compressor_lz4.c           |   2 +-
 lib/compressor_lz4hc.c         |   2 +-
 lib/data.c                     |  65 +++++++------
 lib/decompress.c               |  29 +++---
 lib/dir.c                      |  21 +++--
 lib/fragments.c                |   2 +-
 lib/inode.c                    | 118 ++++++++++++-----------
 lib/io.c                       | 119 +++++++++++-------------
 lib/namei.c                    |  36 ++++---
 lib/super.c                    |  51 +++++-----
 lib/tar.c                      |  36 +++----
 lib/xattr.c                    |  75 ++++++++-------
 lib/zmap.c                     |  37 +++++---
 mkfs/main.c                    |  62 ++++++-------
 33 files changed, 617 insertions(+), 545 deletions(-)
dump/main.c +15 -15
index 7e75719..35f92b1 100644
@@ -154,7 +154,7 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
 			usage();
 			exit(0);
 		case 3:
-			err = blob_open_ro(optarg);
+			err = blob_open_ro(&sbi, optarg);
 			if (err)
 				return err;
 			++sbi.extra_devices;
@@ -202,7 +202,7 @@ static int erofsdump_get_occupied_size(struct erofs_inode *inode,
 	case EROFS_INODE_COMPRESSED_FULL:
 	case EROFS_INODE_COMPRESSED_COMPACT:
 		stats.compressed_files++;
-		*size = inode->u.i_blocks * erofs_blksiz();
+		*size = inode->u.i_blocks * erofs_blksiz(inode->sbi);
 		break;
 	default:
 		erofs_err("unknown datalayout");
@@ -272,10 +272,10 @@ static int erofsdump_read_packed_inode(void)
 	erofs_off_t occupied_size = 0;
 	struct erofs_inode vi = { .nid = sbi.packed_nid };
 
-	if (!(erofs_sb_has_fragments() && sbi.packed_nid > 0))
+	if (!(erofs_sb_has_fragments(&sbi) && sbi.packed_nid > 0))
 		return 0;
 
-	err = erofs_read_inode_from_disk(&vi);
+	err = erofs_read_inode_from_disk(&sbi, &vi);
 	if (err) {
 		erofs_err("failed to read packed file inode from disk");
 		return err;
@@ -298,7 +298,7 @@ static int erofsdump_readdir(struct erofs_dir_context *ctx)
 	erofs_off_t occupied_size = 0;
 	struct erofs_inode vi = { .nid = ctx->de_nid };
 
-	err = erofs_read_inode_from_disk(&vi);
+	err = erofs_read_inode_from_disk(&sbi, &vi);
 	if (err) {
 		erofs_err("failed to read file inode from disk");
 		return err;
@@ -362,13 +362,13 @@ static void erofsdump_show_fileinfo(bool show_extent)
 	};
 
 	if (dumpcfg.inode_path) {
-		err = erofs_ilookup(dumpcfg.inode_path, &inode);
+		err = erofs_ilookup(&sbi, dumpcfg.inode_path, &inode);
 		if (err) {
 			erofs_err("read inode failed @ %s", dumpcfg.inode_path);
 			return;
 		}
 	} else {
-		err = erofs_read_inode_from_disk(&inode);
+		err = erofs_read_inode_from_disk(&sbi, &inode);
 		if (err) {
 			erofs_err("read inode failed @ nid %llu",
 				  inode.nid | 0ULL);
@@ -382,7 +382,7 @@ static void erofsdump_show_fileinfo(bool show_extent)
 		return;
 	}
 
-	err = erofs_get_pathname(inode.nid, path, sizeof(path));
+	err = erofs_get_pathname(inode.sbi, inode.nid, path, sizeof(path));
 	if (err < 0) {
 		strncpy(path, "(not found)", sizeof(path) - 1);
 		path[sizeof(path) - 1] = '\0';
@@ -447,7 +447,7 @@ static void erofsdump_show_fileinfo(bool show_extent)
 			.m_deviceid = map.m_deviceid,
 			.m_pa = map.m_pa,
 		};
-		err = erofs_map_dev(&mdev);
+		err = erofs_map_dev(inode.sbi, &mdev);
 		if (err) {
 			erofs_err("failed to map device");
 			return;
@@ -604,7 +604,7 @@ static void erofsdump_show_superblock(void)
 			sbi.xattr_blkaddr);
 	fprintf(stdout, "Filesystem root nid:                          %llu\n",
 			sbi.root_nid | 0ULL);
-	if (erofs_sb_has_fragments() && sbi.packed_nid > 0)
+	if (erofs_sb_has_fragments(&sbi) && sbi.packed_nid > 0)
 		fprintf(stdout, "Filesystem packed nid:                        %llu\n",
 			sbi.packed_nid | 0ULL);
 	fprintf(stdout, "Filesystem inode count:                       %llu\n",
@@ -636,13 +636,13 @@ int main(int argc, char **argv)
 		goto exit;
 	}
 
-	err = dev_open_ro(cfg.c_img_path);
+	err = dev_open_ro(&sbi, cfg.c_img_path);
 	if (err) {
 		erofs_err("failed to open image file");
 		goto exit;
 	}
 
-	err = erofs_read_superblock();
+	err = erofs_read_superblock(&sbi);
 	if (err) {
 		erofs_err("failed to read superblock");
 		goto exit_dev_close;
@@ -667,11 +667,11 @@ int main(int argc, char **argv)
 		erofsdump_show_fileinfo(dumpcfg.show_extent);
 
 exit_put_super:
-	erofs_put_super();
+	erofs_put_super(&sbi);
 exit_dev_close:
-	dev_close();
+	dev_close(&sbi);
 exit:
-	blob_closeall();
+	blob_closeall(&sbi);
 	erofs_exit_configure();
 	return err;
 }
fsck/main.c +20 -19
index 498c646..4545050 100644
@@ -158,7 +158,7 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
 			}
 			break;
 		case 3:
-			ret = blob_open_ro(optarg);
+			ret = blob_open_ro(&sbi, optarg);
 			if (ret)
 				return ret;
 			++sbi.extra_devices;
@@ -279,7 +279,7 @@ static int erofs_check_sb_chksum(void)
 	struct erofs_super_block *sb;
 	int ret;
 
-	ret = blk_read(0, buf, 0, 1);
+	ret = blk_read(&sbi, 0, buf, 0, 1);
 	if (ret) {
 		erofs_err("failed to read superblock to check checksum: %d",
 			  ret);
@@ -289,7 +289,7 @@ static int erofs_check_sb_chksum(void)
 	sb = (struct erofs_super_block *)(buf + EROFS_SUPER_OFFSET);
 	sb->checksum = 0;
 
-	crc = erofs_crc32c(~0, (u8 *)sb, erofs_blksiz() - EROFS_SUPER_OFFSET);
+	crc = erofs_crc32c(~0, (u8 *)sb, erofs_blksiz(&sbi) - EROFS_SUPER_OFFSET);
 	if (crc != sbi.checksum) {
 		erofs_err("superblock chksum doesn't match: saved(%08xh) calculated(%08xh)",
 			  sbi.checksum, crc);
@@ -302,6 +302,7 @@ static int erofs_check_sb_chksum(void)
 
 static int erofs_verify_xattr(struct erofs_inode *inode)
 {
+	struct erofs_sb_info *sbi = inode->sbi;
 	unsigned int xattr_hdr_size = sizeof(struct erofs_xattr_ibody_header);
 	unsigned int xattr_entry_size = sizeof(struct erofs_xattr_entry);
 	erofs_off_t addr;
@@ -326,7 +327,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
 	}
 
 	addr = iloc(inode) + inode->inode_isize;
-	ret = dev_read(0, buf, addr, xattr_hdr_size);
+	ret = dev_read(sbi, 0, buf, addr, xattr_hdr_size);
 	if (ret < 0) {
 		erofs_err("failed to read xattr header @ nid %llu: %d",
 			  inode->nid | 0ULL, ret);
@@ -335,12 +336,12 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
 	ih = (struct erofs_xattr_ibody_header *)buf;
 	xattr_shared_count = ih->h_shared_count;
 
-	ofs = erofs_blkoff(addr) + xattr_hdr_size;
+	ofs = erofs_blkoff(sbi, addr) + xattr_hdr_size;
 	addr += xattr_hdr_size;
 	remaining -= xattr_hdr_size;
 	for (i = 0; i < xattr_shared_count; ++i) {
-		if (ofs >= erofs_blksiz()) {
-			if (ofs != erofs_blksiz()) {
+		if (ofs >= erofs_blksiz(sbi)) {
+			if (ofs != erofs_blksiz(sbi)) {
 				erofs_err("unaligned xattr entry in xattr shared area @ nid %llu",
 					  inode->nid | 0ULL);
 				ret = -EFSCORRUPTED;
@@ -356,7 +357,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
 	while (remaining > 0) {
 		unsigned int entry_sz;
 
-		ret = dev_read(0, buf, addr, xattr_entry_size);
+		ret = dev_read(sbi, 0, buf, addr, xattr_entry_size);
 		if (ret) {
 			erofs_err("failed to read xattr entry @ nid %llu: %d",
 				  inode->nid | 0ULL, ret);
@@ -483,7 +484,7 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
 				u64 count = min_t(u64, alloc_rawsize,
 						  map.m_llen);
 
-				ret = erofs_read_one_data(&map, raw, p, count);
+				ret = erofs_read_one_data(inode, &map, raw, p, count);
 				if (ret)
 					goto out;
 
@@ -497,8 +498,8 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
 
 	if (fsckcfg.print_comp_ratio) {
 		if (!erofs_is_packed_inode(inode))
-			fsckcfg.logical_blocks += BLK_ROUND_UP(inode->i_size);
-		fsckcfg.physical_blocks += BLK_ROUND_UP(pchunk_len);
+			fsckcfg.logical_blocks += BLK_ROUND_UP(inode->sbi, inode->i_size);
+		fsckcfg.physical_blocks += BLK_ROUND_UP(inode->sbi, pchunk_len);
 	}
 out:
 	if (raw)
@@ -845,7 +846,7 @@ static int erofsfsck_check_inode(erofs_nid_t pnid, erofs_nid_t nid)
 	erofs_dbg("check inode: nid(%llu)", nid | 0ULL);
 
 	inode.nid = nid;
-	ret = erofs_read_inode_from_disk(&inode);
+	ret = erofs_read_inode_from_disk(&sbi, &inode);
 	if (ret) {
 		if (ret == -EIO)
 			erofs_err("I/O error occurred when reading nid(%llu)",
@@ -920,19 +921,19 @@ int main(int argc, char *argv[])
 	cfg.c_dbg_lvl = -1;
 #endif
 
-	err = dev_open_ro(cfg.c_img_path);
+	err = dev_open_ro(&sbi, cfg.c_img_path);
 	if (err) {
 		erofs_err("failed to open image file");
 		goto exit;
 	}
 
-	err = erofs_read_superblock();
+	err = erofs_read_superblock(&sbi);
 	if (err) {
 		erofs_err("failed to read superblock");
 		goto exit_dev_close;
 	}
 
-	if (erofs_sb_has_sb_chksum() && erofs_check_sb_chksum()) {
+	if (erofs_sb_has_sb_chksum(&sbi) && erofs_check_sb_chksum()) {
 		erofs_err("failed to verify superblock checksum");
 		goto exit_put_super;
 	}
@@ -940,7 +941,7 @@ int main(int argc, char *argv[])
 	if (fsckcfg.extract_path)
 		erofsfsck_hardlink_init();
 
-	if (erofs_sb_has_fragments() && sbi.packed_nid > 0) {
+	if (erofs_sb_has_fragments(&sbi) && sbi.packed_nid > 0) {
 		err = erofsfsck_check_inode(sbi.packed_nid, sbi.packed_nid);
 		if (err) {
 			erofs_err("failed to verify packed file");
@@ -974,11 +975,11 @@ exit_hardlink:
 	if (fsckcfg.extract_path)
 		erofsfsck_hardlink_exit();
 exit_put_super:
-	erofs_put_super();
+	erofs_put_super(&sbi);
 exit_dev_close:
-	dev_close();
+	dev_close(&sbi);
 exit:
-	blob_closeall();
+	blob_closeall(&sbi);
 	erofs_exit_configure();
 	return err ? 1 : 0;
 }
fuse/main.c +12 -12
index b060e06..da5b0ff 100644
@@ -49,7 +49,7 @@ int erofsfuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 	};
 	erofs_dbg("readdir:%s offset=%llu", path, (long long)offset);
 
-	ret = erofs_ilookup(path, &dir);
+	ret = erofs_ilookup(&sbi, path, &dir);
 	if (ret)
 		return ret;
 
@@ -88,14 +88,14 @@ static int erofsfuse_getattr(const char *path, struct stat *stbuf)
 	int ret;
 
 	erofs_dbg("getattr(%s)", path);
-	ret = erofs_ilookup(path, &vi);
+	ret = erofs_ilookup(&sbi, path, &vi);
 	if (ret)
 		return -ENOENT;
 
 	stbuf->st_mode  = vi.i_mode;
 	stbuf->st_nlink = vi.i_nlink;
 	stbuf->st_size  = vi.i_size;
-	stbuf->st_blocks = roundup(vi.i_size, erofs_blksiz()) >> 9;
+	stbuf->st_blocks = roundup(vi.i_size, erofs_blksiz(vi.sbi)) >> 9;
 	stbuf->st_uid = vi.i_uid;
 	stbuf->st_gid = vi.i_gid;
 	if (S_ISBLK(vi.i_mode) || S_ISCHR(vi.i_mode))
@@ -115,7 +115,7 @@ static int erofsfuse_read(const char *path, char *buffer,
 
 	erofs_dbg("path:%s size=%zd offset=%llu", path, size, (long long)offset);
 
-	ret = erofs_ilookup(path, &vi);
+	ret = erofs_ilookup(&sbi, path, &vi);
 	if (ret)
 		return ret;
 
@@ -155,7 +155,7 @@ static int erofsfuse_getxattr(const char *path, const char *name, char *value,
 
 	erofs_dbg("getxattr(%s): name=%s size=%llu", path, name, size);
 
-	ret = erofs_ilookup(path, &vi);
+	ret = erofs_ilookup(&sbi, path, &vi);
 	if (ret)
 		return ret;
 
@@ -169,7 +169,7 @@ static int erofsfuse_listxattr(const char *path, char *list, size_t size)
 
 	erofs_dbg("listxattr(%s): size=%llu", path, size);
 
-	ret = erofs_ilookup(path, &vi);
+	ret = erofs_ilookup(&sbi, path, &vi);
 	if (ret)
 		return ret;
 
@@ -244,7 +244,7 @@ static int optional_opt_func(void *data, const char *arg, int key,
 
 	switch (key) {
 	case 1:
-		ret = blob_open_ro(arg + sizeof("--device=") - 1);
+		ret = blob_open_ro(&sbi, arg + sizeof("--device=") - 1);
 		if (ret)
 			return -1;
 		++sbi.extra_devices;
@@ -325,13 +325,13 @@ int main(int argc, char *argv[])
 	cfg.c_offset = fusecfg.offset;
 
 	erofsfuse_dumpcfg();
-	ret = dev_open_ro(fusecfg.disk);
+	ret = dev_open_ro(&sbi, fusecfg.disk);
 	if (ret) {
 		fprintf(stderr, "failed to open: %s\n", fusecfg.disk);
 		goto err_fuse_free_args;
 	}
 
-	ret = erofs_read_superblock();
+	ret = erofs_read_superblock(&sbi);
 	if (ret) {
 		fprintf(stderr, "failed to read erofs super block\n");
 		goto err_dev_close;
@@ -339,10 +339,10 @@ int main(int argc, char *argv[])
 
 	ret = fuse_main(args.argc, args.argv, &erofs_ops, NULL);
 
-	erofs_put_super();
+	erofs_put_super(&sbi);
 err_dev_close:
-	blob_closeall();
-	dev_close();
+	blob_closeall(&sbi);
+	dev_close(&sbi);
 err_fuse_free_args:
 	fuse_opt_free_args(&args);
 err:
include/erofs/blobchunk.h +2 -2
index 4269d82..7c5645e 100644
@@ -18,10 +18,10 @@ struct erofs_blobchunk *erofs_get_unhashed_chunk(erofs_off_t chunksize,
 			unsigned int device_id, erofs_blk_t blkaddr);
 int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, erofs_off_t off);
 int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd);
-int erofs_blob_remap(void);
+int erofs_blob_remap(struct erofs_sb_info *sbi);
 void erofs_blob_exit(void);
 int erofs_blob_init(const char *blobfile_path);
-int erofs_generate_devtable(void);
+int erofs_generate_devtable(struct erofs_sb_info *sbi);
 
 #ifdef __cplusplus
 }
include/erofs/cache.h +3 -3
index 8c3bd46..dc29985 100644
@@ -57,14 +57,14 @@ struct erofs_buffer_block {
 static inline const int get_alignsize(int type, int *type_ret)
 {
 	if (type == DATA)
-		return erofs_blksiz();
+		return erofs_blksiz(&sbi);
 
 	if (type == INODE) {
 		*type_ret = META;
 		return sizeof(struct erofs_inode_compact);
 	} else if (type == DIRA) {
 		*type_ret = META;
-		return erofs_blksiz();
+		return erofs_blksiz(&sbi);
 	} else if (type == XATTR) {
 		*type_ret = META;
 		return sizeof(struct erofs_xattr_entry);
@@ -88,7 +88,7 @@ static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)
 	if (bb->blkaddr == NULL_ADDR)
 		return NULL_ADDR_UL;
 
-	return erofs_pos(bb->blkaddr) +
+	return erofs_pos(&sbi, bb->blkaddr) +
 		(end ? list_next_entry(bh, list)->off : bh->off);
 }
 
include/erofs/compress.h +5 -3
index 08af9e3..8ac93f5 100644
@@ -19,18 +19,20 @@ extern "C"
 void z_erofs_drop_inline_pcluster(struct erofs_inode *inode);
 int erofs_write_compressed_file(struct erofs_inode *inode, int fd);
 
-int z_erofs_compress_init(struct erofs_buffer_head *bh);
+int z_erofs_compress_init(struct erofs_sb_info *sbi, struct erofs_buffer_head *bh);
 int z_erofs_compress_exit(void);
 
 const char *z_erofs_list_available_compressors(unsigned int i);
 
 static inline bool erofs_is_packed_inode(struct erofs_inode *inode)
 {
+	erofs_nid_t packed_nid = inode->sbi->packed_nid;
+
 	if (inode->nid == EROFS_PACKED_NID_UNALLOCATED) {
-		DBG_BUGON(sbi.packed_nid != EROFS_PACKED_NID_UNALLOCATED);
+		DBG_BUGON(packed_nid != EROFS_PACKED_NID_UNALLOCATED);
 		return true;
 	}
-	return (sbi.packed_nid > 0 && inode->nid == sbi.packed_nid);
+	return (packed_nid > 0 && inode->nid == packed_nid);
 }
 
 #ifdef __cplusplus
include/erofs/compress_hints.h +1 -1
index d836f22..9f0d8ae 100644
@@ -25,7 +25,7 @@ struct erofs_compress_hints {
 
 bool z_erofs_apply_compress_hints(struct erofs_inode *inode);
 void erofs_cleanup_compress_hints(void);
-int erofs_load_compress_hints(void);
+int erofs_load_compress_hints(struct erofs_sb_info *sbi);
 
 #ifdef __cplusplus
 }
include/erofs/decompress.h +1 -0
index a9067cb..0d55483 100644
@@ -14,6 +14,7 @@ extern "C"
 #include "internal.h"
 
 struct z_erofs_decompress_req {
+	struct erofs_sb_info *sbi;
 	char *in, *out;
 
 	/*
include/erofs/dir.h +2 -1
index 74bffb5..5460ac4 100644
@@ -62,7 +62,8 @@ struct erofs_dir_context {
 /* Iterate over inodes that are in directory */
 int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck);
 /* Get a full pathname of the inode NID */
-int erofs_get_pathname(erofs_nid_t nid, char *buf, size_t size);
+int erofs_get_pathname(struct erofs_sb_info *sbi, erofs_nid_t nid,
+		       char *buf, size_t size);
 
 #ifdef __cplusplus
 }
include/erofs/internal.h +29 -22

106 lines not on this page · raw message

include/erofs/io.h +20 -18
index 36210a3..4db5716 100644
@@ -22,34 +22,36 @@ extern "C"
 #define O_BINARY	0
 #endif
 
-void blob_closeall(void);
-int blob_open_ro(const char *dev);
-int dev_open(const char *devname);
-int dev_open_ro(const char *dev);
-void dev_close(void);
-int dev_write(const void *buf, u64 offset, size_t len);
-int dev_read(int device_id, void *buf, u64 offset, size_t len);
-int dev_fillzero(u64 offset, size_t len, bool padding);
-int dev_fsync(void);
-int dev_resize(erofs_blk_t nblocks);
-u64 dev_length(void);
-
-extern int erofs_devfd;
+void blob_closeall(struct erofs_sb_info *sbi);
+int blob_open_ro(struct erofs_sb_info *sbi, const char *dev);
+int dev_open(struct erofs_sb_info *sbi, const char *devname);
+int dev_open_ro(struct erofs_sb_info *sbi, const char *dev);
+void dev_close(struct erofs_sb_info *sbi);
+int dev_write(struct erofs_sb_info *sbi, const void *buf,
+	      u64 offset, size_t len);
+int dev_read(struct erofs_sb_info *sbi, int device_id,
+	     void *buf, u64 offset, size_t len);
+int dev_fillzero(struct erofs_sb_info *sbi, u64 offset,
+		 size_t len, bool padding);
+int dev_fsync(struct erofs_sb_info *sbi);
+int dev_resize(struct erofs_sb_info *sbi, erofs_blk_t nblocks);
 
 ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
 			      int fd_out, erofs_off_t *off_out,
 			      size_t length);
 
-static inline int blk_write(const void *buf, erofs_blk_t blkaddr,
-			    u32 nblocks)
+static inline int blk_write(struct erofs_sb_info *sbi, const void *buf,
+			    erofs_blk_t blkaddr, u32 nblocks)
 {
-	return dev_write(buf, erofs_pos(blkaddr), erofs_pos(nblocks));
+	return dev_write(sbi, buf, erofs_pos(sbi, blkaddr),
+			 erofs_pos(sbi, nblocks));
 }
 
-static inline int blk_read(int device_id, void *buf,
+static inline int blk_read(struct erofs_sb_info *sbi, int device_id, void *buf,
 			   erofs_blk_t start, u32 nblocks)
 {
-	return dev_read(device_id, buf, erofs_pos(start), erofs_pos(nblocks));
+	return dev_read(sbi, device_id, buf, erofs_pos(sbi, start),
+			erofs_pos(sbi, nblocks));
 }
 
 #ifdef __cplusplus
include/erofs/tar.h +2 -2
index 268c57b..a14f8ac 100644
@@ -23,7 +23,7 @@ struct erofs_tarfile {
 
 int tarerofs_init_empty_dir(struct erofs_inode *inode);
 int tarerofs_parse_tar(struct erofs_inode *root, struct erofs_tarfile *tar);
-int tarerofs_reserve_devtable(unsigned int devices);
-int tarerofs_write_devtable(struct erofs_tarfile *tar);
+int tarerofs_reserve_devtable(struct erofs_sb_info *sbi, unsigned int devices);
+int tarerofs_write_devtable(struct erofs_sb_info *sbi, struct erofs_tarfile *tar);
 
 #endif
include/erofs/xattr.h +9 -7
index 27e14bf..dc27cf6 100644
@@ -24,15 +24,17 @@ static inline unsigned int inlinexattr_header_size(struct erofs_inode *vi)
 		sizeof(u32) * vi->xattr_shared_count;
 }
 
-static inline erofs_blk_t xattrblock_addr(unsigned int xattr_id)
+static inline erofs_blk_t xattrblock_addr(struct erofs_inode *vi,
+					  unsigned int xattr_id)
 {
-	return sbi.xattr_blkaddr +
-		((xattr_id * sizeof(__u32)) >> sbi.blkszbits);
+	return vi->sbi->xattr_blkaddr +
+		erofs_blknr(vi->sbi, xattr_id * sizeof(__u32));
 }
 
-static inline unsigned int xattrblock_offset(unsigned int xattr_id)
+static inline unsigned int xattrblock_offset(struct erofs_inode *vi,
+					     unsigned int xattr_id)
 {
-	return (xattr_id * sizeof(__u32)) & (erofs_blksiz() - 1);
+	return erofs_blkoff(vi->sbi, xattr_id * sizeof(__u32));
 }
 
 #define EROFS_INODE_XATTR_ICOUNT(_size)	({\
@@ -75,11 +77,11 @@ static inline unsigned int xattrblock_offset(unsigned int xattr_id)
 int erofs_scan_file_xattrs(struct erofs_inode *inode);
 int erofs_prepare_xattr_ibody(struct erofs_inode *inode);
 char *erofs_export_xattr_ibody(struct list_head *ixattrs, unsigned int size);
-int erofs_build_shared_xattrs_from_path(const char *path);
+int erofs_build_shared_xattrs_from_path(struct erofs_sb_info *sbi, const char *path);
 
 int erofs_xattr_insert_name_prefix(const char *prefix);
 void erofs_xattr_cleanup_name_prefixes(void);
-int erofs_xattr_write_name_prefixes(FILE *f);
+int erofs_xattr_write_name_prefixes(struct erofs_sb_info *sbi, FILE *f);
 
 int erofs_setxattr(struct erofs_inode *inode, char *key,
 		   const void *value, size_t size);
lib/blobchunk.c +23 -22

123 lines not on this page · raw message

lib/cache.c +21 -21

130 lines not on this page · raw message

lib/compress.c +88 -77

540 lines not on this page · raw message

lib/compress_hints.c +5 -5
index 0182e93..f549604 100644
@@ -86,7 +86,7 @@ void erofs_cleanup_compress_hints(void)
 	}
 }
 
-int erofs_load_compress_hints(void)
+int erofs_load_compress_hints(struct erofs_sb_info *sbi)
 {
 	char buf[PATH_MAX + 100];
 	FILE *f;
@@ -133,21 +133,21 @@ int erofs_load_compress_hints(void)
 			}
 		}
 
-		if (pclustersize % erofs_blksiz()) {
+		if (pclustersize % erofs_blksiz(sbi)) {
 			erofs_warn("invalid physical clustersize %u, "
 				   "use default pclusterblks %u",
 				   pclustersize, cfg.c_pclusterblks_def);
 			continue;
 		}
 		erofs_insert_compress_hints(pattern,
-					    pclustersize / erofs_blksiz(), ccfg);
+					    pclustersize / erofs_blksiz(sbi), ccfg);
 
 		if (pclustersize > max_pclustersize)
 			max_pclustersize = pclustersize;
 	}
 
-	if (cfg.c_pclusterblks_max * erofs_blksiz() < max_pclustersize) {
-		cfg.c_pclusterblks_max = max_pclustersize / erofs_blksiz();
+	if (cfg.c_pclusterblks_max * erofs_blksiz(sbi) < max_pclustersize) {
+		cfg.c_pclusterblks_max = max_pclustersize / erofs_blksiz(sbi);
 		erofs_warn("update max pclusterblks to %u", cfg.c_pclusterblks_max);
 	}
 out:
lib/compressor.c +9 -6
index f81db5b..4333f26 100644
@@ -42,10 +42,10 @@ int erofs_compress_destsize(const struct erofs_compress *c,
 	if (ret < 0)
 		return ret;
 
-	/* XXX: ret >= erofs_blksiz() is a temporary hack for ztailpacking */
-	if (inblocks || ret >= erofs_blksiz() ||
+	/* XXX: ret >= destsize_alignsize is a temporary hack for ztailpacking */
+	if (inblocks || ret >= c->destsize_alignsize ||
 	    uncompressed_capacity != *srcsize)
-		compressed_size = roundup(ret, erofs_blksiz());
+		compressed_size = roundup(ret, c->destsize_alignsize);
 	else
 		compressed_size = ret;
 	DBG_BUGON(c->compress_threshold < 100);
@@ -72,16 +72,19 @@ int erofs_compressor_setlevel(struct erofs_compress *c, int compression_level)
 	return 0;
 }
 
-int erofs_compressor_init(struct erofs_compress *c, char *alg_name)
+int erofs_compressor_init(struct erofs_sb_info *sbi,
+			  struct erofs_compress *c, char *alg_name)
 {
 	int ret, i;
 
+	c->sbi = sbi;
+
 	/* should be written in "minimum compression ratio * 100" */
 	c->compress_threshold = 100;
 
 	/* optimize for 4k size page */
-	c->destsize_alignsize = erofs_blksiz();
-	c->destsize_redzone_begin = erofs_blksiz() - 16;
+	c->destsize_alignsize = erofs_blksiz(sbi);
+	c->destsize_redzone_begin = erofs_blksiz(sbi) - 16;
 	c->destsize_redzone_end = EROFS_CONFIG_COMPR_DEF_BOUNDARY;
 
 	if (!alg_name) {
lib/compressor.h +3 -1
index f699fe7..08a3988 100644
@@ -27,6 +27,7 @@ struct erofs_compressor {
 };
 
 struct erofs_compress {
+	struct erofs_sb_info *sbi;
 	const struct erofs_compressor *alg;
 
 	unsigned int compress_threshold;
@@ -52,7 +53,8 @@ int erofs_compress_destsize(const struct erofs_compress *c,
 			    void *dst, unsigned int dstsize, bool inblocks);
 
 int erofs_compressor_setlevel(struct erofs_compress *c, int compression_level);
-int erofs_compressor_init(struct erofs_compress *c, char *alg_name);
+int erofs_compressor_init(struct erofs_sb_info *sbi,
+		struct erofs_compress *c, char *alg_name);
 int erofs_compressor_exit(struct erofs_compress *c);
 
 #endif
lib/compressor_lz4.c +1 -1
index b6f6e7e..e507b70 100644
@@ -33,7 +33,7 @@ static int compressor_lz4_exit(struct erofs_compress *c)
 static int compressor_lz4_init(struct erofs_compress *c)
 {
 	c->alg = &erofs_compressor_lz4;
-	sbi.lz4_max_distance = LZ4_DISTANCE_MAX;
+	c->sbi->lz4_max_distance = LZ4_DISTANCE_MAX;
 	return 0;
 }
 
lib/compressor_lz4hc.c +1 -1
index eec1c84..f2120d8 100644
@@ -44,7 +44,7 @@ static int compressor_lz4hc_init(struct erofs_compress *c)
 	if (!c->private_data)
 		return -ENOMEM;
 
-	sbi.lz4_max_distance = LZ4_DISTANCE_MAX;
+	c->sbi->lz4_max_distance = LZ4_DISTANCE_MAX;
 	return 0;
 }
 
lib/data.c +35 -30

192 lines not on this page · raw message

lib/decompress.c +17 -12
index 0b41ff4..a7cf907 100644
@@ -97,14 +97,15 @@ static int zerr(int ret)
 static int z_erofs_decompress_deflate(struct z_erofs_decompress_req *rq)
 {
 	int ret = 0;
+	struct erofs_sb_info *sbi = rq->sbi;
 	u8 *dest = (u8 *)rq->out;
 	u8 *src = (u8 *)rq->in;
 	u8 *buff = NULL;
 	unsigned int inputmargin = 0;
 	z_stream strm;
 
-	while (!src[inputmargin & (erofs_blksiz() - 1)])
-		if (!(++inputmargin & (erofs_blksiz() - 1)))
+	while (!src[inputmargin & (erofs_blksiz(sbi) - 1)])
+		if (!(++inputmargin & (erofs_blksiz(sbi) - 1)))
 			break;
 
 	if (inputmargin >= rq->inputsize)
@@ -158,6 +159,7 @@ out_inflate_end:
 static int z_erofs_decompress_lzma(struct z_erofs_decompress_req *rq)
 {
 	int ret = 0;
+	struct erofs_sb_info *sbi = rq->sbi;
 	u8 *dest = (u8 *)rq->out;
 	u8 *src = (u8 *)rq->in;
 	u8 *buff = NULL;
@@ -165,8 +167,8 @@ static int z_erofs_decompress_lzma(struct z_erofs_decompress_req *rq)
 	lzma_stream strm;
 	lzma_ret ret2;
 
-	while (!src[inputmargin & (erofs_blksiz() - 1)])
-		if (!(++inputmargin & (erofs_blksiz() - 1)))
+	while (!src[inputmargin & (erofs_blksiz(sbi) - 1)])
+		if (!(++inputmargin & (erofs_blksiz(sbi) - 1)))
 			break;
 
 	if (inputmargin >= rq->inputsize)
@@ -224,12 +226,13 @@ static int z_erofs_decompress_lz4(struct z_erofs_decompress_req *rq)
 	char *buff = NULL;
 	bool support_0padding = false;
 	unsigned int inputmargin = 0;
+	struct erofs_sb_info *sbi = rq->sbi;
 
-	if (erofs_sb_has_lz4_0padding()) {
+	if (erofs_sb_has_lz4_0padding(sbi)) {
 		support_0padding = true;
 
-		while (!src[inputmargin & (erofs_blksiz() - 1)])
-			if (!(++inputmargin & (erofs_blksiz() - 1)))
+		while (!src[inputmargin & (erofs_blksiz(sbi) - 1)])
+			if (!(++inputmargin & (erofs_blksiz(sbi) - 1)))
 				break;
 
 		if (inputmargin >= rq->inputsize)
@@ -274,22 +277,24 @@ out:
 
 int z_erofs_decompress(struct z_erofs_decompress_req *rq)
 {
+	struct erofs_sb_info *sbi = rq->sbi;
+
 	if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
 		unsigned int count, rightpart, skip;
 
-		/* XXX: should support inputsize >= erofs_blksiz() later */
-		if (rq->inputsize > erofs_blksiz())
+		/* XXX: should support inputsize >= erofs_blksiz(sbi) later */
+		if (rq->inputsize > erofs_blksiz(sbi))
 			return -EFSCORRUPTED;
 
-		if (rq->decodedlength > erofs_blksiz())
+		if (rq->decodedlength > erofs_blksiz(sbi))
 			return -EFSCORRUPTED;
 
 		if (rq->decodedlength < rq->decodedskip)
 			return -EFSCORRUPTED;
 
 		count = rq->decodedlength - rq->decodedskip;
-		skip = erofs_blkoff(rq->interlaced_offset + rq->decodedskip);
-		rightpart = min(erofs_blksiz() - skip, count);
+		skip = erofs_blkoff(sbi, rq->interlaced_offset + rq->decodedskip);
+		rightpart = min(erofs_blksiz(sbi) - skip, count);
 		memcpy(rq->out, rq->in + skip, rightpart);
 		memcpy(rq->out + rightpart, rq->in, count - rightpart);
 		return 0;
lib/dir.c +12 -9
index 6758b8d..3e87086 100644
@@ -10,6 +10,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 			    bool fsck)
 {
 	struct erofs_inode *dir = ctx->dir;
+	struct erofs_sb_info *sbi = dir->sbi;
 	struct erofs_dirent *de = dentry_blk;
 	const struct erofs_dirent *end = dentry_blk + next_nameoff;
 	const char *prev_name = NULL;
@@ -77,8 +78,8 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 					goto out;
 				}
 				ctx->flags |= EROFS_READDIR_DOTDOT_FOUND;
-				if (sbi.root_nid == dir->nid) {
-					ctx->pnid = sbi.root_nid;
+				if (sbi->root_nid == dir->nid) {
+					ctx->pnid = sbi->root_nid;
 					ctx->flags |= EROFS_READDIR_VALID_PNID;
 				}
 				if (fsck &&
@@ -124,6 +125,7 @@ out:
 int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)
 {
 	struct erofs_inode *dir = ctx->dir;
+	struct erofs_sb_info *sbi = dir->sbi;
 	int err = 0;
 	erofs_off_t pos;
 	char buf[EROFS_MAX_BLOCK_SIZE];
@@ -134,9 +136,9 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)
 	ctx->flags &= ~EROFS_READDIR_ALL_SPECIAL_FOUND;
 	pos = 0;
 	while (pos < dir->i_size) {
-		erofs_blk_t lblk = erofs_blknr(pos);
+		erofs_blk_t lblk = erofs_blknr(sbi, pos);
 		erofs_off_t maxsize = min_t(erofs_off_t,
-					dir->i_size - pos, erofs_blksiz());
+					dir->i_size - pos, erofs_blksiz(sbi));
 		const struct erofs_dirent *de = (const void *)buf;
 		unsigned int nameoff;
 
@@ -149,7 +151,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)
 
 		nameoff = le16_to_cpu(de->nameoff);
 		if (nameoff < sizeof(struct erofs_dirent) ||
-		    nameoff >= erofs_blksiz()) {
+		    nameoff >= erofs_blksiz(sbi)) {
 			erofs_err("invalid de[0].nameoff %u @ nid %llu, lblk %u",
 				  nameoff, dir->nid | 0ULL, lblk);
 			return -EFSCORRUPTED;
@@ -206,7 +208,7 @@ static int erofs_get_pathname_iter(struct erofs_dir_context *ctx)
 	if (ctx->de_ftype == EROFS_FT_DIR || ctx->de_ftype == EROFS_FT_UNKNOWN) {
 		struct erofs_inode dir = { .nid = ctx->de_nid };
 
-		ret = erofs_read_inode_from_disk(&dir);
+		ret = erofs_read_inode_from_disk(ctx->dir->sbi, &dir);
 		if (ret) {
 			erofs_err("read inode failed @ nid %llu", dir.nid | 0ULL);
 			return ret;
@@ -230,10 +232,11 @@ static int erofs_get_pathname_iter(struct erofs_dir_context *ctx)
 	return 0;
 }
 
-int erofs_get_pathname(erofs_nid_t nid, char *buf, size_t size)
+int erofs_get_pathname(struct erofs_sb_info *sbi, erofs_nid_t nid,
+		       char *buf, size_t size)
 {
 	int ret;
-	struct erofs_inode root = { .nid = sbi.root_nid };
+	struct erofs_inode root = { .nid = sbi->root_nid };
 	struct erofs_get_pathname_context pathctx = {
 		.ctx.flags = 0,
 		.ctx.dir = &root,
@@ -256,7 +259,7 @@ int erofs_get_pathname(erofs_nid_t nid, char *buf, size_t size)
 		return 0;
 	}
 
-	ret = erofs_read_inode_from_disk(&root);
+	ret = erofs_read_inode_from_disk(sbi, &root);
 	if (ret) {
 		erofs_err("read inode failed @ nid %llu", root.nid | 0ULL);
 		return ret;
lib/fragments.c +1 -1
index 1d243d3..d4f6be1 100644
@@ -229,7 +229,7 @@ void z_erofs_fragments_commit(struct erofs_inode *inode)
 		inode->datalayout = EROFS_INODE_COMPRESSED_FULL;
 
 	inode->z_advise |= Z_EROFS_ADVISE_FRAGMENT_PCLUSTER;
-	erofs_sb_set_fragments();
+	erofs_sb_set_fragments(inode->sbi);
 }
 
 int z_erofs_pack_file_from_fd(struct erofs_inode *inode, int fd,
lib/inode.c +65 -53

363 lines not on this page · raw message

lib/io.c +55 -64

276 lines not on this page · raw message

lib/namei.c +21 -15
index 4b7e3e4..4a1ff98 100644
@@ -22,15 +22,18 @@ static dev_t erofs_new_decode_dev(u32 dev)
 	return makedev(major, minor);
 }
 
-int erofs_read_inode_from_disk(struct erofs_inode *vi)
+int erofs_read_inode_from_disk(struct erofs_sb_info *sbi, struct erofs_inode *vi)
 {
 	int ret, ifmt;
 	char buf[sizeof(struct erofs_inode_extended)];
 	struct erofs_inode_compact *dic;
 	struct erofs_inode_extended *die;
-	const erofs_off_t inode_loc = iloc(vi);
+	erofs_off_t inode_loc;
 
-	ret = dev_read(0, buf, inode_loc, sizeof(*dic));
+	vi->sbi = sbi;
+	inode_loc = iloc(vi);
+
+	ret = dev_read(sbi, 0, buf, inode_loc, sizeof(*dic));
 	if (ret < 0)
 		return -EIO;
 
@@ -47,7 +50,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 	case EROFS_INODE_LAYOUT_EXTENDED:
 		vi->inode_isize = sizeof(struct erofs_inode_extended);
 
-		ret = dev_read(0, buf + sizeof(*dic), inode_loc + sizeof(*dic),
+		ret = dev_read(sbi, 0, buf + sizeof(*dic), inode_loc + sizeof(*dic),
 			       sizeof(*die) - sizeof(*dic));
 		if (ret < 0)
 			return -EIO;
@@ -114,8 +117,8 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 		vi->i_gid = le16_to_cpu(dic->i_gid);
 		vi->i_nlink = le16_to_cpu(dic->i_nlink);
 
-		vi->i_mtime = sbi.build_time;
-		vi->i_mtime_nsec = sbi.build_time_nsec;
+		vi->i_mtime = sbi->build_time;
+		vi->i_mtime_nsec = sbi->build_time_nsec;
 
 		vi->i_size = le32_to_cpu(dic->i_size);
 		if (vi->datalayout == EROFS_INODE_CHUNK_BASED)
@@ -134,10 +137,10 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 				  vi->u.chunkformat, vi->nid | 0ULL);
 			return -EOPNOTSUPP;
 		}
-		vi->u.chunkbits = sbi.blkszbits +
+		vi->u.chunkbits = sbi->blkszbits +
 			(vi->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
 	} else if (erofs_inode_is_data_compressed(vi->datalayout)) {
-		if (erofs_blksiz() != EROFS_MAX_BLOCK_SIZE)
+		if (erofs_blksiz(vi->sbi) != EROFS_MAX_BLOCK_SIZE)
 			return -EOPNOTSUPP;
 		return z_erofs_fill_inode(vi);
 	}
@@ -185,6 +188,7 @@ struct erofs_dirent *find_target_dirent(erofs_nid_t pnid,
 }
 
 struct nameidata {
+	struct erofs_sb_info *sbi;
 	erofs_nid_t	nid;
 	unsigned int	ftype;
 };
@@ -195,16 +199,17 @@ int erofs_namei(struct nameidata *nd, const char *name, unsigned int len)
 	int ret;
 	char buf[EROFS_MAX_BLOCK_SIZE];
 	struct erofs_inode vi = { .nid = nid };
+	struct erofs_sb_info *sbi = nd->sbi;
 	erofs_off_t offset;
 
-	ret = erofs_read_inode_from_disk(&vi);
+	ret = erofs_read_inode_from_disk(sbi, &vi);
 	if (ret)
 		return ret;
 
 	offset = 0;
 	while (offset < vi.i_size) {
 		erofs_off_t maxsize = min_t(erofs_off_t,
-					    vi.i_size - offset, erofs_blksiz());
+					    vi.i_size - offset, erofs_blksiz(sbi));
 		struct erofs_dirent *de = (void *)buf;
 		unsigned int nameoff;
 
@@ -214,7 +219,7 @@ int erofs_namei(struct nameidata *nd, const char *name, unsigned int len)
 
 		nameoff = le16_to_cpu(de->nameoff);
 		if (nameoff < sizeof(struct erofs_dirent) ||
-		    nameoff >= erofs_blksiz()) {
+		    nameoff >= erofs_blksiz(sbi)) {
 			erofs_err("invalid de[0].nameoff %u @ nid %llu",
 				  nameoff, nid | 0ULL);
 			return -EFSCORRUPTED;
@@ -236,7 +241,7 @@ int erofs_namei(struct nameidata *nd, const char *name, unsigned int len)
 
 static int link_path_walk(const char *name, struct nameidata *nd)
 {
-	nd->nid = sbi.root_nid;
+	nd->nid = nd->sbi->root_nid;
 
 	while (*name == '/')
 		name++;
@@ -263,15 +268,16 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 	return 0;
 }
 
-int erofs_ilookup(const char *path, struct erofs_inode *vi)
+int erofs_ilookup(struct erofs_sb_info *sbi, const char *path,
+		  struct erofs_inode *vi)
 {
 	int ret;
-	struct nameidata nd;
+	struct nameidata nd = { .sbi = sbi };
 
 	ret = link_path_walk(path, &nd);
 	if (ret)
 		return ret;
 
 	vi->nid = nd.nid;
-	return erofs_read_inode_from_disk(vi);
+	return erofs_read_inode_from_disk(sbi, vi);
 }
lib/super.c +26 -25

89 lines not on this page · raw message

lib/tar.c +19 -17
index b62e562..76ba69d 100644
@@ -161,8 +161,8 @@ static struct erofs_dentry *tarerofs_mkdir(struct erofs_inode *dir, const char *
 	inode->i_parent = dir;
 	inode->i_uid = getuid();
 	inode->i_gid = getgid();
-	inode->i_mtime = sbi.build_time;
-	inode->i_mtime_nsec = sbi.build_time_nsec;
+	inode->i_mtime = inode->sbi->build_time;
+	inode->i_mtime_nsec = inode->sbi->build_time_nsec;
 	tarerofs_init_empty_dir(inode);
 
 	d = erofs_d_alloc(dir, s);
@@ -353,14 +353,15 @@ out:
 
 int tarerofs_write_chunk_indexes(struct erofs_inode *inode, erofs_blk_t blkaddr)
 {
+	struct erofs_sb_info *sbi = inode->sbi;
 	unsigned int chunkbits = ilog2(inode->i_size - 1) + 1;
 	unsigned int count, unit;
 	erofs_off_t chunksize, len, pos;
 	struct erofs_inode_chunk_index *idx;
 
-	if (chunkbits < sbi.blkszbits)
-		chunkbits = sbi.blkszbits;
-	inode->u.chunkformat |= chunkbits - sbi.blkszbits;
+	if (chunkbits < sbi->blkszbits)
+		chunkbits = sbi->blkszbits;
+	inode->u.chunkformat |= chunkbits - sbi->blkszbits;
 	inode->u.chunkformat |= EROFS_CHUNK_FORMAT_INDEXES;
 	chunksize = 1ULL << chunkbits;
 	count = DIV_ROUND_UP(inode->i_size, chunksize);
@@ -382,7 +383,7 @@ int tarerofs_write_chunk_indexes(struct erofs_inode *inode, erofs_blk_t blkaddr)
 			return PTR_ERR(chunk);
 
 		*(void **)idx++ = chunk;
-		blkaddr += erofs_blknr(len);
+		blkaddr += erofs_blknr(sbi, len);
 	}
 	inode->datalayout = EROFS_INODE_CHUNK_BASED;
 	return 0;
@@ -410,6 +411,7 @@ int tarerofs_parse_tar(struct erofs_inode *root, struct erofs_tarfile *tar)
 {
 	char path[PATH_MAX];
 	struct erofs_pax_header eh = tar->global;
+	struct erofs_sb_info *sbi = root->sbi;
 	bool e, whout, opq;
 	struct stat st;
 	erofs_off_t tar_offset, data_offset;
@@ -616,7 +618,7 @@ restart:
 			eh.link = strndup(th.linkname, sizeof(th.linkname));
 	}
 
-	if (tar->index_mode && erofs_blkoff(tar_offset + sizeof(th))) {
+	if (tar->index_mode && erofs_blkoff(sbi, tar_offset + sizeof(th))) {
 		erofs_err("invalid tar data alignment @ %llu", tar_offset);
 		ret = -EIO;
 		goto out;
@@ -719,7 +721,7 @@ new_inode:
 			memcpy(inode->i_link, eh.link, inode->i_size + 1);
 		} else if (tar->index_mode) {
 			ret = tarerofs_write_chunk_indexes(inode,
-					erofs_blknr(data_offset));
+					erofs_blknr(sbi, data_offset));
 			if (ret)
 				goto out;
 			if (erofs_lskip(tar->fd, inode->i_size)) {
@@ -774,7 +776,7 @@ invalid_tar:
 
 static struct erofs_buffer_head *bh_devt;
 
-int tarerofs_reserve_devtable(unsigned int devices)
+int tarerofs_reserve_devtable(struct erofs_sb_info *sbi, unsigned int devices)
 {
 	if (!devices)
 		return 0;
@@ -786,27 +788,27 @@ int tarerofs_reserve_devtable(unsigned int devices)
 
 	erofs_mapbh(bh_devt->block);
 	bh_devt->op = &erofs_skip_write_bhops;
-	sbi.devt_slotoff = erofs_btell(bh_devt, false) / EROFS_DEVT_SLOT_SIZE;
-	sbi.extra_devices = devices;
-	erofs_sb_set_device_table();
+	sbi->devt_slotoff = erofs_btell(bh_devt, false) / EROFS_DEVT_SLOT_SIZE;
+	sbi->extra_devices = devices;
+	erofs_sb_set_device_table(sbi);
 	return 0;
 }
 
-int tarerofs_write_devtable(struct erofs_tarfile *tar)
+int tarerofs_write_devtable(struct erofs_sb_info *sbi, struct erofs_tarfile *tar)
 {
 	erofs_off_t pos_out;
 	unsigned int i;
 
-	if (!sbi.extra_devices)
+	if (!sbi->extra_devices)
 		return 0;
 	pos_out = erofs_btell(bh_devt, false);
-	for (i = 0; i < sbi.extra_devices; ++i) {
+	for (i = 0; i < sbi->extra_devices; ++i) {
 		struct erofs_deviceslot dis = {
-			.blocks = erofs_blknr(tar->offset),
+			.blocks = erofs_blknr(sbi, tar->offset),
 		};
 		int ret;
 
-		ret = dev_write(&dis, pos_out, sizeof(dis));
+		ret = dev_write(sbi, &dis, pos_out, sizeof(dis));
 		if (ret)
 			return ret;
 		pos_out += sizeof(dis);
lib/xattr.c +41 -34

207 lines not on this page · raw message

lib/zmap.c +22 -15
index b0ae88e..9750d1c 100644

Lines of this file are not shown. View the raw message.

mkfs/main.c +31 -31

62 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.19.1.6.gb485710b

Part of the diff is not shown here. View the raw message.