Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 19325
b: refs/heads/master
c: aa14ede
h: refs/heads/master
i:
  19323: c1d6585
v: v3
  • Loading branch information
Alasdair G Kergon authored and Linus Torvalds committed Feb 1, 2006
1 parent d277d92 commit 35eb8c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb82a6cdf994d6656ad0a25ed28395af3416a27c
refs/heads/master: aa14edeb994f8f7e223d02ad14780bf2fa719f6d
23 changes: 12 additions & 11 deletions trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,11 @@ static inline ulong round_up(ulong n, ulong size)

static void read_snapshot_metadata(struct dm_snapshot *s)
{
if (s->have_metadata)
return;

if (s->store.read_metadata(&s->store)) {
down_write(&s->lock);
s->valid = 0;
up_write(&s->lock);
}

s->have_metadata = 1;
}

/*
Expand Down Expand Up @@ -471,7 +466,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
s->chunk_shift = ffs(chunk_size) - 1;

s->valid = 1;
s->have_metadata = 0;
s->active = 0;
s->last_percent = 0;
init_rwsem(&s->lock);
s->table = ti->table;
Expand Down Expand Up @@ -506,7 +501,11 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad5;
}

/* Metadata must only be loaded into one table at once */
read_snapshot_metadata(s);

/* Add snapshot to the list of snapshots for this origin */
/* Exceptions aren't triggered till snapshot_resume() is called */
if (register_snapshot(s)) {
r = -EINVAL;
ti->error = "Cannot register snapshot origin";
Expand Down Expand Up @@ -862,7 +861,9 @@ static void snapshot_resume(struct dm_target *ti)
{
struct dm_snapshot *s = (struct dm_snapshot *) ti->private;

read_snapshot_metadata(s);
down_write(&s->lock);
s->active = 1;
up_write(&s->lock);
}

static int snapshot_status(struct dm_target *ti, status_type_t type,
Expand Down Expand Up @@ -932,8 +933,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
/* Do all the snapshots on this origin */
list_for_each_entry (snap, snapshots, list) {

/* Only deal with valid snapshots */
if (!snap->valid)
/* Only deal with valid and active snapshots */
if (!snap->valid || !snap->active)
continue;

/* Nothing to do if writing beyond end of snapshot */
Expand Down Expand Up @@ -1104,7 +1105,7 @@ static int origin_status(struct dm_target *ti, status_type_t type, char *result,

static struct target_type origin_target = {
.name = "snapshot-origin",
.version = {1, 0, 1},
.version = {1, 1, 0},
.module = THIS_MODULE,
.ctr = origin_ctr,
.dtr = origin_dtr,
Expand All @@ -1115,7 +1116,7 @@ static struct target_type origin_target = {

static struct target_type snapshot_target = {
.name = "snapshot",
.version = {1, 0, 1},
.version = {1, 1, 0},
.module = THIS_MODULE,
.ctr = snapshot_ctr,
.dtr = snapshot_dtr,
Expand Down
4 changes: 3 additions & 1 deletion trunk/drivers/md/dm-snap.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ struct dm_snapshot {

/* You can't use a snapshot if this is 0 (e.g. if full) */
int valid;
int have_metadata;

/* Origin writes don't trigger exceptions until this is set */
int active;

/* Used for display of table */
char type;
Expand Down

0 comments on commit 35eb8c6

Please sign in to comment.