From nobody Thu Sep 18 23:32:35 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F044C4321E for ; Thu, 1 Dec 2022 10:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbiLAK7q (ORCPT ); Thu, 1 Dec 2022 05:59:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiLAK7L (ORCPT ); Thu, 1 Dec 2022 05:59:11 -0500 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27790AD9AD for ; Thu, 1 Dec 2022 02:58:32 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=0;PH=DS;RN=4;SR=0;TI=SMTPD_---0VW8aXKh_1669892309; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VW8aXKh_1669892309) by smtp.aliyun-inc.com; Thu, 01 Dec 2022 18:58:30 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] erofs: split inline data reading and tail zeroing in fscache mode Date: Thu, 1 Dec 2022 18:58:29 +0800 Message-Id: <20221201105829.90692-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Prior to this patch, the INLINE routine will also zero the tail part of the folio. This is reasonable since currently for each file, only the tail part over EROFS_BLKSIZ boundary is stored as tail packing format, and thus the tail part in the same folio is treated as EOF and shall be zeroed. Since we have supported large folios now and erofs_fscache_data_read_slice() can be called multiple times for each folio or folio range, for tail packing format, we can defer zeroing the EOF part to the UNMAPPED routine in the next calling of erofs_fscache_data_read_slice(). This cleanup makes the INLINE routine focusing on reading inline data, while zeroing is left to the UNMAPPED routine. Besides, make the naming consistent among INLINE/UNMAPPED/MAPPED routines. Signed-off-by: Jingbo Xu --- v2: rename 'size' to 'count' to make git diff statistics more cleaner, while v1 renames 'count' to 'size' v1: https://lore.kernel.org/all/20221201075018.27925-1-jefflexu@linux.aliba= ba.com/ --- fs/erofs/fscache.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index f14886c479bd..c9bf59aac5ac 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -214,35 +214,32 @@ static int erofs_fscache_data_read_slice(struct erofs= _fscache_request *primary) if (map.m_flags & EROFS_MAP_META) { struct erofs_buf buf =3D __EROFS_BUF_INITIALIZER; erofs_blk_t blknr; - size_t offset, size; + size_t offset; void *src; =20 /* For tail packing layout, the offset may be non-zero. */ offset =3D erofs_blkoff(map.m_pa); blknr =3D erofs_blknr(map.m_pa); - size =3D map.m_llen; + count =3D map.m_llen; =20 src =3D erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP); if (IS_ERR(src)) return PTR_ERR(src); =20 - iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE); - if (copy_to_iter(src + offset, size, &iter) !=3D size) { + iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count); + if (copy_to_iter(src + offset, count, &iter) !=3D count) { erofs_put_metabuf(&buf); return -EFAULT; } - iov_iter_zero(PAGE_SIZE - size, &iter); erofs_put_metabuf(&buf); - primary->submitted +=3D PAGE_SIZE; - return 0; + goto out; } =20 count =3D primary->len - primary->submitted; if (!(map.m_flags & EROFS_MAP_MAPPED)) { iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count); iov_iter_zero(count, &iter); - primary->submitted +=3D count; - return 0; + goto out; } =20 count =3D min_t(size_t, map.m_llen - (pos - map.m_la), count); @@ -263,6 +260,7 @@ static int erofs_fscache_data_read_slice(struct erofs_f= scache_request *primary) ret =3D erofs_fscache_read_folios_async(mdev.m_fscache->cookie, req, mdev.m_pa + (pos - map.m_la), count); erofs_fscache_req_put(req); +out: primary->submitted +=3D count; return ret; } --=20 2.19.1.6.gb485710b