Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2058706pxu; Sun, 6 Dec 2020 17:28:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFTgmqGsXtiL9mlgy87zCgRdu+aPMFCk8dLQ7vIX4B3+qz2RUPx5SUKVrR6tgxKRM43+iJ X-Received: by 2002:a50:998d:: with SMTP id m13mr17767665edb.143.1607304498617; Sun, 06 Dec 2020 17:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607304498; cv=none; d=google.com; s=arc-20160816; b=hM7nFvuxIJH0x8F8pjMw0lX+5faLivhrkRm0aiH4jpzdLYKf0rIntmOVTMClv2MDDj IyOhe8NIAeVWYY9sDdNMnH1dMVkwDL+ljZ8mSWJrNR17ZAzAPNkZoENZNHGsCYM7jDeC hs9lOrGc0ZuKxr5P++wjd89VO8IJJeDCc1JVKIk3/3nBGl4PBFk4FCmJuF/LaM2Of/e9 m1jZSFTC8t5Q+XSjwZ0VbADVxRtnoyoqovw0wpRTyyuj/jTcs0iOEvW+0ftFH0KkFHlt 4VBC921cNdAKrIoNA8R6OMW+o8w0prwb07ZeYbClNg6VAJ0+06FnJLbFQQk2X+UBbx4/ Ov6w== 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=J1oN9sljlo2pwicIsZRRyVmn98jc3XH9a9o30D1qed4=; b=BUsDobh9Au8fu1L1Gt+tX/wq7R1Yxg5JJEFwrMpjwzJ58fDS2PpxcDV9l2WZMf1Rph i9LeFlEyAvo8aZfQjq8Ud0On7BVdPUpKBK4jOsCvW6az7YjCl8GlxGLgIuLMOT87oYXN CikcZaiq8BuN4bEjlDDrIFgC7auLuUj8uZxRFagG1y/YdE8WY1+LdDgdfHyZaezf3ssU dgDb6lV5ky28Yk2SWPMoH5mciZ8p+aYdk401ocIytBl9ul2v7q/ductD+2r04a8HeT/G kTJQXsHOKCSNxbE+3GLkSY8QhtssjNs5hWUqOJPR3QiTDyZ05LlHhDuQCIS5gCNMCsGQ VRsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FWqMZa8I; 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 u4si5658439ejm.412.2020.12.06.17.27.56; Sun, 06 Dec 2020 17:28:18 -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=FWqMZa8I; 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 S1728595AbgLGB0P (ORCPT + 99 others); Sun, 6 Dec 2020 20:26:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31078 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbgLGB0P (ORCPT ); Sun, 6 Dec 2020 20:26:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607304289; 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=J1oN9sljlo2pwicIsZRRyVmn98jc3XH9a9o30D1qed4=; b=FWqMZa8IhxLVzSRwTsSJwfoEeZvP9pVS9v6+zLL9ZWAuU7L8qK7UK6txqHuxGwIXEVsE1p J4pL+h4qrGD3zniuLxrjzal3zE8UZBkwJ6DHdytLCLNfC7UKZ2o2UPG/rW6tAGrpo47eIG QoCYk2bL6ElZgYUXkS3dAvjtrr2pHzs= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-HiHmB0fYMOCvIOmapatulQ-1; Sun, 06 Dec 2020 20:24:47 -0500 X-MC-Unique: HiHmB0fYMOCvIOmapatulQ-1 Received: by mail-pj1-f71.google.com with SMTP id kb15so6100714pjb.4 for ; Sun, 06 Dec 2020 17:24:47 -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=J1oN9sljlo2pwicIsZRRyVmn98jc3XH9a9o30D1qed4=; b=IRxgmBZAT2vFMTsXjRsReql1oYW6zkvRqg9tHqQ71YkFG+zs71Rg/cPCEezFPq/OVU RVMccKaQexi0OpGwKkrsZrznlKaJFX0+BIlLxiubrOLp/YAB8q8Y0oIIrX9QtXBfkBtB Gfo6N39YxG/o4aOt7x9J6Cr+9hbxpELkGchPzXyKnOfgdweqwZK0NorgxyfcuhO/vzYq HGANXJhIjRhE08zaT5/LMakNkjk1el+UpLQe+dFaPSuch0cUIHTPL2Vx9mvfWd9KnUQ7 hoiWXVBOXp9FnVRXBbKJUtbAbZ23+6Fyy1YNQlGxeDbCIpC5LQ82o0muwN5m0zCmzzC4 ytQA== X-Gm-Message-State: AOAM533ZSZmRQYyfu0N90OhHyCBZu8sxB2T9mVTiFDs++1f4vJqU6Zm9 Vw5yK/9h/ey4HyoaDASkvc/nQq05M/jgKEVQztcy7gLfTlaQS+inlt1eY0XXd6VgzUhxIj4l6c1 GW453VBv7HnKLZho7Ujo8cNHM X-Received: by 2002:a17:902:988c:b029:da:60e0:10ec with SMTP id s12-20020a170902988cb02900da60e010ecmr13661214plp.83.1607304286330; Sun, 06 Dec 2020 17:24:46 -0800 (PST) X-Received: by 2002:a17:902:988c:b029:da:60e0:10ec with SMTP id s12-20020a170902988cb02900da60e010ecmr13661200plp.83.1607304286141; Sun, 06 Dec 2020 17:24:46 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id z13sm8600202pjt.45.2020.12.06.17.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 17:24:45 -0800 (PST) From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Chao Yu , Chao Yu , Gao Xiang Subject: [PATCH v2 2/3] erofs: insert to managed cache after adding to pcl Date: Mon, 7 Dec 2020 09:23:45 +0800 Message-Id: <20201207012346.2713857-2-hsiangkao@redhat.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201207012346.2713857-1-hsiangkao@redhat.com> References: <20201207012346.2713857-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. Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index afeadf413c2c..edd7325570e1 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1071,28 +1071,19 @@ 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) { - set_page_private(page, (unsigned long)pcl); - SetPagePrivate(page); + 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); + goto out; } + set_page_private(page, (unsigned long)pcl); + SetPagePrivate(page); out: /* the only exit (for tracing and debugging) */ return page; } -- 2.18.4