Skip to content

Commit 5628068

Browse files
Matthew Garrettaegl
authored andcommitted
pstore: Add extra context for writes and erases
EFI only provides small amounts of individual storage, and conventionally puts metadata in the storage variable name. Rather than add a metadata header to the (already limited) variable storage, it's easier for us to modify pstore to pass all the information we need to construct a unique variable name to the appropriate functions. Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent 638c1fd commit 5628068

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎drivers/acpi/apei/erst.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,10 @@ static int erst_open_pstore(struct pstore_info *psi);
933933
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, struct pstore_info *psi);
936-
static u64 erst_writer(enum pstore_type_id type, size_t size,
936+
static u64 erst_writer(enum pstore_type_id type, int part, size_t size,
937937
struct pstore_info *psi);
938-
static int erst_clearer(u64 id, struct pstore_info *psi);
938+
static int erst_clearer(enum pstore_type_id type, u64 id,
939+
struct pstore_info *psi);
939940

940941
static struct pstore_info erst_info = {
941942
.owner = THIS_MODULE,
@@ -1039,7 +1040,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
10391040
return (rc < 0) ? rc : (len - sizeof(*rcd));
10401041
}
10411042

1042-
static u64 erst_writer(enum pstore_type_id type, size_t size,
1043+
static u64 erst_writer(enum pstore_type_id type, int part, size_t size,
10431044
struct pstore_info *psi)
10441045
{
10451046
struct cper_pstore_record *rcd = (struct cper_pstore_record *)
@@ -1083,7 +1084,8 @@ static u64 erst_writer(enum pstore_type_id type, size_t size,
10831084
return rcd->hdr.record_id;
10841085
}
10851086

1086-
static int erst_clearer(u64 id, struct pstore_info *psi)
1087+
static int erst_clearer(enum pstore_type_id type, u64 id,
1088+
struct pstore_info *psi)
10871089
{
10881090
return erst_clear(id);
10891091
}

‎fs/pstore/inode.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
#define PSTORE_NAMELEN 64
4040

4141
struct pstore_private {
42-
u64 id;
4342
struct pstore_info *psi;
43+
enum pstore_type_id type;
44+
u64 id;
4445
ssize_t size;
4546
char data[];
4647
};
@@ -73,7 +74,7 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
7374
{
7475
struct pstore_private *p = dentry->d_inode->i_private;
7576

76-
p->psi->erase(p->id, p->psi);
77+
p->psi->erase(p->type, p->id, p->psi);
7778

7879
return simple_unlink(dir, dentry);
7980
}
@@ -192,6 +193,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id,
192193
private = kmalloc(sizeof *private + size, GFP_KERNEL);
193194
if (!private)
194195
goto fail_alloc;
196+
private->type = type;
195197
private->id = id;
196198
private->psi = psi;
197199

‎fs/pstore/platform.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
7878
oopscount++;
7979
while (total < kmsg_bytes) {
8080
dst = psinfo->buf;
81-
hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++);
81+
hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part);
8282
size = psinfo->bufsize - hsize;
8383
dst += hsize;
8484

@@ -94,15 +94,16 @@ static void pstore_dump(struct kmsg_dumper *dumper,
9494
memcpy(dst, s1 + s1_start, l1_cpy);
9595
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
9696

97-
id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy,
98-
psinfo);
97+
id = psinfo->write(PSTORE_TYPE_DMESG, part,
98+
hsize + l1_cpy + l2_cpy, psinfo);
9999
if (reason == KMSG_DUMP_OOPS && pstore_is_mounted())
100100
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id,
101101
psinfo->buf, hsize + l1_cpy + l2_cpy,
102102
CURRENT_TIME, psinfo);
103103
l1 -= l1_cpy;
104104
l2 -= l2_cpy;
105105
total += l1_cpy + l2_cpy;
106+
part++;
106107
}
107108
mutex_unlock(&psinfo->buf_mutex);
108109
}
@@ -197,7 +198,7 @@ int pstore_write(enum pstore_type_id type, char *buf, size_t size)
197198

198199
mutex_lock(&psinfo->buf_mutex);
199200
memcpy(psinfo->buf, buf, size);
200-
id = psinfo->write(type, size, psinfo);
201+
id = psinfo->write(type, 0, size, psinfo);
201202
if (pstore_is_mounted())
202203
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf,
203204
size, CURRENT_TIME, psinfo);

‎include/linux/pstore.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ struct pstore_info {
3939
int (*close)(struct pstore_info *psi);
4040
ssize_t (*read)(u64 *id, enum pstore_type_id *type,
4141
struct timespec *time, struct pstore_info *psi);
42-
u64 (*write)(enum pstore_type_id type, size_t size,
42+
u64 (*write)(enum pstore_type_id type, int part,
43+
size_t size, struct pstore_info *psi);
44+
int (*erase)(enum pstore_type_id type, u64 id,
4345
struct pstore_info *psi);
44-
int (*erase)(u64 id, struct pstore_info *psi);
4546
void *data;
4647
};
4748

0 commit comments

Comments
 (0)