Skip to content

Commit a5ae7fa

Browse files
hsiangkaogregkh
authored andcommitted
erofs: fix large fragment handling
[ Upstream commit b44686c8391b427fb1c85a31c35077e6947c6d90 ] Fragments aren't limited by Z_EROFS_PCLUSTER_MAX_DSIZE. However, if a fragment's logical length is larger than Z_EROFS_PCLUSTER_MAX_DSIZE but the fragment is not the whole inode, it currently returns -EOPNOTSUPP because m_flags has the wrong EROFS_MAP_ENCODED flag set. It is not intended by design but should be rare, as it can only be reproduced by mkfs with `-Eall-fragments` in a specific case. Let's normalize fragment m_flags using the new EROFS_MAP_FRAGMENT. Reported-by: Axel Fontaine <[email protected]> Closes: erofs/erofs-utils#23 Fixes: 7c3ca18 ("erofs: restrict pcluster size limitations") Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 41485d7 commit a5ae7fa

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

fs/erofs/internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
324324
/* The length of extent is full */
325325
#define EROFS_MAP_FULL_MAPPED 0x0008
326326
/* Located in the special packed inode */
327-
#define EROFS_MAP_FRAGMENT 0x0010
327+
#define __EROFS_MAP_FRAGMENT 0x0010
328328
/* The extent refers to partial decompressed data */
329329
#define EROFS_MAP_PARTIAL_REF 0x0020
330330

331+
#define EROFS_MAP_FRAGMENT (EROFS_MAP_MAPPED | __EROFS_MAP_FRAGMENT)
332+
331333
struct erofs_map_blocks {
332334
struct erofs_buf buf;
333335

fs/erofs/zdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ static int z_erofs_scan_folio(struct z_erofs_frontend *f,
10161016
if (!(map->m_flags & EROFS_MAP_MAPPED)) {
10171017
folio_zero_segment(folio, cur, end);
10181018
tight = false;
1019-
} else if (map->m_flags & EROFS_MAP_FRAGMENT) {
1019+
} else if (map->m_flags & __EROFS_MAP_FRAGMENT) {
10201020
erofs_off_t fpos = offset + cur - map->m_la;
10211021

10221022
err = z_erofs_read_fragment(inode->i_sb, folio, cur,

fs/erofs/zmap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static int z_erofs_do_map_blocks(struct inode *inode,
481481
goto unmap_out;
482482
}
483483
} else if (fragment && m.lcn == vi->z_tailextent_headlcn) {
484-
map->m_flags |= EROFS_MAP_FRAGMENT;
484+
map->m_flags = EROFS_MAP_FRAGMENT;
485485
} else {
486486
map->m_pa = erofs_pos(sb, m.pblk);
487487
err = z_erofs_get_extent_compressedlen(&m, initial_lcn);
@@ -644,8 +644,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
644644
!vi->z_tailextent_headlcn) {
645645
map->m_la = 0;
646646
map->m_llen = inode->i_size;
647-
map->m_flags = EROFS_MAP_MAPPED |
648-
EROFS_MAP_FULL_MAPPED | EROFS_MAP_FRAGMENT;
647+
map->m_flags = EROFS_MAP_FRAGMENT;
649648
} else {
650649
err = z_erofs_do_map_blocks(inode, map, flags);
651650
}
@@ -678,7 +677,7 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,
678677
iomap->length = map.m_llen;
679678
if (map.m_flags & EROFS_MAP_MAPPED) {
680679
iomap->type = IOMAP_MAPPED;
681-
iomap->addr = map.m_flags & EROFS_MAP_FRAGMENT ?
680+
iomap->addr = map.m_flags & __EROFS_MAP_FRAGMENT ?
682681
IOMAP_NULL_ADDR : map.m_pa;
683682
} else {
684683
iomap->type = IOMAP_HOLE;

0 commit comments

Comments
 (0)