From: David Howells <dhowells@redhat.com> To: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: Jeff Layton <jlayton@kernel.org>, Dominique Martinet <asmadeus@codewreck.org>, kafs-testing@auristor.com, dhowells@redhat.com, Jeff Layton <jlayton@kernel.org>, Ilya Dryomov <idryomov@gmail.com>, Dominique Martinet <asmadeus@codewreck.org>, 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 Subject: [PATCH v4 1/5] folio: Add a function to change the private data attached to a folio Date: Tue, 09 Nov 2021 21:27:23 +0000 [thread overview] Message-ID: <163649324326.309189.17817587229450840783.stgit@warthog.procyon.org.uk> (raw) In-Reply-To: <163649323416.309189.4637503793406396694.stgit@warthog.procyon.org.uk> 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 <dhowells@redhat.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Tested-by: Jeff Layton <jlayton@kernel.org> Tested-by: Dominique Martinet <asmadeus@codewreck.org> 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 --- 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.
next prev parent reply other threads:[~2021-11-09 21:27 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-09 21:27 [PATCH v4 0/5] netfs, 9p, afs, ceph: Support folios, at least partially David Howells 2021-11-09 21:27 ` David Howells [this message] 2021-11-09 21:27 ` [PATCH v4 2/5] folio: Add a function to get the host inode for a folio David Howells 2021-11-09 21:27 ` [PATCH v4 3/5] folio: Add replacements for page_endio() David Howells 2021-11-09 21:28 ` [PATCH v4 4/5] netfs, 9p, afs, ceph: Use folios David Howells 2021-11-09 21:28 ` [PATCH v4 5/5] afs: Use folios in directory handling David Howells 2021-11-10 13:33 ` [PATCH v4 0/5] netfs, 9p, afs, ceph: Support folios, at least partially Jeff Layton 2021-11-10 15:18 ` Marc Dionne
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=163649324326.309189.17817587229450840783.stgit@warthog.procyon.org.uk \ --to=dhowells@redhat.com \ --cc=asmadeus@codewreck.org \ --cc=ceph-devel@vger.kernel.org \ --cc=devel@lists.orangefs.org \ --cc=idryomov@gmail.com \ --cc=jlayton@kernel.org \ --cc=kafs-testing@auristor.com \ --cc=linux-afs@lists.infradead.org \ --cc=linux-cachefs@redhat.com \ --cc=linux-cifs@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nfs@vger.kernel.org \ --cc=v9fs-developer@lists.sourceforge.net \ --cc=willy@infradead.org \ --subject='Re: [PATCH v4 1/5] folio: Add a function to change the private data attached to a folio' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.