1 From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
2 Subject: [RFC][PATCH 09/10] cifs: read pages from FS-Cache
3 Date: Tue, 22 Jun 2010 20:54:21 +0530
5 Message-ID: <1277220261-3717-1-git-send-email-sjayaraman@suse.de>
7 Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
8 linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
9 To: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
10 X-From: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Tue Jun 22 17:44:46 2010
11 Return-path: <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
12 Envelope-to: glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org
13 Received: from vger.kernel.org ([209.132.180.67])
14 by lo.gmane.org with esmtp (Exim 4.69)
15 (envelope-from <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>)
17 for glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org; Tue, 22 Jun 2010 17:44:46 +0200
18 Received: (majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org) by vger.kernel.org via listexpand
19 id S1752563Ab0FVPom (ORCPT <rfc822;glkc-linux-cifs@m.gmane.org>);
20 Tue, 22 Jun 2010 11:44:42 -0400
21 Received: from victor.provo.novell.com ([137.65.250.26]:42741 "EHLO
22 victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23 with ESMTP id S1752542Ab0FVPok (ORCPT
24 <rfc822;groupwise-SJayaraman-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org:0:0>);
25 Tue, 22 Jun 2010 11:44:40 -0400
26 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240])
27 by victor.provo.novell.com with ESMTP; Tue, 22 Jun 2010 09:24:22 -0600
28 X-Mailer: git-send-email 1.6.4.2
30 Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
32 List-ID: <linux-cifs.vger.kernel.org>
33 X-Mailing-List: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
34 Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1001762>
36 Read pages from a FS-Cache data storage object into a CIFS inode.
38 Signed-off-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
40 fs/cifs/file.c | 19 ++++++++++++++
41 fs/cifs/fscache.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
42 fs/cifs/fscache.h | 40 ++++++++++++++++++++++++++++-
43 3 files changed, 131 insertions(+), 1 deletions(-)
45 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
46 index 39c1ce0..42d2f25 100644
49 @@ -1978,6 +1978,16 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
50 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
51 pTcon = cifs_sb->tcon;
54 + * Reads as many pages as possible from fscache. Returns -ENOBUFS
55 + * immediately if the cookie is negative
57 + rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,
59 + cFYI(1, "CIFS: readpages_from_fscache returned %d\n", rc);
63 cFYI(DBG2, "rpages: num pages %d", num_pages);
64 for (i = 0; i < num_pages; ) {
65 unsigned contig_pages;
66 @@ -2090,6 +2100,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
74 @@ -2100,6 +2111,12 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
78 + /* Is the page cached? */
79 + rc = cifs_readpage_from_fscache(file->f_path.dentry->d_inode, page);
80 + cFYI(1, "CIFS: cifs_readpage_from_fscache returned %d\n", rc);
85 read_data = kmap(page);
86 /* for reads over a certain size could initiate async read ahead */
87 @@ -2128,6 +2145,8 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
90 page_cache_release(page);
96 diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
97 index 13e47d5..6813737 100644
98 --- a/fs/cifs/fscache.c
99 +++ b/fs/cifs/fscache.c
100 @@ -145,6 +145,79 @@ int cifs_fscache_release_page(struct page *page, gfp_t gfp)
104 +static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx,
107 + cFYI(1, "CFS: readpage_from_fscache_complete (0x%p/%d)\n",
110 + SetPageUptodate(page);
115 + * Retrieve a page from FS-Cache
117 +int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)
121 + cFYI(1, "CIFS: readpage_from_fscache(fsc:%p, p:%p, i:0x%p\n",
122 + CIFS_I(inode)->fscache, page, inode);
123 + ret = fscache_read_or_alloc_page(CIFS_I(inode)->fscache, page,
124 + cifs_readpage_from_fscache_complete,
129 + case 0: /* page found in fscache, read submitted */
130 + cFYI(1, "CIFS: readpage_from_fscache: submitted\n");
132 + case -ENOBUFS: /* page won't be cached */
133 + case -ENODATA: /* page not in cache */
134 + cFYI(1, "CIFS: readpage_from_fscache %d\n", ret);
138 + cFYI(1, "unknown error ret = %d", ret);
144 + * Retrieve a set of pages from FS-Cache
146 +int __cifs_readpages_from_fscache(struct inode *inode,
147 + struct address_space *mapping,
148 + struct list_head *pages,
149 + unsigned *nr_pages)
153 + cFYI(1, "CIFS: __cifs_readpages_from_fscache (0x%p/%u/0x%p)\n",
154 + CIFS_I(inode)->fscache, *nr_pages, inode);
155 + ret = fscache_read_or_alloc_pages(CIFS_I(inode)->fscache, mapping,
157 + cifs_readpage_from_fscache_complete,
159 + mapping_gfp_mask(mapping));
161 + case 0: /* read submitted to the cache for all pages */
162 + cFYI(1, "CIFS: readpages_from_fscache\n");
165 + case -ENOBUFS: /* some pages are not cached and can't be */
166 + case -ENODATA: /* some pages are not cached */
167 + cFYI(1, "CIFS: readpages_from_fscache: no page\n");
171 + cFYI(1, "unknown error ret = %d", ret);
177 void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
180 diff --git a/fs/cifs/fscache.h b/fs/cifs/fscache.h
181 index e34d8ab..03bd3fe 100644
182 --- a/fs/cifs/fscache.h
183 +++ b/fs/cifs/fscache.h
184 @@ -31,7 +31,6 @@ extern const struct fscache_cookie_def cifs_fscache_server_index_def;
185 extern const struct fscache_cookie_def cifs_fscache_super_index_def;
186 extern const struct fscache_cookie_def cifs_fscache_inode_object_def;
189 extern int cifs_fscache_register(void);
190 extern void cifs_fscache_unregister(void);
192 @@ -49,6 +48,11 @@ extern void cifs_fscache_reset_inode_cookie(struct inode *);
194 extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
195 extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);
196 +extern int __cifs_readpage_from_fscache(struct inode *, struct page *);
197 +extern int __cifs_readpages_from_fscache(struct inode *,
198 + struct address_space *,
199 + struct list_head *,
202 extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
204 @@ -59,6 +63,26 @@ static inline void cifs_fscache_invalidate_page(struct page *page,
205 __cifs_fscache_invalidate_page(page, inode);
208 +static inline int cifs_readpage_from_fscache(struct inode *inode,
211 + if (CIFS_I(inode)->fscache)
212 + return __cifs_readpage_from_fscache(inode, page);
217 +static inline int cifs_readpages_from_fscache(struct inode *inode,
218 + struct address_space *mapping,
219 + struct list_head *pages,
220 + unsigned *nr_pages)
222 + if (CIFS_I(inode)->fscache)
223 + return __cifs_readpages_from_fscache(inode, mapping, pages,
228 static inline void cifs_readpage_to_fscache(struct inode *inode,
231 @@ -89,6 +113,20 @@ static inline void cifs_fscache_release_page(struct page *page, gfp_t gfp)
233 static inline int cifs_fscache_invalidate_page(struct page *page,
236 +cifs_readpage_from_fscache(struct inode *inode, struct page *page)
241 +static inline int cifs_readpages_from_fscache(struct inode *inode,
242 + struct address_space *mapping,
243 + struct list_head *pages,
244 + unsigned *nr_pages)
249 static inline void cifs_readpage_to_fscache(struct inode *inode,
250 struct page *page) {}