From nobody Sun Feb 8 06:56:32 2026 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D339230BF5C for ; Mon, 12 Jan 2026 03:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768189420; cv=none; b=KiLPGMfdjiuGf5Eh4sDwC8NR1y6IK9buuha7nG2QahwusgPcD5MtwXb9OAqmbYjc9dIx2nD14J4agI+9dEdu+RKRjOU+NJatYGStYpq+W+LktY7LhHzrCl9vyfou6qYJnTSBTzh9zb8xnDyV5p48j4JVjCUXTj5ILalxBRx/qEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768189420; c=relaxed/simple; bh=1LI3tf+6REdKx0uTKPi1hXc8xXmtJAB8KltnlIP727g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bBHeN2CERiokN83Xfdt98U+ifGLXrVcFjE2TrwhEVY5cXlCJQ3poXmQ7L+J6rq/ajTO8KU5Vxd5uDObPHQVcTZzBy4LYhMd8Fgwblnw9g90d7VYuPBJodLRwhx3yAQEpZzJzfMlGGbtLUlQQ6aBhafg/0z1gGkTEncUKC1Lc/wM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ZwpCN6c8; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ZwpCN6c8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1768189415; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=fcD6lxrDQmpimeq1+NcWJZC2p8y038Y9kp/asgOJYQI=; b=ZwpCN6c8apLyN3oHrxTzGETINcanMkNm3UwB+PTNfnWtQxyjROl7L7YOCMwepkRV9eEJFFSk8XFzJ5akhO4cxOHc1vbdGd4lgGT4+EqUQAHZ3tRQrAzdBSNCXGKHTbo43hHbcKtd90eUAhlKwlNx04VykSRQQjS6eE0487Jz8I0= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Wwnmgzf_1768189411 cluster:ay36) by smtp.aliyun-inc.com; Mon, 12 Jan 2026 11:43:35 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH] erofs: tidy up synchronous decompression Date: Mon, 12 Jan 2026 11:43:30 +0800 Message-ID: <20260112034330.2263034-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - Get rid of `sbi->opt.max_sync_decompress_pages` since it's fixed as 3 all the time; - Add Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES in bytes instead of in pages, since for non-4K pages, 3-page limitation makes no sense; - Move `sync_decompress` to sbi to avoid unexpected remount impact; - Fold z_erofs_is_sync_decompress() into its caller; - Better description of sysfs entry `sync_decompress`. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-erofs | 14 ++++++---- fs/erofs/internal.h | 5 +--- fs/erofs/super.c | 3 +- fs/erofs/sysfs.c | 2 +- fs/erofs/zdata.c | 35 +++++++++--------------- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-erofs b/Documentation/ABI/t= esting/sysfs-fs-erofs index 76d9808ed581..b9243c7f28d7 100644 --- a/Documentation/ABI/testing/sysfs-fs-erofs +++ b/Documentation/ABI/testing/sysfs-fs-erofs @@ -10,12 +10,16 @@ Description: Shows all enabled kernel features. What: /sys/fs/erofs//sync_decompress Date: November 2021 Contact: "Huang Jianan" -Description: Control strategy of sync decompression: +Description: Control strategy of synchronous decompression. Synchronous + decompression tries to decompress in the reader thread for + synchronous reads and small asynchronous reads (<=3D 12 KiB): =20 - - 0 (default, auto): enable for readpage, and enable for - readahead on atomic contexts only. - - 1 (force on): enable for readpage and readahead. - - 2 (force off): disable for all situations. + - 0 (auto, default): apply to synchronous reads only, but will + switch to 1 (force on) if any decompression + request is detected in atomic contexts; + - 1 (force on): apply to synchronous reads and small + asynchronous reads; + - 2 (force off): disable synchronous decompression completely. =20 What: /sys/fs/erofs//drop_caches Date: November 2024 diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index f7f622836198..87edbb4366d1 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -59,10 +59,6 @@ enum { struct erofs_mount_opts { /* current strategy of how to use managed cache */ unsigned char cache_strategy; - /* strategy of sync decompression (0 - auto, 1 - force on, 2 - force off)= */ - unsigned int sync_decompress; - /* threshold for decompression synchronously */ - unsigned int max_sync_decompress_pages; unsigned int mount_opt; }; =20 @@ -116,6 +112,7 @@ struct erofs_sb_info { /* managed XArray arranged in physical block number */ struct xarray managed_pslots; =20 + unsigned int sync_decompress; /* strategy for sync decompression */ unsigned int shrinker_run_no; u16 available_compr_algs; =20 diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 937a215f626c..9f90d410ab94 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -372,8 +372,7 @@ static void erofs_default_options(struct erofs_sb_info = *sbi) { #ifdef CONFIG_EROFS_FS_ZIP sbi->opt.cache_strategy =3D EROFS_ZIP_CACHE_READAROUND; - sbi->opt.max_sync_decompress_pages =3D 3; - sbi->opt.sync_decompress =3D EROFS_SYNC_DECOMPRESS_AUTO; + sbi->sync_decompress =3D EROFS_SYNC_DECOMPRESS_AUTO; #endif #ifdef CONFIG_EROFS_FS_XATTR set_opt(&sbi->opt, XATTR_USER); diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index 1e0658a1d95b..86b22b9f0c19 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -59,7 +59,7 @@ static struct erofs_attr erofs_attr_##_name =3D { \ #define ATTR_LIST(name) (&erofs_attr_##name.attr) =20 #ifdef CONFIG_EROFS_FS_ZIP -EROFS_ATTR_RW_UI(sync_decompress, erofs_mount_opts); +EROFS_ATTR_RW_UI(sync_decompress, erofs_sb_info); EROFS_ATTR_FUNC(drop_caches, 0200); #endif #ifdef CONFIG_EROFS_FS_ZIP_ACCEL diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 3d31f7840ca0..f07f9db3b019 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -9,6 +9,7 @@ #include #include =20 +#define Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES 12288 #define Z_EROFS_PCLUSTER_MAX_PAGES (Z_EROFS_PCLUSTER_MAX_SIZE / PAGE_SIZE) #define Z_EROFS_INLINE_BVECS 2 =20 @@ -1095,21 +1096,6 @@ static int z_erofs_scan_folio(struct z_erofs_fronten= d *f, return err; } =20 -static bool z_erofs_is_sync_decompress(struct erofs_sb_info *sbi, - unsigned int readahead_pages) -{ - /* auto: enable for read_folio, disable for readahead */ - if ((sbi->opt.sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_AUTO) && - !readahead_pages) - return true; - - if ((sbi->opt.sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_FORCE_ON) && - (readahead_pages <=3D sbi->opt.max_sync_decompress_pages)) - return true; - - return false; -} - static bool z_erofs_page_is_invalidated(struct page *page) { return !page_folio(page)->mapping && !z_erofs_is_shortlived_page(page); @@ -1483,9 +1469,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs= _decompressqueue *io, #else queue_work(z_erofs_workqueue, &io->u.work); #endif - /* enable sync decompression for readahead */ - if (sbi->opt.sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_AUTO) - sbi->opt.sync_decompress =3D EROFS_SYNC_DECOMPRESS_FORCE_ON; + /* See `sync_decompress` in sysfs-fs-erofs for more details */ + if (sbi->sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_AUTO) + sbi->sync_decompress =3D EROFS_SYNC_DECOMPRESS_FORCE_ON; return; } z_erofs_decompressqueue_work(&io->u.work); @@ -1802,16 +1788,21 @@ static void z_erofs_submit_queue(struct z_erofs_fro= ntend *f, z_erofs_decompress_kickoff(q[JQ_SUBMIT], nr_bios); } =20 -static int z_erofs_runqueue(struct z_erofs_frontend *f, unsigned int rapag= es) +static int z_erofs_runqueue(struct z_erofs_frontend *f, unsigned int rabyt= es) { struct z_erofs_decompressqueue io[NR_JOBQUEUES]; struct erofs_sb_info *sbi =3D EROFS_I_SB(f->inode); - bool force_fg =3D z_erofs_is_sync_decompress(sbi, rapages); + int syncmode =3D sbi->sync_decompress; + bool force_fg; int err; =20 + force_fg =3D (syncmode =3D=3D EROFS_SYNC_DECOMPRESS_AUTO && !rabytes) || + (syncmode =3D=3D EROFS_SYNC_DECOMPRESS_FORCE_ON && + (rabytes <=3D Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES)); + if (f->head =3D=3D Z_EROFS_PCLUSTER_TAIL) return 0; - z_erofs_submit_queue(f, io, &force_fg, !!rapages); + z_erofs_submit_queue(f, io, &force_fg, !!rabytes); =20 /* handle bypass queue (no i/o pclusters) immediately */ err =3D z_erofs_decompress_queue(&io[JQ_BYPASS], &f->pagepool); @@ -1932,7 +1923,7 @@ static void z_erofs_readahead(struct readahead_contro= l *rac) z_erofs_pcluster_readmore(&f, rac, false); z_erofs_pcluster_end(&f); =20 - (void)z_erofs_runqueue(&f, nrpages); + (void)z_erofs_runqueue(&f, nrpages << PAGE_SHIFT); erofs_put_metabuf(&f.map.buf); erofs_release_pages(&f.pagepool); } --=20 2.43.5