12 #define FSCACHE_DEBUG_LEVEL PAGE
13 #include <linux/module.h>
17 #include <linux/slab.h>
57 _enter(
"%p,%p,%x", cookie, page, gfp);
122 struct page *xpage =
NULL;
124 spin_lock(&object->
lock);
125 cookie =
object->cookie;
140 spin_unlock(&object->
lock);
159 ret =
object->cache->ops->attr_changed(
object);
189 fscache_operation_init(op, fscache_attr_changed_op,
NULL);
192 spin_lock(&cookie->
lock);
201 spin_unlock(&cookie->
lock);
208 spin_unlock(&cookie->
lock);
228 fscache_put_context(op->
op.object->cookie, op->
context);
244 op = kzalloc(
sizeof(*op),
GFP_NOIO);
250 fscache_operation_init(&op->
op,
NULL, fscache_release_retrieval_op);
256 INIT_LIST_HEAD(&op->
to_do);
263 static int fscache_wait_for_deferred_lookup(
struct fscache_cookie *cookie)
281 _leave(
" = -ERESTARTSYS");
296 static int fscache_wait_for_retrieval_activation(
struct fscache_object *
object,
349 _enter(
"%p,%p,,,", cookie, page);
359 if (fscache_wait_for_deferred_lookup(cookie) < 0)
362 op = fscache_alloc_retrieval(page->
mapping, end_io_func, context);
368 spin_lock(&cookie->
lock);
382 spin_unlock(&cookie->
lock);
392 ret = fscache_wait_for_retrieval_activation(
402 ret =
object->cache->ops->allocate_page(op, page, gfp);
408 ret =
object->cache->ops->read_or_alloc_page(op, page, gfp);
424 fscache_put_retrieval(op);
429 spin_unlock(&cookie->
lock);
468 _enter(
"%p,,%d,,,", cookie, *nr_pages);
477 ASSERT(!list_empty(pages));
479 if (fscache_wait_for_deferred_lookup(cookie) < 0)
482 op = fscache_alloc_retrieval(mapping, end_io_func, context);
486 spin_lock(&cookie->
lock);
498 spin_unlock(&cookie->
lock);
508 ret = fscache_wait_for_retrieval_activation(
518 ret =
object->cache->ops->allocate_pages(
519 op, pages, nr_pages, gfp);
523 ret =
object->cache->ops->read_or_alloc_pages(
524 op, pages, nr_pages, gfp);
540 fscache_put_retrieval(op);
545 spin_unlock(&cookie->
lock);
570 _enter(
"%p,%p,,,", cookie, page);
580 if (fscache_wait_for_deferred_lookup(cookie) < 0)
587 spin_lock(&cookie->
lock);
596 spin_unlock(&cookie->
lock);
600 ret = fscache_wait_for_retrieval_activation(
609 ret =
object->cache->ops->allocate_page(op, page, gfp);
620 fscache_put_retrieval(op);
625 spin_unlock(&cookie->
lock);
658 spin_lock(&object->
lock);
659 cookie =
object->cookie;
662 spin_unlock(&object->
lock);
690 spin_unlock(&object->
lock);
694 ret =
object->cache->ops->write_page(op, page);
696 fscache_end_page_write(
object, page);
712 spin_unlock(&object->
lock);
762 op = kzalloc(
sizeof(*op),
GFP_NOIO);
766 fscache_operation_init(&op->
op, fscache_write_op,
767 fscache_release_write_op);
775 spin_lock(&cookie->
lock);
786 spin_lock(&object->
lock);
795 _debug(
"insert failed %d", ret);
796 goto nobufs_unlock_obj;
806 goto already_pending;
809 spin_unlock(&object->
lock);
817 spin_unlock(&cookie->
lock);
818 radix_tree_preload_end();
831 spin_unlock(&object->
lock);
832 spin_unlock(&cookie->
lock);
833 radix_tree_preload_end();
849 spin_unlock(&object->
lock);
851 spin_unlock(&cookie->
lock);
852 radix_tree_preload_end();
886 spin_lock(&cookie->
lock);
902 object->
cache->ops->uncache_page) {
905 object->cache->ops->uncache_page(
object, page);
911 spin_unlock(&cookie->
lock);
931 #ifdef CONFIG_FSCACHE_STATS
935 for (loop = 0; loop < pagevec->
nr; loop++) {
936 struct page *page = pagevec->
pages[loop];
940 static bool once_only;
944 " Cookie type %s marked page %lx"
951 if (cookie->
def->mark_pages_cached)
954 pagevec_reinit(pagevec);
970 _enter(
"%p,%p", cookie, inode);
972 if (!mapping || mapping->
nrpages == 0) {
977 pagevec_init(&pvec, 0);
982 for (i = 0; i < pagevec_count(&pvec); i++) {
983 struct page *page = pvec.
pages[
i];
990 pagevec_release(&pvec);