Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5054519pxb; Mon, 15 Feb 2021 08:20:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRCxxNaN6FRkAdQDwA/6cn4K9j74IBgmC/lA9f0QyG7togr4qOY1HYKtDaRWYOVbBJgsEd X-Received: by 2002:a50:fe04:: with SMTP id f4mr16567607edt.63.1613406015961; Mon, 15 Feb 2021 08:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613406015; cv=none; d=google.com; s=arc-20160816; b=XYY35CNfiH4qgjdJc2aq1Er8YxoZPaHJIu6kp4YEnFV1nZLT+NsJzYd4jRMEUziIQ9 1Y5kTL7A7VSaeoA9s34EWirU8IERHJCdmemfUUl5fwPhMsYA7yXJHPPw0CWDVIzd3a5q g5Fi2d3XeoYXeTXVXFnzHPDU/wsPDnCruslpxFVhrHuuVKfaQT/KLvZYLtwgadUyrEyT ZIEJmI94yROj/Sh6bjSsIKIVX7YGnTv+WmLSgw1TnJDU7gjWtUdQbfssv7ONyQXFmx1J GmKY0EaceYI6ofDT87gxFganqXM85uOJkd18u/hxxAM1W/qhS6o/FjUHCgPdx5uFzvan LwzQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=eRjZtsA5zhSS/WW5VYasjVbQdw0rYUOiOpY9AmwMNHQ=; b=NfNS7MdALch7lD0yTctsm15ntyZ8rJYtAyqlKXyz7uMeC58ylFEFdqhwWkwIdhLANo LBkD82KSRrSA6G4l9/d51VWuS0x23Nfm6QeD9lbe1LBCCUHt3/1mWTIWvQT8KaSQ9b+D jYM/8jEmg94y6HR6qexBgR9mWqlIvRqB9XC6UyeQnKVjvZWbC+/2eduai84/Xudp8gPG Ql5AIlezzYsi8e4R1FKvyywW8lwQO1wwZSwTITMITDDoV6vmwU9M7B+XN82uGnfZwwoq 1ZOlFZa6RaMQQtQdtZmyKUlcaoDCqLa3HFZbCdrJsk6cCPq95nTSkhEBZjwSAR3hSV/v Ldlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AIMvB0T0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 gn26si11645269ejc.525.2021.02.15.08.19.51; Mon, 15 Feb 2021 08:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=AIMvB0T0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 S231285AbhBOQTg (ORCPT + 99 others); Mon, 15 Feb 2021 11:19:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58244 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbhBOPqU (ORCPT ); Mon, 15 Feb 2021 10:46:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613403892; 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=eRjZtsA5zhSS/WW5VYasjVbQdw0rYUOiOpY9AmwMNHQ=; b=AIMvB0T0e74s2QkMDjHDTN5H6FeyUCtSxz6ru0xGb1uysQJKX82SQc15ys10NGi5ynfmYU hpegw3DcS17uuWesu5hb+913PFFyvrmF+8ughiWRQEaM32KKMLhat3CiSQxm6xzuIfh7DQ 7KGRr4CRbF9ALEqD5HoP64xd0j607fE= 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-448-MqlpGAkWNeC56cKekoPN7Q-1; Mon, 15 Feb 2021 10:44:49 -0500 X-MC-Unique: MqlpGAkWNeC56cKekoPN7Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFEF1107ACC7; Mon, 15 Feb 2021 15:44:46 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-119-68.rdu2.redhat.com [10.10.119.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 462C060CEF; Mon, 15 Feb 2021 15:44:40 +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 Subject: [PATCH 02/33] mm: Add an unlock function for PG_private_2/PG_fscache From: David Howells To: Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet Cc: Linus Torvalds , Linus Torvalds , "Matthew Wilcox (Oracle)" , Alexander Viro , Christoph Hellwig , linux-mm@kvack.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, dhowells@redhat.com, Jeff Layton , David Wysochanski , "Matthew Wilcox (Oracle)" , Alexander Viro , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 15 Feb 2021 15:44:39 +0000 Message-ID: <161340387944.1303470.7944159520278177652.stgit@warthog.procyon.org.uk> In-Reply-To: <161340385320.1303470.2392622971006879777.stgit@warthog.procyon.org.uk> References: <161340385320.1303470.2392622971006879777.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a function, unlock_page_private_2(), to unlock PG_private_2 analogous to that of PG_lock. Add a kerneldoc banner to that indicating the example usage case. A wrapper will need to be placed in the netfs header in the patch that adds that. [This implements a suggestion by Linus to not mix the terminology of PG_private_2 and PG_fscache in the mm core function] Suggested-by: Linus Torvalds Signed-off-by: David Howells cc: Linus Torvalds cc: Matthew Wilcox (Oracle) cc: Alexander Viro cc: Christoph Hellwig cc: linux-mm@kvack.org cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: ceph-devel@vger.kernel.org cc: v9fs-developer@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/linux-fsdevel/1330473.1612974547@warthog.procyon.org.uk/ Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wjgA-74ddehziVk=XAEMTKswPu1Yw4uaro1R3ibs27ztw@mail.gmail.com/ --- include/linux/pagemap.h | 1 + mm/filemap.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d5570deff400..365a28ece763 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -591,6 +591,7 @@ extern int __lock_page_async(struct page *page, struct wait_page_queue *wait); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, unsigned int flags); extern void unlock_page(struct page *page); +extern void unlock_page_private_2(struct page *page); /* * Return true if the page was successfully locked diff --git a/mm/filemap.c b/mm/filemap.c index 5c9d564317a5..7d321152d579 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1466,6 +1466,26 @@ void unlock_page(struct page *page) } EXPORT_SYMBOL(unlock_page); +/** + * unlock_page_private_2 - Unlock a page that's locked with PG_private_2 + * @page: The page + * + * Unlocks a page that's locked with PG_private_2 and wakes up sleepers in + * wait_on_page_private_2(). + * + * This is, for example, used when a netfs page is being written to a local + * disk cache, thereby allowing writes to the cache for the same page to be + * serialised. + */ +void unlock_page_private_2(struct page *page) +{ + page = compound_head(page); + VM_BUG_ON_PAGE(!PagePrivate2(page), page); + clear_bit_unlock(PG_private_2, &page->flags); + wake_up_page_bit(page, PG_private_2); +} +EXPORT_SYMBOL(unlock_page_private_2); + /** * end_page_writeback - end writeback against a page * @page: the page