From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E824C433DB for ; Wed, 10 Feb 2021 16:40:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BCA364E87 for ; Wed, 10 Feb 2021 16:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232929AbhBJQkc (ORCPT ); Wed, 10 Feb 2021 11:40:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57617 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbhBJQiO (ORCPT ); Wed, 10 Feb 2021 11:38:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612975006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6q4l5j2A9zC8AOPQY3ki5vFxtQJE10uxKO//gAn5chg=; b=Uk17T2rZ+x8fvFVPoptUr6EQIUoPx4zOhyIMr09/8PFQxqwTTxKJ/Fz7vcGsxtFqBicL6b AesFQ9YNdDyQK5bzif9XV3fLhhxgHrYYGmLqnC5PPt6tNIuNlrLluxmjxie606DRycfQek ueB57D9fx2BRJRGr7Q7RkKUZK3zJHmw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-0MlIkmEwOxCxZMmDqzOJ6A-1; Wed, 10 Feb 2021 11:36:42 -0500 X-MC-Unique: 0MlIkmEwOxCxZMmDqzOJ6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37F8D803F4C; Wed, 10 Feb 2021 16:36:40 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-115-23.rdu2.redhat.com [10.10.115.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4970D60657; Wed, 10 Feb 2021 16:36:34 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <591237.1612886997@warthog.procyon.org.uk> <20210209202134.GA308988@casper.infradead.org> To: Linus Torvalds Cc: dhowells@redhat.com, Matthew Wilcox , Jeff Layton , David Wysochanski , Anna Schumaker , Trond Myklebust , Steve French , Dominique Martinet , Alexander Viro , ceph-devel@vger.kernel.org, linux-afs@lists.infradead.org, linux-cachefs@redhat.com, CIFS , linux-fsdevel , "open list:NFS, SUNRPC, AND..." , v9fs-developer@lists.sourceforge.net, Linux Kernel Mailing List Subject: Re: [GIT PULL] fscache: I/O API modernisation and netfs helper library MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1331024.1612974993.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 10 Feb 2021 16:36:33 +0000 Message-ID: <1331025.1612974993@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Linus Torvalds wrote: > Does the code not hold a refcount already? The attached patch will do that. Note that it's currently based on top of= the patch that drops the PG_fscache alias, so it refers to PG_private_2. I've run all three patches through xfstests over afs, both with and withou= t a cache, and Jeff has tested ceph with them. David --- commit 803a09110b41b9f6091a517fc8f5c4b15475048c Author: David Howells Date: Wed Feb 10 11:35:15 2021 +0000 netfs: Hold a ref on a page when PG_private_2 is set = Take a reference on a page when PG_private_2 is set and drop it once t= he bit is unlocked. = Reported-by: Linus Torvalds Signed-off-by: David Howells diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index 9018224693e9..043d96ca2aad 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -230,10 +231,13 @@ static void netfs_rreq_completed(struct netfs_read_r= equest *rreq) static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq= ) { struct netfs_read_subrequest *subreq; + struct pagevec pvec; struct page *page; pgoff_t unlocked =3D 0; bool have_unlocked =3D false; = + pagevec_init(&pvec); + rcu_read_lock(); = list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { @@ -247,6 +251,8 @@ static void netfs_rreq_unmark_after_write(struct netfs= _read_request *rreq) continue; unlocked =3D page->index; unlock_page_private_2(page); + if (pagevec_add(&pvec, page) =3D=3D 0) + pagevec_release(&pvec); have_unlocked =3D true; } } @@ -403,8 +409,10 @@ static void netfs_rreq_unlock(struct netfs_read_reque= st *rreq) pg_failed =3D true; break; } - if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) + if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) { + get_page(page); SetPagePrivate2(page); + } pg_failed |=3D subreq_failed; if (pgend < iopos + subreq->len) break;