From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com,
trond.myklebust@fys.uio.no, aviro@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com,
nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/14] FS-Cache: Release page->private in failed readahead [try #10]
Date: Fri, 19 May 2006 16:47:08 +0100 [thread overview]
Message-ID: <20060519154708.11791.66846.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20060519154640.11791.2928.stgit@warthog.cambridge.redhat.com>
The attached patch causes read_cache_pages() to release page-private data on a
page for which add_to_page_cache() fails or the filler function fails. This
permits pages with caching references associated with them to be cleaned up.
Further changes [try #9] that have been made:
(*) The try_to_release_page() is called instead of calling the releasepage()
op directly.
(*) The page is locked before try_to_release_page() is called.
(*) The call to try_to_release_page() and page_cache_release() have been
abstracted out into a helper function as this bit of code occurs twice..
Further changes [try #10] that have been made:
(*) The comment header on the helper function is much expanded. This states
why there's a need to call the releasepage() op in the event of an error.
(*) BUG() if the page is already locked when we try and lock it.
(*) Don't set the page mapping pointer until we've locked the page.
(*) The page is unlocked after try_to_release_page() is called.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
mm/readahead.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/mm/readahead.c b/mm/readahead.c
index 0f142a4..f9361f2 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -14,6 +14,7 @@ #include <linux/module.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/pagevec.h>
+#include <linux/buffer_head.h>
void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
{
@@ -117,6 +118,26 @@ static inline unsigned long get_next_ra_
#define list_to_page(head) (list_entry((head)->prev, struct page, lru))
+/*
+ * see if a page needs releasing upon read_cache_pages() failure
+ * - the caller of read_cache_pages() may have set PG_private before calling,
+ * such as the NFS fs marking pages that are cached locally on disk, thus we
+ * need to give the fs a chance to clean up in the event of an error
+ */
+static inline void read_cache_pages_release_page(struct address_space *mapping,
+ struct page *page)
+{
+ if (PagePrivate(page)) {
+ if (TestSetPageLocked(page))
+ BUG();
+ page->mapping = mapping;
+ try_to_release_page(page, GFP_KERNEL);
+ page->mapping = NULL;
+ unlock_page(page);
+ }
+ page_cache_release(page);
+}
+
/**
* read_cache_pages - populate an address space with some pages, and
* start reads against them.
@@ -141,7 +162,7 @@ int read_cache_pages(struct address_spac
page = list_to_page(pages);
list_del(&page->lru);
if (add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) {
- page_cache_release(page);
+ read_cache_pages_release_page(mapping, page);
continue;
}
ret = filler(data, page);
@@ -153,7 +174,7 @@ int read_cache_pages(struct address_spac
victim = list_to_page(pages);
list_del(&victim->lru);
- page_cache_release(victim);
+ read_cache_pages_release_page(mapping, victim);
}
break;
}
next prev parent reply other threads:[~2006-05-19 15:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-19 15:46 [PATCH 00/14] Permit filesystem local caching and NFS superblock sharing [try #10] David Howells
2006-05-19 15:46 ` [PATCH 01/14] NFS: Permit filesystem to override root dentry on mount " David Howells
2006-05-30 10:45 ` Al Viro
2006-05-19 15:46 ` [PATCH 02/14] NFS: Permit filesystem to perform statfs with a known root dentry " David Howells
2006-05-19 15:46 ` [PATCH 03/14] NFS: Abstract out namespace initialisation " David Howells
2006-05-30 10:35 ` Al Viro
2006-05-30 10:51 ` David Howells
2006-05-19 15:46 ` [PATCH 04/14] NFS: Add dentry materialisation op " David Howells
2006-05-19 15:46 ` [PATCH 05/14] NFS: Split fs/nfs/inode.c into inode, superblock and namespace bits " David Howells
2006-05-19 15:46 ` [PATCH 06/14] NFS: Share NFS superblocks per-protocol per-server per-FSID " David Howells
2006-05-19 15:46 ` [PATCH 07/14] FS-Cache: Provide a filesystem-specific sync'able page bit " David Howells
2006-05-19 15:47 ` [PATCH 08/14] FS-Cache: Add notification of page becoming writable to VMA ops " David Howells
2006-05-19 15:47 ` [PATCH 09/14] FS-Cache: Avoid ENFILE checking for kernel-specific open files " David Howells
2006-05-19 15:47 ` [PATCH 10/14] FS-Cache: Generic filesystem caching facility " David Howells
2006-05-19 15:47 ` David Howells [this message]
2006-05-19 15:47 ` [PATCH 12/14] FS-Cache: Make kAFS use FS-Cache " David Howells
2006-05-19 15:47 ` [PATCH 13/14] FS-Cache: CacheFiles: A cache that backs onto a mounted filesystem " David Howells
2006-05-19 15:47 ` [PATCH 14/14] NFS: Use local caching " David Howells
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=20060519154708.11791.66846.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=aviro@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=steved@redhat.com \
--cc=torvalds@osdl.org \
--cc=trond.myklebust@fys.uio.no \
/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;
as well as URLs for NNTP newsgroup(s).