From: Suresh Jayaraman <sjayaraman@suse.de>
To: Steve French <smfrench@gmail.com>
Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-cachefs@redhat.com, David Howells <dhowells@redhat.com>
Subject: [PATCH 08/09] cifs: read pages from FS-Cache
Date: Mon, 5 Jul 2010 18:13:25 +0530 [thread overview]
Message-ID: <1278333805-30839-1-git-send-email-sjayaraman@suse.de> (raw)
In-Reply-To: <Yes>
Read pages from a FS-Cache data storage object into a CIFS inode.
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Acked-by: David Howells <dhowells@redhat.com>
---
fs/cifs/file.c | 17 ++++++++++++
fs/cifs/fscache.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
fs/cifs/fscache.h | 40 ++++++++++++++++++++++++++++-
3 files changed, 129 insertions(+), 1 deletion(-)
Index: cifs-2.6/fs/cifs/file.c
===================================================================
--- cifs-2.6.orig/fs/cifs/file.c
+++ cifs-2.6/fs/cifs/file.c
@@ -1981,6 +1981,15 @@ static int cifs_readpages(struct file *f
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
pTcon = cifs_sb->tcon;
+ /*
+ * Reads as many pages as possible from fscache. Returns -ENOBUFS
+ * immediately if the cookie is negative
+ */
+ rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,
+ &num_pages);
+ if (rc == 0)
+ goto read_complete;
+
cFYI(DBG2, "rpages: num pages %d", num_pages);
for (i = 0; i < num_pages; ) {
unsigned contig_pages;
@@ -2091,6 +2100,7 @@ static int cifs_readpages(struct file *f
smb_read_data = NULL;
}
+read_complete:
FreeXid(xid);
return rc;
}
@@ -2101,6 +2111,11 @@ static int cifs_readpage_worker(struct f
char *read_data;
int rc;
+ /* Is the page cached? */
+ rc = cifs_readpage_from_fscache(file->f_path.dentry->d_inode, page);
+ if (rc == 0)
+ goto read_complete;
+
page_cache_get(page);
read_data = kmap(page);
/* for reads over a certain size could initiate async read ahead */
@@ -2129,6 +2144,8 @@ static int cifs_readpage_worker(struct f
io_error:
kunmap(page);
page_cache_release(page);
+
+read_complete:
return rc;
}
Index: cifs-2.6/fs/cifs/fscache.c
===================================================================
--- cifs-2.6.orig/fs/cifs/fscache.c
+++ cifs-2.6/fs/cifs/fscache.c
@@ -140,6 +140,79 @@ int cifs_fscache_release_page(struct pag
return 1;
}
+static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx,
+ int error)
+{
+ cFYI(1, "CFS: readpage_from_fscache_complete (0x%p/%d)",
+ page, error);
+ if (!error)
+ SetPageUptodate(page);
+ unlock_page(page);
+}
+
+/*
+ * Retrieve a page from FS-Cache
+ */
+int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)
+{
+ int ret;
+
+ cFYI(1, "CIFS: readpage_from_fscache(fsc:%p, p:%p, i:0x%p",
+ CIFS_I(inode)->fscache, page, inode);
+ ret = fscache_read_or_alloc_page(CIFS_I(inode)->fscache, page,
+ cifs_readpage_from_fscache_complete,
+ NULL,
+ GFP_KERNEL);
+ switch (ret) {
+
+ case 0: /* page found in fscache, read submitted */
+ cFYI(1, "CIFS: readpage_from_fscache: submitted");
+ return ret;
+ case -ENOBUFS: /* page won't be cached */
+ case -ENODATA: /* page not in cache */
+ cFYI(1, "CIFS: readpage_from_fscache %d", ret);
+ return 1;
+
+ default:
+ cERROR(1, "unknown error ret = %d", ret);
+ }
+ return ret;
+}
+
+/*
+ * Retrieve a set of pages from FS-Cache
+ */
+int __cifs_readpages_from_fscache(struct inode *inode,
+ struct address_space *mapping,
+ struct list_head *pages,
+ unsigned *nr_pages)
+{
+ int ret;
+
+ cFYI(1, "CIFS: __cifs_readpages_from_fscache (0x%p/%u/0x%p)",
+ CIFS_I(inode)->fscache, *nr_pages, inode);
+ ret = fscache_read_or_alloc_pages(CIFS_I(inode)->fscache, mapping,
+ pages, nr_pages,
+ cifs_readpage_from_fscache_complete,
+ NULL,
+ mapping_gfp_mask(mapping));
+ switch (ret) {
+ case 0: /* read submitted to the cache for all pages */
+ cFYI(1, "CIFS: readpages_from_fscache: submitted");
+ return ret;
+
+ case -ENOBUFS: /* some pages are not cached and can't be */
+ case -ENODATA: /* some pages are not cached */
+ cFYI(1, "CIFS: readpages_from_fscache: no page");
+ return 1;
+
+ default:
+ cFYI(1, "unknown error ret = %d", ret);
+ }
+
+ return ret;
+}
+
void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
{
int ret;
Index: cifs-2.6/fs/cifs/fscache.h
===================================================================
--- cifs-2.6.orig/fs/cifs/fscache.h
+++ cifs-2.6/fs/cifs/fscache.h
@@ -32,7 +32,6 @@ extern const struct fscache_cookie_def c
extern const struct fscache_cookie_def cifs_fscache_super_index_def;
extern const struct fscache_cookie_def cifs_fscache_inode_object_def;
-
extern int cifs_fscache_register(void);
extern void cifs_fscache_unregister(void);
@@ -50,6 +49,11 @@ extern void cifs_fscache_reset_inode_coo
extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);
+extern int __cifs_readpage_from_fscache(struct inode *, struct page *);
+extern int __cifs_readpages_from_fscache(struct inode *,
+ struct address_space *,
+ struct list_head *,
+ unsigned *);
extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
@@ -60,6 +64,26 @@ static inline void cifs_fscache_invalida
__cifs_fscache_invalidate_page(page, inode);
}
+static inline int cifs_readpage_from_fscache(struct inode *inode,
+ struct page *page)
+{
+ if (CIFS_I(inode)->fscache)
+ return __cifs_readpage_from_fscache(inode, page);
+
+ return -ENOBUFS;
+}
+
+static inline int cifs_readpages_from_fscache(struct inode *inode,
+ struct address_space *mapping,
+ struct list_head *pages,
+ unsigned *nr_pages)
+{
+ if (CIFS_I(inode)->fscache)
+ return __cifs_readpages_from_fscache(inode, mapping, pages,
+ nr_pages);
+ return -ENOBUFS;
+}
+
static inline void cifs_readpage_to_fscache(struct inode *inode,
struct page *page)
{
@@ -90,6 +114,20 @@ static inline void cifs_fscache_release_
static inline int cifs_fscache_invalidate_page(struct page *page,
struct inode *) {}
+static inline int
+cifs_readpage_from_fscache(struct inode *inode, struct page *page)
+{
+ return -ENOBUFS;
+}
+
+static inline int cifs_readpages_from_fscache(struct inode *inode,
+ struct address_space *mapping,
+ struct list_head *pages,
+ unsigned *nr_pages)
+{
+ return -ENOBUFS;
+}
+
static inline void cifs_readpage_to_fscache(struct inode *inode,
struct page *page) {}
next prev parent reply other threads:[~2010-07-05 12:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Yes>
2010-07-05 12:41 ` [PATCH 00/09] cifs: local caching support using FS-Cache Suresh Jayaraman
[not found] ` <1278333663-30464-1-git-send-email-sjayaraman-l3A5Bk7waGM@public.gmane.org>
2010-07-14 17:41 ` Scott Lovenberg
[not found] ` <4C3DF6BF.3070001-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-07-14 18:09 ` Steve French
[not found] ` <AANLkTin2tKtkWTflrrzBMYBEd6SFr35uYUl1SmfYlj9W-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-15 16:23 ` Suresh Jayaraman
[not found] ` <4C3F35F7.8060408-l3A5Bk7waGM@public.gmane.org>
2010-07-22 9:28 ` Suresh Jayaraman
[not found] ` <4C480F51.8070204-l3A5Bk7waGM@public.gmane.org>
2010-07-22 17:40 ` David Howells
[not found] ` <1892.1279820400-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-22 19:12 ` Jeff Layton
2010-07-22 22:49 ` Andreas Dilger
2010-07-23 8:35 ` Stef Bon
[not found] ` <AANLkTikF5Oz5pobaPUJebUg+yPuoVy_B5PBz+nuUTSii-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-23 16:16 ` Suresh Jayaraman
2010-07-24 5:40 ` Stef Bon
2010-07-23 11:57 ` Suresh Jayaraman
[not found] ` <4C4983B0.5080804-l3A5Bk7waGM@public.gmane.org>
2010-07-23 15:03 ` Steve French
2010-07-30 23:08 ` Scott Lovenberg
2010-07-05 12:41 ` [PATCH 01/09] cifs: add kernel config option for CIFS Client caching support Suresh Jayaraman
2010-07-05 12:41 ` [PATCH 02/09] cifs: register CIFS for caching Suresh Jayaraman
2010-07-05 12:42 ` [PATCH 03/09] cifs: define server-level cache index objects and register them Suresh Jayaraman
2010-07-05 12:42 ` [PATCH 04/09] cifs: define superblock-level " Suresh Jayaraman
2010-07-20 12:53 ` Jeff Layton
[not found] ` <20100720085327.4d1bf9d7-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-07-20 13:37 ` Jeff Layton
[not found] ` <20100720093722.4f734f03-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-07-21 14:06 ` Suresh Jayaraman
2010-07-05 12:42 ` [PATCH 05/09] cifs: define inode-level cache object " Suresh Jayaraman
2010-07-05 12:43 ` [PATCH 06/09] cifs: FS-Cache page management Suresh Jayaraman
2010-07-05 12:43 ` [PATCH 07/09] cifs: store pages into local cache Suresh Jayaraman
2010-07-05 12:43 ` Suresh Jayaraman [this message]
2010-07-05 12:43 ` [PATCH 09/09] cifs: add mount option to enable local caching Suresh Jayaraman
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=1278333805-30839-1-git-send-email-sjayaraman@suse.de \
--to=sjayaraman@suse.de \
--cc=dhowells@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=smfrench@gmail.com \
/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).