aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/page.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fscache/page.c')
-rw-r--r--fs/fscache/page.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index b4e4b424160a..780bac6ffde5 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -163,10 +163,12 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
163 163
164 fscache_stat(&fscache_n_attr_changed_calls); 164 fscache_stat(&fscache_n_attr_changed_calls);
165 165
166 if (fscache_object_is_active(object)) { 166 if (fscache_object_is_active(object) &&
167 fscache_use_cookie(object)) {
167 fscache_stat(&fscache_n_cop_attr_changed); 168 fscache_stat(&fscache_n_cop_attr_changed);
168 ret = object->cache->ops->attr_changed(object); 169 ret = object->cache->ops->attr_changed(object);
169 fscache_stat_d(&fscache_n_cop_attr_changed); 170 fscache_stat_d(&fscache_n_cop_attr_changed);
171 fscache_unuse_cookie(object);
170 if (ret < 0) 172 if (ret < 0)
171 fscache_abort_object(object); 173 fscache_abort_object(object);
172 } 174 }
@@ -246,6 +248,7 @@ static void fscache_release_retrieval_op(struct fscache_operation *_op)
246 * allocate a retrieval op 248 * allocate a retrieval op
247 */ 249 */
248static struct fscache_retrieval *fscache_alloc_retrieval( 250static struct fscache_retrieval *fscache_alloc_retrieval(
251 struct fscache_cookie *cookie,
249 struct address_space *mapping, 252 struct address_space *mapping,
250 fscache_rw_complete_t end_io_func, 253 fscache_rw_complete_t end_io_func,
251 void *context) 254 void *context)
@@ -260,7 +263,10 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
260 } 263 }
261 264
262 fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op); 265 fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op);
263 op->op.flags = FSCACHE_OP_MYTHREAD | (1 << FSCACHE_OP_WAITING); 266 atomic_inc(&cookie->n_active);
267 op->op.flags = FSCACHE_OP_MYTHREAD |
268 (1UL << FSCACHE_OP_WAITING) |
269 (1UL << FSCACHE_OP_UNUSE_COOKIE);
264 op->mapping = mapping; 270 op->mapping = mapping;
265 op->end_io_func = end_io_func; 271 op->end_io_func = end_io_func;
266 op->context = context; 272 op->context = context;
@@ -394,7 +400,8 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
394 if (fscache_wait_for_deferred_lookup(cookie) < 0) 400 if (fscache_wait_for_deferred_lookup(cookie) < 0)
395 return -ERESTARTSYS; 401 return -ERESTARTSYS;
396 402
397 op = fscache_alloc_retrieval(page->mapping, end_io_func, context); 403 op = fscache_alloc_retrieval(cookie, page->mapping,
404 end_io_func,context);
398 if (!op) { 405 if (!op) {
399 _leave(" = -ENOMEM"); 406 _leave(" = -ENOMEM");
400 return -ENOMEM; 407 return -ENOMEM;
@@ -465,6 +472,7 @@ nobufs_unlock_dec:
465 atomic_dec(&object->n_reads); 472 atomic_dec(&object->n_reads);
466nobufs_unlock: 473nobufs_unlock:
467 spin_unlock(&cookie->lock); 474 spin_unlock(&cookie->lock);
475 atomic_dec(&cookie->n_active);
468 kfree(op); 476 kfree(op);
469nobufs: 477nobufs:
470 fscache_stat(&fscache_n_retrievals_nobufs); 478 fscache_stat(&fscache_n_retrievals_nobufs);
@@ -522,7 +530,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
522 if (fscache_wait_for_deferred_lookup(cookie) < 0) 530 if (fscache_wait_for_deferred_lookup(cookie) < 0)
523 return -ERESTARTSYS; 531 return -ERESTARTSYS;
524 532
525 op = fscache_alloc_retrieval(mapping, end_io_func, context); 533 op = fscache_alloc_retrieval(cookie, mapping, end_io_func, context);
526 if (!op) 534 if (!op)
527 return -ENOMEM; 535 return -ENOMEM;
528 op->n_pages = *nr_pages; 536 op->n_pages = *nr_pages;
@@ -589,6 +597,7 @@ nobufs_unlock_dec:
589 atomic_dec(&object->n_reads); 597 atomic_dec(&object->n_reads);
590nobufs_unlock: 598nobufs_unlock:
591 spin_unlock(&cookie->lock); 599 spin_unlock(&cookie->lock);
600 atomic_dec(&cookie->n_active);
592 kfree(op); 601 kfree(op);
593nobufs: 602nobufs:
594 fscache_stat(&fscache_n_retrievals_nobufs); 603 fscache_stat(&fscache_n_retrievals_nobufs);
@@ -631,7 +640,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
631 if (fscache_wait_for_deferred_lookup(cookie) < 0) 640 if (fscache_wait_for_deferred_lookup(cookie) < 0)
632 return -ERESTARTSYS; 641 return -ERESTARTSYS;
633 642
634 op = fscache_alloc_retrieval(page->mapping, NULL, NULL); 643 op = fscache_alloc_retrieval(cookie, page->mapping, NULL, NULL);
635 if (!op) 644 if (!op)
636 return -ENOMEM; 645 return -ENOMEM;
637 op->n_pages = 1; 646 op->n_pages = 1;
@@ -675,6 +684,7 @@ error:
675 684
676nobufs_unlock: 685nobufs_unlock:
677 spin_unlock(&cookie->lock); 686 spin_unlock(&cookie->lock);
687 atomic_dec(&cookie->n_active);
678 kfree(op); 688 kfree(op);
679nobufs: 689nobufs:
680 fscache_stat(&fscache_n_allocs_nobufs); 690 fscache_stat(&fscache_n_allocs_nobufs);
@@ -876,7 +886,9 @@ int __fscache_write_page(struct fscache_cookie *cookie,
876 886
877 fscache_operation_init(&op->op, fscache_write_op, 887 fscache_operation_init(&op->op, fscache_write_op,
878 fscache_release_write_op); 888 fscache_release_write_op);
879 op->op.flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_WAITING); 889 op->op.flags = FSCACHE_OP_ASYNC |
890 (1 << FSCACHE_OP_WAITING) |
891 (1 << FSCACHE_OP_UNUSE_COOKIE);
880 892
881 ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM); 893 ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM);
882 if (ret < 0) 894 if (ret < 0)
@@ -922,6 +934,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
922 op->op.debug_id = atomic_inc_return(&fscache_op_debug_id); 934 op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
923 op->store_limit = object->store_limit; 935 op->store_limit = object->store_limit;
924 936
937 atomic_inc(&cookie->n_active);
925 if (fscache_submit_op(object, &op->op) < 0) 938 if (fscache_submit_op(object, &op->op) < 0)
926 goto submit_failed; 939 goto submit_failed;
927 940
@@ -948,6 +961,7 @@ already_pending:
948 return 0; 961 return 0;
949 962
950submit_failed: 963submit_failed:
964 atomic_dec(&cookie->n_active);
951 spin_lock(&cookie->stores_lock); 965 spin_lock(&cookie->stores_lock);
952 radix_tree_delete(&cookie->stores, page->index); 966 radix_tree_delete(&cookie->stores, page->index);
953 spin_unlock(&cookie->stores_lock); 967 spin_unlock(&cookie->stores_lock);