master - lvm-string: add cdata/cmeta as reserved name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2868d897da186d...
Commit: 2868d897da186d0f65856936543e25bcd5057440
Parent: 700b4bfc9428d7440c018c0a5e9d9dcc3cc4cea1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 7 21:36:59 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:14 2014 +0200
lvm-string: add cdata/cmeta as reserved name
---
lib/misc/lvm-string.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
index b96b5cc..a74fd58 100644
--- a/lib/misc/lvm-string.c
+++ b/lib/misc/lvm-string.c
@@ -109,6 +109,8 @@ int apply_lvname_restrictions(const char *name)
};
static const char * const _reserved_strings[] = {
+ "_cdata",
+ "_cmeta",
"_mlog",
"_mimage",
"_pmspare",
10 years, 1 month
master - log: skip repeated hashing when logging once
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=700b4bfc9428d7...
Commit: 700b4bfc9428d7440c018c0a5e9d9dcc3cc4cea1
Parent: 96cf9dc0170d8a807ecac3956a80c3f51cfe48c0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 7 17:51:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:14 2014 +0200
log: skip repeated hashing when logging once
When a message is already found in the hash, no need to hash it again.
---
lib/log/log.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index 194fdd3..a3c0139 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -268,7 +268,8 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
if (_duplicated) {
if (dm_hash_lookup(_duplicated, message))
level = _LOG_NOTICE;
- (void) dm_hash_insert(_duplicated, message, (void*)1);
+ else
+ (void) dm_hash_insert(_duplicated, message, (void*)1);
}
}
10 years, 1 month
master - raid: use internal variables for array alloc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96cf9dc0170d8a...
Commit: 96cf9dc0170d8a807ecac3956a80c3f51cfe48c0
Parent: 89615af349056e3a34788a8b6c0842100389d2b8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:19:58 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200
raid: use internal variables for array alloc
Don't use passed pointer when allocating policies' array.
(In case policy_argc would be NULL, this would have caused
NULL dereference).
---
lib/activate/activate.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6667dfc..4d3f8fe 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1121,9 +1121,9 @@ int lv_cache_policy_info(struct logical_volume *lv,
*policy_argc = status->policy_argc;
if (policy_argv) {
if (!(*policy_argv =
- dm_pool_zalloc(mem, sizeof(char *) * *policy_argc)))
+ dm_pool_zalloc(mem, sizeof(char *) * status->policy_argc)))
return_0;
- for (i = 0; i < *policy_argc; i++)
+ for (i = 0; i < status->policy_argc; ++i)
if (!((*policy_argv)[i] =
dm_pool_strdup(mem, status->policy_argv[i])))
return_0;
10 years, 1 month
master - exec_cmd: skip fork when argv[0] is null
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=89615af349056e...
Commit: 89615af349056e3a34788a8b6c0842100389d2b8
Parent: 6190ded5f1e7862758ff4a18f8a4030331e655d4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:15:17 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200
exec_cmd: skip fork when argv[0] is null
Skip whole fork code path if the arg would be null.
---
lib/misc/lvm-exec.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c
index e862bad..273e7f9 100644
--- a/lib/misc/lvm-exec.c
+++ b/lib/misc/lvm-exec.c
@@ -53,6 +53,11 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
int status;
char buf[PATH_MAX * 2];
+ if (!argv[0]) {
+ log_error(INTERNAL_ERROR "Missing command.");
+ return 0;
+ }
+
if (rstatus)
*rstatus = -1;
@@ -74,8 +79,7 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
/* FIXME Fix effect of reset_locking on cache then include this */
/* destroy_toolcontext(cmd); */
/* FIXME Use execve directly */
- if (argv[0])
- execvp(argv[0], (char **) argv);
+ execvp(argv[0], (char **) argv);
log_sys_error("execvp", argv[0]);
_exit(errno);
}
10 years, 1 month
master - libdm: simplify segtype search
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6190ded5f1e786...
Commit: 6190ded5f1e7862758ff4a18f8a4030331e655d4
Parent: 6d3d2d5e3da3e870e2df07c32cea4dfbbeab572c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 22:34:22 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200
libdm: simplify segtype search
For cache target use directly SEG_CACHE.
Hide dm_segtypes as internal static variable _dm_segtypes,
since noone is supposed to use it.
---
libdm/libdm-deptree.c | 47 ++++++++++++++++++-----------------------------
1 files changed, 18 insertions(+), 29 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 8336249..7c4da9b 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -51,15 +51,14 @@ enum {
SEG_RAID6_ZR,
SEG_RAID6_NR,
SEG_RAID6_NC,
- SEG_LAST,
};
/* FIXME Add crypt and multipath support */
-struct {
+static const struct {
unsigned type;
- const char *target;
-} dm_segtypes[] = {
+ const char target[16];
+} _dm_segtypes[] = {
{ SEG_CACHE, "cache" },
{ SEG_CRYPT, "crypt" },
{ SEG_ERROR, "error" },
@@ -91,7 +90,6 @@ struct {
*/
{ SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */
{ SEG_RAID6_ZR, "raid6"}, /* same as "raid6_zr" */
- { SEG_LAST, NULL },
};
/* Some segment types have a list of areas of other devices attached */
@@ -2243,7 +2241,7 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if ((seg->type == SEG_RAID1) && seg->stripe_size)
log_error("WARNING: Ignoring RAID1 stripe size");
- EMIT_PARAMS(pos, "%s %d %u", dm_segtypes[seg->type].target,
+ EMIT_PARAMS(pos, "%s %d %u", _dm_segtypes[seg->type].target,
param_count, seg->stripe_size);
if (seg->flags & DM_NOSYNC)
@@ -2509,7 +2507,7 @@ static int _emit_segment_line(struct dm_task *dmt, uint32_t major,
}
if (!params[0]) {
log_error("No parameters supplied for %s target "
- "%u:%u.", dm_segtypes[seg->type].target,
+ "%u:%u.", _dm_segtypes[seg->type].target,
major, minor);
return 0;
}
@@ -2519,11 +2517,11 @@ static int _emit_segment_line(struct dm_task *dmt, uint32_t major,
log_debug_activation("Adding target to (%" PRIu32 ":%" PRIu32 "): %" PRIu64
" %" PRIu64 " %s %s", major, minor,
*seg_start, seg->size, target_type_is_raid ? "raid" :
- dm_segtypes[seg->type].target, params);
+ _dm_segtypes[seg->type].target, params);
if (!dm_task_add_target(dmt, *seg_start, seg->size,
target_type_is_raid ? "raid" :
- dm_segtypes[seg->type].target, params))
+ _dm_segtypes[seg->type].target, params))
return_0;
*seg_start += seg->size;
@@ -3110,12 +3108,11 @@ int dm_tree_node_add_raid_target_with_params(struct dm_tree_node *node,
int i;
struct load_segment *seg = NULL;
- for (i = 0; dm_segtypes[i].target && !seg; i++)
- if (!strcmp(p->raid_type, dm_segtypes[i].target))
+ for (i = 0; i < DM_ARRAY_SIZE(_dm_segtypes) && !seg; ++i)
+ if (!strcmp(p->raid_type, _dm_segtypes[i].target))
if (!(seg = _add_segment(node,
- dm_segtypes[i].type, size)))
+ _dm_segtypes[i].type, size)))
return_0;
-
if (!seg)
return_0;
@@ -3242,17 +3239,9 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
unsigned policy_argc,
const char *const *policy_argv)
{
- int i;
- struct load_segment *seg = NULL;
-
- for (i = 0; dm_segtypes[i].target && !seg; i++) {
- if (strcmp("cache", dm_segtypes[i].target))
- continue;
- if (!(seg = _add_segment(node, dm_segtypes[i].type, size)))
- return_0;
- }
+ struct load_segment *seg;
- if (!seg)
+ if (!(seg = _add_segment(node, SEG_CACHE, size)))
return_0;
if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree,
@@ -3485,7 +3474,7 @@ int dm_tree_node_add_replicator_target(struct dm_tree_node *node,
rseg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment);
if (rseg->type != SEG_REPLICATOR) {
log_error(INTERNAL_ERROR "Attempt to use non replicator segment %s.",
- dm_segtypes[rseg->type].target);
+ _dm_segtypes[rseg->type].target);
return 0;
}
@@ -3540,7 +3529,7 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
rep_seg = dm_list_item(dm_list_last(&rseg->replicator->props.segs), struct load_segment);
if (rep_seg->type != SEG_REPLICATOR) {
log_error(INTERNAL_ERROR "Attempt to use non replicator segment %s.",
- dm_segtypes[rep_seg->type].target);
+ _dm_segtypes[rep_seg->type].target);
return 0;
}
rep_seg->rdevice_count++;
@@ -3559,7 +3548,7 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
rseg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment);
if (rseg->type != SEG_REPLICATOR_DEV) {
log_error(INTERNAL_ERROR "Attempt to use non replicator-dev segment %s.",
- dm_segtypes[rseg->type].target);
+ _dm_segtypes[rseg->type].target);
return 0;
}
}
@@ -3598,15 +3587,15 @@ static struct load_segment *_get_single_load_segment(struct dm_tree_node *node,
if (node->props.segment_count != 1) {
log_error("Node %s must have only one segment.",
- dm_segtypes[type].target);
+ _dm_segtypes[type].target);
return NULL;
}
seg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment);
if (seg->type != type) {
log_error("Node %s has segment type %s.",
- dm_segtypes[type].target,
- dm_segtypes[seg->type].target);
+ _dm_segtypes[type].target,
+ _dm_segtypes[seg->type].target);
return NULL;
}
10 years, 1 month
master - libdm: check for _build_dev_path failure
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d3d2d5e3da3e8...
Commit: 6d3d2d5e3da3e870e2df07c32cea4dfbbeab572c
Parent: 2c2819763083d3c2e6b011117d8fa27c77a4d4e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:47:54 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200
libdm: check for _build_dev_path failure
Enhance internal function _build_dev_path for failure
if buffer would be too small.
Use memcpy instead printf for a single string.
---
WHATS_NEW_DM | 1 +
libdm/libdm-common.c | 28 +++++++++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 1c0843e..4004d98 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Check for sprintf error when building internal device path.
Check for sprintf error when creating path for dm control node.
When buffer for dm_get_library_version() is too small, return error code.
Always reinitialize _name_mangling_mode in dm_lib_init().
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 93f3dd1..5c8b49c 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -192,13 +192,20 @@ void dm_log_init_verbose(int level)
_verbose = level;
}
-static void _build_dev_path(char *buffer, size_t len, const char *dev_name)
+static int _build_dev_path(char *buffer, size_t len, const char *dev_name)
{
+ int r;
+
/* If there's a /, assume caller knows what they're doing */
if (strchr(dev_name, '/'))
- snprintf(buffer, len, "%s", dev_name);
+ r = dm_strncpy(buffer, dev_name, len);
else
- snprintf(buffer, len, "%s/%s", _dm_dir, dev_name);
+ r = (dm_snprintf(buffer, len, "%s/%s",
+ _dm_dir, dev_name) < 0) ? 0 : 1;
+ if (!r)
+ log_error("Failed to build dev path for \"%s\".", dev_name);
+
+ return r;
}
int dm_get_library_version(char *version, size_t size)
@@ -955,7 +962,8 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
dev_t dev = MKDEV((dev_t)major, minor);
mode_t old_mask;
- _build_dev_path(path, sizeof(path), dev_name);
+ if (!_build_dev_path(path, sizeof(path), dev_name))
+ return_0;
if (stat(path, &info) >= 0) {
if (!S_ISBLK(info.st_mode)) {
@@ -1005,8 +1013,8 @@ static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed)
char path[PATH_MAX];
struct stat info;
- _build_dev_path(path, sizeof(path), dev_name);
-
+ if (!_build_dev_path(path, sizeof(path), dev_name))
+ return_0;
if (stat(path, &info) < 0)
return 1;
else if (_warn_if_op_needed(warn_if_udev_failed))
@@ -1031,8 +1039,9 @@ static int _rename_dev_node(const char *old_name, const char *new_name,
char newpath[PATH_MAX];
struct stat info;
- _build_dev_path(oldpath, sizeof(oldpath), old_name);
- _build_dev_path(newpath, sizeof(newpath), new_name);
+ if (!_build_dev_path(oldpath, sizeof(oldpath), old_name) ||
+ !_build_dev_path(newpath, sizeof(newpath), new_name))
+ return_0;
if (stat(newpath, &info) == 0) {
if (!S_ISBLK(info.st_mode)) {
@@ -1106,7 +1115,8 @@ static int _open_dev_node(const char *dev_name)
int fd = -1;
char path[PATH_MAX];
- _build_dev_path(path, sizeof(path), dev_name);
+ if (!_build_dev_path(path, sizeof(path), dev_name))
+ return fd;
if ((fd = open(path, O_RDONLY, 0)) < 0)
log_sys_error("open", path);
10 years, 1 month
master - libdm: check for size when opening control node
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2c2819763083d3...
Commit: 2c2819763083d3c2e6b011117d8fa27c77a4d4e8
Parent: 583fbdba84afae3a045915603c6c057c76fcf485
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:46:45 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200
libdm: check for size when opening control node
Use dm_snprintf() to detect fail if open_control node would
not have fit into buffer.
---
WHATS_NEW_DM | 1 +
libdm/ioctl/libdm-iface.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 49a7812..1c0843e 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Check for sprintf error when creating path for dm control node.
When buffer for dm_get_library_version() is too small, return error code.
Always reinitialize _name_mangling_mode in dm_lib_init().
Add tracking flag about implicitly added devices into dm_tree.
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 7b1fead..25f1d90 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -380,7 +380,8 @@ static int _open_control(void)
if (!_uname())
return 0;
- snprintf(control, sizeof(control), "%s/%s", dm_dir(), DM_CONTROL_NODE);
+ if (dm_snprintf(control, sizeof(control), "%s/%s", dm_dir(), DM_CONTROL_NODE) < 0)
+ goto_bad;
/*
* Prior to 2.6.36 the minor number should be looked up in /proc.
10 years, 1 month
master - libdm: fail if buffer for version is to short
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=583fbdba84afae...
Commit: 583fbdba84afae3a045915603c6c057c76fcf485
Parent: f0003d3be5b002aa27de978ad95fb2b310ca6529
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:43:57 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:12 2014 +0200
libdm: fail if buffer for version is to short
Return fail error code, if supplied buffer is too small.
---
WHATS_NEW_DM | 1 +
libdm/libdm-common.c | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 6545127..49a7812 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ When buffer for dm_get_library_version() is too small, return error code.
Always reinitialize _name_mangling_mode in dm_lib_init().
Add tracking flag about implicitly added devices into dm_tree.
Stop timeout thread immediately when the last worker thread is finished.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 9d8836c..93f3dd1 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -203,8 +203,7 @@ static void _build_dev_path(char *buffer, size_t len, const char *dev_name)
int dm_get_library_version(char *version, size_t size)
{
- strncpy(version, DM_LIB_VERSION, size);
- return 1;
+ return dm_strncpy(version, DM_LIB_VERSION, size);
}
void inc_suspended(void)
10 years, 1 month
master - libdm: always dm_lib_init mangling mode
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0003d3be5b002...
Commit: f0003d3be5b002aa27de978ad95fb2b310ca6529
Parent: bd2500e62ea66984d4c3669a4429afa459165178
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 4 21:24:41 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:12 2014 +0200
libdm: always dm_lib_init mangling mode
If there ever would be a second call to dm_lib_init()
and envvar would be improperly set, some last set value
would be used while it should reset to default mangling mode.
---
WHATS_NEW_DM | 1 +
libdm/libdm-common.c | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d6bebb1..6545127 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Always reinitialize _name_mangling_mode in dm_lib_init().
Add tracking flag about implicitly added devices into dm_tree.
Stop timeout thread immediately when the last worker thread is finished.
Fix dmeventd logging with parallel wait event processing.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 72fa508..9d8836c 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -91,16 +91,15 @@ void dm_lib_init(void)
if (getenv("DM_DISABLE_UDEV"))
_udev_disabled = 1;
- env = getenv(DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME);
- if (env && *env) {
+ _name_mangling_mode = DEFAULT_DM_NAME_MANGLING;
+ if ((env = getenv(DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME))) {
if (!strcasecmp(env, "none"))
_name_mangling_mode = DM_STRING_MANGLING_NONE;
else if (!strcasecmp(env, "auto"))
_name_mangling_mode = DM_STRING_MANGLING_AUTO;
else if (!strcasecmp(env, "hex"))
_name_mangling_mode = DM_STRING_MANGLING_HEX;
- } else
- _name_mangling_mode = DEFAULT_DM_NAME_MANGLING;
+ }
}
/*
10 years, 1 month
master - libdm: track implicit dependecies
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd2500e62ea669...
Commit: bd2500e62ea66984d4c3669a4429afa459165178
Parent: 05a421960f5770e1047cc5212d2a11deef730152
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 7 20:21:20 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 8 11:00:12 2014 +0200
libdm: track implicit dependecies
When the node enters dtree with implicit dependency, it
automatically has udev flags from parent node
and could not be changed later when the node has been
entered again via i.e lvm's preload tracking.
Resolve this by tracking whether the node has been
created by implicit dependency tracking or has been
entered explicitely. Implicit node could be later
upgraded by an explicit _add_dev() with proper udev_flags.
For implicit devices add special udev flags to avoid
any scan and udev rule processing if we resume such device.
Patch allows easier removing of orphan nodes.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 20 +++++++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 4f67bc3..d6bebb1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Add tracking flag about implicitly added devices into dm_tree.
Stop timeout thread immediately when the last worker thread is finished.
Fix dmeventd logging with parallel wait event processing.
Reuse _node_send_messages() for validation of transaction_id in preload.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 03ec9cb..8336249 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -263,6 +263,7 @@ struct dm_tree_node {
struct dm_list used_by; /* Nodes that use this node */
int activation_priority; /* 0 gets activated first */
+ int implicit_deps; /* 1 device only implicitly referenced */
uint16_t udev_flags; /* Udev control flags */
@@ -1171,7 +1172,8 @@ struct dm_tree_node *dm_tree_add_new_dev(struct dm_tree *dtree, const char *name
static struct dm_tree_node *_add_dev(struct dm_tree *dtree,
struct dm_tree_node *parent,
uint32_t major, uint32_t minor,
- uint16_t udev_flags)
+ uint16_t udev_flags,
+ int implicit_deps)
{
struct dm_task *dmt = NULL;
struct dm_info info;
@@ -1191,6 +1193,10 @@ static struct dm_tree_node *_add_dev(struct dm_tree *dtree,
NULL, udev_flags)))
goto_out;
new = 1;
+ node->implicit_deps = implicit_deps;
+ } else if (!implicit_deps && node->implicit_deps) {
+ node->udev_flags = udev_flags;
+ node->implicit_deps = 0;
}
if (!_link_tree_nodes(parent, node)) {
@@ -1213,8 +1219,12 @@ static struct dm_tree_node *_add_dev(struct dm_tree *dtree,
/* Add dependencies to tree */
for (i = 0; i < deps->count; i++)
+ /* Implicit devices are by default temporary */
if (!_add_dev(dtree, node, MAJOR(deps->device[i]),
- MINOR(deps->device[i]), udev_flags)) {
+ MINOR(deps->device[i]), udev_flags |
+ DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG |
+ DM_UDEV_DISABLE_DISK_RULES_FLAG |
+ DM_UDEV_DISABLE_OTHER_RULES_FLAG, 1)) {
node = NULL;
goto_out;
}
@@ -1228,13 +1238,13 @@ out:
int dm_tree_add_dev(struct dm_tree *dtree, uint32_t major, uint32_t minor)
{
- return _add_dev(dtree, &dtree->root, major, minor, 0) ? 1 : 0;
+ return _add_dev(dtree, &dtree->root, major, minor, 0, 0) ? 1 : 0;
}
int dm_tree_add_dev_with_udev_flags(struct dm_tree *dtree, uint32_t major,
uint32_t minor, uint16_t udev_flags)
{
- return _add_dev(dtree, &dtree->root, major, minor, udev_flags) ? 1 : 0;
+ return _add_dev(dtree, &dtree->root, major, minor, udev_flags, 0) ? 1 : 0;
}
static int _rename_node(const char *old_name, const char *new_name, uint32_t major,
@@ -3939,7 +3949,7 @@ int dm_tree_node_add_target_area(struct dm_tree_node *node,
/* FIXME Check correct macro use */
if (!(dev_node = _add_dev(node->dtree, node, MAJOR(info.st_rdev),
- MINOR(info.st_rdev), 0)))
+ MINOR(info.st_rdev), 0, 0)))
return_0;
}
10 years, 1 month