sysfs.c (46451874c7c9afaa4e014aea0f0970f886444e0d) | sysfs.c (6f10f7d1b02b1bbc305f88d7696445dd38b13881) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * bcache sysfs interfaces 4 * 5 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 6 * Copyright 2012 Google, Inc. 7 */ 8 --- 293 unchanged lines hidden (view full) --- 302 strtoul_or_return(buf)) 303 bch_cached_dev_run(dc); 304 305 if (attr == &sysfs_cache_mode) { 306 v = __sysfs_match_string(bch_cache_modes, -1, buf); 307 if (v < 0) 308 return v; 309 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * bcache sysfs interfaces 4 * 5 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 6 * Copyright 2012 Google, Inc. 7 */ 8 --- 293 unchanged lines hidden (view full) --- 302 strtoul_or_return(buf)) 303 bch_cached_dev_run(dc); 304 305 if (attr == &sysfs_cache_mode) { 306 v = __sysfs_match_string(bch_cache_modes, -1, buf); 307 if (v < 0) 308 return v; 309 |
310 if ((unsigned) v != BDEV_CACHE_MODE(&dc->sb)) { | 310 if ((unsigned int) v != BDEV_CACHE_MODE(&dc->sb)) { |
311 SET_BDEV_CACHE_MODE(&dc->sb, v); 312 bch_write_bdev_super(dc, NULL); 313 } 314 } 315 316 if (attr == &sysfs_stop_when_cache_set_failed) { 317 v = __sysfs_match_string(bch_stop_on_failure_modes, -1, buf); 318 if (v < 0) --- 209 unchanged lines hidden (view full) --- 528 "floats: %zu\n" 529 "failed: %zu\n", 530 op.nodes, 531 op.stats.sets_written, op.stats.sets_unwritten, 532 op.stats.bytes_written, op.stats.bytes_unwritten, 533 op.stats.floats, op.stats.failed); 534} 535 | 311 SET_BDEV_CACHE_MODE(&dc->sb, v); 312 bch_write_bdev_super(dc, NULL); 313 } 314 } 315 316 if (attr == &sysfs_stop_when_cache_set_failed) { 317 v = __sysfs_match_string(bch_stop_on_failure_modes, -1, buf); 318 if (v < 0) --- 209 unchanged lines hidden (view full) --- 528 "floats: %zu\n" 529 "failed: %zu\n", 530 op.nodes, 531 op.stats.sets_written, op.stats.sets_unwritten, 532 op.stats.bytes_written, op.stats.bytes_unwritten, 533 op.stats.floats, op.stats.failed); 534} 535 |
536static unsigned bch_root_usage(struct cache_set *c) | 536static unsigned int bch_root_usage(struct cache_set *c) |
537{ | 537{ |
538 unsigned bytes = 0; | 538 unsigned int bytes = 0; |
539 struct bkey *k; 540 struct btree *b; 541 struct btree_iter iter; 542 543 goto lock_root; 544 545 do { 546 rw_unlock(false, b); --- 18 unchanged lines hidden (view full) --- 565 mutex_lock(&c->bucket_lock); 566 list_for_each_entry(b, &c->btree_cache, list) 567 ret += 1 << (b->keys.page_order + PAGE_SHIFT); 568 569 mutex_unlock(&c->bucket_lock); 570 return ret; 571} 572 | 539 struct bkey *k; 540 struct btree *b; 541 struct btree_iter iter; 542 543 goto lock_root; 544 545 do { 546 rw_unlock(false, b); --- 18 unchanged lines hidden (view full) --- 565 mutex_lock(&c->bucket_lock); 566 list_for_each_entry(b, &c->btree_cache, list) 567 ret += 1 << (b->keys.page_order + PAGE_SHIFT); 568 569 mutex_unlock(&c->bucket_lock); 570 return ret; 571} 572 |
573static unsigned bch_cache_max_chain(struct cache_set *c) | 573static unsigned int bch_cache_max_chain(struct cache_set *c) |
574{ | 574{ |
575 unsigned ret = 0; | 575 unsigned int ret = 0; |
576 struct hlist_head *h; 577 578 mutex_lock(&c->bucket_lock); 579 580 for (h = c->bucket_hash; 581 h < c->bucket_hash + (1 << BUCKET_HASH_BITS); 582 h++) { | 576 struct hlist_head *h; 577 578 mutex_lock(&c->bucket_lock); 579 580 for (h = c->bucket_hash; 581 h < c->bucket_hash + (1 << BUCKET_HASH_BITS); 582 h++) { |
583 unsigned i = 0; | 583 unsigned int i = 0; |
584 struct hlist_node *p; 585 586 hlist_for_each(p, h) 587 i++; 588 589 ret = max(ret, i); 590 } 591 592 mutex_unlock(&c->bucket_lock); 593 return ret; 594} 595 | 584 struct hlist_node *p; 585 586 hlist_for_each(p, h) 587 i++; 588 589 ret = max(ret, i); 590 } 591 592 mutex_unlock(&c->bucket_lock); 593 return ret; 594} 595 |
596static unsigned bch_btree_used(struct cache_set *c) | 596static unsigned int bch_btree_used(struct cache_set *c) |
597{ 598 return div64_u64(c->gc_stats.key_bytes * 100, 599 (c->gc_stats.nodes ?: 1) * btree_bytes(c)); 600} 601 | 597{ 598 return div64_u64(c->gc_stats.key_bytes * 100, 599 (c->gc_stats.nodes ?: 1) * btree_bytes(c)); 600} 601 |
602static unsigned bch_average_key_size(struct cache_set *c) | 602static unsigned int bch_average_key_size(struct cache_set *c) |
603{ 604 return c->gc_stats.nkeys 605 ? div64_u64(c->gc_stats.data, c->gc_stats.nkeys) 606 : 0; 607} 608 609SHOW(__bch_cache_set) 610{ --- 380 unchanged lines hidden (view full) --- 991 } 992 } 993 994 if (attr == &sysfs_cache_replacement_policy) { 995 v = __sysfs_match_string(cache_replacement_policies, -1, buf); 996 if (v < 0) 997 return v; 998 | 603{ 604 return c->gc_stats.nkeys 605 ? div64_u64(c->gc_stats.data, c->gc_stats.nkeys) 606 : 0; 607} 608 609SHOW(__bch_cache_set) 610{ --- 380 unchanged lines hidden (view full) --- 991 } 992 } 993 994 if (attr == &sysfs_cache_replacement_policy) { 995 v = __sysfs_match_string(cache_replacement_policies, -1, buf); 996 if (v < 0) 997 return v; 998 |
999 if ((unsigned) v != CACHE_REPLACEMENT(&ca->sb)) { | 999 if ((unsigned int) v != CACHE_REPLACEMENT(&ca->sb)) { |
1000 mutex_lock(&ca->set->bucket_lock); 1001 SET_CACHE_REPLACEMENT(&ca->sb, v); 1002 mutex_unlock(&ca->set->bucket_lock); 1003 1004 bcache_write_super(ca->set); 1005 } 1006 } 1007 --- 27 unchanged lines hidden --- | 1000 mutex_lock(&ca->set->bucket_lock); 1001 SET_CACHE_REPLACEMENT(&ca->sb, v); 1002 mutex_unlock(&ca->set->bucket_lock); 1003 1004 bcache_write_super(ca->set); 1005 } 1006 } 1007 --- 27 unchanged lines hidden --- |