aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-11-19 13:11:08 -0500
committerDavid Howells <dhowells@redhat.com>2009-11-19 13:11:08 -0500
commit52bd75fdb135d6133d878ae60c6e7e3f4ebc1cfc (patch)
tree4fad4fa37ce533c520a4575e5b7df90e19c6a666 /fs
parent4fbf4291aa15926cd4fdca0ffe9122e89d0459db (diff)
FS-Cache: Add counters for entry/exit to/from cache operation functions
Count entries to and exits from cache operation table functions. Maintain these as a single counter that's added to or removed from as appropriate. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/fscache/cache.c4
-rw-r--r--fs/fscache/cookie.c9
-rw-r--r--fs/fscache/internal.h22
-rw-r--r--fs/fscache/object.c26
-rw-r--r--fs/fscache/page.c29
-rw-r--r--fs/fscache/stats.c37
6 files changed, 118 insertions, 9 deletions
diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c
index 724384ef96de..6a3c48abd677 100644
--- a/fs/fscache/cache.c
+++ b/fs/fscache/cache.c
@@ -381,11 +381,15 @@ void fscache_withdraw_cache(struct fscache_cache *cache)
381 381
382 /* make sure all pages pinned by operations on behalf of the netfs are 382 /* make sure all pages pinned by operations on behalf of the netfs are
383 * written to disk */ 383 * written to disk */
384 fscache_stat(&fscache_n_cop_sync_cache);
384 cache->ops->sync_cache(cache); 385 cache->ops->sync_cache(cache);
386 fscache_stat_d(&fscache_n_cop_sync_cache);
385 387
386 /* dissociate all the netfs pages backed by this cache from the block 388 /* dissociate all the netfs pages backed by this cache from the block
387 * mappings in the cache */ 389 * mappings in the cache */
390 fscache_stat(&fscache_n_cop_dissociate_pages);
388 cache->ops->dissociate_pages(cache); 391 cache->ops->dissociate_pages(cache);
392 fscache_stat_d(&fscache_n_cop_dissociate_pages);
389 393
390 /* we now have to destroy all the active objects pertaining to this 394 /* we now have to destroy all the active objects pertaining to this
391 * cache - which we do by passing them off to thread pool to be 395 * cache - which we do by passing them off to thread pool to be
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 9b5187328230..432482edc738 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -249,7 +249,9 @@ static int fscache_alloc_object(struct fscache_cache *cache,
249 249
250 /* ask the cache to allocate an object (we may end up with duplicate 250 /* ask the cache to allocate an object (we may end up with duplicate
251 * objects at this stage, but we sort that out later) */ 251 * objects at this stage, but we sort that out later) */
252 fscache_stat(&fscache_n_cop_alloc_object);
252 object = cache->ops->alloc_object(cache, cookie); 253 object = cache->ops->alloc_object(cache, cookie);
254 fscache_stat_d(&fscache_n_cop_alloc_object);
253 if (IS_ERR(object)) { 255 if (IS_ERR(object)) {
254 fscache_stat(&fscache_n_object_no_alloc); 256 fscache_stat(&fscache_n_object_no_alloc);
255 ret = PTR_ERR(object); 257 ret = PTR_ERR(object);
@@ -270,8 +272,11 @@ static int fscache_alloc_object(struct fscache_cache *cache,
270 /* only attach if we managed to allocate all we needed, otherwise 272 /* only attach if we managed to allocate all we needed, otherwise
271 * discard the object we just allocated and instead use the one 273 * discard the object we just allocated and instead use the one
272 * attached to the cookie */ 274 * attached to the cookie */
273 if (fscache_attach_object(cookie, object) < 0) 275 if (fscache_attach_object(cookie, object) < 0) {
276 fscache_stat(&fscache_n_cop_put_object);
274 cache->ops->put_object(object); 277 cache->ops->put_object(object);
278 fscache_stat_d(&fscache_n_cop_put_object);
279 }
275 280
276 _leave(" = 0"); 281 _leave(" = 0");
277 return 0; 282 return 0;
@@ -287,7 +292,9 @@ object_already_extant:
287 return 0; 292 return 0;
288 293
289error_put: 294error_put:
295 fscache_stat(&fscache_n_cop_put_object);
290 cache->ops->put_object(object); 296 cache->ops->put_object(object);
297 fscache_stat_d(&fscache_n_cop_put_object);
291error: 298error:
292 _leave(" = %d", ret); 299 _leave(" = %d", ret);
293 return ret; 300 return ret;
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
index fe02973a9516..b85cc8906818 100644
--- a/fs/fscache/internal.h
+++ b/fs/fscache/internal.h
@@ -208,11 +208,33 @@ extern atomic_t fscache_n_checkaux_okay;
208extern atomic_t fscache_n_checkaux_update; 208extern atomic_t fscache_n_checkaux_update;
209extern atomic_t fscache_n_checkaux_obsolete; 209extern atomic_t fscache_n_checkaux_obsolete;
210 210
211extern atomic_t fscache_n_cop_alloc_object;
212extern atomic_t fscache_n_cop_lookup_object;
213extern atomic_t fscache_n_cop_lookup_complete;
214extern atomic_t fscache_n_cop_grab_object;
215extern atomic_t fscache_n_cop_update_object;
216extern atomic_t fscache_n_cop_drop_object;
217extern atomic_t fscache_n_cop_put_object;
218extern atomic_t fscache_n_cop_sync_cache;
219extern atomic_t fscache_n_cop_attr_changed;
220extern atomic_t fscache_n_cop_read_or_alloc_page;
221extern atomic_t fscache_n_cop_read_or_alloc_pages;
222extern atomic_t fscache_n_cop_allocate_page;
223extern atomic_t fscache_n_cop_allocate_pages;
224extern atomic_t fscache_n_cop_write_page;
225extern atomic_t fscache_n_cop_uncache_page;
226extern atomic_t fscache_n_cop_dissociate_pages;
227
211static inline void fscache_stat(atomic_t *stat) 228static inline void fscache_stat(atomic_t *stat)
212{ 229{
213 atomic_inc(stat); 230 atomic_inc(stat);
214} 231}
215 232
233static inline void fscache_stat_d(atomic_t *stat)
234{
235 atomic_dec(stat);
236}
237
216extern const struct file_operations fscache_stats_fops; 238extern const struct file_operations fscache_stats_fops;
217#else 239#else
218 240
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index ad1644f073bd..0d65c0c92b46 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -144,13 +144,17 @@ static void fscache_object_state_machine(struct fscache_object *object)
144 case FSCACHE_OBJECT_UPDATING: 144 case FSCACHE_OBJECT_UPDATING:
145 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events); 145 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
146 fscache_stat(&fscache_n_updates_run); 146 fscache_stat(&fscache_n_updates_run);
147 fscache_stat(&fscache_n_cop_update_object);
147 object->cache->ops->update_object(object); 148 object->cache->ops->update_object(object);
149 fscache_stat_d(&fscache_n_cop_update_object);
148 goto active_transit; 150 goto active_transit;
149 151
150 /* handle an object dying during lookup or creation */ 152 /* handle an object dying during lookup or creation */
151 case FSCACHE_OBJECT_LC_DYING: 153 case FSCACHE_OBJECT_LC_DYING:
152 object->event_mask &= ~(1 << FSCACHE_OBJECT_EV_UPDATE); 154 object->event_mask &= ~(1 << FSCACHE_OBJECT_EV_UPDATE);
155 fscache_stat(&fscache_n_cop_lookup_complete);
153 object->cache->ops->lookup_complete(object); 156 object->cache->ops->lookup_complete(object);
157 fscache_stat_d(&fscache_n_cop_lookup_complete);
154 158
155 spin_lock(&object->lock); 159 spin_lock(&object->lock);
156 object->state = FSCACHE_OBJECT_DYING; 160 object->state = FSCACHE_OBJECT_DYING;
@@ -416,7 +420,9 @@ static void fscache_initialise_object(struct fscache_object *object)
416 * binding on to us, so we need to make sure we don't 420 * binding on to us, so we need to make sure we don't
417 * add ourself to the list multiple times */ 421 * add ourself to the list multiple times */
418 if (list_empty(&object->dep_link)) { 422 if (list_empty(&object->dep_link)) {
423 fscache_stat(&fscache_n_cop_grab_object);
419 object->cache->ops->grab_object(object); 424 object->cache->ops->grab_object(object);
425 fscache_stat_d(&fscache_n_cop_grab_object);
420 list_add(&object->dep_link, 426 list_add(&object->dep_link,
421 &parent->dependents); 427 &parent->dependents);
422 428
@@ -478,7 +484,9 @@ static void fscache_lookup_object(struct fscache_object *object)
478 object->cache->tag->name); 484 object->cache->tag->name);
479 485
480 fscache_stat(&fscache_n_object_lookups); 486 fscache_stat(&fscache_n_object_lookups);
487 fscache_stat(&fscache_n_cop_lookup_object);
481 object->cache->ops->lookup_object(object); 488 object->cache->ops->lookup_object(object);
489 fscache_stat_d(&fscache_n_cop_lookup_object);
482 490
483 if (test_bit(FSCACHE_OBJECT_EV_ERROR, &object->events)) 491 if (test_bit(FSCACHE_OBJECT_EV_ERROR, &object->events))
484 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags); 492 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags);
@@ -602,7 +610,9 @@ static void fscache_object_available(struct fscache_object *object)
602 } 610 }
603 spin_unlock(&object->lock); 611 spin_unlock(&object->lock);
604 612
613 fscache_stat(&fscache_n_cop_lookup_complete);
605 object->cache->ops->lookup_complete(object); 614 object->cache->ops->lookup_complete(object);
615 fscache_stat_d(&fscache_n_cop_lookup_complete);
606 fscache_enqueue_dependents(object); 616 fscache_enqueue_dependents(object);
607 617
608 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif); 618 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
@@ -625,7 +635,9 @@ static void fscache_drop_object(struct fscache_object *object)
625 list_del_init(&object->cache_link); 635 list_del_init(&object->cache_link);
626 spin_unlock(&cache->object_list_lock); 636 spin_unlock(&cache->object_list_lock);
627 637
638 fscache_stat(&fscache_n_cop_drop_object);
628 cache->ops->drop_object(object); 639 cache->ops->drop_object(object);
640 fscache_stat_d(&fscache_n_cop_drop_object);
629 641
630 if (parent) { 642 if (parent) {
631 _debug("release parent OBJ%x {%d}", 643 _debug("release parent OBJ%x {%d}",
@@ -640,7 +652,9 @@ static void fscache_drop_object(struct fscache_object *object)
640 } 652 }
641 653
642 /* this just shifts the object release to the slow work processor */ 654 /* this just shifts the object release to the slow work processor */
655 fscache_stat(&fscache_n_cop_put_object);
643 object->cache->ops->put_object(object); 656 object->cache->ops->put_object(object);
657 fscache_stat_d(&fscache_n_cop_put_object);
644 658
645 _leave(""); 659 _leave("");
646} 660}
@@ -730,8 +744,12 @@ static int fscache_object_slow_work_get_ref(struct slow_work *work)
730{ 744{
731 struct fscache_object *object = 745 struct fscache_object *object =
732 container_of(work, struct fscache_object, work); 746 container_of(work, struct fscache_object, work);
747 int ret;
733 748
734 return object->cache->ops->grab_object(object) ? 0 : -EAGAIN; 749 fscache_stat(&fscache_n_cop_grab_object);
750 ret = object->cache->ops->grab_object(object) ? 0 : -EAGAIN;
751 fscache_stat_d(&fscache_n_cop_grab_object);
752 return ret;
735} 753}
736 754
737/* 755/*
@@ -742,7 +760,9 @@ static void fscache_object_slow_work_put_ref(struct slow_work *work)
742 struct fscache_object *object = 760 struct fscache_object *object =
743 container_of(work, struct fscache_object, work); 761 container_of(work, struct fscache_object, work);
744 762
745 return object->cache->ops->put_object(object); 763 fscache_stat(&fscache_n_cop_put_object);
764 object->cache->ops->put_object(object);
765 fscache_stat_d(&fscache_n_cop_put_object);
746} 766}
747 767
748/* 768/*
@@ -779,7 +799,9 @@ static void fscache_enqueue_dependents(struct fscache_object *object)
779 799
780 /* sort onto appropriate lists */ 800 /* sort onto appropriate lists */
781 fscache_enqueue_object(dep); 801 fscache_enqueue_object(dep);
802 fscache_stat(&fscache_n_cop_put_object);
782 dep->cache->ops->put_object(dep); 803 dep->cache->ops->put_object(dep);
804 fscache_stat_d(&fscache_n_cop_put_object);
783 805
784 if (!list_empty(&object->dependents)) 806 if (!list_empty(&object->dependents))
785 cond_resched_lock(&object->lock); 807 cond_resched_lock(&object->lock);
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index c5973e38ce39..250dfd34c07b 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -71,7 +71,9 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
71 71
72 if (fscache_object_is_active(object)) { 72 if (fscache_object_is_active(object)) {
73 fscache_set_op_state(op, "CallFS"); 73 fscache_set_op_state(op, "CallFS");
74 fscache_stat(&fscache_n_cop_attr_changed);
74 ret = object->cache->ops->attr_changed(object); 75 ret = object->cache->ops->attr_changed(object);
76 fscache_stat_d(&fscache_n_cop_attr_changed);
75 fscache_set_op_state(op, "Done"); 77 fscache_set_op_state(op, "Done");
76 if (ret < 0) 78 if (ret < 0)
77 fscache_abort_object(object); 79 fscache_abort_object(object);
@@ -300,11 +302,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
300 302
301 /* ask the cache to honour the operation */ 303 /* ask the cache to honour the operation */
302 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) { 304 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
305 fscache_stat(&fscache_n_cop_allocate_page);
303 ret = object->cache->ops->allocate_page(op, page, gfp); 306 ret = object->cache->ops->allocate_page(op, page, gfp);
307 fscache_stat_d(&fscache_n_cop_allocate_page);
304 if (ret == 0) 308 if (ret == 0)
305 ret = -ENODATA; 309 ret = -ENODATA;
306 } else { 310 } else {
311 fscache_stat(&fscache_n_cop_read_or_alloc_page);
307 ret = object->cache->ops->read_or_alloc_page(op, page, gfp); 312 ret = object->cache->ops->read_or_alloc_page(op, page, gfp);
313 fscache_stat_d(&fscache_n_cop_read_or_alloc_page);
308 } 314 }
309 315
310 if (ret == -ENOMEM) 316 if (ret == -ENOMEM)
@@ -358,7 +364,6 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
358 void *context, 364 void *context,
359 gfp_t gfp) 365 gfp_t gfp)
360{ 366{
361 fscache_pages_retrieval_func_t func;
362 struct fscache_retrieval *op; 367 struct fscache_retrieval *op;
363 struct fscache_object *object; 368 struct fscache_object *object;
364 int ret; 369 int ret;
@@ -413,11 +418,17 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
413 } 418 }
414 419
415 /* ask the cache to honour the operation */ 420 /* ask the cache to honour the operation */
416 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) 421 if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) {
417 func = object->cache->ops->allocate_pages; 422 fscache_stat(&fscache_n_cop_allocate_pages);
418 else 423 ret = object->cache->ops->allocate_pages(
419 func = object->cache->ops->read_or_alloc_pages; 424 op, pages, nr_pages, gfp);
420 ret = func(op, pages, nr_pages, gfp); 425 fscache_stat_d(&fscache_n_cop_allocate_pages);
426 } else {
427 fscache_stat(&fscache_n_cop_read_or_alloc_pages);
428 ret = object->cache->ops->read_or_alloc_pages(
429 op, pages, nr_pages, gfp);
430 fscache_stat_d(&fscache_n_cop_read_or_alloc_pages);
431 }
421 432
422 if (ret == -ENOMEM) 433 if (ret == -ENOMEM)
423 fscache_stat(&fscache_n_retrievals_nomem); 434 fscache_stat(&fscache_n_retrievals_nomem);
@@ -500,7 +511,9 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
500 } 511 }
501 512
502 /* ask the cache to honour the operation */ 513 /* ask the cache to honour the operation */
514 fscache_stat(&fscache_n_cop_allocate_page);
503 ret = object->cache->ops->allocate_page(op, page, gfp); 515 ret = object->cache->ops->allocate_page(op, page, gfp);
516 fscache_stat_d(&fscache_n_cop_allocate_page);
504 517
505 if (ret < 0) 518 if (ret < 0)
506 fscache_stat(&fscache_n_allocs_nobufs); 519 fscache_stat(&fscache_n_allocs_nobufs);
@@ -578,7 +591,9 @@ static void fscache_write_op(struct fscache_operation *_op)
578 591
579 if (page) { 592 if (page) {
580 fscache_set_op_state(&op->op, "Store"); 593 fscache_set_op_state(&op->op, "Store");
594 fscache_stat(&fscache_n_cop_write_page);
581 ret = object->cache->ops->write_page(op, page); 595 ret = object->cache->ops->write_page(op, page);
596 fscache_stat_d(&fscache_n_cop_write_page);
582 fscache_set_op_state(&op->op, "EndWrite"); 597 fscache_set_op_state(&op->op, "EndWrite");
583 fscache_end_page_write(cookie, page); 598 fscache_end_page_write(cookie, page);
584 page_cache_release(page); 599 page_cache_release(page);
@@ -786,7 +801,9 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
786 if (TestClearPageFsCache(page) && 801 if (TestClearPageFsCache(page) &&
787 object->cache->ops->uncache_page) { 802 object->cache->ops->uncache_page) {
788 /* the cache backend releases the cookie lock */ 803 /* the cache backend releases the cookie lock */
804 fscache_stat(&fscache_n_cop_uncache_page);
789 object->cache->ops->uncache_page(object, page); 805 object->cache->ops->uncache_page(object, page);
806 fscache_stat_d(&fscache_n_cop_uncache_page);
790 goto done; 807 goto done;
791 } 808 }
792 809
diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
index 65deb99e756b..20233fb44bfd 100644
--- a/fs/fscache/stats.c
+++ b/fs/fscache/stats.c
@@ -93,6 +93,23 @@ atomic_t fscache_n_checkaux_okay;
93atomic_t fscache_n_checkaux_update; 93atomic_t fscache_n_checkaux_update;
94atomic_t fscache_n_checkaux_obsolete; 94atomic_t fscache_n_checkaux_obsolete;
95 95
96atomic_t fscache_n_cop_alloc_object;
97atomic_t fscache_n_cop_lookup_object;
98atomic_t fscache_n_cop_lookup_complete;
99atomic_t fscache_n_cop_grab_object;
100atomic_t fscache_n_cop_update_object;
101atomic_t fscache_n_cop_drop_object;
102atomic_t fscache_n_cop_put_object;
103atomic_t fscache_n_cop_sync_cache;
104atomic_t fscache_n_cop_attr_changed;
105atomic_t fscache_n_cop_read_or_alloc_page;
106atomic_t fscache_n_cop_read_or_alloc_pages;
107atomic_t fscache_n_cop_allocate_page;
108atomic_t fscache_n_cop_allocate_pages;
109atomic_t fscache_n_cop_write_page;
110atomic_t fscache_n_cop_uncache_page;
111atomic_t fscache_n_cop_dissociate_pages;
112
96/* 113/*
97 * display the general statistics 114 * display the general statistics
98 */ 115 */
@@ -192,6 +209,26 @@ static int fscache_stats_show(struct seq_file *m, void *v)
192 atomic_read(&fscache_n_op_deferred_release), 209 atomic_read(&fscache_n_op_deferred_release),
193 atomic_read(&fscache_n_op_release), 210 atomic_read(&fscache_n_op_release),
194 atomic_read(&fscache_n_op_gc)); 211 atomic_read(&fscache_n_op_gc));
212
213 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
214 atomic_read(&fscache_n_cop_alloc_object),
215 atomic_read(&fscache_n_cop_lookup_object),
216 atomic_read(&fscache_n_cop_lookup_complete),
217 atomic_read(&fscache_n_cop_grab_object));
218 seq_printf(m, "CacheOp: upo=%d dro=%d pto=%d atc=%d syn=%d\n",
219 atomic_read(&fscache_n_cop_update_object),
220 atomic_read(&fscache_n_cop_drop_object),
221 atomic_read(&fscache_n_cop_put_object),
222 atomic_read(&fscache_n_cop_attr_changed),
223 atomic_read(&fscache_n_cop_sync_cache));
224 seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n",
225 atomic_read(&fscache_n_cop_read_or_alloc_page),
226 atomic_read(&fscache_n_cop_read_or_alloc_pages),
227 atomic_read(&fscache_n_cop_allocate_page),
228 atomic_read(&fscache_n_cop_allocate_pages),
229 atomic_read(&fscache_n_cop_write_page),
230 atomic_read(&fscache_n_cop_uncache_page),
231 atomic_read(&fscache_n_cop_dissociate_pages));
195 return 0; 232 return 0;
196} 233}
197 234