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

snapshot: keep COW writable for read-only volumes

When snapshot is created in read-only mode with 'lvcreate -s -pr...',
lvm2 still needs to be able to write to layered -cow volume
to store metadata and exceptions blocks.

TODO: in some case we might be able to do full tree with read-only
volume but this probably needs futher validation:
1. checking snapshot header already exist
2. origin & snapshot are both in read-only mode.
This commit is contained in:
Zdenek Kabelac 2018-03-08 10:27:04 +01:00
parent 15b6793528
commit a6fdb9d9d7
4 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.178 - Version 2.02.178 -
===================================== =====================================
Ensure COW device is writable even for read-only thick snapshots.
Support activation of component LVs in read-only mode. Support activation of component LVs in read-only mode.
Extend internal library to recognize and work with component LV. Extend internal library to recognize and work with component LV.
Skip duplicate check for active LV when prompting for its removal. Skip duplicate check for active LV when prompting for its removal.

View File

@ -2694,7 +2694,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
* Nothing to do? * Nothing to do?
*/ */
if (info.exists && !info.suspended && info.live_table && if (info.exists && !info.suspended && info.live_table &&
(info.read_only == read_only_lv(lv, laopts))) { (info.read_only == read_only_lv(lv, laopts, NULL))) {
r = 1; r = 1;
log_debug_activation("LV %s is already active.", display_lvname(lv)); log_debug_activation("LV %s is already active.", display_lvname(lv));
goto out; goto out;

View File

@ -75,8 +75,11 @@ struct lv_layer {
int visible_component; int visible_component;
}; };
int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts) int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts, const char *layer)
{ {
if (layer && lv_is_cow(lv))
return 0; /* Keep snapshot's COW volume writable */
return (laopts->read_only || !(lv->status & LVM_WRITE)); return (laopts->read_only || !(lv->status & LVM_WRITE));
} }
@ -2824,7 +2827,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(dnode = dm_tree_add_new_dev_with_udev_flags(dtree, name, dlid, if (!(dnode = dm_tree_add_new_dev_with_udev_flags(dtree, name, dlid,
layer ? UINT32_C(0) : (uint32_t) lv->major, layer ? UINT32_C(0) : (uint32_t) lv->major,
layer ? UINT32_C(0) : (uint32_t) lv->minor, layer ? UINT32_C(0) : (uint32_t) lv->minor,
read_only_lv(lv, laopts), read_only_lv(lv, laopts, layer),
((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0, ((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0,
lvlayer, lvlayer,
_get_udev_flags(dm, lv, layer, laopts->noscan, laopts->temporary, _get_udev_flags(dm, lv, layer, laopts->noscan, laopts->temporary,

View File

@ -27,7 +27,7 @@ struct dm_info;
struct device; struct device;
struct lv_seg_status; struct lv_seg_status;
int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts); int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts, const char *layer);
/* /*
* Constructor and destructor. * Constructor and destructor.