Skip to content

Commit 6ed23fd

Browse files
committed
Merge branch 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux
* 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux: pstore: gracefully handle NULL pstore_info functions pstore: pass reason to backend write callback
2 parents 5ee354a + 2174f6d commit 6ed23fd

5 files changed

Lines changed: 20 additions & 45 deletions

File tree

‎drivers/acpi/apei/erst.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,8 @@ static int erst_close_pstore(struct pstore_info *psi);
934934
static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
935935
struct timespec *time, char **buf,
936936
struct pstore_info *psi);
937-
static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part,
937+
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
938+
u64 *id, unsigned int part,
938939
size_t size, struct pstore_info *psi);
939940
static int erst_clearer(enum pstore_type_id type, u64 id,
940941
struct pstore_info *psi);
@@ -1053,7 +1054,8 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
10531054
return (rc < 0) ? rc : (len - sizeof(*rcd));
10541055
}
10551056

1056-
static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part,
1057+
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
1058+
u64 *id, unsigned int part,
10571059
size_t size, struct pstore_info *psi)
10581060
{
10591061
struct cper_pstore_record *rcd = (struct cper_pstore_record *)

‎drivers/firmware/efivars.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
495495
return 0;
496496
}
497497

498-
static int efi_pstore_write(enum pstore_type_id type, u64 *id,
498+
static int efi_pstore_write(enum pstore_type_id type,
499+
enum kmsg_dump_reason reason, u64 *id,
499500
unsigned int part, size_t size, struct pstore_info *psi)
500501
{
501502
char name[DUMP_NAME_LEN];
@@ -565,7 +566,7 @@ static int efi_pstore_write(enum pstore_type_id type, u64 *id,
565566
static int efi_pstore_erase(enum pstore_type_id type, u64 id,
566567
struct pstore_info *psi)
567568
{
568-
efi_pstore_write(type, &id, (unsigned int)id, 0, psi);
569+
efi_pstore_write(type, 0, &id, (unsigned int)id, 0, psi);
569570

570571
return 0;
571572
}
@@ -587,7 +588,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
587588
return -1;
588589
}
589590

590-
static int efi_pstore_write(enum pstore_type_id type, u64 *id,
591+
static int efi_pstore_write(enum pstore_type_id type,
592+
enum kmsg_dump_reason reason, u64 *id,
591593
unsigned int part, size_t size, struct pstore_info *psi)
592594
{
593595
return 0;

‎fs/pstore/inode.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
8080
{
8181
struct pstore_private *p = dentry->d_inode->i_private;
8282

83-
p->psi->erase(p->type, p->id, p->psi);
83+
if (p->psi->erase)
84+
p->psi->erase(p->type, p->id, p->psi);
8485

8586
return simple_unlink(dir, dentry);
8687
}

‎fs/pstore/platform.c‎

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
122122
memcpy(dst, s1 + s1_start, l1_cpy);
123123
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
124124

125-
ret = psinfo->write(PSTORE_TYPE_DMESG, &id, part,
125+
ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part,
126126
hsize + l1_cpy + l2_cpy, psinfo);
127127
if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())
128128
pstore_new_entry = 1;
@@ -207,8 +207,7 @@ void pstore_get_records(int quiet)
207207
return;
208208

209209
mutex_lock(&psi->read_mutex);
210-
rc = psi->open(psi);
211-
if (rc)
210+
if (psi->open && psi->open(psi))
212211
goto out;
213212

214213
while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) {
@@ -219,7 +218,8 @@ void pstore_get_records(int quiet)
219218
if (rc && (rc != -EEXIST || !quiet))
220219
failed++;
221220
}
222-
psi->close(psi);
221+
if (psi->close)
222+
psi->close(psi);
223223
out:
224224
mutex_unlock(&psi->read_mutex);
225225

@@ -243,33 +243,5 @@ static void pstore_timefunc(unsigned long dummy)
243243
mod_timer(&pstore_timer, jiffies + PSTORE_INTERVAL);
244244
}
245245

246-
/*
247-
* Call platform driver to write a record to the
248-
* persistent store.
249-
*/
250-
int pstore_write(enum pstore_type_id type, char *buf, size_t size)
251-
{
252-
u64 id;
253-
int ret;
254-
unsigned long flags;
255-
256-
if (!psinfo)
257-
return -ENODEV;
258-
259-
if (size > psinfo->bufsize)
260-
return -EFBIG;
261-
262-
spin_lock_irqsave(&psinfo->buf_lock, flags);
263-
memcpy(psinfo->buf, buf, size);
264-
ret = psinfo->write(type, &id, 0, size, psinfo);
265-
if (ret == 0 && pstore_is_mounted())
266-
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf,
267-
size, CURRENT_TIME, psinfo);
268-
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
269-
270-
return 0;
271-
}
272-
EXPORT_SYMBOL_GPL(pstore_write);
273-
274246
module_param(backend, charp, 0444);
275247
MODULE_PARM_DESC(backend, "Pstore backend to use");

‎include/linux/pstore.h‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#ifndef _LINUX_PSTORE_H
2323
#define _LINUX_PSTORE_H
2424

25+
#include <linux/time.h>
26+
#include <linux/kmsg_dump.h>
27+
2528
/* types */
2629
enum pstore_type_id {
2730
PSTORE_TYPE_DMESG = 0,
@@ -41,7 +44,8 @@ struct pstore_info {
4144
ssize_t (*read)(u64 *id, enum pstore_type_id *type,
4245
struct timespec *time, char **buf,
4346
struct pstore_info *psi);
44-
int (*write)(enum pstore_type_id type, u64 *id,
47+
int (*write)(enum pstore_type_id type,
48+
enum kmsg_dump_reason reason, u64 *id,
4549
unsigned int part, size_t size, struct pstore_info *psi);
4650
int (*erase)(enum pstore_type_id type, u64 id,
4751
struct pstore_info *psi);
@@ -50,18 +54,12 @@ struct pstore_info {
5054

5155
#ifdef CONFIG_PSTORE
5256
extern int pstore_register(struct pstore_info *);
53-
extern int pstore_write(enum pstore_type_id type, char *buf, size_t size);
5457
#else
5558
static inline int
5659
pstore_register(struct pstore_info *psi)
5760
{
5861
return -ENODEV;
5962
}
60-
static inline int
61-
pstore_write(enum pstore_type_id type, char *buf, size_t size)
62-
{
63-
return -ENODEV;
64-
}
6563
#endif
6664

6765
#endif /*_LINUX_PSTORE_H*/

0 commit comments

Comments
 (0)