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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32327C433F5 for ; Wed, 10 Nov 2021 21:08:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B95F161247 for ; Wed, 10 Nov 2021 21:08:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B95F161247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 651126B0071; Wed, 10 Nov 2021 16:08:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DA516B0072; Wed, 10 Nov 2021 16:08:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47AC06B0074; Wed, 10 Nov 2021 16:08:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 39A876B0071 for ; Wed, 10 Nov 2021 16:08:34 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CE6EF80AE834 for ; Wed, 10 Nov 2021 21:08:33 +0000 (UTC) X-FDA: 78794259306.02.125A540 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 4814460019AC for ; Wed, 10 Nov 2021 21:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636578506; 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=ACbG/FwjyxRlnMgIISLIimd21y8r4Isd1KnKpMPaz4E=; b=BSoVIo1rdZXJfZ7XkM/GJdnj2HwS5aflRm7PW2H6+3CJ2mX6CHOvTmD/YEr2VUdcyvDspL eZYaBmxAVZ+X+TXLZ0SEatDIG2gVMsiIylBCTPMXLSjjL5wGSQoIJlZU93J7+Mklb1Snqo 6SjpNfRO13VlWolykpxhTXNJvo0LuaM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636578512; 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=ACbG/FwjyxRlnMgIISLIimd21y8r4Isd1KnKpMPaz4E=; b=NfBzr4/rd6j7Ds2Pt9CL/q6TSDrzDJH6osNdiQGyca3B4iPoEJMS1LDrJd8o+ONTfDYSD/ 5thYwfFk5Bh1efpR5RnjkoiN2FnpEg0P6wgldlIKX7tiMD5JZt296v0JxKSy/c2OZd31TR 93rWsU/uay+nVQFe4TAWSnR4jHLd/dg= 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-22-2kH5HUYCNtatfqP1AiC6Qw-1; Wed, 10 Nov 2021 16:08:21 -0500 X-MC-Unique: 2kH5HUYCNtatfqP1AiC6Qw-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 C4123802C8F; Wed, 10 Nov 2021 21:08:18 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24263BC880; Wed, 10 Nov 2021 21:08:05 +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 v5 1/4] folio: Add a function to change the private data attached to a folio From: David Howells To: "Matthew Wilcox (Oracle)" Cc: Jeff Layton , Dominique Martinet , kafs-testing@auristor.com, dhowells@redhat.com, Jeff Layton , Ilya Dryomov , Dominique Martinet , linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, v9fs-developer@lists.sourceforge.net, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 10 Nov 2021 21:08:05 +0000 Message-ID: <163657848531.834781.14269656212269187893.stgit@warthog.procyon.org.uk> In-Reply-To: <163657847613.834781.7923681076643317435.stgit@warthog.procyon.org.uk> References: <163657847613.834781.7923681076643317435.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 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4814460019AC X-Stat-Signature: 9k4bhodguakyi1ew4cqiru7iwmbi3n4n Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BSoVIo1r; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="NfBzr4/r"; spf=none (imf14.hostedemail.com: domain of dhowells@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1636578514-829026 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a function, folio_change_private(), that will change the private data attached to a folio, without the need to twiddle the private bit or the refcount. It assumes that folio_add_private() has already been called on the page. Signed-off-by: David Howells Reviewed-by: Matthew Wilcox (Oracle) Tested-by: Jeff Layton Tested-by: Dominique Martinet Tested-by: kafs-testing@auristor.com Link: https://lore.kernel.org/r/162981149911.1901565.17776700811659843340.stgit@warthog.procyon.org.uk/ Link: https://lore.kernel.org/r/163005743485.2472992.5100702469503007023.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163584180781.4023316.5037526301198034310.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/163649324326.309189.17817587229450840783.stgit@warthog.procyon.org.uk/ # v4 --- include/linux/pagemap.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 6a30916b76e5..1f560aecd9b5 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -279,6 +279,25 @@ static inline void folio_attach_private(struct folio *folio, void *data) folio_set_private(folio); } +/** + * folio_change_private - Change private data on a folio. + * @folio: Folio to change the data on. + * @data: Data to set on the folio. + * + * Change the private data attached to a folio and return the old + * data. The page must previously have had data attached and the data + * must be detached before the folio will be freed. + * + * Return: Data that was previously attached to the folio. + */ +static inline void *folio_change_private(struct folio *folio, void *data) +{ + void *old = folio_get_private(folio); + + folio->private = data; + return old; +} + /** * folio_detach_private - Detach private data from a folio. * @folio: Folio to detach data from.