From patchwork Thu Dec 21 06:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Hu X-Patchwork-Id: 182011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp218514dyi; Wed, 20 Dec 2023 22:24:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWNgMlrNiLZfwN6iVV48iBROU99dKjBass3dFV/FFy1PVwzPqYgEd6aX6BUOxhEqOjqc1f X-Received: by 2002:a50:cdcf:0:b0:553:d641:a662 with SMTP id h15-20020a50cdcf000000b00553d641a662mr1352546edj.16.1703139893493; Wed, 20 Dec 2023 22:24:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703139893; cv=none; d=google.com; s=arc-20160816; b=Bf8OIkHaKC9uAjSKwXH0Lgg2JVcgvAfOmt+2hKw5tH+TiZdtOOxHNh4EnDCOngQXN5 j3KsKV9608QKqG4x5b6df3CxRTpczOp5iT+tIdg5qcLq5C08wbdfaxzX/AEKkUgwlqiT 2H/IXIO0pdbhd2tVoIJmiHU6lC9EAUjZNKGQt2OB53ucVdsNHIZqR06Kfjh6FO7bySPP rdS5zqXznocdpFEDwRkbzF+BH6etfGnSfUc7TzBK5C3lH0r/gINwVmVQ5LU2Z4w300US FSPwJqM8E0usaCHN/+wJi4eScmQuQAYHs7Hw/VGY8kp8AfJTGIosKxLbv5I8r5XZRKhz yn1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=Ux7YJblT1o8powK/wjkuBKhpWvZytW7tRyNBPemyUJo=; fh=sPnA/FVdGHP9tBof3HsXfXxFzh9acSAlCa1wx+QNGkE=; b=CBCH7gEOkOHYl6i22it4cU9gU45dklVW14NNFcSBmmVfcVqQ2uEJfd0KD+6R1VmqWg LYZIp5zp+b8VKR2PDWVaObQmDHyA4Ws7d/sNxQ2BM7aJjRsZ1isVlcn5tTte6dApsBwF Pen+RhZQ+gIe6DEbpkF1xSx3Xo5fe7Dy1P5HKd7w96myJ8xLugbQzdAUklvHNyGwmmWh nSQ/Ubnb5yG6BAnew4BpHlJ62HDGh+Q/MdGW7N9fs7IH4Sd5JEWWVXhDXAT1TVCwRFC0 OVpzQRc4c3cyJQwbUSv6K4ySBE0I4flHr3jQ5nDfRym7jr0j+ML7tZ1ATNCN2XNrukce 8PHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R9arYC3M; spf=pass (google.com: domain of linux-kernel+bounces-7888-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7888-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v25-20020a50a459000000b005540d0739b9si480971edb.135.2023.12.20.22.24.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 22:24:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7888-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R9arYC3M; spf=pass (google.com: domain of linux-kernel+bounces-7888-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7888-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 21BEC1F24787 for ; Thu, 21 Dec 2023 06:24:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C456BA5F; Thu, 21 Dec 2023 06:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R9arYC3M" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14D2AB647 for ; Thu, 21 Dec 2023 06:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-5e7c1012a42so4890217b3.3 for ; Wed, 20 Dec 2023 22:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703139877; x=1703744677; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ux7YJblT1o8powK/wjkuBKhpWvZytW7tRyNBPemyUJo=; b=R9arYC3MCyNQZOs4t3pssNXItrTvF1teV+ZvfddKPl8O243IOd6XfoYSQnf+Jt43y3 w0f8r7p9+dyp894hBppWdaOhNA+yb3Qpn3PAx8lFFSp0shpFvt3r+ymmEMpqgll5PEfx 9frcJxtzvdXx+CsPAVzyPawsBCrBWu74XM0YrGEY0lOP1OEa3whyAPZ4rRTqsNYCYnTu 5EXDm7vOCHtoVV/xisG+jRXXY77VYfXRnXRrXWavUHwWlF7qX9IEiJTiqvS7I0nXZ5nO Iqu0H4VN6VV2M3BOWRDSBN/0UG3Je8QfPUJCpBNVGMDak2mLSNhJsAv0XEho5Bl9Kah2 WPJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703139877; x=1703744677; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ux7YJblT1o8powK/wjkuBKhpWvZytW7tRyNBPemyUJo=; b=NrivtSw2QK5kS7k/8/N+xOBP16Lf2WXh2mKb2jvVNVVt09wNag3rnHoXnSgwEI0A/P jE2ch13MLsrXa1/L25DKZXcm7tWY0mUge8IBD/LWDFW8wC70O0Ah4xed8meiebizDG1R BIrdvyuzgOtBfbmaj2mAZ68nJj0A+XBx94bMCDxGFJjR7SVeJSNCYLN/nCZ0bCcBN7CF opDWUY9WPyF1orVb/GnRPN9QiIZwE3LoptCMNslR4CvhvAM7w9ov3cSFGUaS7AStLPkv EnpKUVTC124txcvUnN0dlcXns5G5JOwBOmKrHhimvW332QBY1PXCwE24zWeW3yErLIk9 1Ixw== X-Gm-Message-State: AOJu0YzYtRlR4E7Dx1gu7qFO9rCOkmNzMsyZZuDROzxDWLnMFrN89SRQ oZNoDKNFvYZtqQcaM5M13cT8cicgUkA= X-Received: by 2002:a0d:d990:0:b0:5e7:df55:3b1e with SMTP id b138-20020a0dd990000000b005e7df553b1emr937076ywe.12.1703139877000; Wed, 20 Dec 2023 22:24:37 -0800 (PST) Received: from localhost.localdomain ([156.236.96.164]) by smtp.gmail.com with ESMTPSA id k1-20020a170902ba8100b001d2ed17751asm756765pls.261.2023.12.20.22.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 22:24:36 -0800 (PST) From: Yue Hu To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: jefflexu@linux.alibaba.com, linux-kernel@vger.kernel.org, Yue Hu Subject: [PATCH] erofs: allow partially filled compressed bvecs Date: Thu, 21 Dec 2023 14:23:41 +0800 Message-Id: <20231221062341.23901-1-zbestahu@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785871617156037077 X-GMAIL-MSGID: 1785871617156037077 From: Yue Hu In order to reduce memory footprints even further, let's allow partially filled compressed bvecs for readahead to bail out later. Signed-off-by: Yue Hu Reviewed-by: Gao Xiang --- fs/erofs/zdata.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index a2c3e87d2f81..20a0cd415cf7 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1202,34 +1202,27 @@ static int z_erofs_parse_in_bvecs(struct z_erofs_decompress_backend *be, struct z_erofs_bvec *bvec = &pcl->compressed_bvecs[i]; struct page *page = bvec->page; - /* compressed pages ought to be present before decompressing */ + /* compressed data ought to be valid before decompressing */ if (!page) { - DBG_BUGON(1); + err = -EIO; continue; } be->compressed_pages[i] = page; - if (z_erofs_is_inline_pcluster(pcl)) { + if (z_erofs_is_inline_pcluster(pcl) || + erofs_page_is_managed(EROFS_SB(be->sb), page)) { if (!PageUptodate(page)) err = -EIO; continue; } DBG_BUGON(z_erofs_page_is_invalidated(page)); - if (!z_erofs_is_shortlived_page(page)) { - if (erofs_page_is_managed(EROFS_SB(be->sb), page)) { - if (!PageUptodate(page)) - err = -EIO; - continue; - } - z_erofs_do_decompressed_bvec(be, bvec); - *overlapped = true; - } + if (z_erofs_is_shortlived_page(page)) + continue; + z_erofs_do_decompressed_bvec(be, bvec); + *overlapped = true; } - - if (err) - return err; - return 0; + return err; } static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, @@ -1238,7 +1231,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, struct erofs_sb_info *const sbi = EROFS_SB(be->sb); struct z_erofs_pcluster *pcl = be->pcl; unsigned int pclusterpages = z_erofs_pclusterpages(pcl); - const struct z_erofs_decompressor *decompressor = + const struct z_erofs_decompressor *decomp = &erofs_decompressors[pcl->algorithmformat]; int i, err2; struct page *page; @@ -1274,10 +1267,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, err2 = z_erofs_parse_in_bvecs(be, &overlapped); if (err2) err = err2; - if (err) - goto out; - - err = decompressor->decompress(&(struct z_erofs_decompress_req) { + if (!err) + err = decomp->decompress(&(struct z_erofs_decompress_req) { .sb = be->sb, .in = be->compressed_pages, .out = be->decompressed_pages, @@ -1291,7 +1282,6 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, .fillgaps = pcl->multibases, }, be->pagepool); -out: /* must handle all compressed pages before actual file pages */ if (z_erofs_is_inline_pcluster(pcl)) { page = pcl->compressed_bvecs[0].page; @@ -1302,7 +1292,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, /* consider shortlived pages added when decompressing */ page = be->compressed_pages[i]; - if (erofs_page_is_managed(sbi, page)) + if (!page || erofs_page_is_managed(sbi, page)) continue; (void)z_erofs_put_shortlivedpage(be->pagepool, page); WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);