From patchwork Thu Dec 1 07:50:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 28224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp129218wrr; Wed, 30 Nov 2022 23:51:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7fp3tdBwB4zmj/phCBCiLENdnSGwMZXqh9HXNuP5oq0UeX+EMBvOu539xJOhttJ8KO+qzh X-Received: by 2002:a63:5910:0:b0:42b:68a1:4207 with SMTP id n16-20020a635910000000b0042b68a14207mr46079854pgb.326.1669881084406; Wed, 30 Nov 2022 23:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669881084; cv=none; d=google.com; s=arc-20160816; b=q5otA/0z20ha+CmtwcchI/m77YBsfLdjF7+Ha6QYsHo6niQNk3k2F/wKCeFTtUq92+ 9iUMPLjOyrS/31c6SdzSACZkUgrGu1Cp1dwz0CdWjB7bTvZOOf7KU1NtJUlvNjxKeE6c JHc7Mp0VsBJj/4OfKCCq5ztLi98Zf5Gf7+N8gOcgKlHRal903FBuUumpZzT24U0PoF2v KCXeZ57UrwOkk/PI7vmgAbevSvITgHfIn9ypf2hc/8ZGIG0C7auxlQod0+5nL+zroiRh 5qA/uP/olTKqmyLFaKJ3di+JrGez1UU8Ug27da+JeuKsAvfm5k0gVZvfo/nirStGgUFE 2jXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cGOhUBYn0B2KulY8Q648JbDsO7mMf8cgWkfor0qVZwQ=; b=P4S+DCA4P3tyj5II4JRvDLcs1TYa2zJWJR0kxt3rxsAosg3MX3Pv4DuyPHMjOCUkvr P62Q3unBuXOhKQqklLy+pd0dnVkf88DRsGSzhkK9MT2SOCNmyMH3Rzg4qQUno66eLJ99 z8/+h8sp1TZuDzasUcDIVpRS9DCICuFKFe9pdzavxUL+S1xVzVzQk3SLD8zJwSCYDWf6 GzMHJ/VEER6UhHwlWOh7qgWoSsCIZkBhmtGg9Y5nsObCXt6Xu7Q79GQMq8LG2M91RclC BO5XWDJJbl4v5tbCIry5e3iD3DvTdyz//MswAO22GWG4vpSjdzpxlMsPeH45jeoTWMDK qu9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t69-20020a638148000000b004786a82654esi2733323pgd.155.2022.11.30.23.51.11; Wed, 30 Nov 2022 23:51:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiLAHuY (ORCPT + 99 others); Thu, 1 Dec 2022 02:50:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbiLAHuX (ORCPT ); Thu, 1 Dec 2022 02:50:23 -0500 Received: from out30-8.freemail.mail.aliyun.com (out30-8.freemail.mail.aliyun.com [115.124.30.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEB44442F4 for ; Wed, 30 Nov 2022 23:50:21 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R291e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VW7bQwL_1669881018; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VW7bQwL_1669881018) by smtp.aliyun-inc.com; Thu, 01 Dec 2022 15:50:19 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] erofs: split inline data reading and tail zeroing in fscache mode Date: Thu, 1 Dec 2022 15:50:18 +0800 Message-Id: <20221201075018.27925-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750997227614721451?= X-GMAIL-MSGID: =?utf-8?q?1750997227614721451?= 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 --- This relies on the codebase of [1]. [1] https://lore.kernel.org/all/20221201074256.16639-2-jefflexu@linux.alibaba.com/ --- fs/erofs/fscache.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index f14886c479bd..b416a586d94e 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -203,7 +203,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary) struct erofs_map_dev mdev; struct iov_iter iter; loff_t pos = primary->start + primary->submitted; - size_t count; + size_t size; int ret; map.m_la = pos; @@ -214,7 +214,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary) if (map.m_flags & EROFS_MAP_META) { struct erofs_buf buf = __EROFS_BUF_INITIALIZER; erofs_blk_t blknr; - size_t offset, size; + size_t offset; void *src; /* For tail packing layout, the offset may be non-zero. */ @@ -226,27 +226,24 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary) if (IS_ERR(src)) return PTR_ERR(src); - iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE); + iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, size); if (copy_to_iter(src + offset, size, &iter) != size) { erofs_put_metabuf(&buf); return -EFAULT; } - iov_iter_zero(PAGE_SIZE - size, &iter); erofs_put_metabuf(&buf); - primary->submitted += PAGE_SIZE; - return 0; + goto out; } - count = primary->len - primary->submitted; + size = 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 += count; - return 0; + iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, size); + iov_iter_zero(size, &iter); + goto out; } - count = min_t(size_t, map.m_llen - (pos - map.m_la), count); - DBG_BUGON(!count || count % PAGE_SIZE); + size = min_t(size_t, map.m_llen - (pos - map.m_la), size); + DBG_BUGON(!size || size % PAGE_SIZE); mdev = (struct erofs_map_dev) { .m_deviceid = map.m_deviceid, @@ -256,14 +253,15 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary) if (ret) return ret; - req = erofs_fscache_req_chain(primary, count); + req = erofs_fscache_req_chain(primary, size); if (IS_ERR(req)) return PTR_ERR(req); ret = erofs_fscache_read_folios_async(mdev.m_fscache->cookie, - req, mdev.m_pa + (pos - map.m_la), count); + req, mdev.m_pa + (pos - map.m_la), size); erofs_fscache_req_put(req); - primary->submitted += count; +out: + primary->submitted += size; return ret; }