|
9 | 9 | #include <linux/cpuhotplug.h> |
10 | 10 | #include <trace/events/erofs.h> |
11 | 11 |
|
| 12 | +#define Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES 12288 |
12 | 13 | #define Z_EROFS_PCLUSTER_MAX_PAGES (Z_EROFS_PCLUSTER_MAX_SIZE / PAGE_SIZE) |
13 | 14 | #define Z_EROFS_INLINE_BVECS 2 |
14 | 15 |
|
@@ -1095,21 +1096,6 @@ static int z_erofs_scan_folio(struct z_erofs_frontend *f, |
1095 | 1096 | return err; |
1096 | 1097 | } |
1097 | 1098 |
|
1098 | | -static bool z_erofs_is_sync_decompress(struct erofs_sb_info *sbi, |
1099 | | - unsigned int readahead_pages) |
1100 | | -{ |
1101 | | - /* auto: enable for read_folio, disable for readahead */ |
1102 | | - if ((sbi->opt.sync_decompress == EROFS_SYNC_DECOMPRESS_AUTO) && |
1103 | | - !readahead_pages) |
1104 | | - return true; |
1105 | | - |
1106 | | - if ((sbi->opt.sync_decompress == EROFS_SYNC_DECOMPRESS_FORCE_ON) && |
1107 | | - (readahead_pages <= sbi->opt.max_sync_decompress_pages)) |
1108 | | - return true; |
1109 | | - |
1110 | | - return false; |
1111 | | -} |
1112 | | - |
1113 | 1099 | static bool z_erofs_page_is_invalidated(struct page *page) |
1114 | 1100 | { |
1115 | 1101 | return !page_folio(page)->mapping && !z_erofs_is_shortlived_page(page); |
@@ -1484,9 +1470,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, |
1484 | 1470 | #else |
1485 | 1471 | queue_work(z_erofs_workqueue, &io->u.work); |
1486 | 1472 | #endif |
1487 | | - /* enable sync decompression for readahead */ |
1488 | | - if (sbi->opt.sync_decompress == EROFS_SYNC_DECOMPRESS_AUTO) |
1489 | | - sbi->opt.sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON; |
| 1473 | + /* See `sync_decompress` in sysfs-fs-erofs for more details */ |
| 1474 | + if (sbi->sync_decompress == EROFS_SYNC_DECOMPRESS_AUTO) |
| 1475 | + sbi->sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON; |
1490 | 1476 | return; |
1491 | 1477 | } |
1492 | 1478 | z_erofs_decompressqueue_work(&io->u.work); |
@@ -1803,16 +1789,21 @@ static void z_erofs_submit_queue(struct z_erofs_frontend *f, |
1803 | 1789 | z_erofs_decompress_kickoff(q[JQ_SUBMIT], nr_bios); |
1804 | 1790 | } |
1805 | 1791 |
|
1806 | | -static int z_erofs_runqueue(struct z_erofs_frontend *f, unsigned int rapages) |
| 1792 | +static int z_erofs_runqueue(struct z_erofs_frontend *f, unsigned int rabytes) |
1807 | 1793 | { |
1808 | 1794 | struct z_erofs_decompressqueue io[NR_JOBQUEUES]; |
1809 | 1795 | struct erofs_sb_info *sbi = EROFS_I_SB(f->inode); |
1810 | | - bool force_fg = z_erofs_is_sync_decompress(sbi, rapages); |
| 1796 | + int syncmode = sbi->sync_decompress; |
| 1797 | + bool force_fg; |
1811 | 1798 | int err; |
1812 | 1799 |
|
| 1800 | + force_fg = (syncmode == EROFS_SYNC_DECOMPRESS_AUTO && !rabytes) || |
| 1801 | + (syncmode == EROFS_SYNC_DECOMPRESS_FORCE_ON && |
| 1802 | + (rabytes <= Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES)); |
| 1803 | + |
1813 | 1804 | if (f->head == Z_EROFS_PCLUSTER_TAIL) |
1814 | 1805 | return 0; |
1815 | | - z_erofs_submit_queue(f, io, &force_fg, !!rapages); |
| 1806 | + z_erofs_submit_queue(f, io, &force_fg, !!rabytes); |
1816 | 1807 |
|
1817 | 1808 | /* handle bypass queue (no i/o pclusters) immediately */ |
1818 | 1809 | err = z_erofs_decompress_queue(&io[JQ_BYPASS], &f->pagepool); |
@@ -1933,7 +1924,7 @@ static void z_erofs_readahead(struct readahead_control *rac) |
1933 | 1924 | z_erofs_pcluster_readmore(&f, rac, false); |
1934 | 1925 | z_erofs_pcluster_end(&f); |
1935 | 1926 |
|
1936 | | - (void)z_erofs_runqueue(&f, nrpages); |
| 1927 | + (void)z_erofs_runqueue(&f, nrpages << PAGE_SHIFT); |
1937 | 1928 | erofs_put_metabuf(&f.map.buf); |
1938 | 1929 | erofs_release_pages(&f.pagepool); |
1939 | 1930 | } |
|
0 commit comments