Some pstore/ramoops fixes
cover Some pstore/ramoops fixes
Hi Greg,
In the light of Linus' response, and I said this to Colin already, I'll just zap a prz at boot time for pstore/console interface, which means that nowadays there shouldn't be any objections to this bunch of fixes.
These are valid fixes for v3.5, they restore old pstore's behavior nuances, which I changed accidentaly.
Except for the last patch, which is just a fix I happened to make when I got bored of the warning. :-) Not a regression fix, though.
Thanks,
--- fs/pstore/inode.c | 2 +- fs/pstore/ram.c | 3 +++ fs/pstore/ram_core.c | 27 +++++++++++++++++---------- include/linux/pstore_ram.h | 2 ++ 4 files changed, 23 insertions(+), 11 deletions(-)
Signature · 2 lines
Anton Vorontsov Email: [email protected]
PATCH 1/5 pstore/ram: Should update old dmesg buffer before reading
Without the update, we'll only see the new dmesg buffer after the reboot, but previously we could see it right away. Making an oops visible in pstore filesystem before reboot is a somewhat dubious feature, but removing it wasn't an intentional change, so let's restore it.
For this we have to make persistent_ram_save_old() safe for calling multiple times, and also extern it.
--- fs/pstore/ram.c | 2 ++ fs/pstore/ram_core.c | 15 ++++++++------- include/linux/pstore_ram.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-)
fs/pstore/ram.c +2 -0
@@ -106,6 +106,8 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_sec =0 ; time->tv_nsec =0 ; +/* Update old/shadowed buffer. */ +persistent_ram_save_old (prz); size =persistent_ram_old_size (prz); *buf =kmalloc (size,GFP_KERNEL );if (*buf ==NULL )
fs/pstore/ram_core.c +8 -7
@@ -250,23 +250,24 @@ static void notrace persistent_ram_update(struct persistent_ram_zone *prz,persistent_ram_update_ecc (prz, start, count); } -static void __init -persistent_ram_save_old (struct persistent_ram_zone *prz) +void persistent_ram_save_old (struct persistent_ram_zone *prz) {struct persistent_ram_buffer *buffer = prz->buffer;size_t size =buffer_size (prz);size_t start =buffer_start (prz); -char *dest; -persistent_ram_ecc_old (prz); +if (!size) +return ; - dest =kmalloc (size,GFP_KERNEL ); -if (dest ==NULL ) { +if (!prz->old_log) { +persistent_ram_ecc_old (prz); + prz->old_log =kmalloc (size,GFP_KERNEL ); + } +if (!prz->old_log) {pr_err ("persistent_ram: failed to allocate buffer\n" );return ; } - prz->old_log = dest; prz->old_log_size = size;memcpy (prz->old_log, &buffer->data[start], size - start);memcpy (prz->old_log + size - start, &buffer->data[0 ], start);
include/linux/pstore_ram.h +1 -0
@@ -75,6 +75,7 @@ struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,int persistent_ram_write (struct persistent_ram_zone *prz,const void *s,unsigned int count); +void persistent_ram_save_old (struct persistent_ram_zone *prz);size_t persistent_ram_old_size (struct persistent_ram_zone *prz);void *persistent_ram_old (struct persistent_ram_zone *prz);void persistent_ram_free_old (struct persistent_ram_zone *prz);
Signature · 1 line
1.7.9.2
PATCH 2/5 pstore/ram_core: Do not reset restored zone's position and size
In reply to Anton VorontsovOtherwise, the files will survive just one reboot, and on a subsequent boot they will disappear.
--- fs/pstore/ram_core.c | 1 + 1 file changed, 1 insertion(+)
fs/pstore/ram_core.c +1 -0
@@ -406,6 +406,7 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool" size %zu, start %zu\n" , buffer_size(prz), buffer_start(prz));persistent_ram_save_old (prz); +return 0 ; } }else { pr_info("persistent_ram: no valid data in buffer"
Signature · 1 line
1.7.9.2
PATCH 3/5 pstore/ram_core: Factor persistent_ram_zap() out of post_init()
In reply to Anton VorontsovA handy function that we will use outside of ram_core soon. But so far just factor it out and start using it in post_init().
--- fs/pstore/ram_core.c | 11 ++++++++--- include/linux/pstore_ram.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-)
fs/pstore/ram_core.c +8 -3
@@ -320,6 +320,13 @@ void persistent_ram_free_old(struct persistent_ram_zone *prz) prz->old_log_size =0 ; } +void persistent_ram_zap (struct persistent_ram_zone *prz) +{ +atomic_set (&prz->buffer->start,0 ); +atomic_set (&prz->buffer->size,0 ); +persistent_ram_update_header_ecc (prz); +} +static void *persistent_ram_vmap (phys_addr_t start,size_t size) {struct page **pages;
@@ -414,8 +421,7 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool } prz->buffer->sig =PERSISTENT_RAM_SIG ; -atomic_set (&prz->buffer->start,0 ); -atomic_set (&prz->buffer->size,0 ); +persistent_ram_zap (prz);return 0 ; }
@@ -450,7 +456,6 @@ struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, goto err;persistent_ram_post_init (prz, ecc); -persistent_ram_update_header_ecc (prz);return prz; err:
include/linux/pstore_ram.h +1 -0
@@ -69,6 +69,7 @@ struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,size_t size, bool ecc);void persistent_ram_free (struct persistent_ram_zone *prz); +void persistent_ram_zap (struct persistent_ram_zone *prz);struct persistent_ram_zone *persistent_ram_init_ringbuffer (struct device *dev,bool ecc);
Signature · 1 line
1.7.9.2
PATCH 4/5 pstore/ram: Should zap persistent zone on unlink
In reply to Anton VorontsovOtherwise, unlinked file will reappear on the next boot.
--- fs/pstore/ram.c | 1 + 1 file changed, 1 insertion(+)
fs/pstore/ram.c +1 -0
@@ -186,6 +186,7 @@ static int ramoops_pstore_erase(enum pstore_type_id type, u64 id,return -EINVAL ;persistent_ram_free_old (cxt->przs[id]); +persistent_ram_zap (cxt->przs[id]);return 0 ; }
Signature · 1 line
1.7.9.2
PATCH 5/5 pstore/inode: Make pstore_fill_super() static
In reply to Anton VorontsovThere's no reason to extern it. The patch fixes the annoying sparse warning:
CHECK fs/pstore/inode.cfs/pstore/inode.c:264:5: warning: symbol 'pstore_fill_super' was not declared. Should it be static?
--- fs/pstore/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/inode.c +1 -1
@@ -258,7 +258,7 @@ fail:return rc; } -int pstore_fill_super (struct super_block *sb,void *data,int silent) +static int pstore_fill_super (struct super_block *sb,void *data,int silent) {struct inode *inode;
Signature · 1 line
1.7.9.2
Quoted 10 lines · Anton Vorontsov
In the light of Linus' response, and I said this to Colin already, I'll just zap a prz at boot time for pstore/console interface, which means that nowadays there shouldn't be any objections to this bunch of fixes.
These are valid fixes for v3.5, they restore old pstore's behavior nuances, which I changed accidentaly.
Except for the last patch, which is just a fix I happened to make when I got bored of the warning. :-) Not a regression fix, though.
Quoted 8 lines
Thanks,
--- fs/pstore/inode.c | 2 +- fs/pstore/ram.c | 3 +++ fs/pstore/ram_core.c | 27 +++++++++++++++++---------- include/linux/pstore_ram.h | 2 ++ 4 files changed, 23 insertions(+), 11 deletions(-)
Hi Greg,
Have you had a chance to look into these? Plus into "[PATCH v5 0/11] Merge ram_console into pstore" series, I believe there were no objections as well.
Thanks!
p.s. I must confess I have a huge pile of battery-related patches in my inbox that I have to review/apply, and folks start to send similar pings as I send to you now. :-) I should probably start working on my backlog to improve my karma, hehe.
Signature · 2 lines
Anton Vorontsov Email: [email protected]
Quoted 20 lines · Anton Vorontsov
Quoted 10 lines · Anton Vorontsov
In the light of Linus' response, and I said this to Colin already, I'll just zap a prz at boot time for pstore/console interface, which means that nowadays there shouldn't be any objections to this bunch of fixes.
These are valid fixes for v3.5, they restore old pstore's behavior nuances, which I changed accidentaly.
Except for the last patch, which is just a fix I happened to make when I got bored of the warning. :-) Not a regression fix, though.
Quoted 8 lines
Thanks,
--- fs/pstore/inode.c | 2 +- fs/pstore/ram.c | 3 +++ fs/pstore/ram_core.c | 27 +++++++++++++++++---------- include/linux/pstore_ram.h | 2 ++ 4 files changed, 23 insertions(+), 11 deletions(-)
Quoted 5 lines
Hi Greg,
Have you had a chance to look into these? Plus into "[PATCH v5 0/11] Merge
ram_consoleinto pstore" series, I believe there were no objections as well.
I'm getting there, give me this week to get through them all...
Quoted 11 lines · Anton Vorontsov
Hi Greg,
In the light of Linus' response, and I said this to Colin already, I'll just zap a prz at boot time for pstore/console interface, which means that nowadays there shouldn't be any objections to this bunch of fixes.
These are valid fixes for v3.5, they restore old pstore's behavior nuances, which I changed accidentaly.
Except for the last patch, which is just a fix I happened to make when I got bored of the warning. :-) Not a regression fix, though.
All now applied, thanks.
greg k-h