summaryrefslogtreecommitdiffstats
path: root/fs/fscache
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-04-04 08:41:27 -0400
committerDavid Howells <dhowells@redhat.com>2018-04-04 08:41:27 -0400
commit08c2e3d087840cd1e7141b62d92f3dc897147984 (patch)
treef5b5ad5c4732cc5cc4f5244f8153ad134a71d979 /fs/fscache
parenta18feb55769b705a44c4107786c4045eae2e87b6 (diff)
fscache: Add more tracepoints
Add more tracepoints to fscache, including: (*) fscache_page - Tracks netfs pages known to fscache. (*) fscache_check_page - Tracks the netfs querying whether a page is pending storage. (*) fscache_wake_cookie - Tracks cookies being woken up after a page completes/aborts storage in the cache. (*) fscache_op - Tracks operations being initialised. (*) fscache_wrote_page - Tracks return of the backend write_page op. (*) fscache_gang_lookup - Tracks lookup of pages to be stored in the write operation. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/fscache')
-rw-r--r--fs/fscache/cookie.c3
-rw-r--r--fs/fscache/object.c3
-rw-r--r--fs/fscache/operation.c26
-rw-r--r--fs/fscache/page.c51
4 files changed, 76 insertions, 7 deletions
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 20bc3341f113..ea1f80daaff4 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -691,10 +691,11 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
691 if (!op) 691 if (!op)
692 return -ENOMEM; 692 return -ENOMEM;
693 693
694 fscache_operation_init(op, NULL, NULL, NULL); 694 fscache_operation_init(cookie, op, NULL, NULL, NULL);
695 op->flags = FSCACHE_OP_MYTHREAD | 695 op->flags = FSCACHE_OP_MYTHREAD |
696 (1 << FSCACHE_OP_WAITING) | 696 (1 << FSCACHE_OP_WAITING) |
697 (1 << FSCACHE_OP_UNUSE_COOKIE); 697 (1 << FSCACHE_OP_UNUSE_COOKIE);
698 trace_fscache_page_op(cookie, NULL, op, fscache_page_op_check_consistency);
698 699
699 spin_lock(&cookie->lock); 700 spin_lock(&cookie->lock);
700 701
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 99afe64352a5..7c0ddb7ae29a 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -982,11 +982,12 @@ static const struct fscache_state *_fscache_invalidate_object(struct fscache_obj
982 if (!op) 982 if (!op)
983 goto nomem; 983 goto nomem;
984 984
985 fscache_operation_init(op, object->cache->ops->invalidate_object, 985 fscache_operation_init(cookie, op, object->cache->ops->invalidate_object,
986 NULL, NULL); 986 NULL, NULL);
987 op->flags = FSCACHE_OP_ASYNC | 987 op->flags = FSCACHE_OP_ASYNC |
988 (1 << FSCACHE_OP_EXCLUSIVE) | 988 (1 << FSCACHE_OP_EXCLUSIVE) |
989 (1 << FSCACHE_OP_UNUSE_COOKIE); 989 (1 << FSCACHE_OP_UNUSE_COOKIE);
990 trace_fscache_page_op(cookie, NULL, op, fscache_page_op_invalidate);
990 991
991 spin_lock(&cookie->lock); 992 spin_lock(&cookie->lock);
992 if (fscache_submit_exclusive_op(object, op) < 0) 993 if (fscache_submit_exclusive_op(object, op) < 0)
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index de67745e1cd7..7a071e1e952d 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -32,7 +32,8 @@ static void fscache_operation_dummy_cancel(struct fscache_operation *op)
32 * Do basic initialisation of an operation. The caller must still set flags, 32 * Do basic initialisation of an operation. The caller must still set flags,
33 * object and processor if needed. 33 * object and processor if needed.
34 */ 34 */
35void fscache_operation_init(struct fscache_operation *op, 35void fscache_operation_init(struct fscache_cookie *cookie,
36 struct fscache_operation *op,
36 fscache_operation_processor_t processor, 37 fscache_operation_processor_t processor,
37 fscache_operation_cancel_t cancel, 38 fscache_operation_cancel_t cancel,
38 fscache_operation_release_t release) 39 fscache_operation_release_t release)
@@ -46,6 +47,7 @@ void fscache_operation_init(struct fscache_operation *op,
46 op->release = release; 47 op->release = release;
47 INIT_LIST_HEAD(&op->pend_link); 48 INIT_LIST_HEAD(&op->pend_link);
48 fscache_stat(&fscache_n_op_initialised); 49 fscache_stat(&fscache_n_op_initialised);
50 trace_fscache_op(cookie, op, fscache_op_init);
49} 51}
50EXPORT_SYMBOL(fscache_operation_init); 52EXPORT_SYMBOL(fscache_operation_init);
51 53
@@ -59,6 +61,8 @@ EXPORT_SYMBOL(fscache_operation_init);
59 */ 61 */
60void fscache_enqueue_operation(struct fscache_operation *op) 62void fscache_enqueue_operation(struct fscache_operation *op)
61{ 63{
64 struct fscache_cookie *cookie = op->object->cookie;
65
62 _enter("{OBJ%x OP%x,%u}", 66 _enter("{OBJ%x OP%x,%u}",
63 op->object->debug_id, op->debug_id, atomic_read(&op->usage)); 67 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
64 68
@@ -71,12 +75,14 @@ void fscache_enqueue_operation(struct fscache_operation *op)
71 fscache_stat(&fscache_n_op_enqueue); 75 fscache_stat(&fscache_n_op_enqueue);
72 switch (op->flags & FSCACHE_OP_TYPE) { 76 switch (op->flags & FSCACHE_OP_TYPE) {
73 case FSCACHE_OP_ASYNC: 77 case FSCACHE_OP_ASYNC:
78 trace_fscache_op(cookie, op, fscache_op_enqueue_async);
74 _debug("queue async"); 79 _debug("queue async");
75 atomic_inc(&op->usage); 80 atomic_inc(&op->usage);
76 if (!queue_work(fscache_op_wq, &op->work)) 81 if (!queue_work(fscache_op_wq, &op->work))
77 fscache_put_operation(op); 82 fscache_put_operation(op);
78 break; 83 break;
79 case FSCACHE_OP_MYTHREAD: 84 case FSCACHE_OP_MYTHREAD:
85 trace_fscache_op(cookie, op, fscache_op_enqueue_mythread);
80 _debug("queue for caller's attention"); 86 _debug("queue for caller's attention");
81 break; 87 break;
82 default: 88 default:
@@ -101,6 +107,8 @@ static void fscache_run_op(struct fscache_object *object,
101 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); 107 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
102 if (op->processor) 108 if (op->processor)
103 fscache_enqueue_operation(op); 109 fscache_enqueue_operation(op);
110 else
111 trace_fscache_op(object->cookie, op, fscache_op_run);
104 fscache_stat(&fscache_n_op_run); 112 fscache_stat(&fscache_n_op_run);
105} 113}
106 114
@@ -155,6 +163,8 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
155 163
156 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id); 164 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
157 165
166 trace_fscache_op(object->cookie, op, fscache_op_submit_ex);
167
158 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); 168 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
159 ASSERTCMP(atomic_read(&op->usage), >, 0); 169 ASSERTCMP(atomic_read(&op->usage), >, 0);
160 170
@@ -240,6 +250,8 @@ int fscache_submit_op(struct fscache_object *object,
240 _enter("{OBJ%x OP%x},{%u}", 250 _enter("{OBJ%x OP%x},{%u}",
241 object->debug_id, op->debug_id, atomic_read(&op->usage)); 251 object->debug_id, op->debug_id, atomic_read(&op->usage));
242 252
253 trace_fscache_op(object->cookie, op, fscache_op_submit);
254
243 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); 255 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
244 ASSERTCMP(atomic_read(&op->usage), >, 0); 256 ASSERTCMP(atomic_read(&op->usage), >, 0);
245 257
@@ -357,6 +369,8 @@ int fscache_cancel_op(struct fscache_operation *op,
357 369
358 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id); 370 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);
359 371
372 trace_fscache_op(object->cookie, op, fscache_op_cancel);
373
360 ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING); 374 ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING);
361 ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED); 375 ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED);
362 ASSERTCMP(atomic_read(&op->usage), >, 0); 376 ASSERTCMP(atomic_read(&op->usage), >, 0);
@@ -419,6 +433,8 @@ void fscache_cancel_all_ops(struct fscache_object *object)
419 fscache_stat(&fscache_n_op_cancelled); 433 fscache_stat(&fscache_n_op_cancelled);
420 list_del_init(&op->pend_link); 434 list_del_init(&op->pend_link);
421 435
436 trace_fscache_op(object->cookie, op, fscache_op_cancel_all);
437
422 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING); 438 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
423 op->cancel(op); 439 op->cancel(op);
424 op->state = FSCACHE_OP_ST_CANCELLED; 440 op->state = FSCACHE_OP_ST_CANCELLED;
@@ -454,9 +470,11 @@ void fscache_op_complete(struct fscache_operation *op, bool cancelled)
454 spin_lock(&object->lock); 470 spin_lock(&object->lock);
455 471
456 if (!cancelled) { 472 if (!cancelled) {
473 trace_fscache_op(object->cookie, op, fscache_op_completed);
457 op->state = FSCACHE_OP_ST_COMPLETE; 474 op->state = FSCACHE_OP_ST_COMPLETE;
458 } else { 475 } else {
459 op->cancel(op); 476 op->cancel(op);
477 trace_fscache_op(object->cookie, op, fscache_op_cancelled);
460 op->state = FSCACHE_OP_ST_CANCELLED; 478 op->state = FSCACHE_OP_ST_CANCELLED;
461 } 479 }
462 480
@@ -488,6 +506,8 @@ void fscache_put_operation(struct fscache_operation *op)
488 if (!atomic_dec_and_test(&op->usage)) 506 if (!atomic_dec_and_test(&op->usage))
489 return; 507 return;
490 508
509 trace_fscache_op(op->object->cookie, op, fscache_op_put);
510
491 _debug("PUT OP"); 511 _debug("PUT OP");
492 ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED && 512 ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
493 op->state != FSCACHE_OP_ST_COMPLETE, 513 op->state != FSCACHE_OP_ST_COMPLETE,
@@ -563,6 +583,8 @@ void fscache_operation_gc(struct work_struct *work)
563 spin_unlock(&cache->op_gc_list_lock); 583 spin_unlock(&cache->op_gc_list_lock);
564 584
565 object = op->object; 585 object = op->object;
586 trace_fscache_op(object->cookie, op, fscache_op_gc);
587
566 spin_lock(&object->lock); 588 spin_lock(&object->lock);
567 589
568 _debug("GC DEFERRED REL OBJ%x OP%x", 590 _debug("GC DEFERRED REL OBJ%x OP%x",
@@ -601,6 +623,8 @@ void fscache_op_work_func(struct work_struct *work)
601 _enter("{OBJ%x OP%x,%d}", 623 _enter("{OBJ%x OP%x,%d}",
602 op->object->debug_id, op->debug_id, atomic_read(&op->usage)); 624 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
603 625
626 trace_fscache_op(op->object->cookie, op, fscache_op_work);
627
604 ASSERT(op->processor != NULL); 628 ASSERT(op->processor != NULL);
605 start = jiffies; 629 start = jiffies;
606 op->processor(op); 630 op->processor(op);
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index b9f18bf4227d..810b33aced1c 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -27,6 +27,7 @@ bool __fscache_check_page_write(struct fscache_cookie *cookie, struct page *page
27 rcu_read_lock(); 27 rcu_read_lock();
28 val = radix_tree_lookup(&cookie->stores, page->index); 28 val = radix_tree_lookup(&cookie->stores, page->index);
29 rcu_read_unlock(); 29 rcu_read_unlock();
30 trace_fscache_check_page(cookie, page, val, 0);
30 31
31 return val != NULL; 32 return val != NULL;
32} 33}
@@ -39,6 +40,8 @@ void __fscache_wait_on_page_write(struct fscache_cookie *cookie, struct page *pa
39{ 40{
40 wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0); 41 wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
41 42
43 trace_fscache_page(cookie, page, fscache_page_write_wait);
44
42 wait_event(*wq, !__fscache_check_page_write(cookie, page)); 45 wait_event(*wq, !__fscache_check_page_write(cookie, page));
43} 46}
44EXPORT_SYMBOL(__fscache_wait_on_page_write); 47EXPORT_SYMBOL(__fscache_wait_on_page_write);
@@ -69,6 +72,8 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
69 72
70 _enter("%p,%p,%x", cookie, page, gfp); 73 _enter("%p,%p,%x", cookie, page, gfp);
71 74
75 trace_fscache_page(cookie, page, fscache_page_maybe_release);
76
72try_again: 77try_again:
73 rcu_read_lock(); 78 rcu_read_lock();
74 val = radix_tree_lookup(&cookie->stores, page->index); 79 val = radix_tree_lookup(&cookie->stores, page->index);
@@ -101,6 +106,7 @@ try_again:
101 } 106 }
102 107
103 xpage = radix_tree_delete(&cookie->stores, page->index); 108 xpage = radix_tree_delete(&cookie->stores, page->index);
109 trace_fscache_page(cookie, page, fscache_page_radix_delete);
104 spin_unlock(&cookie->stores_lock); 110 spin_unlock(&cookie->stores_lock);
105 111
106 if (xpage) { 112 if (xpage) {
@@ -112,6 +118,7 @@ try_again:
112 } 118 }
113 119
114 wake_up_bit(&cookie->flags, 0); 120 wake_up_bit(&cookie->flags, 0);
121 trace_fscache_wake_cookie(cookie);
115 if (xpage) 122 if (xpage)
116 put_page(xpage); 123 put_page(xpage);
117 __fscache_uncache_page(cookie, page); 124 __fscache_uncache_page(cookie, page);
@@ -144,7 +151,7 @@ static void fscache_end_page_write(struct fscache_object *object,
144 struct page *page) 151 struct page *page)
145{ 152{
146 struct fscache_cookie *cookie; 153 struct fscache_cookie *cookie;
147 struct page *xpage = NULL; 154 struct page *xpage = NULL, *val;
148 155
149 spin_lock(&object->lock); 156 spin_lock(&object->lock);
150 cookie = object->cookie; 157 cookie = object->cookie;
@@ -154,13 +161,24 @@ static void fscache_end_page_write(struct fscache_object *object,
154 spin_lock(&cookie->stores_lock); 161 spin_lock(&cookie->stores_lock);
155 radix_tree_tag_clear(&cookie->stores, page->index, 162 radix_tree_tag_clear(&cookie->stores, page->index,
156 FSCACHE_COOKIE_STORING_TAG); 163 FSCACHE_COOKIE_STORING_TAG);
164 trace_fscache_page(cookie, page, fscache_page_radix_clear_store);
157 if (!radix_tree_tag_get(&cookie->stores, page->index, 165 if (!radix_tree_tag_get(&cookie->stores, page->index,
158 FSCACHE_COOKIE_PENDING_TAG)) { 166 FSCACHE_COOKIE_PENDING_TAG)) {
159 fscache_stat(&fscache_n_store_radix_deletes); 167 fscache_stat(&fscache_n_store_radix_deletes);
160 xpage = radix_tree_delete(&cookie->stores, page->index); 168 xpage = radix_tree_delete(&cookie->stores, page->index);
169 trace_fscache_page(cookie, page, fscache_page_radix_delete);
170 trace_fscache_page(cookie, page, fscache_page_write_end);
171
172 val = radix_tree_lookup(&cookie->stores, page->index);
173 trace_fscache_check_page(cookie, page, val, 1);
174 } else {
175 trace_fscache_page(cookie, page, fscache_page_write_end_pend);
161 } 176 }
162 spin_unlock(&cookie->stores_lock); 177 spin_unlock(&cookie->stores_lock);
163 wake_up_bit(&cookie->flags, 0); 178 wake_up_bit(&cookie->flags, 0);
179 trace_fscache_wake_cookie(cookie);
180 } else {
181 trace_fscache_page(cookie, page, fscache_page_write_end_noc);
164 } 182 }
165 spin_unlock(&object->lock); 183 spin_unlock(&object->lock);
166 if (xpage) 184 if (xpage)
@@ -215,7 +233,8 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
215 return -ENOMEM; 233 return -ENOMEM;
216 } 234 }
217 235
218 fscache_operation_init(op, fscache_attr_changed_op, NULL, NULL); 236 fscache_operation_init(cookie, op, fscache_attr_changed_op, NULL, NULL);
237 trace_fscache_page_op(cookie, NULL, op, fscache_page_op_attr_changed);
219 op->flags = FSCACHE_OP_ASYNC | 238 op->flags = FSCACHE_OP_ASYNC |
220 (1 << FSCACHE_OP_EXCLUSIVE) | 239 (1 << FSCACHE_OP_EXCLUSIVE) |
221 (1 << FSCACHE_OP_UNUSE_COOKIE); 240 (1 << FSCACHE_OP_UNUSE_COOKIE);
@@ -299,7 +318,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
299 return NULL; 318 return NULL;
300 } 319 }
301 320
302 fscache_operation_init(&op->op, NULL, 321 fscache_operation_init(cookie, &op->op, NULL,
303 fscache_do_cancel_retrieval, 322 fscache_do_cancel_retrieval,
304 fscache_release_retrieval_op); 323 fscache_release_retrieval_op);
305 op->op.flags = FSCACHE_OP_MYTHREAD | 324 op->op.flags = FSCACHE_OP_MYTHREAD |
@@ -370,6 +389,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
370 fscache_stat(stat_op_waits); 389 fscache_stat(stat_op_waits);
371 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING, 390 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
372 TASK_INTERRUPTIBLE) != 0) { 391 TASK_INTERRUPTIBLE) != 0) {
392 trace_fscache_op(object->cookie, op, fscache_op_signal);
373 ret = fscache_cancel_op(op, false); 393 ret = fscache_cancel_op(op, false);
374 if (ret == 0) 394 if (ret == 0)
375 return -ERESTARTSYS; 395 return -ERESTARTSYS;
@@ -391,6 +411,7 @@ check_if_dead:
391 if (unlikely(fscache_object_is_dying(object) || 411 if (unlikely(fscache_object_is_dying(object) ||
392 fscache_cache_is_broken(object))) { 412 fscache_cache_is_broken(object))) {
393 enum fscache_operation_state state = op->state; 413 enum fscache_operation_state state = op->state;
414 trace_fscache_op(object->cookie, op, fscache_op_signal);
394 fscache_cancel_op(op, true); 415 fscache_cancel_op(op, true);
395 if (stat_object_dead) 416 if (stat_object_dead)
396 fscache_stat(stat_object_dead); 417 fscache_stat(stat_object_dead);
@@ -445,6 +466,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
445 return -ENOMEM; 466 return -ENOMEM;
446 } 467 }
447 atomic_set(&op->n_pages, 1); 468 atomic_set(&op->n_pages, 1);
469 trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_retr_one);
448 470
449 spin_lock(&cookie->lock); 471 spin_lock(&cookie->lock);
450 472
@@ -573,6 +595,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
573 if (!op) 595 if (!op)
574 return -ENOMEM; 596 return -ENOMEM;
575 atomic_set(&op->n_pages, *nr_pages); 597 atomic_set(&op->n_pages, *nr_pages);
598 trace_fscache_page_op(cookie, NULL, &op->op, fscache_page_op_retr_multi);
576 599
577 spin_lock(&cookie->lock); 600 spin_lock(&cookie->lock);
578 601
@@ -684,6 +707,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
684 if (!op) 707 if (!op)
685 return -ENOMEM; 708 return -ENOMEM;
686 atomic_set(&op->n_pages, 1); 709 atomic_set(&op->n_pages, 1);
710 trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_alloc_one);
687 711
688 spin_lock(&cookie->lock); 712 spin_lock(&cookie->lock);
689 713
@@ -813,9 +837,11 @@ again:
813 fscache_stat(&fscache_n_store_calls); 837 fscache_stat(&fscache_n_store_calls);
814 838
815 /* find a page to store */ 839 /* find a page to store */
840 results[0] = NULL;
816 page = NULL; 841 page = NULL;
817 n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1, 842 n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1,
818 FSCACHE_COOKIE_PENDING_TAG); 843 FSCACHE_COOKIE_PENDING_TAG);
844 trace_fscache_gang_lookup(cookie, &op->op, results, n, op->store_limit);
819 if (n != 1) 845 if (n != 1)
820 goto superseded; 846 goto superseded;
821 page = results[0]; 847 page = results[0];
@@ -825,6 +851,7 @@ again:
825 FSCACHE_COOKIE_STORING_TAG); 851 FSCACHE_COOKIE_STORING_TAG);
826 radix_tree_tag_clear(&cookie->stores, page->index, 852 radix_tree_tag_clear(&cookie->stores, page->index,
827 FSCACHE_COOKIE_PENDING_TAG); 853 FSCACHE_COOKIE_PENDING_TAG);
854 trace_fscache_page(cookie, page, fscache_page_radix_pend2store);
828 855
829 spin_unlock(&cookie->stores_lock); 856 spin_unlock(&cookie->stores_lock);
830 spin_unlock(&object->lock); 857 spin_unlock(&object->lock);
@@ -836,6 +863,7 @@ again:
836 fscache_stat(&fscache_n_cop_write_page); 863 fscache_stat(&fscache_n_cop_write_page);
837 ret = object->cache->ops->write_page(op, page); 864 ret = object->cache->ops->write_page(op, page);
838 fscache_stat_d(&fscache_n_cop_write_page); 865 fscache_stat_d(&fscache_n_cop_write_page);
866 trace_fscache_wrote_page(cookie, page, &op->op, ret);
839 fscache_end_page_write(object, page); 867 fscache_end_page_write(object, page);
840 if (ret < 0) { 868 if (ret < 0) {
841 fscache_abort_object(object); 869 fscache_abort_object(object);
@@ -849,6 +877,7 @@ again:
849 877
850discard_page: 878discard_page:
851 fscache_stat(&fscache_n_store_pages_over_limit); 879 fscache_stat(&fscache_n_store_pages_over_limit);
880 trace_fscache_wrote_page(cookie, page, &op->op, -ENOBUFS);
852 fscache_end_page_write(object, page); 881 fscache_end_page_write(object, page);
853 goto again; 882 goto again;
854 883
@@ -887,6 +916,8 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
887 for (i = n - 1; i >= 0; i--) { 916 for (i = n - 1; i >= 0; i--) {
888 page = results[i]; 917 page = results[i];
889 radix_tree_delete(&cookie->stores, page->index); 918 radix_tree_delete(&cookie->stores, page->index);
919 trace_fscache_page(cookie, page, fscache_page_radix_delete);
920 trace_fscache_page(cookie, page, fscache_page_inval);
890 } 921 }
891 922
892 spin_unlock(&cookie->stores_lock); 923 spin_unlock(&cookie->stores_lock);
@@ -896,6 +927,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
896 } 927 }
897 928
898 wake_up_bit(&cookie->flags, 0); 929 wake_up_bit(&cookie->flags, 0);
930 trace_fscache_wake_cookie(cookie);
899 931
900 _leave(""); 932 _leave("");
901} 933}
@@ -954,7 +986,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
954 if (!op) 986 if (!op)
955 goto nomem; 987 goto nomem;
956 988
957 fscache_operation_init(&op->op, fscache_write_op, NULL, 989 fscache_operation_init(cookie, &op->op, fscache_write_op, NULL,
958 fscache_release_write_op); 990 fscache_release_write_op);
959 op->op.flags = FSCACHE_OP_ASYNC | 991 op->op.flags = FSCACHE_OP_ASYNC |
960 (1 << FSCACHE_OP_WAITING) | 992 (1 << FSCACHE_OP_WAITING) |
@@ -964,6 +996,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
964 if (ret < 0) 996 if (ret < 0)
965 goto nomem_free; 997 goto nomem_free;
966 998
999 trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_write_one);
1000
967 ret = -ENOBUFS; 1001 ret = -ENOBUFS;
968 spin_lock(&cookie->lock); 1002 spin_lock(&cookie->lock);
969 1003
@@ -975,6 +1009,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
975 if (test_bit(FSCACHE_IOERROR, &object->cache->flags)) 1009 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
976 goto nobufs; 1010 goto nobufs;
977 1011
1012 trace_fscache_page(cookie, page, fscache_page_write);
1013
978 /* add the page to the pending-storage radix tree on the backing 1014 /* add the page to the pending-storage radix tree on the backing
979 * object */ 1015 * object */
980 spin_lock(&object->lock); 1016 spin_lock(&object->lock);
@@ -990,8 +1026,10 @@ int __fscache_write_page(struct fscache_cookie *cookie,
990 goto nobufs_unlock_obj; 1026 goto nobufs_unlock_obj;
991 } 1027 }
992 1028
1029 trace_fscache_page(cookie, page, fscache_page_radix_insert);
993 radix_tree_tag_set(&cookie->stores, page->index, 1030 radix_tree_tag_set(&cookie->stores, page->index,
994 FSCACHE_COOKIE_PENDING_TAG); 1031 FSCACHE_COOKIE_PENDING_TAG);
1032 trace_fscache_page(cookie, page, fscache_page_radix_set_pend);
995 get_page(page); 1033 get_page(page);
996 1034
997 /* we only want one writer at a time, but we do need to queue new 1035 /* we only want one writer at a time, but we do need to queue new
@@ -1034,6 +1072,7 @@ already_pending:
1034submit_failed: 1072submit_failed:
1035 spin_lock(&cookie->stores_lock); 1073 spin_lock(&cookie->stores_lock);
1036 radix_tree_delete(&cookie->stores, page->index); 1074 radix_tree_delete(&cookie->stores, page->index);
1075 trace_fscache_page(cookie, page, fscache_page_radix_delete);
1037 spin_unlock(&cookie->stores_lock); 1076 spin_unlock(&cookie->stores_lock);
1038 wake_cookie = __fscache_unuse_cookie(cookie); 1077 wake_cookie = __fscache_unuse_cookie(cookie);
1039 put_page(page); 1078 put_page(page);
@@ -1080,6 +1119,8 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
1080 if (!PageFsCache(page)) 1119 if (!PageFsCache(page))
1081 goto done; 1120 goto done;
1082 1121
1122 trace_fscache_page(cookie, page, fscache_page_uncache);
1123
1083 /* get the object */ 1124 /* get the object */
1084 spin_lock(&cookie->lock); 1125 spin_lock(&cookie->lock);
1085 1126
@@ -1128,6 +1169,8 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
1128 atomic_inc(&fscache_n_marks); 1169 atomic_inc(&fscache_n_marks);
1129#endif 1170#endif
1130 1171
1172 trace_fscache_page(cookie, page, fscache_page_cached);
1173
1131 _debug("- mark %p{%lx}", page, page->index); 1174 _debug("- mark %p{%lx}", page, page->index);
1132 if (TestSetPageFsCache(page)) { 1175 if (TestSetPageFsCache(page)) {
1133 static bool once_only; 1176 static bool once_only;