From patchwork Thu Dec 1 07:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 2461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp128669wrr; Wed, 30 Nov 2022 23:49:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6s8LokfHW6u1+qc0Ltagytiu9fiMGVYBXD1hLkT6auNTGbToKfq0zyi6puPEDVRvzYRbDW X-Received: by 2002:a05:6a00:808:b0:575:41a4:ba52 with SMTP id m8-20020a056a00080800b0057541a4ba52mr17628892pfk.75.1669880967932; Wed, 30 Nov 2022 23:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669880967; cv=none; d=google.com; s=arc-20160816; b=AjV6tlp5mVTYPaBpqLDid4oeJNq3HDfA073zXVHIskmbbOJJHSdc//e+Nf0W/seqgr 4YWcjPWDo8hCMZP3GrRWL01aRMWSXsrR30ndzCDTppUUzscuVpZX9OLbCdKNA9IsSLMM FqU9u/yhidBc1U/zZbic0OmwW2cqSrEJ+ITIEnUbVmDaNv4m7gD9NmEcwSQdanA5eQDy d5VXI/bZmJVy/dJwBPFuoScoJ5QQQ2zlB5p9OidgYM8ChqPNZzpEGIozjeM9BrT8353k TJDDpebwFSJ1TzZSakxTtoyrblNZc5h0yRjR+npQawMLL+0gk544ebvNiVGT224ujCOX N9EA== 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=TCf++1Qxw4s22llUAbg8GWT2aTTaIda83bZHteArlU0=; b=oP9tSgE/YOxBVTmTWXoCwV6grpHi+/PDjrrNFx28vTpv6Uf1R1Di5RqgFqn+QeHrH0 +UkjjBKKxdmmDoYPFQmVABSuTR6ORr1y9QBweEPCv32rK1F49n+zK5QQHN3GEZX8n7fR JFRle1Q1HuUiKcceQALc8DZ5bwBOXF7yaDCjxJHWwB/9jZx3TmJkgNMd2ZtvR/i8Mga1 +wjtbq68dgBPvBXTFmZmzQ0PHPCkZ41H5kV2ooY+rHYu53OcdvbYJEDDXNXDcc3TqAOX AAKP8iS0Y0WLZ1Oi+hBBYfjRw9LgOCwEHWEWgeP5VSqtV5sRxoBa5mMTj3fJpP6ivK9S rBbA== 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 j37-20020a634a65000000b00477f864cf87si3646386pgl.24.2022.11.30.23.49.14; Wed, 30 Nov 2022 23:49:27 -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 S229616AbiLAHnE (ORCPT + 99 others); Thu, 1 Dec 2022 02:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbiLAHnB (ORCPT ); Thu, 1 Dec 2022 02:43:01 -0500 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BF21741D for ; Wed, 30 Nov 2022 23:42:59 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VW7gIzi_1669880576; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VW7gIzi_1669880576) by smtp.aliyun-inc.com; Thu, 01 Dec 2022 15:42:57 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v4 0/2] erofs: support large folios for fscache mode Date: Thu, 1 Dec 2022 15:42:54 +0800 Message-Id: <20221201074256.16639-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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, 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?1750997105901363741?= X-GMAIL-MSGID: =?utf-8?q?1750997105901363741?= v4: - patch 1: move the change to the INLINE routine to a separate patch which will be sent laterly - patch 1: introduce erofs_fscache_req_chain() helper to improve the code organization - patch 1: misc improvement to make the code cleaner - patch 2: also document the new feature in documentation v3: https://lore.kernel.org/all/20221129115833.41062-1-jefflexu@linux.alibaba.com/ v2: https://lore.kernel.org/all/20221128025011.36352-1-jefflexu@linux.alibaba.com/ v1: https://lore.kernel.org/all/20221126005756.7662-1-jefflexu@linux.alibaba.com/ v3: - patch 1: when large folios supported, one folio or folio range can be mapped into several slices, with each slice mapped to different cookies, and thus each slice needs its own netfs_cache_resources. In the implementation of v2, each .read_folio() or .readahead() calling corresponds to only one request, and thus only one netfs_cache_resources (embedded in the request). In this case, fscache_begin_read_operation() may be called multiple times on this cres, while cres->ops->end_operation() is called only once when the whole request completes. This can cause the leakage of the corresponding cachefiles_object->n_accesses refcount, which will cause the user daemon hangs there forever waiting for cache->object_count decreasing to 0 when the user daemon exits. Worsely, as we mentioned previously, when large folios supported, one folio or folio range can be mapped to multiple chunks on different cookies, in which case each mapped chunk needs its own cres. In the implementation of v2, each .read_folio() or .readahead() calling corresponds to only one request, and thus only one cres. This will make the only cres used by the first chunk gets overridden by the following chunk. To fix this, we introduce listed requests, where each .read_folio() or .readahead() calling can correspond to a list of requests, with each request corresponds to one cres. v2: - patch 2: keep the enabling for iomap and fscache mode in separate patches; don't enable the feature for the meta data routine for now (Gao Xiang) Patch 1 is the main part of supporting large folios for fscache mode. It relies on a pending patch[1] adding .prepare_ondemand_read() interface in Cachefiles. Patch 2 just turns the switch on and enables the feature for fscache mode. It relies on a previous patch[2] which enables this feature for iomap mode. [1] https://lore.kernel.org/all/20221124034212.81892-1-jefflexu@linux.alibaba.com/ [2] https://lore.kernel.org/all/20221110074023.8059-1-jefflexu@linux.alibaba.com/ Jingbo Xu (2): erofs: support large folios for fscache mode erofs: enable large folios for fscache mode Documentation/filesystems/erofs.rst | 2 + fs/erofs/fscache.c | 148 +++++++++++++++------------- fs/erofs/inode.c | 3 +- 3 files changed, 83 insertions(+), 70 deletions(-)