Changes since last update:

- Support FS_IOC_GETFSLABEL ioctl;
 
  - Stop meaningless read-more policy on fragment extents;
 
  - Remove a duplicate check for ztailpacking inline.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEQ0A6bDUS9Y+83NPFUXZn5Zlu5qoFAmjalKIRHHhpYW5nQGtl
 cm5lbC5vcmcACgkQUXZn5Zlu5qp8og/6Az/cUH7r5QsPfEmh3xlPiQoO6PDdowdS
 zPXA7s9NhpC7SKyNJLV1z2WyrdBCnwOZ8DtBpfwR3bGCCawxPHro3ypqfudr1/3M
 cLS56qDPL/6X7qwgNdMhalpJNEH4NOsgLqPq2At1pG3Atbtof1ncBw9ZNZdPr+xd
 p7XS/ePcZhS20ts+noP9wHZhd3KVIPGl4Vo0WAquc5z5H4tbtOz+N9uwveY5iQon
 HwEcvq9pvjKDz2+RtSBI4PffkDKg7Eiafd8tV4YAshYGNUZZzk5FA0i6o3ntBcm/
 a/uuhCTbEX5YeVuPiV5G5jbpCJC0LjjemdrOPpZBxSBls64pZd0UNm6ODzzjrb4C
 teYe3FalPeS5gYvl5BfbtZ+UCBeMJEMjB9YG1KF8SS4xbklbHyrkOLlQTGOZd6ph
 bMNXf0etsc+p8I0mC0419Dd4gVZlJ1ekjFb3EN8X9qFS4QWu+TcjGtmwrqfb58ez
 p6Z1jK9l14wFgS57SQbZzh1bmAg0W8wWjS54nTnugcfmKKDFPqEFdxghUr95cafY
 +cVfLMA/9rwJ0wK6g16ilpN4WYWPuXkmlEi7mWSz1jfXL1jo3Ebhq5cJVVVWKKgM
 sN+ibzSQnU+wUiSLYnIhKFC9SE9GsR7QwqIgi5dBtnZUxQO8IK9Dj5PEbkaAAZKJ
 eFU7fKqKp9E=
 =kFYL
 -----END PGP SIGNATURE-----

Merge tag 'erofs-for-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs updates from Gao Xiang:

 - Support FS_IOC_GETFSLABEL ioctl

 - Stop meaningless read-more policy on fragment extents

 - Remove a duplicate check for ztailpacking inline

* tag 'erofs-for-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: drop redundant sanity check for ztailpacking inline
  erofs: Add support for FS_IOC_GETFSLABEL
  erofs: avoid reading more for fragment maps
This commit is contained in:
Linus Torvalds 2025-09-29 15:19:45 -07:00
commit 5928397f57
7 changed files with 61 additions and 11 deletions

View File

@ -475,6 +475,10 @@ static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence)
const struct file_operations erofs_file_fops = {
.llseek = erofs_file_llseek,
.read_iter = erofs_file_read_iter,
.unlocked_ioctl = erofs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = erofs_compat_ioctl,
#endif
.mmap_prepare = erofs_file_mmap_prepare,
.get_unmapped_area = thp_get_unmapped_area,
.splice_read = filemap_splice_read,

View File

@ -123,4 +123,8 @@ const struct file_operations erofs_dir_fops = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.iterate_shared = erofs_readdir,
.unlocked_ioctl = erofs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = erofs_compat_ioctl,
#endif
};

View File

@ -5,6 +5,7 @@
* Copyright (C) 2021, Alibaba Cloud
*/
#include "xattr.h"
#include <linux/compat.h>
#include <trace/events/erofs.h>
static int erofs_fill_symlink(struct inode *inode, void *kaddr,
@ -213,10 +214,7 @@ static int erofs_fill_inode(struct inode *inode)
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
inode->i_op = &erofs_generic_iops;
if (erofs_inode_is_data_compressed(vi->datalayout))
inode->i_fop = &generic_ro_fops;
else
inode->i_fop = &erofs_file_fops;
inode->i_fop = &erofs_file_fops;
break;
case S_IFDIR:
inode->i_op = &erofs_dir_iops;
@ -341,6 +339,40 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
return 0;
}
static int erofs_ioctl_get_volume_label(struct inode *inode, void __user *arg)
{
struct erofs_sb_info *sbi = EROFS_I_SB(inode);
int ret;
if (!sbi->volume_name)
ret = clear_user(arg, 1);
else
ret = copy_to_user(arg, sbi->volume_name,
strlen(sbi->volume_name));
return ret ? -EFAULT : 0;
}
long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(filp);
void __user *argp = (void __user *)arg;
switch (cmd) {
case FS_IOC_GETFSLABEL:
return erofs_ioctl_get_volume_label(inode, argp);
default:
return -ENOTTY;
}
}
#ifdef CONFIG_COMPAT
long erofs_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{
return erofs_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
}
#endif
const struct inode_operations erofs_generic_iops = {
.getattr = erofs_getattr,
.listxattr = erofs_listxattr,

View File

@ -153,6 +153,7 @@ struct erofs_sb_info {
/* used for statfs, f_files - f_favail */
u64 inos;
char *volume_name;
u32 feature_compat;
u32 feature_incompat;
@ -536,6 +537,10 @@ static inline struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev) {
static inline void erofs_fscache_submit_bio(struct bio *bio) {}
#endif
long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
long erofs_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg);
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
#endif /* __EROFS_INTERNAL_H */

View File

@ -343,6 +343,13 @@ static int erofs_read_superblock(struct super_block *sb)
sbi->fixed_nsec = le32_to_cpu(dsb->fixed_nsec);
super_set_uuid(sb, (void *)dsb->uuid, sizeof(dsb->uuid));
if (dsb->volume_name[0]) {
sbi->volume_name = kstrndup(dsb->volume_name,
sizeof(dsb->volume_name), GFP_KERNEL);
if (!sbi->volume_name)
return -ENOMEM;
}
/* parse on-disk compression configurations */
ret = z_erofs_parse_cfgs(sb, dsb);
if (ret < 0)
@ -822,6 +829,7 @@ static void erofs_sb_free(struct erofs_sb_info *sbi)
kfree(sbi->domain_id);
if (sbi->dif0.file)
fput(sbi->dif0.file);
kfree(sbi->volume_name);
kfree(sbi);
}

View File

@ -823,9 +823,6 @@ static int z_erofs_pcluster_begin(struct z_erofs_frontend *fe)
}
rcu_read_unlock();
}
} else if ((map->m_pa & ~PAGE_MASK) + map->m_plen > PAGE_SIZE) {
DBG_BUGON(1);
return -EFSCORRUPTED;
}
if (pcl) {
@ -1835,7 +1832,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_frontend *f,
map->m_la = end;
err = z_erofs_map_blocks_iter(inode, map,
EROFS_GET_BLOCKS_READMORE);
if (err)
if (err || !(map->m_flags & EROFS_MAP_ENCODED))
return;
/* expand ra for the trailing edge if readahead */
@ -1847,7 +1844,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_frontend *f,
end = round_up(end, PAGE_SIZE);
} else {
end = round_up(map->m_la, PAGE_SIZE);
if (!map->m_llen)
if (!(map->m_flags & EROFS_MAP_ENCODED) || !map->m_llen)
return;
}

View File

@ -462,8 +462,8 @@ static int z_erofs_map_blocks_fo(struct inode *inode,
map->m_pa = vi->z_fragmentoff;
map->m_plen = vi->z_idata_size;
if (erofs_blkoff(sb, map->m_pa) + map->m_plen > sb->s_blocksize) {
erofs_err(sb, "invalid tail-packing pclustersize %llu",
map->m_plen);
erofs_err(sb, "ztailpacking inline data across blocks @ nid %llu",
vi->nid);
err = -EFSCORRUPTED;
goto unmap_out;
}