mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-03-10 00:00:04 +03:00
bcacheadm: fix capacity command
regression from 5730e47b
Signed-off-by: Jacob Malevich <jam@daterainc.com>
Issue DAT-1977
Change-Id: I598ca9e5623fde441bb842580c2494fd03316f00
This commit is contained in:
parent
ffb068c2b4
commit
eb1d49d3f1
31
bcache.c
31
bcache.c
@ -1405,24 +1405,24 @@ char *bcache_get_capacity(const char *cset_dir, const char *capacity_uuid,
|
|||||||
double avail_buckets[MAX_DEVS];
|
double avail_buckets[MAX_DEVS];
|
||||||
char *dev_names[MAX_DEVS];
|
char *dev_names[MAX_DEVS];
|
||||||
int dev_count = 0, i;
|
int dev_count = 0, i;
|
||||||
char intbuf[4];
|
|
||||||
double total_cap = 0, total_free = 0;
|
double total_cap = 0, total_free = 0;
|
||||||
int precision = 2;
|
int precision = 2;
|
||||||
|
|
||||||
snprintf(bucket_size_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
|
|
||||||
capacity_uuid, "cache0", "bucket_size_bytes");
|
|
||||||
snprintf(nbuckets_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
|
|
||||||
capacity_uuid, "cache0", "nbuckets");
|
|
||||||
snprintf(avail_buckets_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
|
|
||||||
capacity_uuid, "cache0", "available_buckets");
|
|
||||||
snprintf(cache_path, MAX_PATH, "%s/%s/%s", cset_dir, capacity_uuid,
|
|
||||||
"cache0");
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
int len;
|
int len;
|
||||||
DIR *cache_dir;
|
DIR *cache_dir;
|
||||||
|
|
||||||
|
snprintf(bucket_size_path, sizeof(bucket_size_path), "%s/%s/%s%d/%s", cset_dir,
|
||||||
|
capacity_uuid, "cache", dev_count, "bucket_size_bytes");
|
||||||
|
snprintf(nbuckets_path, sizeof(nbuckets_path), "%s/%s/%s%d/%s", cset_dir,
|
||||||
|
capacity_uuid, "cache", dev_count, "nbuckets");
|
||||||
|
snprintf(avail_buckets_path, sizeof(avail_buckets_path), "%s/%s/%s%d/%s", cset_dir,
|
||||||
|
capacity_uuid, "cache", dev_count, "available_buckets");
|
||||||
|
snprintf(cache_path, sizeof(cache_path), "%s/%s/%s%d", cset_dir, capacity_uuid,
|
||||||
|
"cache", dev_count);
|
||||||
|
|
||||||
if((cache_dir = opendir(cache_path)) == NULL)
|
if((cache_dir = opendir(cache_path)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1452,20 +1452,7 @@ char *bcache_get_capacity(const char *cset_dir, const char *capacity_uuid,
|
|||||||
dev_names[dev_count] = dev_name(buf);
|
dev_names[dev_count] = dev_name(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(intbuf, 4, "%d", dev_count);
|
|
||||||
|
|
||||||
/* remove i/stat and append i++/stat */
|
|
||||||
bucket_size_path[strlen(cache_path) - strlen(intbuf)] = 0;
|
|
||||||
nbuckets_path[strlen(cache_path) - strlen(intbuf)] = 0;
|
|
||||||
avail_buckets_path[strlen(cache_path) - strlen(intbuf)] = 0;
|
|
||||||
cache_path[strlen(cache_path) - strlen(intbuf)] = 0;
|
|
||||||
|
|
||||||
dev_count++;
|
dev_count++;
|
||||||
|
|
||||||
strcat(cache_path, intbuf);
|
|
||||||
strcat(bucket_size_path, intbuf);
|
|
||||||
strcat(nbuckets_path, intbuf);
|
|
||||||
strcat(avail_buckets_path, intbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%-15s%-25s%-25s\n", "Device Name", "Capacity (512 Blocks)", "Free (512 Blocks)");
|
printf("%-15s%-25s%-25s\n", "Device Name", "Capacity (512 Blocks)", "Free (512 Blocks)");
|
||||||
|
@ -270,7 +270,7 @@ static NihOption status_options[] = {
|
|||||||
|
|
||||||
static NihOption capacity_options[] = {
|
static NihOption capacity_options[] = {
|
||||||
{'u', "set", N_("cache_set UUID"), NULL, "UUID", &capacity_uuid, NULL},
|
{'u', "set", N_("cache_set UUID"), NULL, "UUID", &capacity_uuid, NULL},
|
||||||
{'d', "devs", N_("dev UUID"), NULL, NULL, &capacity_devs, NULL},
|
{'d', "devs", N_("Individual device capacities"), NULL, NULL, &capacity_devs, NULL},
|
||||||
NIH_OPTION_LAST
|
NIH_OPTION_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user