mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: add dm_stats_bind_from_fd()
dmsetup already has a version of this function, and dmfilemapd will need it too: move it to libdevmapper to avoid copying it around.
This commit is contained in:
parent
009b711834
commit
c90e9392e4
@ -1,5 +1,6 @@
|
||||
Version 1.02.138 -
|
||||
=====================================
|
||||
Add dm_stats_bind_from_fd() to bind a stats handle from a file descriptor.
|
||||
Do not try call callback when reverting activation on error path.
|
||||
Fix file mapping for extents with physically adjacent extents.
|
||||
Validation vsnprintf result in runtime translate of dm_log (1.02.136).
|
||||
|
@ -1,3 +1,4 @@
|
||||
dm_bit_get_last
|
||||
dm_bit_get_prev
|
||||
dm_bitset_parse_list
|
||||
dm_stats_bind_from_fd
|
||||
|
@ -517,6 +517,16 @@ int dm_stats_bind_name(struct dm_stats *dms, const char *name);
|
||||
*/
|
||||
int dm_stats_bind_uuid(struct dm_stats *dms, const char *uuid);
|
||||
|
||||
/*
|
||||
* Bind a dm_stats handle to the device backing the file referenced
|
||||
* by the specified file descriptor.
|
||||
*
|
||||
* File descriptor fd must reference a regular file, open for reading,
|
||||
* in a local file system, backed by a device-mapper device, that
|
||||
* supports the FIEMAP ioctl, and that returns data describing the
|
||||
* physical location of extents.
|
||||
*/
|
||||
int dm_stats_bind_from_fd(struct dm_stats *dms, int fd);
|
||||
/*
|
||||
* Test whether the running kernel supports the precise_timestamps
|
||||
* feature. Presence of this feature also implies histogram support.
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "dmlib.h"
|
||||
#include "kdev_t.h"
|
||||
|
||||
#include "math.h" /* log10() */
|
||||
|
||||
@ -452,6 +453,24 @@ int dm_stats_bind_uuid(struct dm_stats *dms, const char *uuid)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_stats_bind_from_fd(struct dm_stats *dms, int fd)
|
||||
{
|
||||
int major, minor;
|
||||
struct stat buf;
|
||||
|
||||
if (fstat(fd, &buf)) {
|
||||
log_error("fstat failed for fd %d.", fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
major = (int) MAJOR(buf.st_dev);
|
||||
minor = (int) MINOR(buf.st_dev);
|
||||
|
||||
if (!dm_stats_bind_devno(dms, major, minor))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _stats_check_precise_timestamps(const struct dm_stats *dms)
|
||||
{
|
||||
/* Already checked? */
|
||||
|
@ -4640,24 +4640,6 @@ static int _bind_stats_device(struct dm_stats *dms, const char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _bind_stats_from_fd(struct dm_stats *dms, int fd)
|
||||
{
|
||||
int major, minor;
|
||||
struct stat buf;
|
||||
|
||||
if (fstat(fd, &buf)) {
|
||||
log_error("fstat failed for fd %d.", fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
major = (int) MAJOR(buf.st_dev);
|
||||
minor = (int) MINOR(buf.st_dev);
|
||||
|
||||
if (!dm_stats_bind_devno(dms, major, minor))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _stats_clear_one_region(struct dm_stats *dms, uint64_t region_id)
|
||||
{
|
||||
|
||||
@ -5068,7 +5050,7 @@ static int _stats_create_file(CMD_ARGS)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!_bind_stats_from_fd(dms, fd))
|
||||
if (!dm_stats_bind_from_fd(dms, fd))
|
||||
goto_bad;
|
||||
|
||||
if (!strlen(program_id))
|
||||
|
Loading…
Reference in New Issue
Block a user