aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/namei.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2015-02-19 18:47:31 -0500
committerDavid Howells <dhowells@redhat.com>2015-02-24 05:05:27 -0500
commit182d919b84902eece162c63ed3d476c8016b4197 (patch)
treec2f02f26cdcaa4718121c94e8b050a598fab5f8c /fs/cachefiles/namei.c
parentb2b89ebfc0f0287e20516a5443d93af309b800cf (diff)
FS-Cache: Count culled objects and objects rejected due to lack of space
Count the number of objects that get culled by the cache backend and the number of objects that the cache backend declines to instantiate due to lack of space in the cache. These numbers are made available through /proc/fs/fscache/stats Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Steve Dickson <steved@redhat.com> Acked-by: Jeff Layton <jeff.layton@primarydata.com>
Diffstat (limited to 'fs/cachefiles/namei.c')
-rw-r--r--fs/cachefiles/namei.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 7f8e83f9d74e..1d60195fc518 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -97,7 +97,8 @@ static noinline void cachefiles_printk_object(struct cachefiles_object *object,
97 * call vfs_unlink(), vfs_rmdir() or vfs_rename() 97 * call vfs_unlink(), vfs_rmdir() or vfs_rename()
98 */ 98 */
99static void cachefiles_mark_object_buried(struct cachefiles_cache *cache, 99static void cachefiles_mark_object_buried(struct cachefiles_cache *cache,
100 struct dentry *dentry) 100 struct dentry *dentry,
101 enum fscache_why_object_killed why)
101{ 102{
102 struct cachefiles_object *object; 103 struct cachefiles_object *object;
103 struct rb_node *p; 104 struct rb_node *p;
@@ -132,8 +133,9 @@ found_dentry:
132 pr_err("\n"); 133 pr_err("\n");
133 pr_err("Error: Can't preemptively bury live object\n"); 134 pr_err("Error: Can't preemptively bury live object\n");
134 cachefiles_printk_object(object, NULL); 135 cachefiles_printk_object(object, NULL);
135 } else if (test_and_set_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { 136 } else {
136 pr_err("Error: Object already preemptively buried\n"); 137 if (why != FSCACHE_OBJECT_IS_STALE)
138 fscache_object_mark_killed(&object->fscache, why);
137 } 139 }
138 140
139 write_unlock(&cache->active_lock); 141 write_unlock(&cache->active_lock);
@@ -265,7 +267,8 @@ requeue:
265static int cachefiles_bury_object(struct cachefiles_cache *cache, 267static int cachefiles_bury_object(struct cachefiles_cache *cache,
266 struct dentry *dir, 268 struct dentry *dir,
267 struct dentry *rep, 269 struct dentry *rep,
268 bool preemptive) 270 bool preemptive,
271 enum fscache_why_object_killed why)
269{ 272{
270 struct dentry *grave, *trap; 273 struct dentry *grave, *trap;
271 struct path path, path_to_graveyard; 274 struct path path, path_to_graveyard;
@@ -289,7 +292,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
289 ret = vfs_unlink(dir->d_inode, rep, NULL); 292 ret = vfs_unlink(dir->d_inode, rep, NULL);
290 293
291 if (preemptive) 294 if (preemptive)
292 cachefiles_mark_object_buried(cache, rep); 295 cachefiles_mark_object_buried(cache, rep, why);
293 } 296 }
294 297
295 mutex_unlock(&dir->d_inode->i_mutex); 298 mutex_unlock(&dir->d_inode->i_mutex);
@@ -394,7 +397,7 @@ try_again:
394 "Rename failed with error %d", ret); 397 "Rename failed with error %d", ret);
395 398
396 if (preemptive) 399 if (preemptive)
397 cachefiles_mark_object_buried(cache, rep); 400 cachefiles_mark_object_buried(cache, rep, why);
398 } 401 }
399 402
400 unlock_rename(cache->graveyard, dir); 403 unlock_rename(cache->graveyard, dir);
@@ -422,7 +425,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
422 425
423 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 426 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
424 427
425 if (test_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { 428 if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) {
426 /* object allocation for the same key preemptively deleted this 429 /* object allocation for the same key preemptively deleted this
427 * object's file so that it could create its own file */ 430 * object's file so that it could create its own file */
428 _debug("object preemptively buried"); 431 _debug("object preemptively buried");
@@ -433,7 +436,8 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
433 * may have been renamed */ 436 * may have been renamed */
434 if (dir == object->dentry->d_parent) { 437 if (dir == object->dentry->d_parent) {
435 ret = cachefiles_bury_object(cache, dir, 438 ret = cachefiles_bury_object(cache, dir,
436 object->dentry, false); 439 object->dentry, false,
440 FSCACHE_OBJECT_WAS_RETIRED);
437 } else { 441 } else {
438 /* it got moved, presumably by cachefilesd culling it, 442 /* it got moved, presumably by cachefilesd culling it,
439 * so it's no longer in the key path and we can ignore 443 * so it's no longer in the key path and we can ignore
@@ -522,7 +526,7 @@ lookup_again:
522 if (!next->d_inode) { 526 if (!next->d_inode) {
523 ret = cachefiles_has_space(cache, 1, 0); 527 ret = cachefiles_has_space(cache, 1, 0);
524 if (ret < 0) 528 if (ret < 0)
525 goto create_error; 529 goto no_space_error;
526 530
527 path.dentry = dir; 531 path.dentry = dir;
528 ret = security_path_mkdir(&path, next, 0); 532 ret = security_path_mkdir(&path, next, 0);
@@ -551,7 +555,7 @@ lookup_again:
551 if (!next->d_inode) { 555 if (!next->d_inode) {
552 ret = cachefiles_has_space(cache, 1, 0); 556 ret = cachefiles_has_space(cache, 1, 0);
553 if (ret < 0) 557 if (ret < 0)
554 goto create_error; 558 goto no_space_error;
555 559
556 path.dentry = dir; 560 path.dentry = dir;
557 ret = security_path_mknod(&path, next, S_IFREG, 0); 561 ret = security_path_mknod(&path, next, S_IFREG, 0);
@@ -602,7 +606,8 @@ lookup_again:
602 * mutex) */ 606 * mutex) */
603 object->dentry = NULL; 607 object->dentry = NULL;
604 608
605 ret = cachefiles_bury_object(cache, dir, next, true); 609 ret = cachefiles_bury_object(cache, dir, next, true,
610 FSCACHE_OBJECT_IS_STALE);
606 dput(next); 611 dput(next);
607 next = NULL; 612 next = NULL;
608 613
@@ -610,6 +615,7 @@ lookup_again:
610 goto delete_error; 615 goto delete_error;
611 616
612 _debug("redo lookup"); 617 _debug("redo lookup");
618 fscache_object_retrying_stale(&object->fscache);
613 goto lookup_again; 619 goto lookup_again;
614 } 620 }
615 } 621 }
@@ -662,6 +668,8 @@ lookup_again:
662 _leave(" = 0 [%lu]", object->dentry->d_inode->i_ino); 668 _leave(" = 0 [%lu]", object->dentry->d_inode->i_ino);
663 return 0; 669 return 0;
664 670
671no_space_error:
672 fscache_object_mark_killed(&object->fscache, FSCACHE_OBJECT_NO_SPACE);
665create_error: 673create_error:
666 _debug("create error %d", ret); 674 _debug("create error %d", ret);
667 if (ret == -EIO) 675 if (ret == -EIO)
@@ -927,7 +935,8 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
927 /* actually remove the victim (drops the dir mutex) */ 935 /* actually remove the victim (drops the dir mutex) */
928 _debug("bury"); 936 _debug("bury");
929 937
930 ret = cachefiles_bury_object(cache, dir, victim, false); 938 ret = cachefiles_bury_object(cache, dir, victim, false,
939 FSCACHE_OBJECT_WAS_CULLED);
931 if (ret < 0) 940 if (ret < 0)
932 goto error; 941 goto error;
933 942