Rename [pl]blk_alloc to [pl]blk_used
Also a bit of minor cleanup.
This commit is contained in:
parent
e70d283921
commit
efc83e0dc2
|
@ -259,7 +259,8 @@ do_stats(int argc, char** argv)
|
|||
|
||||
cbd_stats(name, &stats);
|
||||
printf("Stats:\n");
|
||||
printf("pblk alloc: %lu\n", (unsigned long)stats.pblk_alloc);
|
||||
printf("pblk used: %lu\n", (unsigned long)stats.pblk_used);
|
||||
printf("lblk used: %lu\n", (unsigned long)stats.lblk_used);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -160,8 +160,8 @@ compress_read_header(struct compress* c)
|
|||
printk(KERN_INFO " nr_zones=%u\n", (unsigned int)header.params.nr_zones);
|
||||
printk(KERN_INFO " lblk_per_zone=%u\n", (unsigned int)header.params.lblk_per_zone);
|
||||
printk(KERN_INFO "%s: stats...\n", __func__);
|
||||
printk(KERN_INFO " pblk_used=%lu\n", (unsigned long)header.stats.pblk_alloc);
|
||||
printk(KERN_INFO " lblk_used=%lu\n", (unsigned long)header.stats.lblk_alloc);
|
||||
printk(KERN_INFO " pblk_used=%lu\n", (unsigned long)header.stats.pblk_used);
|
||||
printk(KERN_INFO " lblk_used=%lu\n", (unsigned long)header.stats.lblk_used);
|
||||
|
||||
memcpy(&c->kparams.params, &header.params, sizeof(header.params));
|
||||
memcpy(&c->kstats.stats, &header.stats, sizeof(header.stats));
|
||||
|
@ -327,14 +327,14 @@ compress_attr_show(struct kobject* kobj, struct attribute* attr,
|
|||
val = PBLK_SIZE * lblk_per_pblk(&c->kparams.params);
|
||||
break;
|
||||
case attr_pblk_used:
|
||||
val = c->kstats.stats.pblk_alloc;
|
||||
val = c->kstats.stats.pblk_used;
|
||||
break;
|
||||
case attr_pblk_total:
|
||||
val = pbat_len(&c->kparams.params) * PBLK_SIZE_BITS *
|
||||
c->kparams.params.nr_zones;
|
||||
break;
|
||||
case attr_lblk_used:
|
||||
val = c->kstats.stats.lblk_alloc;
|
||||
val = c->kstats.stats.lblk_used;
|
||||
break;
|
||||
case attr_lblk_total:
|
||||
val = c->kparams.params.lblk_per_zone *
|
||||
|
@ -452,9 +452,8 @@ compress_unregister_sysfs(struct compress* c)
|
|||
* end_sector is the ending sector of the backing device.
|
||||
* compress is the name of this module.
|
||||
* backing_device is the name backing device.
|
||||
* args is:
|
||||
* create [lblk_shift=#]
|
||||
* open
|
||||
* args may include:
|
||||
* cache_pages=#
|
||||
* compress_name is the name of the compress device.
|
||||
*/
|
||||
static int
|
||||
|
@ -484,16 +483,6 @@ compress_ctr(struct dm_target *ti, unsigned int argc, char **argv)
|
|||
if (eq) {
|
||||
val = eq + 1;
|
||||
}
|
||||
#if 0
|
||||
if (!memcmp(arg, "verbose", 7)) {
|
||||
err = kstrtouint(eq + 1, 0, &verbose_level);
|
||||
if (err) {
|
||||
ti->error = "Failed to parse verbose";
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* XXX: Parse suffixes */
|
||||
if (!memcmp(arg, "cache_pages", 7)) {
|
||||
err = kstrtouint(eq + 1, 0, &cache_pages);
|
||||
|
|
|
@ -382,15 +382,15 @@ do_free:
|
|||
elem_lelen = __cpu_to_le32(len);
|
||||
lbatview_wmem(lv, elem_off, lba_elem_len_bytes(&lv->kparams->params), &elem_lelen);
|
||||
mutex_lock(&lv->kstats->lock);
|
||||
lv->kstats->stats.pblk_alloc += req_nalloc - old_nalloc;
|
||||
lv->kstats->stats.pblk_used += req_nalloc - old_nalloc;
|
||||
if (old_nalloc == 0) {
|
||||
if (req_nalloc != 0) {
|
||||
++lv->kstats->stats.lblk_alloc;
|
||||
++lv->kstats->stats.lblk_used;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (req_nalloc == 0) {
|
||||
--lv->kstats->stats.lblk_alloc;
|
||||
--lv->kstats->stats.lblk_used;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&lv->kstats->lock);
|
||||
|
|
|
@ -51,8 +51,8 @@ struct cbd_params {
|
|||
};
|
||||
|
||||
struct cbd_stats {
|
||||
u64 pblk_alloc;
|
||||
u64 lblk_alloc;
|
||||
u64 pblk_used;
|
||||
u64 lblk_used;
|
||||
};
|
||||
|
||||
struct cbd_header {
|
||||
|
@ -351,8 +351,8 @@ cbd_header_get(const u8* buf, struct cbd_header* header)
|
|||
header->params.nr_zones = get32_le(&buf);
|
||||
header->params.lblk_per_zone = get32_le(&buf);
|
||||
buf += 32; /* Reserved */
|
||||
header->stats.pblk_alloc = get64_le(&buf);
|
||||
header->stats.lblk_alloc = get64_le(&buf);
|
||||
header->stats.pblk_used = get64_le(&buf);
|
||||
header->stats.lblk_used = get64_le(&buf);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -370,8 +370,8 @@ cbd_header_put(u8* buf, const struct cbd_header* header)
|
|||
put32_le(&buf, header->params.nr_zones);
|
||||
put32_le(&buf, header->params.lblk_per_zone);
|
||||
buf += 32; /* Reserved */
|
||||
put64_le(&buf, header->stats.pblk_alloc);
|
||||
put64_le(&buf, header->stats.lblk_alloc);
|
||||
put64_le(&buf, header->stats.pblk_used);
|
||||
put64_le(&buf, header->stats.lblk_used);
|
||||
}
|
||||
|
||||
static inline u32
|
||||
|
|
|
@ -7,27 +7,13 @@
|
|||
typedef off_t off64_t;
|
||||
#include <zlib.h>
|
||||
|
||||
/*
|
||||
* Problem:
|
||||
* - Memory usage is rather high (1.5gb for 700gb device).
|
||||
* - Startup is quite long.
|
||||
* Fix:
|
||||
* - Do not read lbat at start, read in check_lbat().
|
||||
* - Do not read pbat at start, read in check_pbat().
|
||||
*
|
||||
* Update stats as we go (pblk_alloc etc.)
|
||||
*
|
||||
* With the above, struct zone_metadata name is not really accurate.
|
||||
* Name it something else, like...???
|
||||
*/
|
||||
|
||||
struct check_state
|
||||
{
|
||||
int fd;
|
||||
bool check_lblk_data;
|
||||
bool clean;
|
||||
u64 pblk_alloc;
|
||||
u64 lblk_alloc;
|
||||
u64 pblk_used;
|
||||
u64 lblk_used;
|
||||
u8** pbatv;
|
||||
|
||||
u8* compress_buf;
|
||||
|
@ -354,8 +340,8 @@ check_lbat(struct check_state* state, const struct cbd_params* params)
|
|||
}
|
||||
len = lba_len_get(params, buf);
|
||||
if (len != 0) {
|
||||
++state->lblk_alloc;
|
||||
state->pblk_alloc += DIV_ROUND_UP(len, PBLK_SIZE);
|
||||
++state->lblk_used;
|
||||
state->pblk_used += DIV_ROUND_UP(len, PBLK_SIZE);
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
|
@ -437,17 +423,17 @@ cbd_check(const char* dev,
|
|||
free(state.pbatv);
|
||||
|
||||
if (state.clean) {
|
||||
if (state.pblk_alloc != header.stats.pblk_alloc) {
|
||||
verbose(1, "pblk alloc incorrect (%lu expected, %lu found), fixing\n",
|
||||
(unsigned long)state.pblk_alloc,
|
||||
(unsigned long)header.stats.pblk_alloc);
|
||||
header.stats.pblk_alloc = state.pblk_alloc;
|
||||
if (state.pblk_used != header.stats.pblk_used) {
|
||||
verbose(1, "pblk used incorrect (%lu expected, %lu found), fixing\n",
|
||||
(unsigned long)state.pblk_used,
|
||||
(unsigned long)header.stats.pblk_used);
|
||||
header.stats.pblk_used = state.pblk_used;
|
||||
}
|
||||
if (state.lblk_alloc != header.stats.lblk_alloc) {
|
||||
verbose(1, "lblk alloc incorrect (%lu expected, %lu found), fixing\n",
|
||||
(unsigned long)state.lblk_alloc,
|
||||
(unsigned long)header.stats.lblk_alloc);
|
||||
header.stats.lblk_alloc = state.lblk_alloc;
|
||||
if (state.lblk_used != header.stats.lblk_used) {
|
||||
verbose(1, "lblk used incorrect (%lu expected, %lu found), fixing\n",
|
||||
(unsigned long)state.lblk_used,
|
||||
(unsigned long)header.stats.lblk_used);
|
||||
header.stats.lblk_used = state.lblk_used;
|
||||
}
|
||||
header.params.flags &= ~(CBD_FLAG_ERROR | CBD_FLAG_DIRTY);
|
||||
cbd_header_put(pblkbuf, &header);
|
||||
|
|
Loading…
Reference in New Issue