diff options
-rw-r--r-- | drivers/acpi/apei/erst.c | 8 | ||||
-rw-r--r-- | drivers/firmware/efi/efi-pstore.c | 26 | ||||
-rw-r--r-- | fs/pstore/inode.c | 12 | ||||
-rw-r--r-- | fs/pstore/ram.c | 15 | ||||
-rw-r--r-- | include/linux/pstore.h | 16 |
5 files changed, 31 insertions, 46 deletions
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 440588d189e7..7207e5fc9d3d 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
@@ -927,8 +927,7 @@ static int erst_open_pstore(struct pstore_info *psi); | |||
927 | static int erst_close_pstore(struct pstore_info *psi); | 927 | static int erst_close_pstore(struct pstore_info *psi); |
928 | static ssize_t erst_reader(struct pstore_record *record); | 928 | static ssize_t erst_reader(struct pstore_record *record); |
929 | static int erst_writer(struct pstore_record *record); | 929 | static int erst_writer(struct pstore_record *record); |
930 | static int erst_clearer(enum pstore_type_id type, u64 id, int count, | 930 | static int erst_clearer(struct pstore_record *record); |
931 | struct timespec time, struct pstore_info *psi); | ||
932 | 931 | ||
933 | static struct pstore_info erst_info = { | 932 | static struct pstore_info erst_info = { |
934 | .owner = THIS_MODULE, | 933 | .owner = THIS_MODULE, |
@@ -1100,10 +1099,9 @@ static int erst_writer(struct pstore_record *record) | |||
1100 | return ret; | 1099 | return ret; |
1101 | } | 1100 | } |
1102 | 1101 | ||
1103 | static int erst_clearer(enum pstore_type_id type, u64 id, int count, | 1102 | static int erst_clearer(struct pstore_record *record) |
1104 | struct timespec time, struct pstore_info *psi) | ||
1105 | { | 1103 | { |
1106 | return erst_clear(id); | 1104 | return erst_clear(record->id); |
1107 | } | 1105 | } |
1108 | 1106 | ||
1109 | static int __init erst_init(void) | 1107 | static int __init erst_init(void) |
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index f81e3ec6f1c0..93d8cdbe7ef4 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c | |||
@@ -266,10 +266,7 @@ static int efi_pstore_write(struct pstore_record *record) | |||
266 | }; | 266 | }; |
267 | 267 | ||
268 | struct pstore_erase_data { | 268 | struct pstore_erase_data { |
269 | u64 id; | 269 | struct pstore_record *record; |
270 | enum pstore_type_id type; | ||
271 | int count; | ||
272 | struct timespec time; | ||
273 | efi_char16_t *name; | 270 | efi_char16_t *name; |
274 | }; | 271 | }; |
275 | 272 | ||
@@ -295,8 +292,9 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) | |||
295 | * Check if an old format, which doesn't support | 292 | * Check if an old format, which doesn't support |
296 | * holding multiple logs, remains. | 293 | * holding multiple logs, remains. |
297 | */ | 294 | */ |
298 | sprintf(name_old, "dump-type%u-%u-%lu", ed->type, | 295 | snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu", |
299 | (unsigned int)ed->id, ed->time.tv_sec); | 296 | ed->record->type, (unsigned int)ed->record->id, |
297 | ed->record->time.tv_sec); | ||
300 | 298 | ||
301 | for (i = 0; i < DUMP_NAME_LEN; i++) | 299 | for (i = 0; i < DUMP_NAME_LEN; i++) |
302 | efi_name_old[i] = name_old[i]; | 300 | efi_name_old[i] = name_old[i]; |
@@ -321,8 +319,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) | |||
321 | return 1; | 319 | return 1; |
322 | } | 320 | } |
323 | 321 | ||
324 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | 322 | static int efi_pstore_erase(struct pstore_record *record) |
325 | struct timespec time, struct pstore_info *psi) | ||
326 | { | 323 | { |
327 | struct pstore_erase_data edata; | 324 | struct pstore_erase_data edata; |
328 | struct efivar_entry *entry = NULL; | 325 | struct efivar_entry *entry = NULL; |
@@ -331,17 +328,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
331 | int found, i; | 328 | int found, i; |
332 | unsigned int part; | 329 | unsigned int part; |
333 | 330 | ||
334 | do_div(id, 1000); | 331 | do_div(record->id, 1000); |
335 | part = do_div(id, 100); | 332 | part = do_div(record->id, 100); |
336 | sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec); | 333 | snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu", |
334 | record->type, record->part, record->count, | ||
335 | record->time.tv_sec); | ||
337 | 336 | ||
338 | for (i = 0; i < DUMP_NAME_LEN; i++) | 337 | for (i = 0; i < DUMP_NAME_LEN; i++) |
339 | efi_name[i] = name[i]; | 338 | efi_name[i] = name[i]; |
340 | 339 | ||
341 | edata.id = part; | 340 | edata.record = record; |
342 | edata.type = type; | ||
343 | edata.count = count; | ||
344 | edata.time = time; | ||
345 | edata.name = efi_name; | 341 | edata.name = efi_name; |
346 | 342 | ||
347 | if (efivar_entry_iter_begin()) | 343 | if (efivar_entry_iter_begin()) |
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 0ea281b457fa..06504b69575b 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -210,14 +210,12 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry) | |||
210 | if (err) | 210 | if (err) |
211 | return err; | 211 | return err; |
212 | 212 | ||
213 | if (record->psi->erase) { | 213 | if (!record->psi->erase) |
214 | mutex_lock(&record->psi->read_mutex); | ||
215 | record->psi->erase(record->type, record->id, record->count, | ||
216 | d_inode(dentry)->i_ctime, record->psi); | ||
217 | mutex_unlock(&record->psi->read_mutex); | ||
218 | } else { | ||
219 | return -EPERM; | 214 | return -EPERM; |
220 | } | 215 | |
216 | mutex_lock(&record->psi->read_mutex); | ||
217 | record->psi->erase(record); | ||
218 | mutex_unlock(&record->psi->read_mutex); | ||
221 | 219 | ||
222 | return simple_unlink(dir, dentry); | 220 | return simple_unlink(dir, dentry); |
223 | } | 221 | } |
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index ca6e2a814e37..a18575fe32e9 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c | |||
@@ -469,25 +469,24 @@ static int notrace ramoops_pstore_write_buf_user(enum pstore_type_id type, | |||
469 | return -EINVAL; | 469 | return -EINVAL; |
470 | } | 470 | } |
471 | 471 | ||
472 | static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, int count, | 472 | static int ramoops_pstore_erase(struct pstore_record *record) |
473 | struct timespec time, struct pstore_info *psi) | ||
474 | { | 473 | { |
475 | struct ramoops_context *cxt = psi->data; | 474 | struct ramoops_context *cxt = record->psi->data; |
476 | struct persistent_ram_zone *prz; | 475 | struct persistent_ram_zone *prz; |
477 | 476 | ||
478 | switch (type) { | 477 | switch (record->type) { |
479 | case PSTORE_TYPE_DMESG: | 478 | case PSTORE_TYPE_DMESG: |
480 | if (id >= cxt->max_dump_cnt) | 479 | if (record->id >= cxt->max_dump_cnt) |
481 | return -EINVAL; | 480 | return -EINVAL; |
482 | prz = cxt->dprzs[id]; | 481 | prz = cxt->dprzs[record->id]; |
483 | break; | 482 | break; |
484 | case PSTORE_TYPE_CONSOLE: | 483 | case PSTORE_TYPE_CONSOLE: |
485 | prz = cxt->cprz; | 484 | prz = cxt->cprz; |
486 | break; | 485 | break; |
487 | case PSTORE_TYPE_FTRACE: | 486 | case PSTORE_TYPE_FTRACE: |
488 | if (id >= cxt->max_ftrace_cnt) | 487 | if (record->id >= cxt->max_ftrace_cnt) |
489 | return -EINVAL; | 488 | return -EINVAL; |
490 | prz = cxt->fprzs[id]; | 489 | prz = cxt->fprzs[record->id]; |
491 | break; | 490 | break; |
492 | case PSTORE_TYPE_PMSG: | 491 | case PSTORE_TYPE_PMSG: |
493 | prz = cxt->mprz; | 492 | prz = cxt->mprz; |
diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 9335f75c3ddb..2cd1979d1f9a 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h | |||
@@ -177,15 +177,11 @@ struct pstore_record { | |||
177 | * | 177 | * |
178 | * @erase: | 178 | * @erase: |
179 | * Delete a record from backend storage. Different backends | 179 | * Delete a record from backend storage. Different backends |
180 | * identify records differently, so all possible methods of | 180 | * identify records differently, so entire original record is |
181 | * identification are included to help the backend locate the | 181 | * passed back to assist in identification of what the backend |
182 | * record to remove. | 182 | * should remove from storage. |
183 | * | 183 | * |
184 | * @type: in: pstore record type to write | 184 | * @record: pointer to record metadata. |
185 | * @id: in: per-type unique identifier for the record | ||
186 | * @count: in: Oops count | ||
187 | * @time: in: timestamp for the record | ||
188 | * @psi: in: pointer to the struct pstore_info for the backend | ||
189 | * | 185 | * |
190 | * Returns 0 on success, and non-zero on error. | 186 | * Returns 0 on success, and non-zero on error. |
191 | * | 187 | * |
@@ -215,9 +211,7 @@ struct pstore_info { | |||
215 | enum kmsg_dump_reason reason, u64 *id, | 211 | enum kmsg_dump_reason reason, u64 *id, |
216 | unsigned int part, const char __user *buf, | 212 | unsigned int part, const char __user *buf, |
217 | bool compressed, size_t size, struct pstore_info *psi); | 213 | bool compressed, size_t size, struct pstore_info *psi); |
218 | int (*erase)(enum pstore_type_id type, u64 id, | 214 | int (*erase)(struct pstore_record *record); |
219 | int count, struct timespec time, | ||
220 | struct pstore_info *psi); | ||
221 | }; | 215 | }; |
222 | 216 | ||
223 | /* Supported frontends */ | 217 | /* Supported frontends */ |