Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matthew Garrett and committed by
Tony Luck
56280682 638c1fd3

+18 -12
+6 -4
drivers/acpi/apei/erst.c
··· 933 933 static int erst_close_pstore(struct pstore_info *psi); 934 934 static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, 935 935 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, 937 937 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); 939 940 940 941 static struct pstore_info erst_info = { 941 942 .owner = THIS_MODULE, ··· 1040 1039 return (rc < 0) ? rc : (len - sizeof(*rcd)); 1041 1040 } 1042 1041 1043 - static u64 erst_writer(enum pstore_type_id type, size_t size, 1042 + static u64 erst_writer(enum pstore_type_id type, int part, size_t size, 1044 1043 struct pstore_info *psi) 1045 1044 { 1046 1045 struct cper_pstore_record *rcd = (struct cper_pstore_record *) ··· 1084 1083 return rcd->hdr.record_id; 1085 1084 } 1086 1085 1087 - static int erst_clearer(u64 id, struct pstore_info *psi) 1086 + static int erst_clearer(enum pstore_type_id type, u64 id, 1087 + struct pstore_info *psi) 1088 1088 { 1089 1089 return erst_clear(id); 1090 1090 }
+4 -2
fs/pstore/inode.c
··· 39 39 #define PSTORE_NAMELEN 64 40 40 41 41 struct pstore_private { 42 - u64 id; 43 42 struct pstore_info *psi; 43 + enum pstore_type_id type; 44 + u64 id; 44 45 ssize_t size; 45 46 char data[]; 46 47 }; ··· 74 73 { 75 74 struct pstore_private *p = dentry->d_inode->i_private; 76 75 77 - p->psi->erase(p->id, p->psi); 76 + p->psi->erase(p->type, p->id, p->psi); 78 77 79 78 return simple_unlink(dir, dentry); 80 79 } ··· 193 192 private = kmalloc(sizeof *private + size, GFP_KERNEL); 194 193 if (!private) 195 194 goto fail_alloc; 195 + private->type = type; 196 196 private->id = id; 197 197 private->psi = psi; 198 198
+5 -4
fs/pstore/platform.c
··· 78 78 oopscount++; 79 79 while (total < kmsg_bytes) { 80 80 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); 82 82 size = psinfo->bufsize - hsize; 83 83 dst += hsize; 84 84 ··· 94 94 memcpy(dst, s1 + s1_start, l1_cpy); 95 95 memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); 96 96 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); 99 99 if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) 100 100 pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, 101 101 psinfo->buf, hsize + l1_cpy + l2_cpy, ··· 103 103 l1 -= l1_cpy; 104 104 l2 -= l2_cpy; 105 105 total += l1_cpy + l2_cpy; 106 + part++; 106 107 } 107 108 mutex_unlock(&psinfo->buf_mutex); 108 109 } ··· 198 197 199 198 mutex_lock(&psinfo->buf_mutex); 200 199 memcpy(psinfo->buf, buf, size); 201 - id = psinfo->write(type, size, psinfo); 200 + id = psinfo->write(type, 0, size, psinfo); 202 201 if (pstore_is_mounted()) 203 202 pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf, 204 203 size, CURRENT_TIME, psinfo);
+3 -2
include/linux/pstore.h
··· 39 39 int (*close)(struct pstore_info *psi); 40 40 ssize_t (*read)(u64 *id, enum pstore_type_id *type, 41 41 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, 43 45 struct pstore_info *psi); 44 - int (*erase)(u64 id, struct pstore_info *psi); 45 46 void *data; 46 47 }; 47 48