erofs-utils: lib/cache.c: replace &g_sbi with sbi
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Wed, 10 Jul 2024 08:29:05 +0000 (16:29 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sat, 13 Jul 2024 17:05:58 +0000 (01:05 +0800)
Prepare for the upcoming per-sbi buffers.

Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240710082906.203180-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
include/erofs/cache.h
lib/cache.c

index 234185fb099896570293ae1794877f71ef76b091..288843ebd8941317ebf1d7b161c6a79fe554d34a 100644 (file)
@@ -55,15 +55,17 @@ struct erofs_buffer_block {
 
 static inline const int get_alignsize(int type, int *type_ret)
 {
+       struct erofs_sb_info *sbi = &g_sbi;
+
        if (type == DATA)
-               return erofs_blksiz(&g_sbi);
+               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(&g_sbi);
+               return erofs_blksiz(sbi);
        } else if (type == XATTR) {
                *type_ret = META;
                return sizeof(struct erofs_xattr_entry);
@@ -83,11 +85,12 @@ extern const struct erofs_bhops erofs_skip_write_bhops;
 static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)
 {
        const struct erofs_buffer_block *bb = bh->block;
+       struct erofs_sb_info *sbi = &g_sbi;
 
        if (bb->blkaddr == NULL_ADDR)
                return NULL_ADDR_UL;
 
-       return erofs_pos(&g_sbi, bb->blkaddr) +
+       return erofs_pos(sbi, bb->blkaddr) +
                (end ? list_next_entry(bh, list)->off : bh->off);
 }
 
index e3dc9de076a24407e2e69ba59c33d328adcd61c9..1deaa8622e2be790d2daf813c15419d99d8563c1 100644 (file)
@@ -50,13 +50,14 @@ void erofs_buffer_init(erofs_blk_t startblk)
 
 static void erofs_bupdate_mapped(struct erofs_buffer_block *bb)
 {
+       struct erofs_sb_info *sbi = &g_sbi;
        struct list_head *bkt;
 
        if (bb->blkaddr == NULL_ADDR)
                return;
 
        bkt = mapped_buckets[bb->type] +
-               (bb->buffers.off & (erofs_blksiz(&g_sbi) - 1));
+               (bb->buffers.off & (erofs_blksiz(sbi) - 1));
        list_del(&bb->mapped_list);
        list_add_tail(&bb->mapped_list, bkt);
 }
@@ -69,7 +70,8 @@ static int __erofs_battach(struct erofs_buffer_block *bb,
                           unsigned int extrasize,
                           bool dryrun)
 {
-       const unsigned int blksiz = erofs_blksiz(&g_sbi);
+       struct erofs_sb_info *sbi = &g_sbi;
+       const unsigned int blksiz = erofs_blksiz(sbi);
        const unsigned int blkmask = blksiz - 1;
        erofs_off_t boff = bb->buffers.off;
        const erofs_off_t alignedoffset = roundup(boff, alignsize);
@@ -86,7 +88,7 @@ static int __erofs_battach(struct erofs_buffer_block *bb,
                blkaddr = bb->blkaddr;
                if (blkaddr != NULL_ADDR) {
                        tailupdate = (tail_blkaddr == blkaddr +
-                                     BLK_ROUND_UP(&g_sbi, boff));
+                                     BLK_ROUND_UP(sbi, boff));
                        if (oob && !tailupdate)
                                return -EINVAL;
                }
@@ -102,7 +104,7 @@ static int __erofs_battach(struct erofs_buffer_block *bb,
                bb->buffers.off = boff;
                /* need to update the tail_blkaddr */
                if (tailupdate)
-                       tail_blkaddr = blkaddr + BLK_ROUND_UP(&g_sbi, boff);
+                       tail_blkaddr = blkaddr + BLK_ROUND_UP(sbi, boff);
                erofs_bupdate_mapped(bb);
        }
        return ((alignedoffset + incr - 1) & blkmask) + 1;
@@ -125,7 +127,8 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,
                                  unsigned int alignsize,
                                  struct erofs_buffer_block **bbp)
 {
-       const unsigned int blksiz = erofs_blksiz(&g_sbi);
+       struct erofs_sb_info *sbi = &g_sbi;
+       const unsigned int blksiz = erofs_blksiz(sbi);
        struct erofs_buffer_block *cur, *bb;
        unsigned int used0, used_before, usedmax, used;
        int ret;
@@ -314,6 +317,7 @@ struct erofs_buffer_head *erofs_battach(struct erofs_buffer_head *bh,
 
 static erofs_blk_t __erofs_mapbh(struct erofs_buffer_block *bb)
 {
+       struct erofs_sb_info *sbi = &g_sbi;
        erofs_blk_t blkaddr;
 
        if (bb->blkaddr == NULL_ADDR) {
@@ -322,7 +326,7 @@ static erofs_blk_t __erofs_mapbh(struct erofs_buffer_block *bb)
                erofs_bupdate_mapped(bb);
        }
 
-       blkaddr = bb->blkaddr + BLK_ROUND_UP(&g_sbi, bb->buffers.off);
+       blkaddr = bb->blkaddr + BLK_ROUND_UP(sbi, bb->buffers.off);
        if (blkaddr > tail_blkaddr)
                tail_blkaddr = blkaddr;
 
@@ -360,7 +364,8 @@ static void erofs_bfree(struct erofs_buffer_block *bb)
 
 int erofs_bflush(struct erofs_buffer_block *bb)
 {
-       const unsigned int blksiz = erofs_blksiz(&g_sbi);
+       struct erofs_sb_info *sbi = &g_sbi;
+       const unsigned int blksiz = erofs_blksiz(sbi);
        struct erofs_buffer_block *p, *n;
        erofs_blk_t blkaddr;
 
@@ -392,11 +397,11 @@ int erofs_bflush(struct erofs_buffer_block *bb)
 
                padding = blksiz - (p->buffers.off & (blksiz - 1));
                if (padding != blksiz)
-                       erofs_dev_fillzero(&g_sbi, erofs_pos(&g_sbi, blkaddr) - padding,
+                       erofs_dev_fillzero(sbi, erofs_pos(sbi, blkaddr) - padding,
                                           padding, true);
 
                if (p->type != DATA)
-                       erofs_metablkcnt += BLK_ROUND_UP(&g_sbi, p->buffers.off);
+                       erofs_metablkcnt += BLK_ROUND_UP(sbi, p->buffers.off);
                erofs_dbg("block %u to %u flushed", p->blkaddr, blkaddr - 1);
                erofs_bfree(p);
        }
@@ -406,12 +411,13 @@ int erofs_bflush(struct erofs_buffer_block *bb)
 void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke)
 {
        struct erofs_buffer_block *const bb = bh->block;
+       struct erofs_sb_info *sbi = &g_sbi;
        const erofs_blk_t blkaddr = bh->block->blkaddr;
        bool rollback = false;
 
        /* tail_blkaddr could be rolled back after revoking all bhs */
        if (tryrevoke && blkaddr != NULL_ADDR &&
-           tail_blkaddr == blkaddr + BLK_ROUND_UP(&g_sbi, bb->buffers.off))
+           tail_blkaddr == blkaddr + BLK_ROUND_UP(sbi, bb->buffers.off))
                rollback = true;
 
        bh->op = &erofs_drop_directly_bhops;
@@ -421,7 +427,7 @@ void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke)
                return;
 
        if (!rollback && bb->type != DATA)
-               erofs_metablkcnt += BLK_ROUND_UP(&g_sbi, bb->buffers.off);
+               erofs_metablkcnt += BLK_ROUND_UP(sbi, bb->buffers.off);
        erofs_bfree(bb);
        if (rollback)
                tail_blkaddr = blkaddr;