mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: add dm_get_status_snapshot
Add dm_get_status_snapshot() for parsing snapshot status.
This commit is contained in:
parent
3ba3bc0d66
commit
4707ac7200
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.78 -
|
Version 1.02.78 -
|
||||||
===================================
|
===================================
|
||||||
|
Add dm_get_status_snapshot() for parsing snapshot status.
|
||||||
Detecte mounted fs also via reading /proc/self/mountinfo.
|
Detecte mounted fs also via reading /proc/self/mountinfo.
|
||||||
Add dm_mountinfo_read() for parsing /proc/self/mountinfo.
|
Add dm_mountinfo_read() for parsing /proc/self/mountinfo.
|
||||||
Report error for nonexisting devices in dmeventd communication.
|
Report error for nonexisting devices in dmeventd communication.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of the device-mapper userspace tools.
|
* This file is part of the device-mapper userspace tools.
|
||||||
*
|
*
|
||||||
@ -286,6 +286,24 @@ struct dm_status_raid {
|
|||||||
int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||||
struct dm_status_raid **status);
|
struct dm_status_raid **status);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Snapshot target's format:
|
||||||
|
* <= 1.7.0: <used_sectors>/<total_sectors>
|
||||||
|
* >= 1.8.0: <used_sectors>/<total_sectors> <metadata_sectors>
|
||||||
|
*/
|
||||||
|
struct dm_status_snapshot {
|
||||||
|
uint64_t used_sectors; /* in 512b units */
|
||||||
|
uint64_t total_sectors;
|
||||||
|
uint64_t metadata_sectors;
|
||||||
|
unsigned has_metadata_sectors : 1; /* set when metadata_sectors is present */
|
||||||
|
unsigned invalid : 1; /* set when snapshot is invalidated */
|
||||||
|
unsigned merge_failed : 1; /* set when snapshot merge failed */
|
||||||
|
};
|
||||||
|
|
||||||
|
int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
|
||||||
|
struct dm_status_snapshot **status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse params from STATUS call for thin_pool target
|
* Parse params from STATUS call for thin_pool target
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2012 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2005-2013 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of the device-mapper userspace tools.
|
* This file is part of the device-mapper userspace tools.
|
||||||
*
|
*
|
||||||
@ -2718,6 +2718,43 @@ int dm_tree_node_add_snapshot_merge_target(struct dm_tree_node *node,
|
|||||||
merge_uuid, 1, chunk_size);
|
merge_uuid, 1, chunk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
|
||||||
|
struct dm_status_snapshot **status)
|
||||||
|
{
|
||||||
|
struct dm_status_snapshot *s;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (!params) {
|
||||||
|
log_error("Failed to parse invalid snapshot params.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(s = dm_pool_zalloc(mem, sizeof(*s)))) {
|
||||||
|
log_error("Failed to allocate snapshot status structure.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sscanf(params, "%" PRIu64 "/%" PRIu64 " %" PRIu64,
|
||||||
|
&s->used_sectors, &s->total_sectors,
|
||||||
|
&s->metadata_sectors);
|
||||||
|
|
||||||
|
if (r == 3 || r == 2)
|
||||||
|
s->has_metadata_sectors = (r == 3);
|
||||||
|
else if (!strcmp(params, "Invalid"))
|
||||||
|
s->invalid = 1;
|
||||||
|
else if (!strcmp(params, "Merge failed"))
|
||||||
|
s->merge_failed = 1;
|
||||||
|
else {
|
||||||
|
dm_pool_free(mem, s);
|
||||||
|
log_error("Failed to parse snapshot params: %s.", params);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*status = s;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int dm_tree_node_add_error_target(struct dm_tree_node *node,
|
int dm_tree_node_add_error_target(struct dm_tree_node *node,
|
||||||
uint64_t size)
|
uint64_t size)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user