1 /* Cache page management and data I/O routines
3 * Copyright (C) 2004-2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
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>
20 * check to see if a page is being written to the cache
22 bool __fscache_check_page_write(struct fscache_cookie *cookie, struct page *page)
27 val = radix_tree_lookup(&cookie->stores, page->index);
32 EXPORT_SYMBOL(__fscache_check_page_write);
35 * wait for a page to finish being written to the cache
37 void __fscache_wait_on_page_write(struct fscache_cookie *cookie, struct page *page)
39 wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
41 wait_event(*wq, !__fscache_check_page_write(cookie, page));
43 EXPORT_SYMBOL(__fscache_wait_on_page_write);
46 * note that a page has finished being written to the cache
48 static void fscache_end_page_write(struct fscache_object *object,
51 struct fscache_cookie *cookie;
52 struct page *xpage = NULL;
54 spin_lock(&object->lock);
55 cookie = object->cookie;
57 /* delete the page from the tree if it is now no longer
59 spin_lock(&cookie->stores_lock);
60 fscache_stat(&fscache_n_store_radix_deletes);
61 xpage = radix_tree_delete(&cookie->stores, page->index);
62 spin_unlock(&cookie->stores_lock);
63 wake_up_bit(&cookie->flags, 0);
65 spin_unlock(&object->lock);
67 page_cache_release(xpage);
71 * actually apply the changed attributes to a cache object
73 static void fscache_attr_changed_op(struct fscache_operation *op)
75 struct fscache_object *object = op->object;
78 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
80 fscache_stat(&fscache_n_attr_changed_calls);
82 if (fscache_object_is_active(object)) {
83 fscache_set_op_state(op, "CallFS");
84 fscache_stat(&fscache_n_cop_attr_changed);
85 ret = object->cache->ops->attr_changed(object);
86 fscache_stat_d(&fscache_n_cop_attr_changed);
87 fscache_set_op_state(op, "Done");
89 fscache_abort_object(object);
96 * notification that the attributes on an object have changed
98 int __fscache_attr_changed(struct fscache_cookie *cookie)
100 struct fscache_operation *op;
101 struct fscache_object *object;
103 _enter("%p", cookie);
105 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
107 fscache_stat(&fscache_n_attr_changed);
109 op = kzalloc(sizeof(*op), GFP_KERNEL);
111 fscache_stat(&fscache_n_attr_changed_nomem);
112 _leave(" = -ENOMEM");
116 fscache_operation_init(op, NULL);
117 fscache_operation_init_slow(op, fscache_attr_changed_op);
118 op->flags = FSCACHE_OP_SLOW | (1 << FSCACHE_OP_EXCLUSIVE);
119 fscache_set_op_name(op, "Attr");
121 spin_lock(&cookie->lock);
123 if (hlist_empty(&cookie->backing_objects))
125 object = hlist_entry(cookie->backing_objects.first,
126 struct fscache_object, cookie_link);
128 if (fscache_submit_exclusive_op(object, op) < 0)
130 spin_unlock(&cookie->lock);
131 fscache_stat(&fscache_n_attr_changed_ok);
132 fscache_put_operation(op);
137 spin_unlock(&cookie->lock);
139 fscache_stat(&fscache_n_attr_changed_nobufs);
140 _leave(" = %d", -ENOBUFS);
143 EXPORT_SYMBOL(__fscache_attr_changed);
146 * handle secondary execution given to a retrieval op on behalf of the
149 static void fscache_retrieval_work(struct work_struct *work)
151 struct fscache_retrieval *op =
152 container_of(work, struct fscache_retrieval, op.fast_work);
155 _enter("{OP%x}", op->op.debug_id);
158 op->op.processor(&op->op);
159 fscache_hist(fscache_ops_histogram, start);
160 fscache_put_operation(&op->op);
164 * release a retrieval op reference
166 static void fscache_release_retrieval_op(struct fscache_operation *_op)
168 struct fscache_retrieval *op =
169 container_of(_op, struct fscache_retrieval, op);
171 _enter("{OP%x}", op->op.debug_id);
173 fscache_hist(fscache_retrieval_histogram, op->start_time);
175 fscache_put_context(op->op.object->cookie, op->context);
181 * allocate a retrieval op
183 static struct fscache_retrieval *fscache_alloc_retrieval(
184 struct address_space *mapping,
185 fscache_rw_complete_t end_io_func,
188 struct fscache_retrieval *op;
190 /* allocate a retrieval operation and attempt to submit it */
191 op = kzalloc(sizeof(*op), GFP_NOIO);
193 fscache_stat(&fscache_n_retrievals_nomem);
197 fscache_operation_init(&op->op, fscache_release_retrieval_op);
198 op->op.flags = FSCACHE_OP_MYTHREAD | (1 << FSCACHE_OP_WAITING);
199 op->mapping = mapping;
200 op->end_io_func = end_io_func;
201 op->context = context;
202 op->start_time = jiffies;
203 INIT_WORK(&op->op.fast_work, fscache_retrieval_work);
204 INIT_LIST_HEAD(&op->to_do);
205 fscache_set_op_name(&op->op, "Retr");
210 * wait for a deferred lookup to complete
212 static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
218 if (!test_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags)) {
219 _leave(" = 0 [imm]");
223 fscache_stat(&fscache_n_retrievals_wait);
226 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
227 fscache_wait_bit_interruptible,
228 TASK_INTERRUPTIBLE) != 0) {
229 fscache_stat(&fscache_n_retrievals_intr);
230 _leave(" = -ERESTARTSYS");
234 ASSERT(!test_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags));
237 fscache_hist(fscache_retrieval_delay_histogram, jif);
238 _leave(" = 0 [dly]");
243 * read a page from the cache or allocate a block in which to store it
245 * -ENOMEM - out of memory, nothing done
246 * -ERESTARTSYS - interrupted
247 * -ENOBUFS - no backing object available in which to cache the block
248 * -ENODATA - no data available in the backing object for this block
249 * 0 - dispatched a read - it'll call end_io_func() when finished
251 int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
253 fscache_rw_complete_t end_io_func,
257 struct fscache_retrieval *op;
258 struct fscache_object *object;
261 _enter("%p,%p,,,", cookie, page);
263 fscache_stat(&fscache_n_retrievals);
265 if (hlist_empty(&cookie->backing_objects))
268 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
269 ASSERTCMP(page, !=, NULL);
271 if (fscache_wait_for_deferred_lookup(cookie) < 0)
274 op = fscache_alloc_retrieval(page->mapping, end_io_func, context);
276 _leave(" = -ENOMEM");
279 fscache_set_op_name(&op->op, "RetrRA1");
281 spin_lock(&cookie->lock);
283 if (hlist_empty(&cookie->backing_objects))
285 object = hlist_entry(cookie->backing_objects.first,
286 struct fscache_object, cookie_link);
288 ASSERTCMP(object->state, >, FSCACHE_OBJECT_LOOKING_UP);
290 atomic_inc(&object->n_reads);
291 set_bit(FSCACHE_OP_DEC_READ_CNT, &op->op.flags);
293 if (fscache_submit_op(object, &op->op) < 0)
295 spin_unlock(&cookie->lock);
297 fscache_stat(&fscache_n_retrieval_ops);
299 /* pin the netfs read context in case we need to do the actual netfs
300 * read because we've encountered a cache read failure */
301 fscache_get_context(object->cookie, op->context);
303 /* we wait for the operation to become active, and then process it
304 * *here*, in this thread, and not in the thread pool */
305 if (test_bit(FSCACHE_OP_WAITING, &op->op.flags)) {
307 fscache_stat(&fscache_n_retrieval_op_waits);
308 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
309 fscache_wait_bit_interruptible,
310 TASK_INTERRUPTIBLE) < 0) {
311 ret = fscache_cancel_op(&op->op);
317 /* it's been removed from the pending queue by another
318 * party, so we should get to run shortly */
319 wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
320 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
325 /* ask the cache to honour the operation */
326 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
327 fscache_stat(&fscache_n_cop_allocate_page);
328 ret = object->cache->ops->allocate_page(op, page, gfp);
329 fscache_stat_d(&fscache_n_cop_allocate_page);
333 fscache_stat(&fscache_n_cop_read_or_alloc_page);
334 ret = object->cache->ops->read_or_alloc_page(op, page, gfp);
335 fscache_stat_d(&fscache_n_cop_read_or_alloc_page);
340 fscache_stat(&fscache_n_retrievals_nomem);
341 else if (ret == -ERESTARTSYS)
342 fscache_stat(&fscache_n_retrievals_intr);
343 else if (ret == -ENODATA)
344 fscache_stat(&fscache_n_retrievals_nodata);
346 fscache_stat(&fscache_n_retrievals_nobufs);
348 fscache_stat(&fscache_n_retrievals_ok);
350 fscache_put_retrieval(op);
351 _leave(" = %d", ret);
355 spin_unlock(&cookie->lock);
358 fscache_stat(&fscache_n_retrievals_nobufs);
359 _leave(" = -ENOBUFS");
362 EXPORT_SYMBOL(__fscache_read_or_alloc_page);
365 * read a list of page from the cache or allocate a block in which to store
368 * -ENOMEM - out of memory, some pages may be being read
369 * -ERESTARTSYS - interrupted, some pages may be being read
370 * -ENOBUFS - no backing object or space available in which to cache any
371 * pages not being read
372 * -ENODATA - no data available in the backing object for some or all of
374 * 0 - dispatched a read on all pages
376 * end_io_func() will be called for each page read from the cache as it is
377 * finishes being read
379 * any pages for which a read is dispatched will be removed from pages and
382 int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
383 struct address_space *mapping,
384 struct list_head *pages,
386 fscache_rw_complete_t end_io_func,
390 struct fscache_retrieval *op;
391 struct fscache_object *object;
394 _enter("%p,,%d,,,", cookie, *nr_pages);
396 fscache_stat(&fscache_n_retrievals);
398 if (hlist_empty(&cookie->backing_objects))
401 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
402 ASSERTCMP(*nr_pages, >, 0);
403 ASSERT(!list_empty(pages));
405 if (fscache_wait_for_deferred_lookup(cookie) < 0)
408 op = fscache_alloc_retrieval(mapping, end_io_func, context);
411 fscache_set_op_name(&op->op, "RetrRAN");
413 spin_lock(&cookie->lock);
415 if (hlist_empty(&cookie->backing_objects))
417 object = hlist_entry(cookie->backing_objects.first,
418 struct fscache_object, cookie_link);
420 atomic_inc(&object->n_reads);
421 set_bit(FSCACHE_OP_DEC_READ_CNT, &op->op.flags);
423 if (fscache_submit_op(object, &op->op) < 0)
425 spin_unlock(&cookie->lock);
427 fscache_stat(&fscache_n_retrieval_ops);
429 /* pin the netfs read context in case we need to do the actual netfs
430 * read because we've encountered a cache read failure */
431 fscache_get_context(object->cookie, op->context);
433 /* we wait for the operation to become active, and then process it
434 * *here*, in this thread, and not in the thread pool */
435 if (test_bit(FSCACHE_OP_WAITING, &op->op.flags)) {
437 fscache_stat(&fscache_n_retrieval_op_waits);
438 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
439 fscache_wait_bit_interruptible,
440 TASK_INTERRUPTIBLE) < 0) {
441 ret = fscache_cancel_op(&op->op);
447 /* it's been removed from the pending queue by another
448 * party, so we should get to run shortly */
449 wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
450 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
455 /* ask the cache to honour the operation */
456 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
457 fscache_stat(&fscache_n_cop_allocate_pages);
458 ret = object->cache->ops->allocate_pages(
459 op, pages, nr_pages, gfp);
460 fscache_stat_d(&fscache_n_cop_allocate_pages);
462 fscache_stat(&fscache_n_cop_read_or_alloc_pages);
463 ret = object->cache->ops->read_or_alloc_pages(
464 op, pages, nr_pages, gfp);
465 fscache_stat_d(&fscache_n_cop_read_or_alloc_pages);
470 fscache_stat(&fscache_n_retrievals_nomem);
471 else if (ret == -ERESTARTSYS)
472 fscache_stat(&fscache_n_retrievals_intr);
473 else if (ret == -ENODATA)
474 fscache_stat(&fscache_n_retrievals_nodata);
476 fscache_stat(&fscache_n_retrievals_nobufs);
478 fscache_stat(&fscache_n_retrievals_ok);
480 fscache_put_retrieval(op);
481 _leave(" = %d", ret);
485 spin_unlock(&cookie->lock);
488 fscache_stat(&fscache_n_retrievals_nobufs);
489 _leave(" = -ENOBUFS");
492 EXPORT_SYMBOL(__fscache_read_or_alloc_pages);
495 * allocate a block in the cache on which to store a page
497 * -ENOMEM - out of memory, nothing done
498 * -ERESTARTSYS - interrupted
499 * -ENOBUFS - no backing object available in which to cache the block
500 * 0 - block allocated
502 int __fscache_alloc_page(struct fscache_cookie *cookie,
506 struct fscache_retrieval *op;
507 struct fscache_object *object;
510 _enter("%p,%p,,,", cookie, page);
512 fscache_stat(&fscache_n_allocs);
514 if (hlist_empty(&cookie->backing_objects))
517 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
518 ASSERTCMP(page, !=, NULL);
520 if (fscache_wait_for_deferred_lookup(cookie) < 0)
523 op = fscache_alloc_retrieval(page->mapping, NULL, NULL);
526 fscache_set_op_name(&op->op, "RetrAL1");
528 spin_lock(&cookie->lock);
530 if (hlist_empty(&cookie->backing_objects))
532 object = hlist_entry(cookie->backing_objects.first,
533 struct fscache_object, cookie_link);
535 if (fscache_submit_op(object, &op->op) < 0)
537 spin_unlock(&cookie->lock);
539 fscache_stat(&fscache_n_alloc_ops);
541 if (test_bit(FSCACHE_OP_WAITING, &op->op.flags)) {
543 fscache_stat(&fscache_n_alloc_op_waits);
544 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
545 fscache_wait_bit_interruptible,
546 TASK_INTERRUPTIBLE) < 0) {
547 ret = fscache_cancel_op(&op->op);
553 /* it's been removed from the pending queue by another
554 * party, so we should get to run shortly */
555 wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
556 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
561 /* ask the cache to honour the operation */
562 fscache_stat(&fscache_n_cop_allocate_page);
563 ret = object->cache->ops->allocate_page(op, page, gfp);
564 fscache_stat_d(&fscache_n_cop_allocate_page);
567 if (ret == -ERESTARTSYS)
568 fscache_stat(&fscache_n_allocs_intr);
570 fscache_stat(&fscache_n_allocs_nobufs);
572 fscache_stat(&fscache_n_allocs_ok);
574 fscache_put_retrieval(op);
575 _leave(" = %d", ret);
579 spin_unlock(&cookie->lock);
582 fscache_stat(&fscache_n_allocs_nobufs);
583 _leave(" = -ENOBUFS");
586 EXPORT_SYMBOL(__fscache_alloc_page);
589 * release a write op reference
591 static void fscache_release_write_op(struct fscache_operation *_op)
593 _enter("{OP%x}", _op->debug_id);
597 * perform the background storage of a page into the cache
599 static void fscache_write_op(struct fscache_operation *_op)
601 struct fscache_storage *op =
602 container_of(_op, struct fscache_storage, op);
603 struct fscache_object *object = op->op.object;
604 struct fscache_cookie *cookie;
610 _enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage));
612 fscache_set_op_state(&op->op, "GetPage");
614 spin_lock(&object->lock);
615 cookie = object->cookie;
617 if (!fscache_object_is_active(object) || !cookie) {
618 spin_unlock(&object->lock);
623 spin_lock(&cookie->stores_lock);
625 fscache_stat(&fscache_n_store_calls);
627 /* find a page to store */
629 n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1,
630 FSCACHE_COOKIE_PENDING_TAG);
634 _debug("gang %d [%lx]", n, page->index);
635 if (page->index > op->store_limit) {
636 fscache_stat(&fscache_n_store_pages_over_limit);
640 radix_tree_tag_clear(&cookie->stores, page->index,
641 FSCACHE_COOKIE_PENDING_TAG);
643 spin_unlock(&cookie->stores_lock);
644 spin_unlock(&object->lock);
647 fscache_set_op_state(&op->op, "Store");
648 fscache_stat(&fscache_n_store_pages);
649 fscache_stat(&fscache_n_cop_write_page);
650 ret = object->cache->ops->write_page(op, page);
651 fscache_stat_d(&fscache_n_cop_write_page);
652 fscache_set_op_state(&op->op, "EndWrite");
653 fscache_end_page_write(object, page);
655 fscache_set_op_state(&op->op, "Abort");
656 fscache_abort_object(object);
658 fscache_enqueue_operation(&op->op);
666 /* this writer is going away and there aren't any more things to
669 spin_unlock(&cookie->stores_lock);
670 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
671 spin_unlock(&object->lock);
676 * request a page be stored in the cache
678 * -ENOMEM - out of memory, nothing done
679 * -ENOBUFS - no backing object available in which to cache the page
680 * 0 - dispatched a write - it'll call end_io_func() when finished
682 * if the cookie still has a backing object at this point, that object can be
683 * in one of a few states with respect to storage processing:
685 * (1) negative lookup, object not yet created (FSCACHE_COOKIE_CREATING is
688 * (a) no writes yet (set FSCACHE_COOKIE_PENDING_FILL and queue deferred
691 * (b) writes deferred till post-creation (mark page for writing and
692 * return immediately)
694 * (2) negative lookup, object created, initial fill being made from netfs
695 * (FSCACHE_COOKIE_INITIAL_FILL is set)
697 * (a) fill point not yet reached this page (mark page for writing and
700 * (b) fill point passed this page (queue op to store this page)
702 * (3) object extant (queue op to store this page)
704 * any other state is invalid
706 int __fscache_write_page(struct fscache_cookie *cookie,
710 struct fscache_storage *op;
711 struct fscache_object *object;
714 _enter("%p,%x,", cookie, (u32) page->flags);
716 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
717 ASSERT(PageFsCache(page));
719 fscache_stat(&fscache_n_stores);
721 op = kzalloc(sizeof(*op), GFP_NOIO);
725 fscache_operation_init(&op->op, fscache_release_write_op);
726 fscache_operation_init_slow(&op->op, fscache_write_op);
727 op->op.flags = FSCACHE_OP_SLOW | (1 << FSCACHE_OP_WAITING);
728 fscache_set_op_name(&op->op, "Write1");
730 ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM);
735 spin_lock(&cookie->lock);
737 if (hlist_empty(&cookie->backing_objects))
739 object = hlist_entry(cookie->backing_objects.first,
740 struct fscache_object, cookie_link);
741 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
744 /* add the page to the pending-storage radix tree on the backing
746 spin_lock(&object->lock);
747 spin_lock(&cookie->stores_lock);
749 _debug("store limit %llx", (unsigned long long) object->store_limit);
751 ret = radix_tree_insert(&cookie->stores, page->index, page);
755 _debug("insert failed %d", ret);
756 goto nobufs_unlock_obj;
759 radix_tree_tag_set(&cookie->stores, page->index,
760 FSCACHE_COOKIE_PENDING_TAG);
761 page_cache_get(page);
763 /* we only want one writer at a time, but we do need to queue new
764 * writers after exclusive ops */
765 if (test_and_set_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags))
766 goto already_pending;
768 spin_unlock(&cookie->stores_lock);
769 spin_unlock(&object->lock);
771 op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
772 op->store_limit = object->store_limit;
774 if (fscache_submit_op(object, &op->op) < 0)
777 spin_unlock(&cookie->lock);
778 radix_tree_preload_end();
779 fscache_stat(&fscache_n_store_ops);
780 fscache_stat(&fscache_n_stores_ok);
782 /* the slow work queue now carries its own ref on the object */
783 fscache_put_operation(&op->op);
788 fscache_stat(&fscache_n_stores_again);
790 spin_unlock(&cookie->stores_lock);
791 spin_unlock(&object->lock);
792 spin_unlock(&cookie->lock);
793 radix_tree_preload_end();
795 fscache_stat(&fscache_n_stores_ok);
800 spin_lock(&cookie->stores_lock);
801 radix_tree_delete(&cookie->stores, page->index);
802 spin_unlock(&cookie->stores_lock);
803 page_cache_release(page);
808 spin_unlock(&object->lock);
810 spin_unlock(&cookie->lock);
811 radix_tree_preload_end();
813 fscache_stat(&fscache_n_stores_nobufs);
814 _leave(" = -ENOBUFS");
820 fscache_stat(&fscache_n_stores_oom);
821 _leave(" = -ENOMEM");
824 EXPORT_SYMBOL(__fscache_write_page);
827 * remove a page from the cache
829 void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
831 struct fscache_object *object;
835 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
836 ASSERTCMP(page, !=, NULL);
838 fscache_stat(&fscache_n_uncaches);
840 /* cache withdrawal may beat us to it */
841 if (!PageFsCache(page))
845 spin_lock(&cookie->lock);
847 if (hlist_empty(&cookie->backing_objects)) {
848 ClearPageFsCache(page);
852 object = hlist_entry(cookie->backing_objects.first,
853 struct fscache_object, cookie_link);
855 /* there might now be stuff on disk we could read */
856 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
858 /* only invoke the cache backend if we managed to mark the page
859 * uncached here; this deals with synchronisation vs withdrawal */
860 if (TestClearPageFsCache(page) &&
861 object->cache->ops->uncache_page) {
862 /* the cache backend releases the cookie lock */
863 fscache_stat(&fscache_n_cop_uncache_page);
864 object->cache->ops->uncache_page(object, page);
865 fscache_stat_d(&fscache_n_cop_uncache_page);
870 spin_unlock(&cookie->lock);
874 EXPORT_SYMBOL(__fscache_uncache_page);
877 * fscache_mark_pages_cached - Mark pages as being cached
878 * @op: The retrieval op pages are being marked for
879 * @pagevec: The pages to be marked
881 * Mark a bunch of netfs pages as being cached. After this is called,
882 * the netfs must call fscache_uncache_page() to remove the mark.
884 void fscache_mark_pages_cached(struct fscache_retrieval *op,
885 struct pagevec *pagevec)
887 struct fscache_cookie *cookie = op->op.object->cookie;
890 #ifdef CONFIG_FSCACHE_STATS
891 atomic_add(pagevec->nr, &fscache_n_marks);
894 for (loop = 0; loop < pagevec->nr; loop++) {
895 struct page *page = pagevec->pages[loop];
897 _debug("- mark %p{%lx}", page, page->index);
898 if (TestSetPageFsCache(page)) {
899 static bool once_only;
902 printk(KERN_WARNING "FS-Cache:"
903 " Cookie type %s marked page %lx"
905 cookie->def->name, page->index);
910 if (cookie->def->mark_pages_cached)
911 cookie->def->mark_pages_cached(cookie->netfs_data,
912 op->mapping, pagevec);
913 pagevec_reinit(pagevec);
915 EXPORT_SYMBOL(fscache_mark_pages_cached);