Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp155908rwb; Wed, 30 Nov 2022 23:57:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UPRHXxUuc3njlAPolR87nZ9i6ydntIwo2xM87COSs+LGj7pRAe69L2AUfunRfuU53NW0R X-Received: by 2002:a17:903:120c:b0:188:fc5f:84f3 with SMTP id l12-20020a170903120c00b00188fc5f84f3mr58292750plh.2.1669881475861; Wed, 30 Nov 2022 23:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669881475; cv=none; d=google.com; s=arc-20160816; b=rj78YSijySwINQo03OIqAjl+WwGMzq0Ler78M3GSvzQPsJakJO5AWhvmPBphXeKqGb wSEXUMMaC6P59ZBaNNuaJgtWs5QMUlQiUr5ayOQ1EmSKTiOVwwCQRx4TqXN5XSGlWpSm 9Xs1HdVO1t+IS8UWiQqpZaZHss2x+fbu9VApSNmy4nixCvCYNHQEhm2ZCUaJIL+Cjmy3 GN6QE0WT3jgZjLBD8+j+ExOtuUOlC2PHBZXvzLx787SKBny+asJENlwn3P5t/vBSQ2Ov N29ttIYzu+NpTS74yhqpnCSoRgz2+z89vyjv5IsoPXbgjRJREKq16rS6Xd00rItoeMHR vD7Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h184-20020a6383c1000000b0047875103016si600600pge.654.2022.11.30.23.57.45; Wed, 30 Nov 2022 23:57:55 -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 + 82 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 Content-Transfer-Encoding: 8bit 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 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; } -- 2.19.1.6.gb485710b