Skip to content

Commit 5fbad44

Browse files
committed
Merge tag 'erofs-for-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: "Two patches fixes issues reported by syzbot, one fixes a missing `domain_id` mount option in documentation and a minor cleanup: - Fix wrong iomap->length calculation post EOF, which could cause a WARN_ON in iomap_iter_done() (Siddh) - Fix improper kvcalloc() use with __GFP_NOFAIL (me) - Add missing `domain_id` mount option in documentation (Jingbo) - Clean up fscache option parsing (Jingbo)" * tag 'erofs-for-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: clean up parsing of fscache related options erofs: add documentation for 'domain_id' mount option erofs: fix kvcalloc() misuse with __GFP_NOFAIL erofs/zmap.c: Fix incorrect offset calculation
2 parents 84bd7e0 + e02ac3e commit 5fbad44

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

Documentation/filesystems/erofs.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ dax={always,never} Use direct access (no page cache). See
120120
dax A legacy option which is an alias for ``dax=always``.
121121
device=%s Specify a path to an extra device to be used together.
122122
fsid=%s Specify a filesystem image ID for Fscache back-end.
123+
domain_id=%s Specify a domain ID in fscache mode so that different images
124+
with the same blobs under a given domain ID can share storage.
123125
=================== =========================================================
124126

125127
Sysfs Entries

fs/erofs/super.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,26 +577,25 @@ static int erofs_fc_parse_param(struct fs_context *fc,
577577
}
578578
++ctx->devs->extra_devices;
579579
break;
580-
case Opt_fsid:
581580
#ifdef CONFIG_EROFS_FS_ONDEMAND
581+
case Opt_fsid:
582582
kfree(ctx->fsid);
583583
ctx->fsid = kstrdup(param->string, GFP_KERNEL);
584584
if (!ctx->fsid)
585585
return -ENOMEM;
586-
#else
587-
errorfc(fc, "fsid option not supported");
588-
#endif
589586
break;
590587
case Opt_domain_id:
591-
#ifdef CONFIG_EROFS_FS_ONDEMAND
592588
kfree(ctx->domain_id);
593589
ctx->domain_id = kstrdup(param->string, GFP_KERNEL);
594590
if (!ctx->domain_id)
595591
return -ENOMEM;
592+
break;
596593
#else
597-
errorfc(fc, "domain_id option not supported");
598-
#endif
594+
case Opt_fsid:
595+
case Opt_domain_id:
596+
errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);
599597
break;
598+
#endif
600599
default:
601600
return -ENOPARAM;
602601
}

fs/erofs/zdata.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
10321032

10331033
if (!be->decompressed_pages)
10341034
be->decompressed_pages =
1035-
kvcalloc(be->nr_pages, sizeof(struct page *),
1036-
GFP_KERNEL | __GFP_NOFAIL);
1035+
kcalloc(be->nr_pages, sizeof(struct page *),
1036+
GFP_KERNEL | __GFP_NOFAIL);
10371037
if (!be->compressed_pages)
10381038
be->compressed_pages =
1039-
kvcalloc(pclusterpages, sizeof(struct page *),
1040-
GFP_KERNEL | __GFP_NOFAIL);
1039+
kcalloc(pclusterpages, sizeof(struct page *),
1040+
GFP_KERNEL | __GFP_NOFAIL);
10411041

10421042
z_erofs_parse_out_bvecs(be);
10431043
err2 = z_erofs_parse_in_bvecs(be, &overlapped);
@@ -1085,7 +1085,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
10851085
}
10861086
if (be->compressed_pages < be->onstack_pages ||
10871087
be->compressed_pages >= be->onstack_pages + Z_EROFS_ONSTACK_PAGES)
1088-
kvfree(be->compressed_pages);
1088+
kfree(be->compressed_pages);
10891089
z_erofs_fill_other_copies(be, err);
10901090

10911091
for (i = 0; i < be->nr_pages; ++i) {
@@ -1104,7 +1104,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
11041104
}
11051105

11061106
if (be->decompressed_pages != be->onstack_pages)
1107-
kvfree(be->decompressed_pages);
1107+
kfree(be->decompressed_pages);
11081108

11091109
pcl->length = 0;
11101110
pcl->partial = true;

fs/erofs/zmap.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,16 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,
793793
iomap->type = IOMAP_HOLE;
794794
iomap->addr = IOMAP_NULL_ADDR;
795795
/*
796-
* No strict rule how to describe extents for post EOF, yet
797-
* we need do like below. Otherwise, iomap itself will get
796+
* No strict rule on how to describe extents for post EOF, yet
797+
* we need to do like below. Otherwise, iomap itself will get
798798
* into an endless loop on post EOF.
799+
*
800+
* Calculate the effective offset by subtracting extent start
801+
* (map.m_la) from the requested offset, and add it to length.
802+
* (NB: offset >= map.m_la always)
799803
*/
800804
if (iomap->offset >= inode->i_size)
801-
iomap->length = length + map.m_la - offset;
805+
iomap->length = length + offset - map.m_la;
802806
}
803807
iomap->flags = 0;
804808
return 0;

0 commit comments

Comments
 (0)