]> git.notmuchmail.org Git - notmuch/blob - test/corpora/lkml/cur/1382298770.001736:2,
test: add 'lkml' corpus
[notmuch] / test / corpora / lkml / cur / 1382298770.001736:2,
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
4 Lines: 219
5 Message-ID: <1277220261-3717-1-git-send-email-sjayaraman@suse.de>
6 References: <yes>
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>)
16         id 1OR5eX-0008O2-Q4
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
29 In-Reply-To: <yes>
30 Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
31 Precedence: bulk
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>
35
36 Read pages from a FS-Cache data storage object into a CIFS inode.
37
38 Signed-off-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
39 ---
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(-)
44
45 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
46 index 39c1ce0..42d2f25 100644
47 --- a/fs/cifs/file.c
48 +++ b/fs/cifs/file.c
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;
52  
53 +       /*
54 +        * Reads as many pages as possible from fscache. Returns -ENOBUFS
55 +        * immediately if the cookie is negative
56 +        */
57 +       rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,
58 +                                        &num_pages);
59 +       cFYI(1, "CIFS: readpages_from_fscache returned %d\n", rc);
60 +       if (rc == 0)
61 +               goto read_complete;
62 +
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,
67                 smb_read_data = NULL;
68         }
69  
70 +read_complete:
71         FreeXid(xid);
72         return rc;
73  }
74 @@ -2100,6 +2111,12 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
75         char *read_data;
76         int rc;
77  
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);
81 +       if (rc == 0)
82 +               goto read_complete;
83 +
84         page_cache_get(page);
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,
88  io_error:
89         kunmap(page);
90         page_cache_release(page);
91 +
92 +read_complete:
93         return rc;
94  }
95  
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)
101         return 1;
102  }
103  
104 +static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx,
105 +                                               int error)
106 +{
107 +       cFYI(1, "CFS: readpage_from_fscache_complete (0x%p/%d)\n",
108 +                       page, error);
109 +       if (!error)
110 +               SetPageUptodate(page);
111 +       unlock_page(page);
112 +}
113 +
114 +/*
115 + * Retrieve a page from FS-Cache
116 + */
117 +int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)
118 +{
119 +       int ret;
120 +
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,
125 +                                        NULL,
126 +                                        GFP_KERNEL);
127 +       switch (ret) {
128 +
129 +       case 0: /* page found in fscache, read submitted */
130 +               cFYI(1, "CIFS: readpage_from_fscache: submitted\n");
131 +               return ret;
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);
135 +               return 1;
136 +
137 +       default:
138 +               cFYI(1, "unknown error ret = %d", ret);
139 +       }
140 +       return ret;
141 +}
142 +
143 +/*
144 + * Retrieve a set of pages from FS-Cache
145 + */
146 +int __cifs_readpages_from_fscache(struct inode *inode,
147 +                               struct address_space *mapping,
148 +                               struct list_head *pages,
149 +                               unsigned *nr_pages)
150 +{
151 +       int ret;
152 +
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,
156 +                                         pages, nr_pages,
157 +                                         cifs_readpage_from_fscache_complete,
158 +                                         NULL,
159 +                                         mapping_gfp_mask(mapping));
160 +       switch (ret) {
161 +       case 0: /* read submitted to the cache for all pages */
162 +               cFYI(1, "CIFS: readpages_from_fscache\n");
163 +               return ret;
164 +
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");
168 +               return 1;
169 +
170 +       default:
171 +               cFYI(1, "unknown error ret = %d", ret);
172 +       }
173 +
174 +       return ret;
175 +}
176 +
177  void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
178  {
179         int ret;
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;
187  
188 -
189  extern int cifs_fscache_register(void);
190  extern void cifs_fscache_unregister(void);
191  
192 @@ -49,6 +48,11 @@ extern void cifs_fscache_reset_inode_cookie(struct inode *);
193  
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 *,
200 +                                        unsigned *);
201  
202  extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
203  
204 @@ -59,6 +63,26 @@ static inline void cifs_fscache_invalidate_page(struct page *page,
205                 __cifs_fscache_invalidate_page(page, inode);
206  }
207  
208 +static inline int cifs_readpage_from_fscache(struct inode *inode,
209 +                                            struct page *page)
210 +{
211 +       if (CIFS_I(inode)->fscache)
212 +               return __cifs_readpage_from_fscache(inode, page);
213 +
214 +       return -ENOBUFS;
215 +}
216 +
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)
221 +{
222 +       if (CIFS_I(inode)->fscache)
223 +               return __cifs_readpages_from_fscache(inode, mapping, pages,
224 +                                                    nr_pages);
225 +       return -ENOBUFS;
226 +}
227 +
228  static inline void cifs_readpage_to_fscache(struct inode *inode,
229                                             struct page *page)
230  {
231 @@ -89,6 +113,20 @@ static inline void cifs_fscache_release_page(struct page *page, gfp_t gfp)
232  
233  static inline int cifs_fscache_invalidate_page(struct page *page,
234                         struct inode *) {}
235 +static inline int
236 +cifs_readpage_from_fscache(struct inode *inode, struct page *page)
237 +{
238 +       return -ENOBUFS;
239 +}
240 +
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)
245 +{
246 +       return -ENOBUFS;
247 +}
248 +
249  static inline void cifs_readpage_to_fscache(struct inode *inode,
250                         struct page *page) {}
251  
252 -- 
253 1.6.4.2
254
255
256