mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: support newer thin pool status parameters
Support read_only and discards information.
This commit is contained in:
parent
c1becaefe5
commit
d2eae42c0e
@ -1,5 +1,6 @@
|
||||
Version 1.02.78 -
|
||||
===================================
|
||||
Extend support for status info of thin pool target.
|
||||
Fix segfault for truncated string token in config file after the first '"'.
|
||||
Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
|
||||
Fix resource leak in error path of dmeventd's umount of thin volume.
|
||||
|
@ -279,6 +279,12 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
/*
|
||||
* Parse params from STATUS call for thin_pool target
|
||||
*/
|
||||
typedef enum {
|
||||
DM_THIN_DISCARDS_IGNORE,
|
||||
DM_THIN_DISCARDS_NO_PASSDOWN,
|
||||
DM_THIN_DISCARDS_PASSDOWN
|
||||
} dm_thin_discards_t;
|
||||
|
||||
struct dm_status_thin_pool {
|
||||
uint64_t transaction_id;
|
||||
uint64_t used_metadata_blocks;
|
||||
@ -286,6 +292,8 @@ struct dm_status_thin_pool {
|
||||
uint64_t used_data_blocks;
|
||||
uint64_t total_data_blocks;
|
||||
uint64_t held_metadata_root;
|
||||
uint32_t read_only;
|
||||
dm_thin_discards_t discards;
|
||||
};
|
||||
|
||||
int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
|
||||
|
@ -3295,6 +3295,7 @@ int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
|
||||
struct dm_status_thin_pool **status)
|
||||
{
|
||||
struct dm_status_thin_pool *s;
|
||||
int pos;
|
||||
|
||||
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
|
||||
log_error("Failed to allocate thin_pool status structure.");
|
||||
@ -3302,16 +3303,26 @@ int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
|
||||
}
|
||||
|
||||
/* FIXME: add support for held metadata root */
|
||||
if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
|
||||
if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64 "%n",
|
||||
&s->transaction_id,
|
||||
&s->used_metadata_blocks,
|
||||
&s->total_metadata_blocks,
|
||||
&s->used_data_blocks,
|
||||
&s->total_data_blocks) != 5) {
|
||||
&s->total_data_blocks, &pos) < 5) {
|
||||
log_error("Failed to parse thin pool params: %s.", params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* New status flags */
|
||||
if (strstr(params + pos, "no_discard_passdown"))
|
||||
s->discards = DM_THIN_DISCARDS_NO_PASSDOWN;
|
||||
else if (strstr(params + pos, "ignore_discard"))
|
||||
s->discards = DM_THIN_DISCARDS_IGNORE;
|
||||
else /* default discard_passdown */
|
||||
s->discards = DM_THIN_DISCARDS_PASSDOWN;
|
||||
|
||||
s->read_only = (strstr(params + pos, "ro ")) ? 1 : 0;
|
||||
|
||||
*status = s;
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user