From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, linux-cachefs@redhat.com,
linux-fsdevel@vger.kernel.org, nfsv4@linux-nfs.org
Subject: [PATCH 6/12] FS-Cache: Add a function to replace a page in the pagecache
Date: Mon, 14 Nov 2005 21:54:38 GMT [thread overview]
Message-ID: <200511142154.jAELscNf007525@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <dhowells1132005277@warthog.cambridge.redhat.com>
The attached patch adds a function by which an existing page in the pagecache
may be traded for a new one at the same location without having to allocate or
free any radix tree nodes.
This permits CacheFS to write to start making a new version of a disk block in
memory for which the old version has not yet been written and journalled.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 replace-in-pagecache-2614mm2.diff
include/linux/pagemap.h | 3 +++
mm/filemap.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff -uNrp linux-2.6.14-mm2/include/linux/pagemap.h linux-2.6.14-mm2-cachefs/include/linux/pagemap.h
--- linux-2.6.14-mm2/include/linux/pagemap.h 2005-11-14 16:17:59.000000000 +0000
+++ linux-2.6.14-mm2-cachefs/include/linux/pagemap.h 2005-11-14 16:24:47.000000000 +0000
@@ -96,6 +96,9 @@ int add_to_page_cache(struct page *page,
unsigned long index, gfp_t gfp_mask);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
unsigned long index, gfp_t gfp_mask);
+extern struct page *replace_in_page_cache(struct page *page,
+ struct address_space *mapping,
+ pgoff_t offset);
extern void remove_from_page_cache(struct page *page);
extern void __remove_from_page_cache(struct page *page);
diff -uNrp linux-2.6.14-mm2/mm/filemap.c linux-2.6.14-mm2-cachefs/mm/filemap.c
--- linux-2.6.14-mm2/mm/filemap.c 2005-11-14 16:18:00.000000000 +0000
+++ linux-2.6.14-mm2-cachefs/mm/filemap.c 2005-11-14 16:23:41.000000000 +0000
@@ -427,6 +427,39 @@ int add_to_page_cache_lru(struct page *p
EXPORT_SYMBOL(add_to_page_cache_lru);
/*
+ * This function replaces a page already in the page cache for a particular
+ * index with another, but only if there is already such a page in the page
+ * cache
+ */
+struct page *replace_in_page_cache(struct page *page,
+ struct address_space *mapping,
+ pgoff_t offset)
+{
+ struct page *old;
+ void **slot;
+
+ write_lock_irq(&mapping->tree_lock);
+
+ slot = radix_tree_lookup_slot(&mapping->page_tree, offset);
+ old = NULL;
+ if (slot) {
+ old = *slot;
+ *slot = page;
+ page_cache_get(page);
+ SetPageLocked(page);
+ page->mapping = mapping;
+ page->index = offset;
+ if (old)
+ old->mapping = NULL;
+ }
+
+ write_unlock_irq(&mapping->tree_lock);
+ return old;
+}
+
+EXPORT_SYMBOL(replace_in_page_cache);
+
+/*
* In order to wait for pages to become available there must be
* waitqueues associated with pages. By using a hash table of
* waitqueues where the bucket discipline is to maintain all
next prev parent reply other threads:[~2005-11-14 21:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-14 21:54 [PATCH 0/12] FS-Cache: Generic filesystem caching facility David Howells
2005-11-14 21:54 ` [PATCH 1/12] FS-Cache: Handle -Wsign-compare in i386 bitops David Howells
2005-11-14 21:54 ` [PATCH 2/12] FS-Cache: Permit multiple inclusion of linux/pagevec.h David Howells
2005-11-14 21:54 ` [PATCH 4/12] FS-Cache: Permit pre-allocation of radix-tree nodes David Howells
2005-11-14 21:54 ` [PATCH 5/12] FS-Cache: Release page->private in failed readahead David Howells
2005-11-14 21:54 ` [PATCH 3/12] FS-Cache: Add list_for_each_entry_safe_reverse() David Howells
2005-11-14 21:54 ` [PATCH 7/12] FS-Cache: Export a couple of VM functions David Howells
2005-11-14 21:54 ` [PATCH 8/12] FS-Cache: Add generic filesystem cache core module David Howells
2005-11-14 21:54 ` David Howells [this message]
2005-11-14 21:54 ` [PATCH 9/12] FS-Cache: Add documentation for FS-Cache and its interfaces David Howells
2005-11-14 21:54 ` [PATCH 12/12] FS-Cache: CacheFS: Add Documentation David Howells
2005-11-14 21:54 ` [PATCH 10/12] FS-Cache: Make kAFS use FS-Cache David Howells
2005-11-14 22:45 ` [PATCH 0/12] FS-Cache: Generic filesystem caching facility Linus Torvalds
2005-11-14 23:03 ` Andrew Morton
2005-11-14 23:17 ` Trond Myklebust
2005-11-15 8:57 ` [Linux-cachefs] " Jeff Garzik
2005-11-18 22:07 ` Troy Benjegerdes
2005-11-15 16:32 ` Jamie Lokier
2005-11-15 16:54 ` Linus Torvalds
2005-11-15 17:59 ` David Howells
2005-11-15 19:25 ` Andrew Morton
2005-11-15 23:45 ` Kyle Moffett
2005-11-16 11:26 ` David Howells
2005-11-16 11:56 ` Andrew Morton
2005-11-17 19:28 ` David Howells
2005-11-17 21:29 ` Andrew Morton
2005-11-18 8:43 ` Paul Jackson
2005-11-14 23:47 ` [PATCH] FS-Cache: Make NFS use FS-Cache Steve Dickson
2005-11-15 0:07 ` Andrew Morton
2005-11-15 2:31 ` Steve Dickson
2005-11-15 12:28 ` [PATCH 0/12] FS-Cache: Generic filesystem caching facility Nick Piggin
2005-11-15 13:20 ` [PATCHES 0-12/12] " David Howells
2005-11-15 14:06 ` [Linux-cachefs] " J. Bruce Fields
2005-11-15 16:24 ` David Howells
2005-11-15 13:51 ` [PATCH 0/12] " David Howells
2005-11-15 17:05 ` Linus Torvalds
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=200511142154.jAELscNf007525@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=torvalds@osdl.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®