Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5034601pxb; Mon, 15 Feb 2021 07:53:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC6QZuKHQZpdk21ipH47sot+75y2eKqqYDmgJPFmGXcXfMZcdMcGeYag9/p+NEg7FRTM4m X-Received: by 2002:aa7:dc0d:: with SMTP id b13mr16545466edu.170.1613404402846; Mon, 15 Feb 2021 07:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613404402; cv=none; d=google.com; s=arc-20160816; b=uzlcArNzGHMTftciiQn/BnT3m20SOmRgZ1UL3GwugA0d8hmDSRIjEYx84E6X4yHg/C nIxd+BLWptB3NeL9NVYUjnnEffmUKT0WcweB5QHNMkqWJp5N9FuV1mvW6u19HDplXidp bAtIMq3/W8RfOUHbts4GM+Ep15ScAm/ClyLvgDTZ/NoAk+J2oKX6ZM5T5ejumjAqoM+r FEKbI/AZkd8O9jB9vPv6oAaI441RZsEv0WNcpzXqpg5HUs91J8mafrV+lZfT/O0OoQc1 c1zRdw/AsvSlWJ4NaNKo0a7bifgGpBpBuP26LvBtOMBhDWg0GCadNsKV0IJIzk5F+o8+ GLLQ== 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=wLM2gSa0kD6zIHb8GDXyN66lajfI3bDPXzUqDwmVInE=; b=q9SwN2vOEkk/vVif+XFnrpx37bGi74CE9xSFDwJkrrOLjsf06RfkXhmfQAJKf3JtoD 66HU7HiYqV/mfTWP8uZnYScHpkye+uCbLApQMtxg43wDd7EQCvtA8BuIy/shbXh7irCV 6ni3NuiGOWIfwutNJLO5LQSZEKG49CebB0M62fIV1obU9gDH9SWZXKp4KuQJs0QGg/AN +kOGJI3CbSNBEfxoglYdY93RPTTTsoCi4LS3Lprig+S9n9RP4lbJp+CstlhJNg8mUSvq EMfqDmNt+BaS2mmKjRGZLr9Nxb7yBd8RB6+FtETugidV+qhLnmfe1aOd0xG4+ECltpbY mnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cp3MDTGu; 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 re9si12369785ejb.135.2021.02.15.07.52.59; Mon, 15 Feb 2021 07:53:22 -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=Cp3MDTGu; 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 S231713AbhBOPtf (ORCPT + 99 others); Mon, 15 Feb 2021 10:49:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31467 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231723AbhBOPrQ (ORCPT ); Mon, 15 Feb 2021 10:47:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613403949; 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=wLM2gSa0kD6zIHb8GDXyN66lajfI3bDPXzUqDwmVInE=; b=Cp3MDTGu8pLBF+uVty7Xzm1TOH8bphBkOD0xHhRFbLisD7qFWmXwp73KQB9Nujf4ahbrKO IiyeKDedHzVvtIfz+lkcV73Gm+XLAIbZjc9cMPRzbog6QPZDPFF1tuRm9YGMuikAiThnF4 6Xgfql4NSQN5vhZ9aVvXUIyXp2bUdyg= 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-201-kf4scoX2NFOwQcvbtP7Y1g-1; Mon, 15 Feb 2021 10:45:45 -0500 X-MC-Unique: kf4scoX2NFOwQcvbtP7Y1g-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 7BF09874980; Mon, 15 Feb 2021 15:45:43 +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 BB4A519C99; Mon, 15 Feb 2021 15:45:36 +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 07/33] netfs, mm: Add unlock_page_fscache() and wait_on_page_fscache() From: David Howells To: Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet Cc: Linus Torvalds , Matthew Wilcox , 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:45:35 +0000 Message-ID: <161340393568.1303470.4997526899111310530.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.11 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add unlock_page_fscache() as an alias of unlock_page_private_2(). This allows a page 'locked' with PG_fscache to be unlocked. Add wait_on_page_fscache() to wait for PG_fscache to be unlocked. [Linus suggested putting the fscache-themed functions into the caching-specific headers rather than pagemap.h] Signed-off-by: David Howells cc: Linus Torvalds cc: Matthew Wilcox 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/netfs.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b3d869ec7d2a..f69703543788 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -22,4 +22,33 @@ #define TestSetPageFsCache(page) TestSetPagePrivate2((page)) #define TestClearPageFsCache(page) TestClearPagePrivate2((page)) +/** + * unlock_page_fscache - Unlock a page that's locked with PG_fscache + * @page: The page + * + * Unlocks a page that's locked with PG_fscache and wakes up sleepers in + * wait_on_page_fscache(). This page bit is used by the netfs helpers 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. + */ +static inline void unlock_page_fscache(struct page *page) +{ + unlock_page_private_2(page); +} + +/** + * wait_on_page_fscache - Wait for PG_fscache to be cleared on a page + * @page: The page + * + * Wait for the PG_fscache (PG_private_2) page bit to be removed from a page. + * This is, for example, used to handle a netfs page being written to a local + * disk cache, thereby allowing writes to the cache for the same page to be + * serialised. + */ +static inline void wait_on_page_fscache(struct page *page) +{ + if (PageFsCache(page)) + wait_on_page_bit(compound_head(page), PG_fscache); +} + #endif /* _LINUX_NETFS_H */