1
0
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:
Zdenek Kabelac 2012-12-10 10:23:17 +01:00
parent c1becaefe5
commit d2eae42c0e
3 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.78 - 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 '"'. Fix segfault for truncated string token in config file after the first '"'.
Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC). Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
Fix resource leak in error path of dmeventd's umount of thin volume. Fix resource leak in error path of dmeventd's umount of thin volume.

View File

@ -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 * 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 { struct dm_status_thin_pool {
uint64_t transaction_id; uint64_t transaction_id;
uint64_t used_metadata_blocks; uint64_t used_metadata_blocks;
@ -286,6 +292,8 @@ struct dm_status_thin_pool {
uint64_t used_data_blocks; uint64_t used_data_blocks;
uint64_t total_data_blocks; uint64_t total_data_blocks;
uint64_t held_metadata_root; 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, int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,

View File

@ -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 **status)
{ {
struct dm_status_thin_pool *s; struct dm_status_thin_pool *s;
int pos;
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) { if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
log_error("Failed to allocate thin_pool status structure."); 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 */ /* 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->transaction_id,
&s->used_metadata_blocks, &s->used_metadata_blocks,
&s->total_metadata_blocks, &s->total_metadata_blocks,
&s->used_data_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); log_error("Failed to parse thin pool params: %s.", params);
return 0; 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; *status = s;
return 1; return 1;