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);
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);
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);
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)
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;
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;
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;
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)
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;
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);
}
}
- 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);
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;
#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;
/* 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);
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;
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);
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;
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);
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)));
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);