Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp482331pxf; Thu, 8 Apr 2021 07:07:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKo50DF4NmgpyuDbdHghIb49MbOAo0OoNKX7vEDvVHv3b2rebeRbyWlALR8yDY4yF5HGP3 X-Received: by 2002:a17:902:988d:b029:e8:dd65:e2b5 with SMTP id s13-20020a170902988db02900e8dd65e2b5mr8003332plp.36.1617890835109; Thu, 08 Apr 2021 07:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617890835; cv=none; d=google.com; s=arc-20160816; b=EXu5nLytGKrQbVuOZ3+bpX3YXNQAbvFCDbXUaAcGPIDNKzxsNIC5x6oyoYGuCUC2Le LqoqBuKCtBQNEC3MgMENkMuc+Wf3X8Q1QQ3dMVVrg88yaLuPXtx/qZROQ0SGnCfWP5Es wmiUspd+3YyO4+OzOSKMfkc7fAYFWQdFLzKHK6hQnqFpjxt8bobaeybkUNTLJt8ui2Z2 X/YpLEV0NrNsiXWA/JiuZNpxOp4eQalZCAYaITaCsUYmuLFVqpBF8I+XR4fDD+uCk/C2 15Sc157J/a0okLAdG2znyrKowMuk9RRNYuBJGMIvSybwUXc75iXtWU94W9cPWTKGBVae e7Mw== 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=oTBge8nmEARoCRFAOiSm2hyLBCSS0qDGBiOvqy+1jY4=; b=MJPawWBcYccM2M1JSkbZ3QLtwKw8/86qexh4Va3WP9e0IWeRR3wEEh/O9004xBoK41 gSKzBvlmUIEZuY73NMWk/2mOG3LfStGvajuxHEag7b7zPFdta+JX80df5Cd+r+f6mRy4 AjIilRjwxYLU91yqcYklRQNSvEzMotPrOgbwH6HK/NL8/6NRcmcqqREaPUW23bbfbTC9 ySFtLGNVlE2qt4AR+qdw96Lyr4svEDsFcB1u99DK0fS1IKvMUF9nwhQ6IHv5HLgIBo3q zA/jFeSIYw8gWm/nS3Pu39D7u4jrVSGlfzEOIYHtYshBfD2oFfIh44tgjFk3htnqAYYO kaVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7l9mL2g; 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 q11si29589841pfn.3.2021.04.08.07.06.54; Thu, 08 Apr 2021 07:07:15 -0700 (PDT) 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=O7l9mL2g; 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 S231919AbhDHOGX (ORCPT + 99 others); Thu, 8 Apr 2021 10:06:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28621 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhDHOGS (ORCPT ); Thu, 8 Apr 2021 10:06:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617890766; 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=oTBge8nmEARoCRFAOiSm2hyLBCSS0qDGBiOvqy+1jY4=; b=O7l9mL2gAQq+XCCyOStoRXOdGJVTV1PN4U/LO5PKqRBMWUYg7WXCG1NeRdqaoST1zT/lOH Wz1sQhzHRZF8+p9l75bfGB3UZFepDl/Gdp15Fxe5jPmLSDrVjfAEHX9uVZy60vH69KMc+c vshU22ZIKD9RZ1s4hwJg4FLdF/dCRAQ= 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-415-tRwChXVmOUqS5aulZ-mhdw-1; Thu, 08 Apr 2021 10:06:04 -0400 X-MC-Unique: tRwChXVmOUqS5aulZ-mhdw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BB3CC73A0; Thu, 8 Apr 2021 14:06:00 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-119-35.rdu2.redhat.com [10.10.119.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D90719744; Thu, 8 Apr 2021 14:05:53 +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 v6 09/30] netfs, mm: Add set/end/wait_on_page_fscache() aliases From: David Howells To: linux-fsdevel@vger.kernel.org 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, dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , 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-kernel@vger.kernel.org, linux-mm@kvack.org Date: Thu, 08 Apr 2021 15:05:53 +0100 Message-ID: <161789075327.6155.7432127924219092385.stgit@warthog.procyon.org.uk> In-Reply-To: <161789062190.6155.12711584466338493050.stgit@warthog.procyon.org.uk> References: <161789062190.6155.12711584466338493050.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.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add set/end/wait_on_page_fscache() as aliases of set/end/wait_page_private_2(). These allow a page to marked with PG_fscache, the flag to be removed and waiters woken and waiting for the flag to be cleared. A ref on the page is also taken and dropped. [Linus suggested putting the fscache-themed functions into the caching-specific headers rather than pagemap.h[1]] Changes: v5: - Mirror the changes to the core routines[2]. 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/r/1330473.1612974547@warthog.procyon.org.uk/ Link: https://lore.kernel.org/r/CAHk-=wjgA-74ddehziVk=XAEMTKswPu1Yw4uaro1R3ibs27ztw@mail.gmail.com/ [1] Link: https://lore.kernel.org/r/161340393568.1303470.4997526899111310530.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/161539536093.286939.5076448803512118764.stgit@warthog.procyon.org.uk/ # v4 Link: https://lore.kernel.org/r/2499407.1616505440@warthog.procyon.org.uk/ [2] Link: https://lore.kernel.org/r/161653793873.2770958.12157243390965814502.stgit@warthog.procyon.org.uk/ # v5 --- include/linux/netfs.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/include/linux/netfs.h b/include/linux/netfs.h index cc1102040488..8479d63406f7 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -26,4 +26,61 @@ #define TestSetPageFsCache(page) TestSetPagePrivate2((page)) #define TestClearPageFsCache(page) TestClearPagePrivate2((page)) +/** + * set_page_fscache - Set PG_fscache on a page and take a ref + * @page: The page. + * + * Set the PG_fscache (PG_private_2) flag on a page and take the reference + * needed for the VM to handle its lifetime correctly. This sets the flag and + * takes the reference unconditionally, so care must be taken not to set the + * flag again if it's already set. + */ +static inline void set_page_fscache(struct page *page) +{ + set_page_private_2(page); +} + +/** + * end_page_fscache - Clear PG_fscache and release any waiters + * @page: The page + * + * Clear the PG_fscache (PG_private_2) bit on a page and wake up any sleepers + * waiting for this. The page ref held for PG_private_2 being set is released. + * + * 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. + */ +static inline void end_page_fscache(struct page *page) +{ + end_page_private_2(page); +} + +/** + * wait_on_page_fscache - Wait for PG_fscache to be cleared on a page + * @page: The page to wait on + * + * Wait for PG_fscache (aka PG_private_2) to be cleared on a page. + */ +static inline void wait_on_page_fscache(struct page *page) +{ + wait_on_page_private_2(page); +} + +/** + * wait_on_page_fscache_killable - Wait for PG_fscache to be cleared on a page + * @page: The page to wait on + * + * Wait for PG_fscache (aka PG_private_2) to be cleared on a page or until a + * fatal signal is received by the calling task. + * + * Return: + * - 0 if successful. + * - -EINTR if a fatal signal was encountered. + */ +static inline int wait_on_page_fscache_killable(struct page *page) +{ + return wait_on_page_private_2_killable(page); +} + #endif /* _LINUX_NETFS_H */