erofs-utils: lib: cache: get rid of required_ext
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 19 Dec 2024 06:43:28 +0000 (14:43 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sat, 5 Apr 2025 16:25:21 +0000 (00:25 +0800)
It's never used and doesn't have clear meanings.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241219064331.2223001-1-hsiangkao@linux.alibaba.com
include/erofs/cache.h
lib/blobchunk.c
lib/cache.c
lib/compress.c
lib/inode.c
lib/super.c
lib/xattr.c

index 5411eed9e25a2491ab304d7c8aca1ebfb9939e80..646d6def418c1c24094d3a50c17b6bc553d42319 100644 (file)
@@ -120,7 +120,6 @@ int erofs_bh_balloon(struct erofs_buffer_head *bh, erofs_off_t incr);
 
 struct erofs_buffer_head *erofs_balloc(struct erofs_bufmgr *bmgr,
                                       int type, erofs_off_t size,
-                                      unsigned int required_ext,
                                       unsigned int inline_ext);
 struct erofs_buffer_head *erofs_battach(struct erofs_buffer_head *bh,
                                        int type, unsigned int size);
index abbcba4427cc9ec9c037434e3d9d87186574d8b1..e6386d64d639bf013580c4ee4a7094d37b8d88de 100644 (file)
@@ -529,7 +529,7 @@ int erofs_mkfs_dump_blobs(struct erofs_sb_info *sbi)
                return 0;
        }
 
-       bh = erofs_balloc(sbi->bmgr, DATA, datablob_size, 0, 0);
+       bh = erofs_balloc(sbi->bmgr, DATA, datablob_size, 0);
        if (IS_ERR(bh))
                return PTR_ERR(bh);
 
@@ -647,7 +647,7 @@ int erofs_mkfs_init_devices(struct erofs_sb_info *sbi, unsigned int devices)
                return -ENOMEM;
 
        bh_devt = erofs_balloc(sbi->bmgr, DEVT,
-               sizeof(struct erofs_deviceslot) * devices, 0, 0);
+               sizeof(struct erofs_deviceslot) * devices, 0);
        if (IS_ERR(bh_devt)) {
                free(sbi->devs);
                return PTR_ERR(bh_devt);
index 3208e9f96b74685000cede97e4c797e9c774890d..66bbdca2f774307073bfc19665e2a670a3ba063d 100644 (file)
@@ -127,7 +127,6 @@ int erofs_bh_balloon(struct erofs_buffer_head *bh, erofs_off_t incr)
 
 static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
                                  int type, erofs_off_t size,
-                                 unsigned int required_ext,
                                  unsigned int inline_ext,
                                  unsigned int alignsize,
                                  struct erofs_buffer_block **bbp)
@@ -137,7 +136,7 @@ static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
        unsigned int used0, used_before, usedmax, used;
        int ret;
 
-       used0 = ((size + required_ext) & (blksiz - 1)) + inline_ext;
+       used0 = (size & (blksiz - 1)) + inline_ext;
        /* inline data should be in the same fs block */
        if (used0 > blksiz)
                return -ENOSPC;
@@ -151,11 +150,10 @@ static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
        bb = NULL;
 
        /* try to find a most-fit mapped buffer block first */
-       if (size + required_ext + inline_ext >= blksiz)
+       if (size + inline_ext >= blksiz)
                goto skip_mapped;
 
-       used_before = rounddown(blksiz -
-                               (size + required_ext + inline_ext), alignsize);
+       used_before = rounddown(blksiz - (size + inline_ext), alignsize);
        for (; used_before; --used_before) {
                struct list_head *bt = bmgr->mapped_buckets[type] + used_before;
 
@@ -175,14 +173,14 @@ static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
                DBG_BUGON(used_before != (cur->buffers.off & (blksiz - 1)));
 
                ret = __erofs_battach(cur, NULL, size, alignsize,
-                                     required_ext + inline_ext, true);
+                                     inline_ext, true);
                if (ret < 0) {
                        DBG_BUGON(1);
                        continue;
                }
 
                /* should contain all data in the current block */
-               used = ret + required_ext + inline_ext;
+               used = ret + inline_ext;
                DBG_BUGON(used > blksiz);
 
                bb = cur;
@@ -207,11 +205,11 @@ skip_mapped:
                        continue;
 
                ret = __erofs_battach(cur, NULL, size, alignsize,
-                                     required_ext + inline_ext, true);
+                                     inline_ext, true);
                if (ret < 0)
                        continue;
 
-               used = ((ret + required_ext) & (blksiz - 1)) + inline_ext;
+               used = (ret & (blksiz - 1)) + inline_ext;
 
                /* should contain inline data in current block */
                if (used > blksiz)
@@ -235,7 +233,6 @@ skip_mapped:
 
 struct erofs_buffer_head *erofs_balloc(struct erofs_bufmgr *bmgr,
                                       int type, erofs_off_t size,
-                                      unsigned int required_ext,
                                       unsigned int inline_ext)
 {
        struct erofs_buffer_block *bb;
@@ -251,7 +248,7 @@ struct erofs_buffer_head *erofs_balloc(struct erofs_bufmgr *bmgr,
        alignsize = ret;
 
        /* try to find if we could reuse an allocated buffer block */
-       ret = erofs_bfind_for_attach(bmgr, type, size, required_ext, inline_ext,
+       ret = erofs_bfind_for_attach(bmgr, type, size, inline_ext,
                                     alignsize, &bb);
        if (ret)
                return ERR_PTR(ret);
@@ -285,8 +282,7 @@ struct erofs_buffer_head *erofs_balloc(struct erofs_bufmgr *bmgr,
                }
        }
 
-       ret = __erofs_battach(bb, bh, size, alignsize,
-                             required_ext + inline_ext, false);
+       ret = __erofs_battach(bb, bh, size, alignsize, inline_ext, false);
        if (ret < 0) {
                free(bh);
                return ERR_PTR(ret);
index cc7dce02b54b11da798bb45b40e1bd3dc1783e9d..5ecb9c853b184ee7a3c5271bf938fc8241f99ded 100644 (file)
@@ -1480,7 +1480,7 @@ int erofs_mt_write_compressed_file(struct z_erofs_compress_ictx *ictx)
        erofs_off_t pstart, ptotal = 0;
        int ret;
 
-       bh = erofs_balloc(sbi->bmgr, DATA, 0, 0, 0);
+       bh = erofs_balloc(sbi->bmgr, DATA, 0, 0);
        if (IS_ERR(bh)) {
                ret = PTR_ERR(bh);
                goto out;
@@ -1681,7 +1681,7 @@ int erofs_write_compressed_file(struct z_erofs_compress_ictx *ictx)
 #endif
 
        /* allocate main data buffer */
-       bh = erofs_balloc(inode->sbi->bmgr, DATA, 0, 0, 0);
+       bh = erofs_balloc(inode->sbi->bmgr, DATA, 0, 0);
        if (IS_ERR(bh)) {
                ret = PTR_ERR(bh);
                goto err_free_idata;
index 91ff4ceeb4b3b79da7763ea827e63e5ec1c1d7ba..108aa9eee65aa4dd5d5c68854e3e771e789e2661 100644 (file)
@@ -195,7 +195,7 @@ int erofs_allocate_inode_bh_data(struct erofs_inode *inode, erofs_blk_t nblocks)
 
        /* allocate main data buffer */
        type = S_ISDIR(inode->i_mode) ? DIRA : DATA;
-       bh = erofs_balloc(bmgr, type, erofs_pos(inode->sbi, nblocks), 0, 0);
+       bh = erofs_balloc(bmgr, type, erofs_pos(inode->sbi, nblocks), 0);
        if (IS_ERR(bh))
                return PTR_ERR(bh);
 
@@ -757,7 +757,7 @@ static int erofs_prepare_inode_buffer(struct erofs_inode *inode)
                        inode->datalayout = EROFS_INODE_FLAT_PLAIN;
        }
 
-       bh = erofs_balloc(bmgr, INODE, inodesize, 0, inode->idata_size);
+       bh = erofs_balloc(bmgr, INODE, inodesize, inode->idata_size);
        if (bh == ERR_PTR(-ENOSPC)) {
                int ret;
 
@@ -770,7 +770,7 @@ noinline:
                ret = erofs_prepare_tail_block(inode);
                if (ret)
                        return ret;
-               bh = erofs_balloc(bmgr, INODE, inodesize, 0, 0);
+               bh = erofs_balloc(bmgr, INODE, inodesize, 0);
                if (IS_ERR(bh))
                        return PTR_ERR(bh);
                DBG_BUGON(inode->bh_inline);
@@ -852,7 +852,7 @@ static int erofs_write_tail_end(struct erofs_inode *inode)
                if (!bh) {
                        bh = erofs_balloc(sbi->bmgr,
                                          S_ISDIR(inode->i_mode) ? DIRA: DATA,
-                                         erofs_blksiz(sbi), 0, 0);
+                                         erofs_blksiz(sbi), 0);
                        if (IS_ERR(bh))
                                return PTR_ERR(bh);
                        bh->op = &erofs_skip_write_bhops;
@@ -1167,7 +1167,7 @@ static int erofs_inode_reserve_data_blocks(struct erofs_inode *inode)
        struct erofs_buffer_head *bh;
 
        /* allocate data blocks */
-       bh = erofs_balloc(sbi->bmgr, DATA, alignedsz, 0, 0);
+       bh = erofs_balloc(sbi->bmgr, DATA, alignedsz, 0);
        if (IS_ERR(bh))
                return PTR_ERR(bh);
 
index d4cea50fe63c81f448479e664dc1ff227b38c869..6c8fa521b7cae4bf4a7181b11a7ae3352b29d366 100644 (file)
@@ -211,7 +211,7 @@ struct erofs_buffer_head *erofs_reserve_sb(struct erofs_bufmgr *bmgr)
        struct erofs_buffer_head *bh;
        int err;
 
-       bh = erofs_balloc(bmgr, META, 0, 0, 0);
+       bh = erofs_balloc(bmgr, META, 0, 0);
        if (IS_ERR(bh)) {
                erofs_err("failed to allocate super: %s",
                          erofs_strerror(PTR_ERR(bh)));
index 5b4c98d87098932735e690fe08bd60ca01909a75..68a96cc86d0e6c95f0ccda969abeb2bed3bded9e 100644 (file)
@@ -930,7 +930,7 @@ int erofs_build_shared_xattrs_from_path(struct erofs_sb_info *sbi, const char *p
                return -ENOMEM;
        }
 
-       bh = erofs_balloc(sbi->bmgr, XATTR, shared_xattrs_size, 0, 0);
+       bh = erofs_balloc(sbi->bmgr, XATTR, shared_xattrs_size, 0);
        if (IS_ERR(bh)) {
                free(sorted_n);
                free(buf);