Skip to content

Commit c2da8b3

Browse files
committed
Merge tag 'erofs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs updates from Gao Xiang: "Still no new features for this cycle, as some ongoing improvements remain premature for now. This includes a micro-optimization for the superblock checksum, along with minor bugfixes and code cleanups, as usual: - Micro-optimize superblock checksum - Avoid overly large bvecs[] for file-backed mounts - Some leftover folio conversion in z_erofs_bind_cache() - Minor bugfixes and cleanups" * tag 'erofs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: refine z_erofs_get_extent_compressedlen() erofs: remove dead code in erofs_fc_parse_param erofs: return SHRINK_EMPTY if no objects to free erofs: convert z_erofs_bind_cache() to folios erofs: tidy up zdata.c erofs: get rid of `z_erofs_next_pcluster_t` erofs: simplify z_erofs_load_compact_lcluster() erofs: fix potential return value overflow of z_erofs_shrink_scan() erofs: shorten bvecs[] for file-backed mounts erofs: micro-optimize superblock checksum fs: erofs: xattr.c change kzalloc to kcalloc
2 parents aa22f4d + 8f9530a commit c2da8b3

File tree

8 files changed

+162
-272
lines changed

8 files changed

+162
-272
lines changed

fs/erofs/compress.h

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,8 @@ struct z_erofs_decompressor {
2929
char *name;
3030
};
3131

32-
/* some special page->private (unsigned long, see below) */
3332
#define Z_EROFS_SHORTLIVED_PAGE (-1UL << 2)
34-
#define Z_EROFS_PREALLOCATED_PAGE (-2UL << 2)
35-
36-
/*
37-
* For all pages in a pcluster, page->private should be one of
38-
* Type Last 2bits page->private
39-
* short-lived page 00 Z_EROFS_SHORTLIVED_PAGE
40-
* preallocated page (tryalloc) 00 Z_EROFS_PREALLOCATED_PAGE
41-
* cached/managed page 00 pointer to z_erofs_pcluster
42-
* online page (file-backed, 01/10/11 sub-index << 2 | count
43-
* some pages can be used for inplace I/O)
44-
*
45-
* page->mapping should be one of
46-
* Type page->mapping
47-
* short-lived page NULL
48-
* preallocated page NULL
49-
* cached/managed page non-NULL or NULL (invalidated/truncated page)
50-
* online page non-NULL
51-
*
52-
* For all managed pages, PG_private should be set with 1 extra refcount,
53-
* which is used for page reclaim / migration.
54-
*/
33+
#define Z_EROFS_PREALLOCATED_FOLIO ((void *)(-2UL << 2))
5534

5635
/*
5736
* Currently, short-lived pages are pages directly from buddy system

fs/erofs/erofs_fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef __EROFS_FS_H
1010
#define __EROFS_FS_H
1111

12+
/* to allow for x86 boot sectors and other oddities. */
1213
#define EROFS_SUPER_OFFSET 1024
1314

1415
#define EROFS_FEATURE_COMPAT_SB_CHKSUM 0x00000001
@@ -54,7 +55,7 @@ struct erofs_deviceslot {
5455
/* erofs on-disk super block (currently 128 bytes) */
5556
struct erofs_super_block {
5657
__le32 magic; /* file system magic number */
57-
__le32 checksum; /* crc32c(super_block) */
58+
__le32 checksum; /* crc32c to avoid unexpected on-disk overlap */
5859
__le32 feature_compat;
5960
__u8 blkszbits; /* filesystem block size in bit shift */
6061
__u8 sb_extslots; /* superblock size = 128 + sb_extslots * 16 */

fs/erofs/fileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <trace/events/erofs.h>
77

88
struct erofs_fileio_rq {
9-
struct bio_vec bvecs[BIO_MAX_VECS];
9+
struct bio_vec bvecs[16];
1010
struct bio bio;
1111
struct kiocb iocb;
1212
struct super_block *sb;
@@ -68,7 +68,7 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
6868
struct erofs_fileio_rq *rq = kzalloc(sizeof(*rq),
6969
GFP_KERNEL | __GFP_NOFAIL);
7070

71-
bio_init(&rq->bio, NULL, rq->bvecs, BIO_MAX_VECS, REQ_OP_READ);
71+
bio_init(&rq->bio, NULL, rq->bvecs, ARRAY_SIZE(rq->bvecs), REQ_OP_READ);
7272
rq->iocb.ki_filp = mdev->m_dif->file;
7373
rq->sb = mdev->m_sb;
7474
return rq;

fs/erofs/super.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,21 @@ void _erofs_printk(struct super_block *sb, const char *fmt, ...)
3939

4040
static int erofs_superblock_csum_verify(struct super_block *sb, void *sbdata)
4141
{
42-
size_t len = 1 << EROFS_SB(sb)->blkszbits;
43-
struct erofs_super_block *dsb;
44-
u32 expected_crc, crc;
42+
struct erofs_super_block *dsb = sbdata + EROFS_SUPER_OFFSET;
43+
u32 len = 1 << EROFS_SB(sb)->blkszbits, crc;
4544

4645
if (len > EROFS_SUPER_OFFSET)
4746
len -= EROFS_SUPER_OFFSET;
47+
len -= offsetof(struct erofs_super_block, checksum) +
48+
sizeof(dsb->checksum);
4849

49-
dsb = kmemdup(sbdata + EROFS_SUPER_OFFSET, len, GFP_KERNEL);
50-
if (!dsb)
51-
return -ENOMEM;
52-
53-
expected_crc = le32_to_cpu(dsb->checksum);
54-
dsb->checksum = 0;
55-
/* to allow for x86 boot sectors and other oddities. */
56-
crc = crc32c(~0, dsb, len);
57-
kfree(dsb);
58-
59-
if (crc != expected_crc) {
60-
erofs_err(sb, "invalid checksum 0x%08x, 0x%08x expected",
61-
crc, expected_crc);
62-
return -EBADMSG;
63-
}
64-
return 0;
50+
/* skip .magic(pre-verified) and .checksum(0) fields */
51+
crc = crc32c(0x5045B54A, (&dsb->checksum) + 1, len);
52+
if (crc == le32_to_cpu(dsb->checksum))
53+
return 0;
54+
erofs_err(sb, "invalid checksum 0x%08x, 0x%08x expected",
55+
crc, le32_to_cpu(dsb->checksum));
56+
return -EBADMSG;
6557
}
6658

6759
static void erofs_inode_init_once(void *ptr)
@@ -516,8 +508,6 @@ static int erofs_fc_parse_param(struct fs_context *fc,
516508
errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);
517509
#endif
518510
break;
519-
default:
520-
return -ENOPARAM;
521511
}
522512
return 0;
523513
}

fs/erofs/xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
478478
if (!sbi->xattr_prefix_count)
479479
return 0;
480480

481-
pfs = kzalloc(sbi->xattr_prefix_count * sizeof(*pfs), GFP_KERNEL);
481+
pfs = kcalloc(sbi->xattr_prefix_count, sizeof(*pfs), GFP_KERNEL);
482482
if (!pfs)
483483
return -ENOMEM;
484484

0 commit comments

Comments
 (0)