Skip to content

Commit 732c275

Browse files
committed
Merge tag 'erofs-for-6.11-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull more erofs updates from Gao Xiang: - Support STATX_DIOALIGN and FS_IOC_GETFSSYSFSPATH - Fix a race of LZ4 decompression due to recent refactoring - Another multi-page folio adaption in erofs_bread() * tag 'erofs-for-6.11-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: convert comma to semicolon erofs: support multi-page folios for erofs_bread() erofs: add support for FS_IOC_GETFSSYSFSPATH erofs: fix race in z_erofs_get_gbuf() erofs: support STATX_DIOALIGN
2 parents dd90ad5 + 14e9283 commit 732c275

File tree

5 files changed

+49
-21
lines changed

5 files changed

+49
-21
lines changed

fs/erofs/data.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,32 @@ void erofs_put_metabuf(struct erofs_buf *buf)
2121
if (!buf->page)
2222
return;
2323
erofs_unmap_metabuf(buf);
24-
put_page(buf->page);
24+
folio_put(page_folio(buf->page));
2525
buf->page = NULL;
2626
}
2727

28-
/*
29-
* Derive the block size from inode->i_blkbits to make compatible with
30-
* anonymous inode in fscache mode.
31-
*/
3228
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
3329
enum erofs_kmap_type type)
3430
{
3531
pgoff_t index = offset >> PAGE_SHIFT;
36-
struct page *page = buf->page;
37-
struct folio *folio;
38-
unsigned int nofs_flag;
32+
struct folio *folio = NULL;
3933

40-
if (!page || page->index != index) {
34+
if (buf->page) {
35+
folio = page_folio(buf->page);
36+
if (folio_file_page(folio, index) != buf->page)
37+
erofs_unmap_metabuf(buf);
38+
}
39+
if (!folio || !folio_contains(folio, index)) {
4140
erofs_put_metabuf(buf);
42-
43-
nofs_flag = memalloc_nofs_save();
44-
folio = read_cache_folio(buf->mapping, index, NULL, NULL);
45-
memalloc_nofs_restore(nofs_flag);
41+
folio = read_mapping_folio(buf->mapping, index, NULL);
4642
if (IS_ERR(folio))
4743
return folio;
48-
49-
/* should already be PageUptodate, no need to lock page */
50-
page = folio_file_page(folio, index);
51-
buf->page = page;
5244
}
45+
buf->page = folio_file_page(folio, index);
46+
5347
if (buf->kmap_type == EROFS_NO_KMAP) {
5448
if (type == EROFS_KMAP)
55-
buf->base = kmap_local_page(page);
49+
buf->base = kmap_local_page(buf->page);
5650
buf->kmap_type = type;
5751
} else if (buf->kmap_type != type) {
5852
DBG_BUGON(1);

fs/erofs/decompressor_lzma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
188188
!rq->partial_decoding);
189189
buf.in_size = min(rq->inputsize, PAGE_SIZE - rq->pageofs_in);
190190
rq->inputsize -= buf.in_size;
191-
buf.in = dctx.kin + rq->pageofs_in,
191+
buf.in = dctx.kin + rq->pageofs_in;
192192
dctx.bounce = strm->bounce;
193193
do {
194194
dctx.avail_out = buf.out_size - buf.out_pos;

fs/erofs/inode.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
334334
unsigned int query_flags)
335335
{
336336
struct inode *const inode = d_inode(path->dentry);
337+
bool compressed =
338+
erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout);
337339

338-
if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout))
340+
if (compressed)
339341
stat->attributes |= STATX_ATTR_COMPRESSED;
340-
341342
stat->attributes |= STATX_ATTR_IMMUTABLE;
342343
stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
343344
STATX_ATTR_IMMUTABLE);
344345

346+
/*
347+
* Return the DIO alignment restrictions if requested.
348+
*
349+
* In EROFS, STATX_DIOALIGN is not supported in ondemand mode and
350+
* compressed files, so in these cases we report no DIO support.
351+
*/
352+
if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
353+
stat->result_mask |= STATX_DIOALIGN;
354+
if (!erofs_is_fscache_mode(inode->i_sb) && !compressed) {
355+
stat->dio_mem_align =
356+
bdev_logical_block_size(inode->i_sb->s_bdev);
357+
stat->dio_offset_align = stat->dio_mem_align;
358+
}
359+
}
345360
generic_fillattr(idmap, request_mask, inode, stat);
346361
return 0;
347362
}

fs/erofs/super.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,21 @@ static const struct export_operations erofs_export_ops = {
576576
.get_parent = erofs_get_parent,
577577
};
578578

579+
static void erofs_set_sysfs_name(struct super_block *sb)
580+
{
581+
struct erofs_sb_info *sbi = EROFS_SB(sb);
582+
583+
if (erofs_is_fscache_mode(sb)) {
584+
if (sbi->domain_id)
585+
super_set_sysfs_name_generic(sb, "%s,%s",sbi->domain_id,
586+
sbi->fsid);
587+
else
588+
super_set_sysfs_name_generic(sb, "%s", sbi->fsid);
589+
return;
590+
}
591+
super_set_sysfs_name_id(sb);
592+
}
593+
579594
static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
580595
{
581596
struct inode *inode;
@@ -643,6 +658,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
643658
sb->s_flags |= SB_POSIXACL;
644659
else
645660
sb->s_flags &= ~SB_POSIXACL;
661+
erofs_set_sysfs_name(sb);
646662

647663
#ifdef CONFIG_EROFS_FS_ZIP
648664
xa_init(&sbi->managed_pslots);

fs/erofs/zutil.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ void *z_erofs_get_gbuf(unsigned int requiredpages)
3838
{
3939
struct z_erofs_gbuf *gbuf;
4040

41+
migrate_disable();
4142
gbuf = &z_erofs_gbufpool[z_erofs_gbuf_id()];
4243
spin_lock(&gbuf->lock);
4344
/* check if the buffer is too small */
4445
if (requiredpages > gbuf->nrpages) {
4546
spin_unlock(&gbuf->lock);
47+
migrate_enable();
4648
/* (for sparse checker) pretend gbuf->lock is still taken */
4749
__acquire(gbuf->lock);
4850
return NULL;
@@ -57,6 +59,7 @@ void z_erofs_put_gbuf(void *ptr) __releases(gbuf->lock)
5759
gbuf = &z_erofs_gbufpool[z_erofs_gbuf_id()];
5860
DBG_BUGON(gbuf->ptr != ptr);
5961
spin_unlock(&gbuf->lock);
62+
migrate_enable();
6063
}
6164

6265
int z_erofs_gbuf_growsize(unsigned int nrpages)

0 commit comments

Comments
 (0)