Commit 1e302a929e2da6e8448e2058e4b07b07252b57fe
Committed by
Alasdair G Kergon
1 parent
fee1998e9c
Exists in
master
and in
39 other branches
dm snapshot: move status to exception store
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>
Showing 4 changed files with 29 additions and 16 deletions Side-by-side Diff
drivers/md/dm-exception-store.h
... | ... | @@ -79,8 +79,9 @@ |
79 | 79 | */ |
80 | 80 | void (*drop_snapshot) (struct dm_exception_store *store); |
81 | 81 | |
82 | - int (*status) (struct dm_exception_store *store, status_type_t status, | |
83 | - char *result, unsigned int maxlen); | |
82 | + unsigned (*status) (struct dm_exception_store *store, | |
83 | + status_type_t status, char *result, | |
84 | + unsigned maxlen); | |
84 | 85 | |
85 | 86 | /* |
86 | 87 | * Return how full the snapshot is. |
drivers/md/dm-snap-persistent.c
... | ... | @@ -688,11 +688,19 @@ |
688 | 688 | return 0; |
689 | 689 | } |
690 | 690 | |
691 | -static int persistent_status(struct dm_exception_store *store, | |
692 | - status_type_t status, char *result, | |
693 | - unsigned int maxlen) | |
691 | +static unsigned persistent_status(struct dm_exception_store *store, | |
692 | + status_type_t status, char *result, | |
693 | + unsigned maxlen) | |
694 | 694 | { |
695 | - int sz = 0; | |
695 | + unsigned sz = 0; | |
696 | + | |
697 | + switch (status) { | |
698 | + case STATUSTYPE_INFO: | |
699 | + break; | |
700 | + case STATUSTYPE_TABLE: | |
701 | + DMEMIT(" %s P %llu", store->cow->name, | |
702 | + (unsigned long long)store->chunk_size); | |
703 | + } | |
696 | 704 | |
697 | 705 | return sz; |
698 | 706 | } |
drivers/md/dm-snap-transient.c
... | ... | @@ -81,11 +81,19 @@ |
81 | 81 | return 0; |
82 | 82 | } |
83 | 83 | |
84 | -static int transient_status(struct dm_exception_store *store, | |
85 | - status_type_t status, char *result, | |
86 | - unsigned maxlen) | |
84 | +static unsigned transient_status(struct dm_exception_store *store, | |
85 | + status_type_t status, char *result, | |
86 | + unsigned maxlen) | |
87 | 87 | { |
88 | - int sz = 0; | |
88 | + unsigned sz = 0; | |
89 | + | |
90 | + switch (status) { | |
91 | + case STATUSTYPE_INFO: | |
92 | + break; | |
93 | + case STATUSTYPE_TABLE: | |
94 | + DMEMIT(" %s N %llu", store->cow->name, | |
95 | + (unsigned long long)store->chunk_size); | |
96 | + } | |
89 | 97 | |
90 | 98 | return sz; |
91 | 99 | } |
drivers/md/dm-snap.c
... | ... | @@ -70,9 +70,6 @@ |
70 | 70 | /* Origin writes don't trigger exceptions until this is set */ |
71 | 71 | int active; |
72 | 72 | |
73 | - /* Used for display of table */ | |
74 | - char type; | |
75 | - | |
76 | 73 | mempool_t *pending_pool; |
77 | 74 | |
78 | 75 | atomic_t pending_exceptions_count; |
... | ... | @@ -1166,9 +1163,8 @@ |
1166 | 1163 | * make sense. |
1167 | 1164 | */ |
1168 | 1165 | DMEMIT("%s", snap->origin->name); |
1169 | - DMEMIT(" %s %s %llu", snap->store->cow->name, | |
1170 | - snap->store->type->name, | |
1171 | - (unsigned long long)snap->store->chunk_size); | |
1166 | + snap->store->type->status(snap->store, type, result + sz, | |
1167 | + maxlen - sz); | |
1172 | 1168 | break; |
1173 | 1169 | } |
1174 | 1170 |