Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3127368pxu; Tue, 8 Dec 2020 04:25:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIngWetKF1C6Ubi93Q5K3VcENpYfL18IegXs6FMsYHsYGjbqRSAeMZ9k+LldxeJK5/6jAj X-Received: by 2002:aa7:d886:: with SMTP id u6mr25036935edq.139.1607430346033; Tue, 08 Dec 2020 04:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607430346; cv=none; d=google.com; s=arc-20160816; b=eWxZIyjWEhYa49dqVgVrF/ljRTVLLLWRT3cdNQBZ+Bfi+9XXc/ePSpL+OWu4DNVq2Q YWlICW8D67A/lMY1cSwZmYdosPdQJ177WXJJkOub0awTqSFWMA8ryGScUDNIZSbMyGm8 kjfJrmhxIugT2X9csA0IulK1kQYHAmePuapUO2cU9fgPhLfQGa7WOXd9XF6UIhJNM6W7 z91euKMTHfwgQ+RFWKQkX26OZ7zAAwSg/t0WaaVn8CFOURLuQu8+3nCoL7xZDkfvlCtT wysfP2+Vno0g9UJ+r8MEsbncN1zxD2/kfBEQ77/vVT+h2hC7SgpQXSPePcyeF+63z/U3 YMQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=OnbVOCo3bXOU9/kWOo4VVhQfQzo7GWaQzsbv1nJLpY0=; b=yuDqF/jzmRTxAs6QTLld60C4D1w/COJA10HcscQ5zOfnSyqPuNsGnkhe58bTNlJGsN LHQk5I+/hILNW5t4i00s1OuMaLSt4RY94LsLyORr01cmmXCzTOJlNtJct3XA9HqmOHa7 SYF7Qf32FvagsSCtq3/A6B68q5ozRj0jnVe6LQp/Wkis9KmzmuilL84p0xCIUEGcD9K3 G3sjQi9XnETePXF/QDWQF8x+q3Ldbba8ZyBDytmsnO3BKE56ZkcGXRTlGya2ZOUASnb/ fs8HEl0GPXWXlVzM3VPC5PQfgTSUtsQcRgaGvW7ommnlci1yRsJvq6o3DIXa2QVl/Iw8 os4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bx27fKQ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf17si8122317ejb.338.2020.12.08.04.25.23; Tue, 08 Dec 2020 04:25:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bx27fKQ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727135AbgLHKBX (ORCPT + 99 others); Tue, 8 Dec 2020 05:01:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21570 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbgLHKBX (ORCPT ); Tue, 8 Dec 2020 05:01:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607421596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=OnbVOCo3bXOU9/kWOo4VVhQfQzo7GWaQzsbv1nJLpY0=; b=Bx27fKQ3cQPBbVez8/yZTlGImFp6deW8zHYDuGxzPw3+7pdsgPdg7ATEu2Qr71cb3Ufv+A nvTgdp3VZUxYK4S/QEky0QwHVlX3W1P4lLtoyptXMdBi2YQvI5IhMw0aC2nbUarbrOGgO9 7xksxqts1L/VPe02kSQ0aXVcAx/aPkY= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-nQKv4MegOvSd6rI3mZDWZg-1; Tue, 08 Dec 2020 04:59:54 -0500 X-MC-Unique: nQKv4MegOvSd6rI3mZDWZg-1 Received: by mail-pl1-f200.google.com with SMTP id x12so1003543plr.21 for ; Tue, 08 Dec 2020 01:59:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OnbVOCo3bXOU9/kWOo4VVhQfQzo7GWaQzsbv1nJLpY0=; b=L8lUHkJaqtSHjy96vPsBqDAmj1RPjXbeN9PsoVIAGA4V/Kc4Cv01Q474VBfVtUaUWY KzOaYKnwSbCFNk1bvMPX6UPed6Yl9v9xLLsOH/86JYhRv6dpv8PwEWnR+jJqlwmBIA++ E7cGU2I+54FHcip4kYchrKDMapj/naEit82bipslIF4incQLzZHdg5e5q/zRv9gVSwca DZasfaAX3LIi8nuT1DZnvfMngHgGSXR6MpVrWyk/Bv/gpjyjZCxXiuYXthoCE2jLh5dJ asIH8uGOIao75K5X7ODFgXqFSRHwyMmCu+oZSU+oYYuUVqjWHIMo2Xu1jfEjH/519ZPA pAow== X-Gm-Message-State: AOAM5311hkSd3xn4McY3o5AyGWHTYSuIcTULuZ4Xz4KfvNcG69+FpHha 177XMtOzaIuF4DHbxiR+nhIS6bSNyFqOM6VOsebP7fcZI9C5tpC/VWJCmL/bfWrLi/E9gkL4IOr TTar+xgq44C9+NvnGmNii5MCV X-Received: by 2002:a62:2b4e:0:b029:197:96c2:bfef with SMTP id r75-20020a622b4e0000b029019796c2bfefmr19807445pfr.46.1607421593388; Tue, 08 Dec 2020 01:59:53 -0800 (PST) X-Received: by 2002:a62:2b4e:0:b029:197:96c2:bfef with SMTP id r75-20020a622b4e0000b029019796c2bfefmr19807435pfr.46.1607421593111; Tue, 08 Dec 2020 01:59:53 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id z7sm11529018pfq.193.2020.12.08.01.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 01:59:52 -0800 (PST) From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: LKML , Chao Yu , Gao Xiang Subject: [PATCH v3 2/3] erofs: insert to managed cache after adding to pcl Date: Tue, 8 Dec 2020 17:58:33 +0800 Message-Id: <20201208095834.3133565-2-hsiangkao@redhat.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201208095834.3133565-1-hsiangkao@redhat.com> References: <20201208095834.3133565-1-hsiangkao@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, it could be some concern to call add_to_page_cache_lru() with page->mapping == Z_EROFS_MAPPING_STAGING (!= NULL). In contrast, page->private is used instead now, so partially revert commit 5ddcee1f3a1c ("erofs: get rid of __stagingpage_alloc helper") with some adaption for simplicity. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index cfb0d11f893b..37fee144f0e7 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1065,29 +1065,21 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl, put_page(page); out_allocpage: page = erofs_allocpage(pagepool, gfp | __GFP_NOFAIL); - if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) { - /* turn into temporary page if fails */ - set_page_private(page, Z_EROFS_SHORTLIVED_PAGE); - tocache = false; - } - if (oldpage != cmpxchg(&pcl->compressed_pages[nr], oldpage, page)) { - if (tocache) { - /* since it added to managed cache successfully */ - unlock_page(page); - put_page(page); - } else { - list_add(&page->lru, pagepool); - } + list_add(&page->lru, pagepool); cond_resched(); goto repeat; } - if (tocache) { - attach_page_private(page, pcl); - /* drop a ref added by allocpage (then we have 2 refs here) */ - put_page(page); + if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) { + /* turn into temporary page if fails (1 ref) */ + set_page_private(page, Z_EROFS_SHORTLIVED_PAGE); + goto out; } + attach_page_private(page, pcl); + /* drop a refcount added by allocpage (then we have 2 refs here) */ + put_page(page); + out: /* the only exit (for tracing and debugging) */ return page; } -- 2.18.4