blob: b4e4b424160af9d39e1c6dc08708b589629b617b [file] [log] [blame]
David Howellsb5108822009-04-03 16:42:39 +01001/* Cache page management and data I/O routines
2 *
3 * Copyright (C) 2004-2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#define FSCACHE_DEBUG_LEVEL PAGE
13#include <linux/module.h>
14#include <linux/fscache-cache.h>
15#include <linux/buffer_head.h>
16#include <linux/pagevec.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
David Howellsb5108822009-04-03 16:42:39 +010018#include "internal.h"
19
20/*
21 * check to see if a page is being written to the cache
22 */
23bool __fscache_check_page_write(struct fscache_cookie *cookie, struct page *page)
24{
25 void *val;
26
27 rcu_read_lock();
28 val = radix_tree_lookup(&cookie->stores, page->index);
29 rcu_read_unlock();
30
31 return val != NULL;
32}
33EXPORT_SYMBOL(__fscache_check_page_write);
34
35/*
36 * wait for a page to finish being written to the cache
37 */
38void __fscache_wait_on_page_write(struct fscache_cookie *cookie, struct page *page)
39{
40 wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
41
42 wait_event(*wq, !__fscache_check_page_write(cookie, page));
43}
44EXPORT_SYMBOL(__fscache_wait_on_page_write);
45
46/*
David Howells201a1542009-11-19 18:11:35 +000047 * decide whether a page can be released, possibly by cancelling a store to it
48 * - we're allowed to sleep if __GFP_WAIT is flagged
49 */
50bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
51 struct page *page,
52 gfp_t gfp)
53{
54 struct page *xpage;
55 void *val;
56
57 _enter("%p,%p,%x", cookie, page, gfp);
58
David Howells8c209ce2012-12-05 13:34:49 +000059try_again:
David Howells201a1542009-11-19 18:11:35 +000060 rcu_read_lock();
61 val = radix_tree_lookup(&cookie->stores, page->index);
62 if (!val) {
63 rcu_read_unlock();
64 fscache_stat(&fscache_n_store_vmscan_not_storing);
65 __fscache_uncache_page(cookie, page);
66 return true;
67 }
68
69 /* see if the page is actually undergoing storage - if so we can't get
70 * rid of it till the cache has finished with it */
71 if (radix_tree_tag_get(&cookie->stores, page->index,
72 FSCACHE_COOKIE_STORING_TAG)) {
73 rcu_read_unlock();
74 goto page_busy;
75 }
76
77 /* the page is pending storage, so we attempt to cancel the store and
78 * discard the store request so that the page can be reclaimed */
79 spin_lock(&cookie->stores_lock);
80 rcu_read_unlock();
81
82 if (radix_tree_tag_get(&cookie->stores, page->index,
83 FSCACHE_COOKIE_STORING_TAG)) {
84 /* the page started to undergo storage whilst we were looking,
85 * so now we can only wait or return */
86 spin_unlock(&cookie->stores_lock);
87 goto page_busy;
88 }
89
90 xpage = radix_tree_delete(&cookie->stores, page->index);
91 spin_unlock(&cookie->stores_lock);
92
93 if (xpage) {
94 fscache_stat(&fscache_n_store_vmscan_cancelled);
95 fscache_stat(&fscache_n_store_radix_deletes);
96 ASSERTCMP(xpage, ==, page);
97 } else {
98 fscache_stat(&fscache_n_store_vmscan_gone);
99 }
100
101 wake_up_bit(&cookie->flags, 0);
102 if (xpage)
103 page_cache_release(xpage);
104 __fscache_uncache_page(cookie, page);
105 return true;
106
107page_busy:
David Howells8c209ce2012-12-05 13:34:49 +0000108 /* We will wait here if we're allowed to, but that could deadlock the
109 * allocator as the work threads writing to the cache may all end up
110 * sleeping on memory allocation, so we may need to impose a timeout
111 * too. */
David Howells0c59a952013-05-10 19:50:25 +0100112 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
David Howells8c209ce2012-12-05 13:34:49 +0000113 fscache_stat(&fscache_n_store_vmscan_busy);
114 return false;
115 }
116
117 fscache_stat(&fscache_n_store_vmscan_wait);
118 __fscache_wait_on_page_write(cookie, page);
119 gfp &= ~__GFP_WAIT;
120 goto try_again;
David Howells201a1542009-11-19 18:11:35 +0000121}
122EXPORT_SYMBOL(__fscache_maybe_release_page);
123
124/*
David Howellsb5108822009-04-03 16:42:39 +0100125 * note that a page has finished being written to the cache
126 */
David Howells1bccf512009-11-19 18:11:25 +0000127static void fscache_end_page_write(struct fscache_object *object,
128 struct page *page)
David Howellsb5108822009-04-03 16:42:39 +0100129{
David Howells1bccf512009-11-19 18:11:25 +0000130 struct fscache_cookie *cookie;
131 struct page *xpage = NULL;
David Howellsb5108822009-04-03 16:42:39 +0100132
David Howells1bccf512009-11-19 18:11:25 +0000133 spin_lock(&object->lock);
134 cookie = object->cookie;
135 if (cookie) {
136 /* delete the page from the tree if it is now no longer
137 * pending */
138 spin_lock(&cookie->stores_lock);
David Howells201a1542009-11-19 18:11:35 +0000139 radix_tree_tag_clear(&cookie->stores, page->index,
140 FSCACHE_COOKIE_STORING_TAG);
David Howells285e7282009-11-19 18:11:29 +0000141 if (!radix_tree_tag_get(&cookie->stores, page->index,
142 FSCACHE_COOKIE_PENDING_TAG)) {
143 fscache_stat(&fscache_n_store_radix_deletes);
144 xpage = radix_tree_delete(&cookie->stores, page->index);
145 }
David Howells1bccf512009-11-19 18:11:25 +0000146 spin_unlock(&cookie->stores_lock);
147 wake_up_bit(&cookie->flags, 0);
148 }
149 spin_unlock(&object->lock);
150 if (xpage)
151 page_cache_release(xpage);
David Howellsb5108822009-04-03 16:42:39 +0100152}
153
154/*
155 * actually apply the changed attributes to a cache object
156 */
157static void fscache_attr_changed_op(struct fscache_operation *op)
158{
159 struct fscache_object *object = op->object;
David Howells440f0af2009-11-19 18:11:01 +0000160 int ret;
David Howellsb5108822009-04-03 16:42:39 +0100161
162 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
163
164 fscache_stat(&fscache_n_attr_changed_calls);
165
David Howells440f0af2009-11-19 18:11:01 +0000166 if (fscache_object_is_active(object)) {
David Howells52bd75f2009-11-19 18:11:08 +0000167 fscache_stat(&fscache_n_cop_attr_changed);
David Howells440f0af2009-11-19 18:11:01 +0000168 ret = object->cache->ops->attr_changed(object);
David Howells52bd75f2009-11-19 18:11:08 +0000169 fscache_stat_d(&fscache_n_cop_attr_changed);
David Howells440f0af2009-11-19 18:11:01 +0000170 if (ret < 0)
171 fscache_abort_object(object);
172 }
David Howellsb5108822009-04-03 16:42:39 +0100173
David Howells1f372df2012-12-13 20:03:13 +0000174 fscache_op_complete(op, true);
David Howellsb5108822009-04-03 16:42:39 +0100175 _leave("");
176}
177
178/*
179 * notification that the attributes on an object have changed
180 */
181int __fscache_attr_changed(struct fscache_cookie *cookie)
182{
183 struct fscache_operation *op;
184 struct fscache_object *object;
185
186 _enter("%p", cookie);
187
188 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
189
190 fscache_stat(&fscache_n_attr_changed);
191
192 op = kzalloc(sizeof(*op), GFP_KERNEL);
193 if (!op) {
194 fscache_stat(&fscache_n_attr_changed_nomem);
195 _leave(" = -ENOMEM");
196 return -ENOMEM;
197 }
198
Tejun Heo8af7c122010-07-20 22:09:01 +0200199 fscache_operation_init(op, fscache_attr_changed_op, NULL);
200 op->flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_EXCLUSIVE);
David Howellsb5108822009-04-03 16:42:39 +0100201
202 spin_lock(&cookie->lock);
203
204 if (hlist_empty(&cookie->backing_objects))
205 goto nobufs;
206 object = hlist_entry(cookie->backing_objects.first,
207 struct fscache_object, cookie_link);
208
209 if (fscache_submit_exclusive_op(object, op) < 0)
210 goto nobufs;
211 spin_unlock(&cookie->lock);
212 fscache_stat(&fscache_n_attr_changed_ok);
213 fscache_put_operation(op);
214 _leave(" = 0");
215 return 0;
216
217nobufs:
218 spin_unlock(&cookie->lock);
219 kfree(op);
220 fscache_stat(&fscache_n_attr_changed_nobufs);
221 _leave(" = %d", -ENOBUFS);
222 return -ENOBUFS;
223}
224EXPORT_SYMBOL(__fscache_attr_changed);
225
226/*
David Howellsb5108822009-04-03 16:42:39 +0100227 * release a retrieval op reference
228 */
229static void fscache_release_retrieval_op(struct fscache_operation *_op)
230{
231 struct fscache_retrieval *op =
232 container_of(_op, struct fscache_retrieval, op);
233
234 _enter("{OP%x}", op->op.debug_id);
235
David Howells9f105232012-12-20 21:52:35 +0000236 ASSERTCMP(op->n_pages, ==, 0);
237
David Howellsb5108822009-04-03 16:42:39 +0100238 fscache_hist(fscache_retrieval_histogram, op->start_time);
239 if (op->context)
240 fscache_put_context(op->op.object->cookie, op->context);
241
242 _leave("");
243}
244
245/*
246 * allocate a retrieval op
247 */
248static struct fscache_retrieval *fscache_alloc_retrieval(
249 struct address_space *mapping,
250 fscache_rw_complete_t end_io_func,
251 void *context)
252{
253 struct fscache_retrieval *op;
254
255 /* allocate a retrieval operation and attempt to submit it */
256 op = kzalloc(sizeof(*op), GFP_NOIO);
257 if (!op) {
258 fscache_stat(&fscache_n_retrievals_nomem);
259 return NULL;
260 }
261
Tejun Heo8af7c122010-07-20 22:09:01 +0200262 fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op);
David Howellsb5108822009-04-03 16:42:39 +0100263 op->op.flags = FSCACHE_OP_MYTHREAD | (1 << FSCACHE_OP_WAITING);
264 op->mapping = mapping;
265 op->end_io_func = end_io_func;
266 op->context = context;
267 op->start_time = jiffies;
David Howellsb5108822009-04-03 16:42:39 +0100268 INIT_LIST_HEAD(&op->to_do);
269 return op;
270}
271
272/*
273 * wait for a deferred lookup to complete
274 */
275static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
276{
277 unsigned long jif;
278
279 _enter("");
280
281 if (!test_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags)) {
282 _leave(" = 0 [imm]");
283 return 0;
284 }
285
286 fscache_stat(&fscache_n_retrievals_wait);
287
288 jif = jiffies;
289 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
290 fscache_wait_bit_interruptible,
291 TASK_INTERRUPTIBLE) != 0) {
292 fscache_stat(&fscache_n_retrievals_intr);
293 _leave(" = -ERESTARTSYS");
294 return -ERESTARTSYS;
295 }
296
297 ASSERT(!test_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags));
298
299 smp_rmb();
300 fscache_hist(fscache_retrieval_delay_histogram, jif);
301 _leave(" = 0 [dly]");
302 return 0;
303}
304
305/*
David Howells91c7fbb2012-12-14 11:02:22 +0000306 * Handle cancellation of a pending retrieval op
307 */
308static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
309{
310 struct fscache_retrieval *op =
311 container_of(_op, struct fscache_retrieval, op);
312
313 op->n_pages = 0;
314}
315
316/*
David Howells60d543c2009-11-19 18:11:45 +0000317 * wait for an object to become active (or dead)
318 */
319static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
320 struct fscache_retrieval *op,
321 atomic_t *stat_op_waits,
322 atomic_t *stat_object_dead)
323{
324 int ret;
325
326 if (!test_bit(FSCACHE_OP_WAITING, &op->op.flags))
327 goto check_if_dead;
328
329 _debug(">>> WT");
330 fscache_stat(stat_op_waits);
331 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
332 fscache_wait_bit_interruptible,
David Howells9c04caa2012-12-07 18:08:02 +0000333 TASK_INTERRUPTIBLE) != 0) {
David Howells91c7fbb2012-12-14 11:02:22 +0000334 ret = fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
David Howells60d543c2009-11-19 18:11:45 +0000335 if (ret == 0)
336 return -ERESTARTSYS;
337
338 /* it's been removed from the pending queue by another party,
339 * so we should get to run shortly */
340 wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
341 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
342 }
343 _debug("<<< GO");
344
345check_if_dead:
David Howells9f105232012-12-20 21:52:35 +0000346 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
347 fscache_stat(stat_object_dead);
348 _leave(" = -ENOBUFS [cancelled]");
349 return -ENOBUFS;
350 }
David Howells60d543c2009-11-19 18:11:45 +0000351 if (unlikely(fscache_object_is_dead(object))) {
David Howells91c7fbb2012-12-14 11:02:22 +0000352 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
353 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
David Howells60d543c2009-11-19 18:11:45 +0000354 fscache_stat(stat_object_dead);
355 return -ENOBUFS;
356 }
357 return 0;
358}
359
360/*
David Howellsb5108822009-04-03 16:42:39 +0100361 * read a page from the cache or allocate a block in which to store it
362 * - we return:
363 * -ENOMEM - out of memory, nothing done
364 * -ERESTARTSYS - interrupted
365 * -ENOBUFS - no backing object available in which to cache the block
366 * -ENODATA - no data available in the backing object for this block
367 * 0 - dispatched a read - it'll call end_io_func() when finished
368 */
369int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
370 struct page *page,
371 fscache_rw_complete_t end_io_func,
372 void *context,
373 gfp_t gfp)
374{
375 struct fscache_retrieval *op;
376 struct fscache_object *object;
377 int ret;
378
379 _enter("%p,%p,,,", cookie, page);
380
381 fscache_stat(&fscache_n_retrievals);
382
383 if (hlist_empty(&cookie->backing_objects))
384 goto nobufs;
385
David Howellsef778e72012-12-20 21:52:36 +0000386 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
387 _leave(" = -ENOBUFS [invalidating]");
388 return -ENOBUFS;
389 }
390
David Howellsb5108822009-04-03 16:42:39 +0100391 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
392 ASSERTCMP(page, !=, NULL);
393
394 if (fscache_wait_for_deferred_lookup(cookie) < 0)
395 return -ERESTARTSYS;
396
397 op = fscache_alloc_retrieval(page->mapping, end_io_func, context);
398 if (!op) {
399 _leave(" = -ENOMEM");
400 return -ENOMEM;
401 }
David Howells9f105232012-12-20 21:52:35 +0000402 op->n_pages = 1;
David Howellsb5108822009-04-03 16:42:39 +0100403
404 spin_lock(&cookie->lock);
405
406 if (hlist_empty(&cookie->backing_objects))
407 goto nobufs_unlock;
408 object = hlist_entry(cookie->backing_objects.first,
409 struct fscache_object, cookie_link);
410
David Howellscaaef692013-05-10 19:50:26 +0100411 ASSERT(test_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags));
David Howellsb5108822009-04-03 16:42:39 +0100412
David Howells4fbf4292009-11-19 18:11:04 +0000413 atomic_inc(&object->n_reads);
David Howells9f105232012-12-20 21:52:35 +0000414 __set_bit(FSCACHE_OP_DEC_READ_CNT, &op->op.flags);
David Howells4fbf4292009-11-19 18:11:04 +0000415
David Howellsb5108822009-04-03 16:42:39 +0100416 if (fscache_submit_op(object, &op->op) < 0)
David Howells9f105232012-12-20 21:52:35 +0000417 goto nobufs_unlock_dec;
David Howellsb5108822009-04-03 16:42:39 +0100418 spin_unlock(&cookie->lock);
419
420 fscache_stat(&fscache_n_retrieval_ops);
421
422 /* pin the netfs read context in case we need to do the actual netfs
423 * read because we've encountered a cache read failure */
424 fscache_get_context(object->cookie, op->context);
425
426 /* we wait for the operation to become active, and then process it
427 * *here*, in this thread, and not in the thread pool */
David Howells60d543c2009-11-19 18:11:45 +0000428 ret = fscache_wait_for_retrieval_activation(
429 object, op,
430 __fscache_stat(&fscache_n_retrieval_op_waits),
431 __fscache_stat(&fscache_n_retrievals_object_dead));
432 if (ret < 0)
433 goto error;
David Howellsb5108822009-04-03 16:42:39 +0100434
435 /* ask the cache to honour the operation */
436 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
David Howells52bd75f2009-11-19 18:11:08 +0000437 fscache_stat(&fscache_n_cop_allocate_page);
David Howellsb5108822009-04-03 16:42:39 +0100438 ret = object->cache->ops->allocate_page(op, page, gfp);
David Howells52bd75f2009-11-19 18:11:08 +0000439 fscache_stat_d(&fscache_n_cop_allocate_page);
David Howellsb5108822009-04-03 16:42:39 +0100440 if (ret == 0)
441 ret = -ENODATA;
442 } else {
David Howells52bd75f2009-11-19 18:11:08 +0000443 fscache_stat(&fscache_n_cop_read_or_alloc_page);
David Howellsb5108822009-04-03 16:42:39 +0100444 ret = object->cache->ops->read_or_alloc_page(op, page, gfp);
David Howells52bd75f2009-11-19 18:11:08 +0000445 fscache_stat_d(&fscache_n_cop_read_or_alloc_page);
David Howellsb5108822009-04-03 16:42:39 +0100446 }
447
David Howells5753c442009-11-19 18:11:19 +0000448error:
David Howellsb5108822009-04-03 16:42:39 +0100449 if (ret == -ENOMEM)
450 fscache_stat(&fscache_n_retrievals_nomem);
451 else if (ret == -ERESTARTSYS)
452 fscache_stat(&fscache_n_retrievals_intr);
453 else if (ret == -ENODATA)
454 fscache_stat(&fscache_n_retrievals_nodata);
455 else if (ret < 0)
456 fscache_stat(&fscache_n_retrievals_nobufs);
457 else
458 fscache_stat(&fscache_n_retrievals_ok);
459
460 fscache_put_retrieval(op);
461 _leave(" = %d", ret);
462 return ret;
463
David Howells9f105232012-12-20 21:52:35 +0000464nobufs_unlock_dec:
465 atomic_dec(&object->n_reads);
David Howellsb5108822009-04-03 16:42:39 +0100466nobufs_unlock:
467 spin_unlock(&cookie->lock);
468 kfree(op);
469nobufs:
470 fscache_stat(&fscache_n_retrievals_nobufs);
471 _leave(" = -ENOBUFS");
472 return -ENOBUFS;
473}
474EXPORT_SYMBOL(__fscache_read_or_alloc_page);
475
476/*
477 * read a list of page from the cache or allocate a block in which to store
478 * them
479 * - we return:
480 * -ENOMEM - out of memory, some pages may be being read
481 * -ERESTARTSYS - interrupted, some pages may be being read
482 * -ENOBUFS - no backing object or space available in which to cache any
483 * pages not being read
484 * -ENODATA - no data available in the backing object for some or all of
485 * the pages
486 * 0 - dispatched a read on all pages
487 *
488 * end_io_func() will be called for each page read from the cache as it is
489 * finishes being read
490 *
491 * any pages for which a read is dispatched will be removed from pages and
492 * nr_pages
493 */
494int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
495 struct address_space *mapping,
496 struct list_head *pages,
497 unsigned *nr_pages,
498 fscache_rw_complete_t end_io_func,
499 void *context,
500 gfp_t gfp)
501{
David Howellsb5108822009-04-03 16:42:39 +0100502 struct fscache_retrieval *op;
503 struct fscache_object *object;
504 int ret;
505
506 _enter("%p,,%d,,,", cookie, *nr_pages);
507
508 fscache_stat(&fscache_n_retrievals);
509
510 if (hlist_empty(&cookie->backing_objects))
511 goto nobufs;
512
David Howellsef778e72012-12-20 21:52:36 +0000513 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
514 _leave(" = -ENOBUFS [invalidating]");
515 return -ENOBUFS;
516 }
517
David Howellsb5108822009-04-03 16:42:39 +0100518 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
519 ASSERTCMP(*nr_pages, >, 0);
520 ASSERT(!list_empty(pages));
521
522 if (fscache_wait_for_deferred_lookup(cookie) < 0)
523 return -ERESTARTSYS;
524
525 op = fscache_alloc_retrieval(mapping, end_io_func, context);
526 if (!op)
527 return -ENOMEM;
David Howells9f105232012-12-20 21:52:35 +0000528 op->n_pages = *nr_pages;
David Howellsb5108822009-04-03 16:42:39 +0100529
530 spin_lock(&cookie->lock);
531
532 if (hlist_empty(&cookie->backing_objects))
533 goto nobufs_unlock;
534 object = hlist_entry(cookie->backing_objects.first,
535 struct fscache_object, cookie_link);
536
David Howells4fbf4292009-11-19 18:11:04 +0000537 atomic_inc(&object->n_reads);
David Howells9f105232012-12-20 21:52:35 +0000538 __set_bit(FSCACHE_OP_DEC_READ_CNT, &op->op.flags);
David Howells4fbf4292009-11-19 18:11:04 +0000539
David Howellsb5108822009-04-03 16:42:39 +0100540 if (fscache_submit_op(object, &op->op) < 0)
David Howells9f105232012-12-20 21:52:35 +0000541 goto nobufs_unlock_dec;
David Howellsb5108822009-04-03 16:42:39 +0100542 spin_unlock(&cookie->lock);
543
544 fscache_stat(&fscache_n_retrieval_ops);
545
546 /* pin the netfs read context in case we need to do the actual netfs
547 * read because we've encountered a cache read failure */
548 fscache_get_context(object->cookie, op->context);
549
550 /* we wait for the operation to become active, and then process it
551 * *here*, in this thread, and not in the thread pool */
David Howells60d543c2009-11-19 18:11:45 +0000552 ret = fscache_wait_for_retrieval_activation(
553 object, op,
554 __fscache_stat(&fscache_n_retrieval_op_waits),
555 __fscache_stat(&fscache_n_retrievals_object_dead));
556 if (ret < 0)
557 goto error;
David Howellsb5108822009-04-03 16:42:39 +0100558
559 /* ask the cache to honour the operation */
David Howells52bd75f2009-11-19 18:11:08 +0000560 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
561 fscache_stat(&fscache_n_cop_allocate_pages);
562 ret = object->cache->ops->allocate_pages(
563 op, pages, nr_pages, gfp);
564 fscache_stat_d(&fscache_n_cop_allocate_pages);
565 } else {
566 fscache_stat(&fscache_n_cop_read_or_alloc_pages);
567 ret = object->cache->ops->read_or_alloc_pages(
568 op, pages, nr_pages, gfp);
569 fscache_stat_d(&fscache_n_cop_read_or_alloc_pages);
570 }
David Howellsb5108822009-04-03 16:42:39 +0100571
David Howells5753c442009-11-19 18:11:19 +0000572error:
David Howellsb5108822009-04-03 16:42:39 +0100573 if (ret == -ENOMEM)
574 fscache_stat(&fscache_n_retrievals_nomem);
575 else if (ret == -ERESTARTSYS)
576 fscache_stat(&fscache_n_retrievals_intr);
577 else if (ret == -ENODATA)
578 fscache_stat(&fscache_n_retrievals_nodata);
579 else if (ret < 0)
580 fscache_stat(&fscache_n_retrievals_nobufs);
581 else
582 fscache_stat(&fscache_n_retrievals_ok);
583
584 fscache_put_retrieval(op);
585 _leave(" = %d", ret);
586 return ret;
587
David Howells9f105232012-12-20 21:52:35 +0000588nobufs_unlock_dec:
589 atomic_dec(&object->n_reads);
David Howellsb5108822009-04-03 16:42:39 +0100590nobufs_unlock:
591 spin_unlock(&cookie->lock);
592 kfree(op);
593nobufs:
594 fscache_stat(&fscache_n_retrievals_nobufs);
595 _leave(" = -ENOBUFS");
596 return -ENOBUFS;
597}
598EXPORT_SYMBOL(__fscache_read_or_alloc_pages);
599
600/*
601 * allocate a block in the cache on which to store a page
602 * - we return:
603 * -ENOMEM - out of memory, nothing done
604 * -ERESTARTSYS - interrupted
605 * -ENOBUFS - no backing object available in which to cache the block
606 * 0 - block allocated
607 */
608int __fscache_alloc_page(struct fscache_cookie *cookie,
609 struct page *page,
610 gfp_t gfp)
611{
612 struct fscache_retrieval *op;
613 struct fscache_object *object;
614 int ret;
615
616 _enter("%p,%p,,,", cookie, page);
617
618 fscache_stat(&fscache_n_allocs);
619
620 if (hlist_empty(&cookie->backing_objects))
621 goto nobufs;
622
623 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
624 ASSERTCMP(page, !=, NULL);
625
David Howellsef778e72012-12-20 21:52:36 +0000626 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
627 _leave(" = -ENOBUFS [invalidating]");
628 return -ENOBUFS;
629 }
630
David Howellsb5108822009-04-03 16:42:39 +0100631 if (fscache_wait_for_deferred_lookup(cookie) < 0)
632 return -ERESTARTSYS;
633
634 op = fscache_alloc_retrieval(page->mapping, NULL, NULL);
635 if (!op)
636 return -ENOMEM;
David Howells9f105232012-12-20 21:52:35 +0000637 op->n_pages = 1;
David Howellsb5108822009-04-03 16:42:39 +0100638
639 spin_lock(&cookie->lock);
640
641 if (hlist_empty(&cookie->backing_objects))
642 goto nobufs_unlock;
643 object = hlist_entry(cookie->backing_objects.first,
644 struct fscache_object, cookie_link);
645
646 if (fscache_submit_op(object, &op->op) < 0)
647 goto nobufs_unlock;
648 spin_unlock(&cookie->lock);
649
650 fscache_stat(&fscache_n_alloc_ops);
651
David Howells60d543c2009-11-19 18:11:45 +0000652 ret = fscache_wait_for_retrieval_activation(
653 object, op,
654 __fscache_stat(&fscache_n_alloc_op_waits),
655 __fscache_stat(&fscache_n_allocs_object_dead));
656 if (ret < 0)
657 goto error;
David Howellsb5108822009-04-03 16:42:39 +0100658
659 /* ask the cache to honour the operation */
David Howells52bd75f2009-11-19 18:11:08 +0000660 fscache_stat(&fscache_n_cop_allocate_page);
David Howellsb5108822009-04-03 16:42:39 +0100661 ret = object->cache->ops->allocate_page(op, page, gfp);
David Howells52bd75f2009-11-19 18:11:08 +0000662 fscache_stat_d(&fscache_n_cop_allocate_page);
David Howellsb5108822009-04-03 16:42:39 +0100663
David Howells5753c442009-11-19 18:11:19 +0000664error:
665 if (ret == -ERESTARTSYS)
666 fscache_stat(&fscache_n_allocs_intr);
667 else if (ret < 0)
David Howellsb5108822009-04-03 16:42:39 +0100668 fscache_stat(&fscache_n_allocs_nobufs);
669 else
670 fscache_stat(&fscache_n_allocs_ok);
671
672 fscache_put_retrieval(op);
673 _leave(" = %d", ret);
674 return ret;
675
676nobufs_unlock:
677 spin_unlock(&cookie->lock);
678 kfree(op);
679nobufs:
680 fscache_stat(&fscache_n_allocs_nobufs);
681 _leave(" = -ENOBUFS");
682 return -ENOBUFS;
683}
684EXPORT_SYMBOL(__fscache_alloc_page);
685
686/*
687 * release a write op reference
688 */
689static void fscache_release_write_op(struct fscache_operation *_op)
690{
691 _enter("{OP%x}", _op->debug_id);
692}
693
694/*
695 * perform the background storage of a page into the cache
696 */
697static void fscache_write_op(struct fscache_operation *_op)
698{
699 struct fscache_storage *op =
700 container_of(_op, struct fscache_storage, op);
701 struct fscache_object *object = op->op.object;
David Howells1bccf512009-11-19 18:11:25 +0000702 struct fscache_cookie *cookie;
David Howellsb5108822009-04-03 16:42:39 +0100703 struct page *page;
704 unsigned n;
705 void *results[1];
706 int ret;
707
708 _enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage));
709
David Howellsb5108822009-04-03 16:42:39 +0100710 spin_lock(&object->lock);
David Howells1bccf512009-11-19 18:11:25 +0000711 cookie = object->cookie;
David Howellsb5108822009-04-03 16:42:39 +0100712
David Howells7ef001e2012-12-07 10:41:26 +0000713 if (!fscache_object_is_active(object)) {
714 /* If we get here, then the on-disk cache object likely longer
715 * exists, so we should just cancel this write operation.
716 */
David Howellsb5108822009-04-03 16:42:39 +0100717 spin_unlock(&object->lock);
David Howells1f372df2012-12-13 20:03:13 +0000718 fscache_op_complete(&op->op, false);
David Howells7ef001e2012-12-07 10:41:26 +0000719 _leave(" [inactive]");
720 return;
721 }
722
723 if (!cookie) {
724 /* If we get here, then the cookie belonging to the object was
725 * detached, probably by the cookie being withdrawn due to
726 * memory pressure, which means that the pages we might write
727 * to the cache from no longer exist - therefore, we can just
728 * cancel this write operation.
729 */
730 spin_unlock(&object->lock);
David Howells1f372df2012-12-13 20:03:13 +0000731 fscache_op_complete(&op->op, false);
David Howellscaaef692013-05-10 19:50:26 +0100732 _leave(" [cancel] op{f=%lx s=%u} obj{s=%s f=%lx}",
733 _op->flags, _op->state, object->state->short_name,
734 object->flags);
David Howellsb5108822009-04-03 16:42:39 +0100735 return;
736 }
737
David Howells1bccf512009-11-19 18:11:25 +0000738 spin_lock(&cookie->stores_lock);
739
David Howellsb5108822009-04-03 16:42:39 +0100740 fscache_stat(&fscache_n_store_calls);
741
742 /* find a page to store */
743 page = NULL;
744 n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1,
745 FSCACHE_COOKIE_PENDING_TAG);
746 if (n != 1)
747 goto superseded;
748 page = results[0];
749 _debug("gang %d [%lx]", n, page->index);
David Howells1bccf512009-11-19 18:11:25 +0000750 if (page->index > op->store_limit) {
751 fscache_stat(&fscache_n_store_pages_over_limit);
David Howellsb5108822009-04-03 16:42:39 +0100752 goto superseded;
David Howells1bccf512009-11-19 18:11:25 +0000753 }
David Howellsb5108822009-04-03 16:42:39 +0100754
Dan Carpenter08a66852010-06-01 20:58:22 +0100755 radix_tree_tag_set(&cookie->stores, page->index,
756 FSCACHE_COOKIE_STORING_TAG);
757 radix_tree_tag_clear(&cookie->stores, page->index,
758 FSCACHE_COOKIE_PENDING_TAG);
David Howellsb5108822009-04-03 16:42:39 +0100759
David Howells1bccf512009-11-19 18:11:25 +0000760 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100761 spin_unlock(&object->lock);
David Howellsb5108822009-04-03 16:42:39 +0100762
Dan Carpenter08a66852010-06-01 20:58:22 +0100763 fscache_stat(&fscache_n_store_pages);
764 fscache_stat(&fscache_n_cop_write_page);
765 ret = object->cache->ops->write_page(op, page);
766 fscache_stat_d(&fscache_n_cop_write_page);
Dan Carpenter08a66852010-06-01 20:58:22 +0100767 fscache_end_page_write(object, page);
768 if (ret < 0) {
Dan Carpenter08a66852010-06-01 20:58:22 +0100769 fscache_abort_object(object);
David Howells1f372df2012-12-13 20:03:13 +0000770 fscache_op_complete(&op->op, true);
Dan Carpenter08a66852010-06-01 20:58:22 +0100771 } else {
772 fscache_enqueue_operation(&op->op);
David Howellsb5108822009-04-03 16:42:39 +0100773 }
774
775 _leave("");
776 return;
777
778superseded:
779 /* this writer is going away and there aren't any more things to
780 * write */
781 _debug("cease");
David Howells1bccf512009-11-19 18:11:25 +0000782 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100783 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
784 spin_unlock(&object->lock);
David Howells1f372df2012-12-13 20:03:13 +0000785 fscache_op_complete(&op->op, true);
David Howellsb5108822009-04-03 16:42:39 +0100786 _leave("");
787}
788
789/*
David Howellsef778e72012-12-20 21:52:36 +0000790 * Clear the pages pending writing for invalidation
791 */
792void fscache_invalidate_writes(struct fscache_cookie *cookie)
793{
794 struct page *page;
795 void *results[16];
796 int n, i;
797
798 _enter("");
799
Sebastian Andrzej Siewioree8be572013-05-10 19:50:24 +0100800 for (;;) {
801 spin_lock(&cookie->stores_lock);
802 n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0,
803 ARRAY_SIZE(results),
804 FSCACHE_COOKIE_PENDING_TAG);
805 if (n == 0) {
806 spin_unlock(&cookie->stores_lock);
807 break;
808 }
809
David Howellsef778e72012-12-20 21:52:36 +0000810 for (i = n - 1; i >= 0; i--) {
811 page = results[i];
812 radix_tree_delete(&cookie->stores, page->index);
813 }
814
815 spin_unlock(&cookie->stores_lock);
816
817 for (i = n - 1; i >= 0; i--)
818 page_cache_release(results[i]);
819 }
820
David Howellsef778e72012-12-20 21:52:36 +0000821 _leave("");
822}
823
824/*
David Howellsb5108822009-04-03 16:42:39 +0100825 * request a page be stored in the cache
826 * - returns:
827 * -ENOMEM - out of memory, nothing done
828 * -ENOBUFS - no backing object available in which to cache the page
829 * 0 - dispatched a write - it'll call end_io_func() when finished
830 *
831 * if the cookie still has a backing object at this point, that object can be
832 * in one of a few states with respect to storage processing:
833 *
834 * (1) negative lookup, object not yet created (FSCACHE_COOKIE_CREATING is
835 * set)
836 *
David Howellscaaef692013-05-10 19:50:26 +0100837 * (a) no writes yet
David Howellsb5108822009-04-03 16:42:39 +0100838 *
839 * (b) writes deferred till post-creation (mark page for writing and
840 * return immediately)
841 *
842 * (2) negative lookup, object created, initial fill being made from netfs
David Howellsb5108822009-04-03 16:42:39 +0100843 *
844 * (a) fill point not yet reached this page (mark page for writing and
845 * return)
846 *
847 * (b) fill point passed this page (queue op to store this page)
848 *
849 * (3) object extant (queue op to store this page)
850 *
851 * any other state is invalid
852 */
853int __fscache_write_page(struct fscache_cookie *cookie,
854 struct page *page,
855 gfp_t gfp)
856{
857 struct fscache_storage *op;
858 struct fscache_object *object;
859 int ret;
860
861 _enter("%p,%x,", cookie, (u32) page->flags);
862
863 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
864 ASSERT(PageFsCache(page));
865
866 fscache_stat(&fscache_n_stores);
867
David Howellsef778e72012-12-20 21:52:36 +0000868 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
869 _leave(" = -ENOBUFS [invalidating]");
870 return -ENOBUFS;
871 }
872
David Howells5f4f9f42012-12-20 21:52:33 +0000873 op = kzalloc(sizeof(*op), GFP_NOIO | __GFP_NOMEMALLOC | __GFP_NORETRY);
David Howellsb5108822009-04-03 16:42:39 +0100874 if (!op)
875 goto nomem;
876
Tejun Heo8af7c122010-07-20 22:09:01 +0200877 fscache_operation_init(&op->op, fscache_write_op,
878 fscache_release_write_op);
879 op->op.flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_WAITING);
David Howellsb5108822009-04-03 16:42:39 +0100880
881 ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM);
882 if (ret < 0)
883 goto nomem_free;
884
885 ret = -ENOBUFS;
886 spin_lock(&cookie->lock);
887
888 if (hlist_empty(&cookie->backing_objects))
889 goto nobufs;
890 object = hlist_entry(cookie->backing_objects.first,
891 struct fscache_object, cookie_link);
892 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
893 goto nobufs;
894
895 /* add the page to the pending-storage radix tree on the backing
896 * object */
897 spin_lock(&object->lock);
David Howells1bccf512009-11-19 18:11:25 +0000898 spin_lock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100899
900 _debug("store limit %llx", (unsigned long long) object->store_limit);
901
902 ret = radix_tree_insert(&cookie->stores, page->index, page);
903 if (ret < 0) {
904 if (ret == -EEXIST)
905 goto already_queued;
906 _debug("insert failed %d", ret);
907 goto nobufs_unlock_obj;
908 }
909
910 radix_tree_tag_set(&cookie->stores, page->index,
911 FSCACHE_COOKIE_PENDING_TAG);
912 page_cache_get(page);
913
914 /* we only want one writer at a time, but we do need to queue new
915 * writers after exclusive ops */
916 if (test_and_set_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags))
917 goto already_pending;
918
David Howells1bccf512009-11-19 18:11:25 +0000919 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100920 spin_unlock(&object->lock);
921
922 op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
923 op->store_limit = object->store_limit;
924
925 if (fscache_submit_op(object, &op->op) < 0)
926 goto submit_failed;
927
928 spin_unlock(&cookie->lock);
929 radix_tree_preload_end();
930 fscache_stat(&fscache_n_store_ops);
931 fscache_stat(&fscache_n_stores_ok);
932
Tejun Heo8af7c122010-07-20 22:09:01 +0200933 /* the work queue now carries its own ref on the object */
David Howellsb5108822009-04-03 16:42:39 +0100934 fscache_put_operation(&op->op);
935 _leave(" = 0");
936 return 0;
937
938already_queued:
939 fscache_stat(&fscache_n_stores_again);
940already_pending:
David Howells1bccf512009-11-19 18:11:25 +0000941 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100942 spin_unlock(&object->lock);
943 spin_unlock(&cookie->lock);
944 radix_tree_preload_end();
945 kfree(op);
946 fscache_stat(&fscache_n_stores_ok);
947 _leave(" = 0");
948 return 0;
949
950submit_failed:
David Howells1bccf512009-11-19 18:11:25 +0000951 spin_lock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100952 radix_tree_delete(&cookie->stores, page->index);
David Howells1bccf512009-11-19 18:11:25 +0000953 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100954 page_cache_release(page);
955 ret = -ENOBUFS;
956 goto nobufs;
957
958nobufs_unlock_obj:
Dan Carpenter1147d0f2010-03-23 14:48:37 +0000959 spin_unlock(&cookie->stores_lock);
David Howellsb5108822009-04-03 16:42:39 +0100960 spin_unlock(&object->lock);
961nobufs:
962 spin_unlock(&cookie->lock);
963 radix_tree_preload_end();
964 kfree(op);
965 fscache_stat(&fscache_n_stores_nobufs);
966 _leave(" = -ENOBUFS");
967 return -ENOBUFS;
968
969nomem_free:
970 kfree(op);
971nomem:
972 fscache_stat(&fscache_n_stores_oom);
973 _leave(" = -ENOMEM");
974 return -ENOMEM;
975}
976EXPORT_SYMBOL(__fscache_write_page);
977
978/*
979 * remove a page from the cache
980 */
981void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
982{
983 struct fscache_object *object;
984
985 _enter(",%p", page);
986
987 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
988 ASSERTCMP(page, !=, NULL);
989
990 fscache_stat(&fscache_n_uncaches);
991
992 /* cache withdrawal may beat us to it */
993 if (!PageFsCache(page))
994 goto done;
995
996 /* get the object */
997 spin_lock(&cookie->lock);
998
999 if (hlist_empty(&cookie->backing_objects)) {
1000 ClearPageFsCache(page);
1001 goto done_unlock;
1002 }
1003
1004 object = hlist_entry(cookie->backing_objects.first,
1005 struct fscache_object, cookie_link);
1006
1007 /* there might now be stuff on disk we could read */
1008 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
1009
1010 /* only invoke the cache backend if we managed to mark the page
1011 * uncached here; this deals with synchronisation vs withdrawal */
1012 if (TestClearPageFsCache(page) &&
1013 object->cache->ops->uncache_page) {
1014 /* the cache backend releases the cookie lock */
David Howells52bd75f2009-11-19 18:11:08 +00001015 fscache_stat(&fscache_n_cop_uncache_page);
David Howellsb5108822009-04-03 16:42:39 +01001016 object->cache->ops->uncache_page(object, page);
David Howells52bd75f2009-11-19 18:11:08 +00001017 fscache_stat_d(&fscache_n_cop_uncache_page);
David Howellsb5108822009-04-03 16:42:39 +01001018 goto done;
1019 }
1020
1021done_unlock:
1022 spin_unlock(&cookie->lock);
1023done:
1024 _leave("");
1025}
1026EXPORT_SYMBOL(__fscache_uncache_page);
1027
1028/**
David Howellsc4d6d8d2012-12-20 21:52:32 +00001029 * fscache_mark_page_cached - Mark a page as being cached
1030 * @op: The retrieval op pages are being marked for
1031 * @page: The page to be marked
1032 *
1033 * Mark a netfs page as being cached. After this is called, the netfs
1034 * must call fscache_uncache_page() to remove the mark.
1035 */
1036void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
1037{
1038 struct fscache_cookie *cookie = op->op.object->cookie;
1039
1040#ifdef CONFIG_FSCACHE_STATS
1041 atomic_inc(&fscache_n_marks);
1042#endif
1043
1044 _debug("- mark %p{%lx}", page, page->index);
1045 if (TestSetPageFsCache(page)) {
1046 static bool once_only;
1047 if (!once_only) {
1048 once_only = true;
1049 printk(KERN_WARNING "FS-Cache:"
1050 " Cookie type %s marked page %lx"
1051 " multiple times\n",
1052 cookie->def->name, page->index);
1053 }
1054 }
1055
1056 if (cookie->def->mark_page_cached)
1057 cookie->def->mark_page_cached(cookie->netfs_data,
1058 op->mapping, page);
1059}
1060EXPORT_SYMBOL(fscache_mark_page_cached);
1061
1062/**
David Howellsb5108822009-04-03 16:42:39 +01001063 * fscache_mark_pages_cached - Mark pages as being cached
1064 * @op: The retrieval op pages are being marked for
1065 * @pagevec: The pages to be marked
1066 *
1067 * Mark a bunch of netfs pages as being cached. After this is called,
1068 * the netfs must call fscache_uncache_page() to remove the mark.
1069 */
1070void fscache_mark_pages_cached(struct fscache_retrieval *op,
1071 struct pagevec *pagevec)
1072{
David Howellsb5108822009-04-03 16:42:39 +01001073 unsigned long loop;
1074
David Howellsc4d6d8d2012-12-20 21:52:32 +00001075 for (loop = 0; loop < pagevec->nr; loop++)
1076 fscache_mark_page_cached(op, pagevec->pages[loop]);
David Howellsb5108822009-04-03 16:42:39 +01001077
David Howellsb5108822009-04-03 16:42:39 +01001078 pagevec_reinit(pagevec);
1079}
1080EXPORT_SYMBOL(fscache_mark_pages_cached);
David Howellsc902ce12011-07-07 12:19:48 +01001081
1082/*
1083 * Uncache all the pages in an inode that are marked PG_fscache, assuming them
1084 * to be associated with the given cookie.
1085 */
1086void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
1087 struct inode *inode)
1088{
1089 struct address_space *mapping = inode->i_mapping;
1090 struct pagevec pvec;
1091 pgoff_t next;
1092 int i;
1093
1094 _enter("%p,%p", cookie, inode);
1095
1096 if (!mapping || mapping->nrpages == 0) {
1097 _leave(" [no pages]");
1098 return;
1099 }
1100
1101 pagevec_init(&pvec, 0);
1102 next = 0;
Jan Beulichb307d462011-07-21 15:02:43 +01001103 do {
1104 if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE))
1105 break;
David Howellsc902ce12011-07-07 12:19:48 +01001106 for (i = 0; i < pagevec_count(&pvec); i++) {
1107 struct page *page = pvec.pages[i];
Jan Beulichb307d462011-07-21 15:02:43 +01001108 next = page->index;
David Howellsc902ce12011-07-07 12:19:48 +01001109 if (PageFsCache(page)) {
1110 __fscache_wait_on_page_write(cookie, page);
1111 __fscache_uncache_page(cookie, page);
1112 }
1113 }
1114 pagevec_release(&pvec);
1115 cond_resched();
Jan Beulichb307d462011-07-21 15:02:43 +01001116 } while (++next);
David Howellsc902ce12011-07-07 12:19:48 +01001117
1118 _leave("");
1119}
1120EXPORT_SYMBOL(__fscache_uncache_all_inode_pages);