diff options
Diffstat (limited to 'drivers/md/dm-log-userspace-base.c')
| -rw-r--r-- | drivers/md/dm-log-userspace-base.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c index e69b96560997..6e186b1a062d 100644 --- a/drivers/md/dm-log-userspace-base.c +++ b/drivers/md/dm-log-userspace-base.c | |||
| @@ -21,6 +21,7 @@ struct log_c { | |||
| 21 | struct dm_target *ti; | 21 | struct dm_target *ti; |
| 22 | uint32_t region_size; | 22 | uint32_t region_size; |
| 23 | region_t region_count; | 23 | region_t region_count; |
| 24 | uint64_t luid; | ||
| 24 | char uuid[DM_UUID_LEN]; | 25 | char uuid[DM_UUID_LEN]; |
| 25 | 26 | ||
| 26 | char *usr_argv_str; | 27 | char *usr_argv_str; |
| @@ -63,7 +64,7 @@ static int userspace_do_request(struct log_c *lc, const char *uuid, | |||
| 63 | * restored. | 64 | * restored. |
| 64 | */ | 65 | */ |
| 65 | retry: | 66 | retry: |
| 66 | r = dm_consult_userspace(uuid, request_type, data, | 67 | r = dm_consult_userspace(uuid, lc->luid, request_type, data, |
| 67 | data_size, rdata, rdata_size); | 68 | data_size, rdata, rdata_size); |
| 68 | 69 | ||
| 69 | if (r != -ESRCH) | 70 | if (r != -ESRCH) |
| @@ -74,14 +75,15 @@ retry: | |||
| 74 | set_current_state(TASK_INTERRUPTIBLE); | 75 | set_current_state(TASK_INTERRUPTIBLE); |
| 75 | schedule_timeout(2*HZ); | 76 | schedule_timeout(2*HZ); |
| 76 | DMWARN("Attempting to contact userspace log server..."); | 77 | DMWARN("Attempting to contact userspace log server..."); |
| 77 | r = dm_consult_userspace(uuid, DM_ULOG_CTR, lc->usr_argv_str, | 78 | r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_CTR, |
| 79 | lc->usr_argv_str, | ||
| 78 | strlen(lc->usr_argv_str) + 1, | 80 | strlen(lc->usr_argv_str) + 1, |
| 79 | NULL, NULL); | 81 | NULL, NULL); |
| 80 | if (!r) | 82 | if (!r) |
| 81 | break; | 83 | break; |
| 82 | } | 84 | } |
| 83 | DMINFO("Reconnected to userspace log server... DM_ULOG_CTR complete"); | 85 | DMINFO("Reconnected to userspace log server... DM_ULOG_CTR complete"); |
| 84 | r = dm_consult_userspace(uuid, DM_ULOG_RESUME, NULL, | 86 | r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_RESUME, NULL, |
| 85 | 0, NULL, NULL); | 87 | 0, NULL, NULL); |
| 86 | if (!r) | 88 | if (!r) |
| 87 | goto retry; | 89 | goto retry; |
| @@ -111,10 +113,9 @@ static int build_constructor_string(struct dm_target *ti, | |||
| 111 | return -ENOMEM; | 113 | return -ENOMEM; |
| 112 | } | 114 | } |
| 113 | 115 | ||
| 114 | for (i = 0, str_size = 0; i < argc; i++) | 116 | str_size = sprintf(str, "%llu", (unsigned long long)ti->len); |
| 115 | str_size += sprintf(str + str_size, "%s ", argv[i]); | 117 | for (i = 0; i < argc; i++) |
| 116 | str_size += sprintf(str + str_size, "%llu", | 118 | str_size += sprintf(str + str_size, " %s", argv[i]); |
| 117 | (unsigned long long)ti->len); | ||
| 118 | 119 | ||
| 119 | *ctr_str = str; | 120 | *ctr_str = str; |
| 120 | return str_size; | 121 | return str_size; |
| @@ -154,6 +155,9 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, | |||
| 154 | return -ENOMEM; | 155 | return -ENOMEM; |
| 155 | } | 156 | } |
| 156 | 157 | ||
| 158 | /* The ptr value is sufficient for local unique id */ | ||
| 159 | lc->luid = (uint64_t)lc; | ||
| 160 | |||
| 157 | lc->ti = ti; | 161 | lc->ti = ti; |
| 158 | 162 | ||
| 159 | if (strlen(argv[0]) > (DM_UUID_LEN - 1)) { | 163 | if (strlen(argv[0]) > (DM_UUID_LEN - 1)) { |
| @@ -173,7 +177,7 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, | |||
| 173 | } | 177 | } |
| 174 | 178 | ||
| 175 | /* Send table string */ | 179 | /* Send table string */ |
| 176 | r = dm_consult_userspace(lc->uuid, DM_ULOG_CTR, | 180 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_CTR, |
| 177 | ctr_str, str_size, NULL, NULL); | 181 | ctr_str, str_size, NULL, NULL); |
| 178 | 182 | ||
| 179 | if (r == -ESRCH) { | 183 | if (r == -ESRCH) { |
| @@ -183,7 +187,7 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, | |||
| 183 | 187 | ||
| 184 | /* Since the region size does not change, get it now */ | 188 | /* Since the region size does not change, get it now */ |
| 185 | rdata_size = sizeof(rdata); | 189 | rdata_size = sizeof(rdata); |
| 186 | r = dm_consult_userspace(lc->uuid, DM_ULOG_GET_REGION_SIZE, | 190 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_GET_REGION_SIZE, |
| 187 | NULL, 0, (char *)&rdata, &rdata_size); | 191 | NULL, 0, (char *)&rdata, &rdata_size); |
| 188 | 192 | ||
| 189 | if (r) { | 193 | if (r) { |
| @@ -212,7 +216,7 @@ static void userspace_dtr(struct dm_dirty_log *log) | |||
| 212 | int r; | 216 | int r; |
| 213 | struct log_c *lc = log->context; | 217 | struct log_c *lc = log->context; |
| 214 | 218 | ||
| 215 | r = dm_consult_userspace(lc->uuid, DM_ULOG_DTR, | 219 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_DTR, |
| 216 | NULL, 0, | 220 | NULL, 0, |
| 217 | NULL, NULL); | 221 | NULL, NULL); |
| 218 | 222 | ||
| @@ -227,7 +231,7 @@ static int userspace_presuspend(struct dm_dirty_log *log) | |||
| 227 | int r; | 231 | int r; |
| 228 | struct log_c *lc = log->context; | 232 | struct log_c *lc = log->context; |
| 229 | 233 | ||
| 230 | r = dm_consult_userspace(lc->uuid, DM_ULOG_PRESUSPEND, | 234 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_PRESUSPEND, |
| 231 | NULL, 0, | 235 | NULL, 0, |
| 232 | NULL, NULL); | 236 | NULL, NULL); |
| 233 | 237 | ||
| @@ -239,7 +243,7 @@ static int userspace_postsuspend(struct dm_dirty_log *log) | |||
| 239 | int r; | 243 | int r; |
| 240 | struct log_c *lc = log->context; | 244 | struct log_c *lc = log->context; |
| 241 | 245 | ||
| 242 | r = dm_consult_userspace(lc->uuid, DM_ULOG_POSTSUSPEND, | 246 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_POSTSUSPEND, |
| 243 | NULL, 0, | 247 | NULL, 0, |
| 244 | NULL, NULL); | 248 | NULL, NULL); |
| 245 | 249 | ||
| @@ -252,7 +256,7 @@ static int userspace_resume(struct dm_dirty_log *log) | |||
| 252 | struct log_c *lc = log->context; | 256 | struct log_c *lc = log->context; |
| 253 | 257 | ||
| 254 | lc->in_sync_hint = 0; | 258 | lc->in_sync_hint = 0; |
| 255 | r = dm_consult_userspace(lc->uuid, DM_ULOG_RESUME, | 259 | r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_RESUME, |
| 256 | NULL, 0, | 260 | NULL, 0, |
| 257 | NULL, NULL); | 261 | NULL, NULL); |
| 258 | 262 | ||
| @@ -561,6 +565,7 @@ static int userspace_status(struct dm_dirty_log *log, status_type_t status_type, | |||
| 561 | char *result, unsigned maxlen) | 565 | char *result, unsigned maxlen) |
| 562 | { | 566 | { |
| 563 | int r = 0; | 567 | int r = 0; |
| 568 | char *table_args; | ||
| 564 | size_t sz = (size_t)maxlen; | 569 | size_t sz = (size_t)maxlen; |
| 565 | struct log_c *lc = log->context; | 570 | struct log_c *lc = log->context; |
| 566 | 571 | ||
| @@ -577,8 +582,12 @@ static int userspace_status(struct dm_dirty_log *log, status_type_t status_type, | |||
| 577 | break; | 582 | break; |
| 578 | case STATUSTYPE_TABLE: | 583 | case STATUSTYPE_TABLE: |
| 579 | sz = 0; | 584 | sz = 0; |
| 580 | DMEMIT("%s %u %s %s", log->type->name, lc->usr_argc + 1, | 585 | table_args = strstr(lc->usr_argv_str, " "); |
| 581 | lc->uuid, lc->usr_argv_str); | 586 | BUG_ON(!table_args); /* There will always be a ' ' */ |
| 587 | table_args++; | ||
| 588 | |||
| 589 | DMEMIT("%s %u %s %s ", log->type->name, lc->usr_argc, | ||
| 590 | lc->uuid, table_args); | ||
| 582 | break; | 591 | break; |
| 583 | } | 592 | } |
| 584 | return (r) ? 0 : (int)sz; | 593 | return (r) ? 0 : (int)sz; |
