mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: call uname once
Call uname() once and keep result for mirror use-case.
This commit is contained in:
parent
d81e3f9b06
commit
1287edf626
@ -1,5 +1,6 @@
|
||||
Version 1.02.147 -
|
||||
=====================================
|
||||
Reuse uname() result for mirror target.
|
||||
Recognize also mounted btrfs through dm_device_has_mounted_fs().
|
||||
Add missing log_error() into dm_stats_populate() returning 0.
|
||||
Avoid calling dm_stats_populat() for DM devices without any stats regions.
|
||||
|
@ -133,9 +133,9 @@ static char *_align(char *ptr, unsigned int a)
|
||||
}
|
||||
|
||||
#ifdef DM_IOCTLS
|
||||
static int _kernel_major = 0;
|
||||
static int _kernel_minor = 0;
|
||||
static int _kernel_release = 0;
|
||||
static unsigned _kernel_major = 0;
|
||||
static unsigned _kernel_minor = 0;
|
||||
static unsigned _kernel_release = 0;
|
||||
|
||||
static int _uname(void)
|
||||
{
|
||||
@ -151,7 +151,7 @@ static int _uname(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
parts = sscanf(_uts.release, "%d.%d.%d",
|
||||
parts = sscanf(_uts.release, "%u.%u.%u",
|
||||
&_kernel_major, &_kernel_minor, &_kernel_release);
|
||||
|
||||
/* Kernels with a major number of 2 always had 3 parts. */
|
||||
@ -164,6 +164,17 @@ static int _uname(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int get_uname_version(unsigned *major, unsigned *minor, unsigned *release)
|
||||
{
|
||||
if (!_uname())
|
||||
return_0;
|
||||
|
||||
*major = _kernel_major;
|
||||
*minor = _kernel_minor;
|
||||
*release = _kernel_release;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* Set number to NULL to populate _dm_bitset - otherwise first
|
||||
* match is returned.
|
||||
|
@ -53,4 +53,6 @@ void dec_suspended(void);
|
||||
|
||||
int parse_thin_pool_status(const char *params, struct dm_status_thin_pool *s);
|
||||
|
||||
int get_uname_version(unsigned *major, unsigned *minor, unsigned *release);
|
||||
|
||||
#endif
|
||||
|
@ -2105,24 +2105,14 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
|
||||
int block_on_error = 0;
|
||||
int handle_errors = 0;
|
||||
int dm_log_userspace = 0;
|
||||
struct utsname uts;
|
||||
unsigned log_parm_count;
|
||||
int pos = 0, parts;
|
||||
int pos = 0;
|
||||
char logbuf[DM_FORMAT_DEV_BUFSIZE];
|
||||
const char *logtype;
|
||||
unsigned kmaj = 0, kmin = 0, krel = 0;
|
||||
|
||||
if (uname(&uts) == -1) {
|
||||
log_error("Cannot read kernel release version.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kernels with a major number of 2 always had 3 parts. */
|
||||
parts = sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel);
|
||||
if (parts < 1 || (kmaj < 3 && parts < 3)) {
|
||||
log_error("Wrong kernel release version %s.", uts.release);
|
||||
return 0;
|
||||
}
|
||||
if (!get_uname_version(&kmaj, &kmin, &krel))
|
||||
return_0;
|
||||
|
||||
if ((seg->flags & DM_BLOCK_ON_ERROR)) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user