mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
dev_manager: use setup_task_run for mknod
Simplify info run for use only for INFO & STATUS. Drop handling MKNODES within _info_run() call and use more advanced _setup_task_run() directly. This allows to further simplify _info_run().
This commit is contained in:
parent
5163b8f697
commit
114f7e6285
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.169 -
|
Version 2.02.169 -
|
||||||
=====================================
|
=====================================
|
||||||
|
Simplify internal _info_run() and use _setup_task_run() for mknod.
|
||||||
Better API for internal function _setup_task_run.
|
Better API for internal function _setup_task_run.
|
||||||
Avoid using lv_has_target_type() call within lv_info_with_seg_status.
|
Avoid using lv_has_target_type() call within lv_info_with_seg_status.
|
||||||
Simplify internal lv_info_with_seg_status API.
|
Simplify internal lv_info_with_seg_status API.
|
||||||
|
@ -211,10 +211,9 @@ static int _get_segment_status_from_target_params(const char *target_name,
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
INFO, /* DM_DEVICE_INFO ioctl */
|
INFO, /* DM_DEVICE_INFO ioctl */
|
||||||
STATUS, /* DM_DEVICE_STATUS ioctl */
|
STATUS, /* DM_DEVICE_STATUS ioctl */
|
||||||
MKNODES
|
|
||||||
} info_type_t;
|
} info_type_t;
|
||||||
|
|
||||||
static int _info_run(info_type_t type, const char *name, const char *dlid,
|
static int _info_run(info_type_t type, const char *dlid,
|
||||||
struct dm_info *dminfo, uint32_t *read_ahead,
|
struct dm_info *dminfo, uint32_t *read_ahead,
|
||||||
struct lv_seg_status *seg_status,
|
struct lv_seg_status *seg_status,
|
||||||
int with_open_count, int with_read_ahead,
|
int with_open_count, int with_read_ahead,
|
||||||
@ -236,17 +235,13 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
|
|||||||
dmtask = DM_DEVICE_STATUS;
|
dmtask = DM_DEVICE_STATUS;
|
||||||
with_flush = 0;
|
with_flush = 0;
|
||||||
break;
|
break;
|
||||||
case MKNODES:
|
|
||||||
dmtask = DM_DEVICE_MKNODES;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
log_error(INTERNAL_ERROR "_info_run: unhandled info type");
|
log_error(INTERNAL_ERROR "_info_run: unhandled info type");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dmt = _setup_task_run(dmtask, dminfo,
|
if (!(dmt = _setup_task_run(dmtask, dminfo,
|
||||||
(type == MKNODES) ? name : NULL, dlid, 0,
|
NULL, dlid, 0, major, minor, with_open_count, with_flush, 0)))
|
||||||
major, minor, with_open_count, with_flush, 0)))
|
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (with_read_ahead && dminfo->exists) {
|
if (with_read_ahead && dminfo->exists) {
|
||||||
@ -686,7 +681,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
|
|||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
/* Check for dlid */
|
/* Check for dlid */
|
||||||
if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid, dminfo, read_ahead,
|
if ((r = _info_run(seg_status ? STATUS : INFO, dlid, dminfo, read_ahead,
|
||||||
seg_status, with_open_count, with_read_ahead, 0, 0)) && dminfo->exists)
|
seg_status, with_open_count, with_read_ahead, 0, 0)) && dminfo->exists)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -698,7 +693,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
|
|||||||
|
|
||||||
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
||||||
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
|
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
|
||||||
if ((r = _info_run(seg_status ? STATUS : INFO, NULL, old_style_dlid, dminfo,
|
if ((r = _info_run(seg_status ? STATUS : INFO, old_style_dlid, dminfo,
|
||||||
read_ahead, seg_status, with_open_count,
|
read_ahead, seg_status, with_open_count,
|
||||||
with_read_ahead, 0, 0)) && dminfo->exists)
|
with_read_ahead, 0, 0)) && dminfo->exists)
|
||||||
return 1;
|
return 1;
|
||||||
@ -710,7 +705,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* Check for dlid before UUID_PREFIX was added */
|
/* Check for dlid before UUID_PREFIX was added */
|
||||||
if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid + sizeof(UUID_PREFIX) - 1,
|
if ((r = _info_run(seg_status ? STATUS : INFO, dlid + sizeof(UUID_PREFIX) - 1,
|
||||||
dminfo, read_ahead, seg_status, with_open_count,
|
dminfo, read_ahead, seg_status, with_open_count,
|
||||||
with_read_ahead, 0, 0)) && dminfo->exists)
|
with_read_ahead, 0, 0)) && dminfo->exists)
|
||||||
return 1;
|
return 1;
|
||||||
@ -720,7 +715,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
|
|||||||
|
|
||||||
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
|
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
|
||||||
{
|
{
|
||||||
return _info_run(INFO, NULL, NULL, info, NULL, 0, 0, 0, major, minor);
|
return _info_run(INFO, NULL, info, NULL, 0, 0, 0, major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
|
int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
|
||||||
@ -1561,21 +1556,24 @@ static int _lv_has_mknode(const struct logical_volume *lv)
|
|||||||
int dev_manager_mknodes(const struct logical_volume *lv)
|
int dev_manager_mknodes(const struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
struct dm_info dminfo;
|
struct dm_info dminfo;
|
||||||
|
struct dm_task *dmt;
|
||||||
char *name;
|
char *name;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
|
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if ((r = _info_run(MKNODES, name, NULL, &dminfo, NULL, NULL, 0, 0, 0, 0))) {
|
if (!(dmt = _setup_task_run(DM_DEVICE_MKNODES, &dminfo, name, NULL, 0, 0, 0, 0, 0, 0)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
if (dminfo.exists) {
|
if (dminfo.exists) {
|
||||||
if (_lv_has_mknode(lv))
|
if (_lv_has_mknode(lv))
|
||||||
r = _dev_manager_lv_mknodes(lv);
|
r = _dev_manager_lv_mknodes(lv);
|
||||||
} else
|
} else
|
||||||
r = _dev_manager_lv_rmnodes(lv);
|
r = _dev_manager_lv_rmnodes(lv);
|
||||||
}
|
|
||||||
|
|
||||||
dm_pool_free(lv->vg->cmd->mem, name);
|
dm_task_destroy(dmt);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user