[PATCH linux-next] pstore/ram: Fix pstore lost information

From: chenguanxi11234
Date: Mon Aug 12 2024 - 09:41:29 EST


From: Chen Haonan <chen.haonan2@xxxxxxxxxx>

persistent_ram_zap() is used to clear relevant log messages
in dmesg, but in other cases it is not needed.In particular,
in console and pmsg, it will cause that after we perform
a delete operation, the next time the system is reset, we
will only see the logs after performing the delete operation.

Signed-off-by: Chen Haonan <chen.haonan2@xxxxxxxxxx>
---
fs/pstore/ram.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 4311fcbc84f2..4cb6e96df6b9 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -436,7 +436,8 @@ static int ramoops_pstore_erase(struct pstore_record *record)
}

persistent_ram_free_old(prz);
- persistent_ram_zap(prz);
+ if (record->type == PSTORE_TYPE_DMESG)
+ persistent_ram_zap(prz);

return 0;
}
--
2.25.1