* RE: [linux-lvm] Some ideas regarding snapshots (was: Reiserfs, 2. 4.7, snapshots w/ 0.9)
@ 2001-07-27 17:22 Dale Stephenson
2001-07-30 9:47 ` Joe Thornber
0 siblings, 1 reply; 2+ messages in thread
From: Dale Stephenson @ 2001-07-27 17:22 UTC (permalink / raw)
To: 'linux-lvm@sistina.com'
Joe Thornber wrote:
> Writeable snapshot's are easy to implement, I believe someone has
> already made a patch for the current LVM series (search the list). I
> certainly intend putting it into the experimental LVM branch soon.
>
> - Joe
I haven't tried to apply it with beta8, but this is the writeable snapshot
patch I used for beta7:
(All I've used it for is replays and UUID changes, so YMMV.)
--- linux/drivers/md/lvm.c.orig Fri May 18 19:04:30 2001
+++ linux/drivers/md/lvm.c Fri May 18 19:30:44 2001
@@ -1120,8 +1120,8 @@
ulong pe_start;
ulong size = bh->b_size >> 9;
ulong rsector_org = bh->b_rsector;
- ulong rsector_map;
- kdev_t rdev_map;
+ ulong rsector_map, rsector_sav;
+ kdev_t rdev_map, rdev_sav;
vg_t *vg_this = vg[VG_BLK(minor)];
lv_t *lv = vg_this->lv[LV_BLK(minor)];
@@ -1228,12 +1228,42 @@
goto out;
if (lv->lv_access & LV_SNAPSHOT) { /* remap snapshot */
- if (lv->lv_block_exception)
+ if (lv->lv_block_exception) {
+ if (rw == WRITE || rw == WRITEA) {
+ /* Start of writeable snapshot portion */
+ rdev_sav = rdev_map;
+ rsector_sav = rsector_map;
+
+ if (!lvm_snapshot_remap_block(&rdev_map,
+ &rsector_map,
+ pe_start,
+ lv)) {
+ /* create a new mapping */
+ if (lvm_snapshot_COW(rdev_map,
+ rsector_map,
+ pe_start,
+ rsector_sav,
+ vg_this,lv)) {
+ goto bad;
+ }
+ lvm_write_COW_table_block(vg_this,lv);
+ rdev_map = rdev_sav;
+ rsector_map = rsector_sav;
+ if (!lvm_snapshot_remap_block(&rdev_map,
+ &rsector_map,
+ pe_start,
+ lv)) {
+ goto bad;
+ }
+ }
+ /* End of writable snapshot portion */
+ }
+ else
lvm_snapshot_remap_block(&rdev_map, &rsector_map,
pe_start, lv);
- else
+ }
+ else
goto bad;
-
} else if(rw == WRITE || rw == WRITEA) { /* snapshot origin */
lv_t *snap;
Note that snapshots are created read-only, so you need to change lvchange to
let you make it read-write:
--- LVM_0_9/tools/lvchange.c.orig Thu Dec 14 11:29:30 2000
+++ LVM_0_9/tools/lvchange.c Thu Dec 14 11:36:16 2000
@@ -329,7 +330,8 @@
continue;
}
- if ( lv->lv_access & LV_SNAPSHOT) {
+ if ( ( lv->lv_access & LV_SNAPSHOT) &&
+ ( (opt_C) || (opt_a) || (opt_r))) {
fprintf ( stderr, "%s -- change on snapshot logical "
"volume \"%s\" not allowed\n", cmd, lv_name);
continue;
@@ -370,7 +372,12 @@
if ( doit > 0) {
doit_sum++;
- lv->lv_access = lv_access;
+ /* don't clear access flags except for LV_WRITE and LV_READ */
+ if (lv->lv_access & LV_WRITE)
+ lv->lv_access -= LV_WRITE;
+ if (lv->lv_access & LV_READ)
+ lv->lv_access -= LV_READ;
+ lv->lv_access |= lv_access;
if ( opt_v > 0) printf ( "%s -- changing access permissions "
"of logical volume \"%s\"\n",
cmd, lv_name);
Dale J. Stephenson
steph@connex.com
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [linux-lvm] Some ideas regarding snapshots (was: Reiserfs, 2. 4.7, snapshots w/ 0.9)
2001-07-27 17:22 [linux-lvm] Some ideas regarding snapshots (was: Reiserfs, 2. 4.7, snapshots w/ 0.9) Dale Stephenson
@ 2001-07-30 9:47 ` Joe Thornber
0 siblings, 0 replies; 2+ messages in thread
From: Joe Thornber @ 2001-07-30 9:47 UTC (permalink / raw)
To: linux-lvm
On Fri, Jul 27, 2001 at 10:22:06AM -0700, Dale Stephenson wrote:
> Joe Thornber wrote:
> > Writeable snapshot's are easy to implement, I believe someone has
> > already made a patch for the current LVM series (search the list). I
> > certainly intend putting it into the experimental LVM branch soon.
> >
> > - Joe
>
> I haven't tried to apply it with beta8, but this is the writeable snapshot
> patch I used for beta7:
> (All I've used it for is replays and UUID changes, so YMMV.)
Thanks for posting this Dale, a short patch that adds a lot of
functionality! The reason I'm holding off applying this patch is that
I have a new asnyc. snapshot driver that is waiting to drop into
experimental soon. For the moment I've removed snapshots and pvmove
from the experimental branch.
- Joe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-07-30 9:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-27 17:22 [linux-lvm] Some ideas regarding snapshots (was: Reiserfs, 2. 4.7, snapshots w/ 0.9) Dale Stephenson
2001-07-30 9:47 ` Joe Thornber
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.