1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cleanup: indent changes

Some code indention.
Use dm_strncpy() for simplier code.

TODO: we could possibly use   %32s  for printing pvid...
so maybe adding extra  FMT_PVID....
This commit is contained in:
Zdenek Kabelac 2016-02-22 10:44:46 +01:00
parent fba54ae55e
commit 2d6ef123a6

50
lib/cache/lvmetad.c vendored
View File

@ -105,6 +105,7 @@ void lvmetad_disconnect(void)
{ {
if (_lvmetad_connected) if (_lvmetad_connected)
daemon_close(_lvmetad); daemon_close(_lvmetad);
_lvmetad_connected = 0; _lvmetad_connected = 0;
} }
@ -165,14 +166,17 @@ int lvmetad_socket_present(void)
int lvmetad_active(void) int lvmetad_active(void)
{ {
lvmetad_connect_or_warn(); lvmetad_connect_or_warn();
return _lvmetad_connected; return _lvmetad_connected;
} }
void lvmetad_set_active(struct cmd_context *cmd, int active) void lvmetad_set_active(struct cmd_context *cmd, int active)
{ {
_lvmetad_use = active; _lvmetad_use = active;
if (!active && lvmetad_active()) if (!active && lvmetad_active())
lvmetad_disconnect(); lvmetad_disconnect();
if (cmd && !refresh_filters(cmd)) if (cmd && !refresh_filters(cmd))
stack; stack;
} }
@ -282,6 +286,7 @@ static int _token_update(void)
} }
daemon_reply_destroy(repl); daemon_reply_destroy(repl);
return 1; return 1;
} }
@ -490,6 +495,7 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
static int _pv_update_struct_pv(struct physical_volume *pv, struct format_instance *fid) static int _pv_update_struct_pv(struct physical_volume *pv, struct format_instance *fid)
{ {
struct lvmcache_info *info; struct lvmcache_info *info;
if ((info = lvmcache_info_from_pvid((const char *)&pv->id, 0))) { if ((info = lvmcache_info_from_pvid((const char *)&pv->id, 0))) {
pv->label_sector = lvmcache_get_label(info)->sector; pv->label_sector = lvmcache_get_label(info)->sector;
pv->dev = lvmcache_device(info); pv->dev = lvmcache_device(info);
@ -497,9 +503,10 @@ static int _pv_update_struct_pv(struct physical_volume *pv, struct format_instan
pv->status |= MISSING_PV; pv->status |= MISSING_PV;
if (!lvmcache_fid_add_mdas_pv(info, fid)) if (!lvmcache_fid_add_mdas_pv(info, fid))
return_0; return_0;
pv->fid = fid; pv->fid = fid;
} else } else
pv->status |= MISSING_PV; /* probably missing */ pv->status |= MISSING_PV; /* probably missing */
return 1; return 1;
} }
@ -680,9 +687,12 @@ struct _fixup_baton {
static int _fixup_ignored(struct metadata_area *mda, void *baton) { static int _fixup_ignored(struct metadata_area *mda, void *baton) {
struct _fixup_baton *b = baton; struct _fixup_baton *b = baton;
if (b->i == b->find) if (b->i == b->find)
mda_set_ignored(mda, b->ignore); mda_set_ignored(mda, b->ignore);
b->i ++; b->i ++;
return 1; return 1;
} }
@ -829,6 +839,7 @@ out_success:
out: out:
daemon_reply_destroy(reply); daemon_reply_destroy(reply);
return result; return result;
} }
@ -903,6 +914,7 @@ int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids)
} }
daemon_reply_destroy(reply); daemon_reply_destroy(reply);
return 1; return 1;
} }
@ -938,6 +950,7 @@ int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd)
} }
daemon_reply_destroy(reply); daemon_reply_destroy(reply);
return 1; return 1;
} }
@ -1005,13 +1018,15 @@ static int _extract_ba(struct disk_locn *ba, void *baton)
static int _extract_mdas(struct lvmcache_info *info, struct dm_config_tree *cft, static int _extract_mdas(struct lvmcache_info *info, struct dm_config_tree *cft,
struct dm_config_node *pre_sib) struct dm_config_node *pre_sib)
{ {
struct _extract_dl_baton baton = { .i = 0, .cft = cft, .pre_sib = NULL }; struct _extract_dl_baton baton = { .cft = cft };
if (!lvmcache_foreach_mda(info, &_extract_mda, &baton)) if (!lvmcache_foreach_mda(info, &_extract_mda, &baton))
return 0; return 0;
baton.i = 0; baton.i = 0;
if (!lvmcache_foreach_da(info, &_extract_da, &baton)) if (!lvmcache_foreach_da(info, &_extract_da, &baton))
return 0; return 0;
baton.i = 0; baton.i = 0;
if (!lvmcache_foreach_ba(info, &_extract_ba, &baton)) if (!lvmcache_foreach_ba(info, &_extract_ba, &baton))
return 0; return 0;
@ -1172,11 +1187,11 @@ int lvmetad_pv_gone(dev_t devno, const char *pv_name, activation_handler handler
return 1; return 1;
/* /*
* TODO: automatic volume deactivation takes place here *before* * TODO: automatic volume deactivation takes place here *before*
* all cached info is gone - call handler. Also, consider * all cached info is gone - call handler. Also, consider
* integrating existing deactivation script that deactivates * integrating existing deactivation script that deactivates
* the whole stack from top to bottom (not yet upstream). * the whole stack from top to bottom (not yet upstream).
*/ */
log_debug_lvmetad("Telling lvmetad to forget any PV on %s", pv_name); log_debug_lvmetad("Telling lvmetad to forget any PV on %s", pv_name);
reply = _lvmetad_send("pv_gone", "device = %" PRId64, (int64_t) devno, NULL); reply = _lvmetad_send("pv_gone", "device = %" PRId64, (int64_t) devno, NULL);
@ -1415,8 +1430,9 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
bad: bad:
/* FIXME kill lvmetad automatically if we can */ /* FIXME kill lvmetad automatically if we can */
log_error("Update of lvmetad failed. This is a serious problem.\n " log_error("Update of lvmetad failed. This is a serious problem.\n"
"It is strongly recommended that you restart lvmetad immediately."); "It is strongly recommended that you restart lvmetad immediately.");
return 0; return 0;
} }
@ -1536,6 +1552,7 @@ static int _lvmetad_get_pv_cache_list(struct cmd_context *cmd, struct dm_list *p
return 1; return 1;
log_debug_lvmetad("Asking lvmetad for complete list of known PVs"); log_debug_lvmetad("Asking lvmetad for complete list of known PVs");
reply = _lvmetad_send("pv_list", NULL); reply = _lvmetad_send("pv_list", NULL);
if (!_lvmetad_handle_reply(reply, "list PVs", "", NULL)) { if (!_lvmetad_handle_reply(reply, "list PVs", "", NULL)) {
log_error("lvmetad message failed."); log_error("lvmetad message failed.");
@ -1632,10 +1649,8 @@ static void _update_changed_pvs_in_udev(struct cmd_context *cmd,
continue; continue;
if (!id_equal(&before->pvid, &after->pvid)) { if (!id_equal(&before->pvid, &after->pvid)) {
memset(id_before, 0, sizeof(id_before)); dm_strncpy(id_before, (char *) &before->pvid, sizeof(id_before));
memset(id_after, 0, sizeof(id_after)); dm_strncpy(id_after, (char *) &after->pvid, sizeof(id_after));
strncpy(&id_before[0], (char *) &before->pvid, sizeof(id_before) - 1);
strncpy(&id_after[0], (char *) &after->pvid, sizeof(id_after) - 1);
log_debug_devs("device %d:%d changed pvid from %s to %s", log_debug_devs("device %d:%d changed pvid from %s to %s",
(int)MAJOR(before->devt), (int)MINOR(before->devt), (int)MAJOR(before->devt), (int)MINOR(before->devt),
@ -1661,8 +1676,7 @@ static void _update_changed_pvs_in_udev(struct cmd_context *cmd,
} }
if (!found) { if (!found) {
memset(id_before, 0, sizeof(id_before)); dm_strncpy(id_before, (char *) &before->pvid, sizeof(id_before));
strncpy(&id_before[0], (char *) &before->pvid, sizeof(id_before) - 1);
log_debug_devs("device %d:%d pvid %s vg %s is gone", log_debug_devs("device %d:%d pvid %s vg %s is gone",
(int)MAJOR(before->devt), (int)MINOR(before->devt), (int)MAJOR(before->devt), (int)MINOR(before->devt),
@ -1754,10 +1768,8 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)
daemon_reply_destroy(reply); daemon_reply_destroy(reply);
if (!global_invalid) { if (!global_invalid)
/* cache is valid */ return; /* cache is valid */
return;
}
do_scan: do_scan:
/* /*
@ -1839,6 +1851,6 @@ int lvmetad_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const cha
ret = !is_system_id_allowed(cmd, system_id); ret = !is_system_id_allowed(cmd, system_id);
daemon_reply_destroy(reply); daemon_reply_destroy(reply);
return ret; return ret;
} }