Skip to content

Commit

Permalink
dm snapshot: move status to exception store
Browse files Browse the repository at this point in the history
Let the exception store types print out their status through
the new API, rather than having the snapshot code do it.

Adjust the buffer position to allow for the preceding DMEMIT in the
arguments to type->status().

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Jonathan Brassow authored and Alasdair G Kergon committed Apr 2, 2009
1 parent fee1998 commit 1e302a9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
5 changes: 3 additions & 2 deletions drivers/md/dm-exception-store.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ struct dm_exception_store_type {
*/
void (*drop_snapshot) (struct dm_exception_store *store);

int (*status) (struct dm_exception_store *store, status_type_t status,
char *result, unsigned int maxlen);
unsigned (*status) (struct dm_exception_store *store,
status_type_t status, char *result,
unsigned maxlen);

/*
* Return how full the snapshot is.
Expand Down
16 changes: 12 additions & 4 deletions drivers/md/dm-snap-persistent.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,19 @@ static int persistent_ctr(struct dm_exception_store *store,
return 0;
}

static int persistent_status(struct dm_exception_store *store,
status_type_t status, char *result,
unsigned int maxlen)
static unsigned persistent_status(struct dm_exception_store *store,
status_type_t status, char *result,
unsigned maxlen)
{
int sz = 0;
unsigned sz = 0;

switch (status) {
case STATUSTYPE_INFO:
break;
case STATUSTYPE_TABLE:
DMEMIT(" %s P %llu", store->cow->name,
(unsigned long long)store->chunk_size);
}

return sz;
}
Expand Down
16 changes: 12 additions & 4 deletions drivers/md/dm-snap-transient.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ static int transient_ctr(struct dm_exception_store *store,
return 0;
}

static int transient_status(struct dm_exception_store *store,
status_type_t status, char *result,
unsigned maxlen)
static unsigned transient_status(struct dm_exception_store *store,
status_type_t status, char *result,
unsigned maxlen)
{
int sz = 0;
unsigned sz = 0;

switch (status) {
case STATUSTYPE_INFO:
break;
case STATUSTYPE_TABLE:
DMEMIT(" %s N %llu", store->cow->name,
(unsigned long long)store->chunk_size);
}

return sz;
}
Expand Down
8 changes: 2 additions & 6 deletions drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ struct dm_snapshot {
/* Origin writes don't trigger exceptions until this is set */
int active;

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

mempool_t *pending_pool;

atomic_t pending_exceptions_count;
Expand Down Expand Up @@ -1166,9 +1163,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
* make sense.
*/
DMEMIT("%s", snap->origin->name);
DMEMIT(" %s %s %llu", snap->store->cow->name,
snap->store->type->name,
(unsigned long long)snap->store->chunk_size);
snap->store->type->status(snap->store, type, result + sz,
maxlen - sz);
break;
}

Expand Down

0 comments on commit 1e302a9

Please sign in to comment.