summaryrefslogtreecommitdiff
path: root/lib/cache.c
diff options
context:
space:
mode:
authorGao Xiang <gaoxiang25@huawei.com>2019-09-26 12:15:15 +0800
committerGao Xiang <hsiangkao@aol.com>2019-10-06 13:21:10 +0800
commitb0ca535297b6dfb1026fd1618a67571ccbcbe8e4 (patch)
treeeb532922b5dfba3df097cb974f5d6d056bdde697 /lib/cache.c
parentfbba92dc493401dec79c902580f6ac2101660eb9 (diff)
erofs-utils: support 64-bit internal buffer cache
Previously, the type of off in struct erofs_buffer_head is unsigned int, it's not enough for large files. Fix to a 64-bit field in order to support large files. Reviewed-by: Li Guifu <blucerlee@gmail.com> Tested-by: Li Guifu <blucerlee@gmail.com> Link: https://lore.kernel.org/r/20191004204630.22696-1-hsiangkao@aol.com Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Diffstat (limited to 'lib/cache.c')
-rw-r--r--lib/cache.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/cache.c b/lib/cache.c
index 4f03cb9..41d2d5d 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -74,14 +74,15 @@ struct erofs_buffer_head *erofs_buffer_init(void)
/* return occupied bytes in specific buffer block if succeed */
static int __erofs_battach(struct erofs_buffer_block *bb,
struct erofs_buffer_head *bh,
- unsigned int incr,
+ erofs_off_t incr,
unsigned int alignsize,
unsigned int extrasize,
bool dryrun)
{
- const unsigned int alignedoffset = roundup(bb->buffers.off, alignsize);
- const int oob = alignedoffset + incr + extrasize -
- roundup(bb->buffers.off + 1, EROFS_BLKSIZ);
+ const erofs_off_t alignedoffset = roundup(bb->buffers.off, alignsize);
+ const int oob = sgn(roundup(bb->buffers.off % EROFS_BLKSIZ,
+ alignsize) + incr + extrasize -
+ EROFS_BLKSIZ);
bool tailupdate = false;
erofs_blk_t blkaddr;
@@ -113,7 +114,7 @@ static int __erofs_battach(struct erofs_buffer_block *bb,
return (alignedoffset + incr) % EROFS_BLKSIZ;
}
-int erofs_bh_balloon(struct erofs_buffer_head *bh, unsigned int incr)
+int erofs_bh_balloon(struct erofs_buffer_head *bh, erofs_off_t incr)
{
struct erofs_buffer_block *const bb = bh->block;
@@ -124,7 +125,7 @@ int erofs_bh_balloon(struct erofs_buffer_head *bh, unsigned int incr)
return __erofs_battach(bb, NULL, incr, 1, 0, false);
}
-struct erofs_buffer_head *erofs_balloc(int type, unsigned int size,
+struct erofs_buffer_head *erofs_balloc(int type, erofs_off_t size,
unsigned int required_ext,
unsigned int inline_ext)
{
@@ -214,7 +215,7 @@ found:
}
struct erofs_buffer_head *erofs_battach(struct erofs_buffer_head *bh,
- int type, int size)
+ int type, unsigned int size)
{
struct erofs_buffer_block *const bb = bh->block;
struct erofs_buffer_head *nbh;