[PATCH] fs/erofs: Remove an unnecessary assertion

2023-07-26 Thread Yifan Zhao
In [1] Sam points out an assertion does not hold true for 32-bit
platforms, which only impacts Large File Support (LFS) API usage
in erofs-utils according to Xiang [2]. We don't think these APIs
are used in u-boot and this restriction could be safely removed.

[1] https://lists.denx.de/pipermail/u-boot/2023-July/524679.html
[2] https://lists.denx.de/pipermail/u-boot/2023-July/524727.html

Fixes: 3a21e92fc255 ("fs/erofs: Introduce new features including ztailpacking, 
fragments and dedupe")
Signed-off-by: Yifan Zhao 
---
 fs/erofs/internal.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 433a3c6c1e..1875f37fcd 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -105,9 +105,6 @@ struct erofs_sb_info {
u8 xattr_prefix_count;
 };
 
-/* make sure that any user of the erofs headers has at least 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);
-- 
2.41.0



[PATCH] fs/erofs: Introduce new features including ztailpacking, fragments and dedupe

2023-07-07 Thread Yifan Zhao
This patch updates erofs driver code to catch up with the latest code of
erofs_utils (commit e4939f9eaa177e05d697ace85d8dc283e25dc2ed).

LZMA will be supported in the separate patch later.

Signed-off-by: Yifan Zhao 
---
CI result here:
https://github.com/u-boot/u-boot/pull/344

 fs/erofs/data.c   | 165 ++-
 fs/erofs/decompress.c |  32 -
 fs/erofs/decompress.h |   3 +
 fs/erofs/erofs_fs.h   | 301 +++---
 fs/erofs/fs.c |  12 +-
 fs/erofs/internal.h   | 119 ++---
 fs/erofs/namei.c  |  44 +++---
 fs/erofs/super.c  |  33 ++---
 fs/erofs/zmap.c   | 277 +-
 9 files changed, 642 insertions(+), 344 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 761896054c..f4b21d7917 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -12,23 +12,23 @@ static int erofs_map_blocks_flatmode(struct erofs_inode 
*inode,
struct erofs_inode *vi = inode;
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
 
-   nblocks = DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ);
+   nblocks = BLK_ROUND_UP(inode->i_size);
lastblk = nblocks - tailendpacking;
 
/* there is no hole in flatmode */
map->m_flags = EROFS_MAP_MAPPED;
 
-   if (offset < blknr_to_addr(lastblk)) {
-   map->m_pa = blknr_to_addr(vi->u.i_blkaddr) + map->m_la;
-   map->m_plen = blknr_to_addr(lastblk) - offset;
+   if (offset < erofs_pos(lastblk)) {
+   map->m_pa = erofs_pos(vi->u.i_blkaddr) + map->m_la;
+   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 +
vi->xattr_isize + erofs_blkoff(map->m_la);
map->m_plen = inode->i_size - offset;
 
-   /* inline data should be located in one meta block */
-   if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
+   /* inline data should be located in the same meta block */
+   if (erofs_blkoff(map->m_pa) + map->m_plen > erofs_blksiz()) {
erofs_err("inline data cross block boundary @ nid %" 
PRIu64,
  vi->nid);
DBG_BUGON(1);
@@ -55,7 +55,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
 {
struct erofs_inode *vi = inode;
struct erofs_inode_chunk_index *idx;
-   u8 buf[EROFS_BLKSIZ];
+   u8 buf[EROFS_MAX_BLOCK_SIZE];
u64 chunknr;
unsigned int unit;
erofs_off_t pos;
@@ -87,7 +87,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
 
map->m_la = chunknr << vi->u.chunkbits;
map->m_plen = min_t(erofs_off_t, 1UL << vi->u.chunkbits,
-   roundup(inode->i_size - map->m_la, EROFS_BLKSIZ));
+   roundup(inode->i_size - map->m_la, erofs_blksiz()));
 
/* handle block map */
if (!(vi->u.chunkformat & EROFS_CHUNK_FORMAT_INDEXES)) {
@@ -96,7 +96,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
if (le32_to_cpu(*blkaddr) == EROFS_NULL_ADDR) {
map->m_flags = 0;
} else {
-   map->m_pa = blknr_to_addr(le32_to_cpu(*blkaddr));
+   map->m_pa = erofs_pos(le32_to_cpu(*blkaddr));
map->m_flags = EROFS_MAP_MAPPED;
}
goto out;
@@ -110,7 +110,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
default:
map->m_deviceid = le16_to_cpu(idx->device_id) &
sbi.device_id_mask;
-   map->m_pa = blknr_to_addr(le32_to_cpu(idx->blkaddr));
+   map->m_pa = erofs_pos(le32_to_cpu(idx->blkaddr));
map->m_flags = EROFS_MAP_MAPPED;
break;
}
@@ -119,23 +119,23 @@ out:
return err;
 }
 
-int erofs_map_dev(struct erofs_sb_info *sbi, struct erofs_map_dev *map)
+int erofs_map_dev(struct erofs_map_dev *map)
 {
struct erofs_device_info *dif;
int id;
 
if (map->m_deviceid) {
-   if (sbi->extra_devices < map->m_deviceid)
+   if (sbi.extra_devices < map->m_deviceid)
return -ENODEV;
-   } else if (sbi->extra_devices) {
-   for (id = 0; id < sbi->extra_devices; ++id) {
+   } else if (sbi.extra_devices) {
+   for (id = 0; id < sbi.extra_devices; ++id) {
erofs_off_t startoff, length;
 
-   dif = sbi->devs + id;
+   dif = sbi.devs + id;