summaryrefslogtreecommitdiffstats
path: root/fs/pstore/zone.c
diff options
context:
space:
mode:
authorWeiXiong Liao <liaoweixiong@allwinnertech.com>2020-03-25 16:55:05 +0800
committerKees Cook <keescook@chromium.org>2020-05-31 19:49:00 -0700
commit7dcb7848ba110ff192efc917d1a6de66b4c9ca4f (patch)
tree53e7bdd3c266bbadeb9b7091889a736f5c76897a /fs/pstore/zone.c
parent1525fb3bb6d69028b3941d34363397c28345ffab (diff)
downloadlinux-7dcb7848ba110ff192efc917d1a6de66b4c9ca4f.tar.gz
linux-7dcb7848ba110ff192efc917d1a6de66b4c9ca4f.tar.bz2
linux-7dcb7848ba110ff192efc917d1a6de66b4c9ca4f.zip
pstore/blk: Support non-block storage devices
Add support for non-block devices (e.g. MTD). A non-block driver calls pstore_blk_register_device() to register iself. In addition, pstore/zone is updated to handle non-block devices, where an erase must be done before a write. Without this, there is no way to remove records stored to an MTD. Signed-off-by: WeiXiong Liao <liaoweixiong@allwinnertech.com> Link: https://lore.kernel.org/lkml/20200511233229.27745-10-keescook@chromium.org/ Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore/zone.c')
-rw-r--r--fs/pstore/zone.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c
index add26b125984..819428dfa32f 100644
--- a/fs/pstore/zone.c
+++ b/fs/pstore/zone.c
@@ -660,15 +660,21 @@ static inline int psz_kmsg_erase(struct psz_context *cxt,
struct psz_buffer *buffer = zone->buffer;
struct psz_kmsg_header *hdr =
(struct psz_kmsg_header *)buffer->data;
+ size_t size;
if (unlikely(!psz_ok(zone)))
return 0;
+
/* this zone is already updated, no need to erase */
if (record->count != hdr->counter)
return 0;
+ size = buffer_datalen(zone) + sizeof(*zone->buffer);
atomic_set(&zone->buffer->datalen, 0);
- return psz_zone_write(zone, FLUSH_META, NULL, 0, 0);
+ if (cxt->pstore_zone_info->erase)
+ return cxt->pstore_zone_info->erase(size, zone->off);
+ else
+ return psz_zone_write(zone, FLUSH_META, NULL, 0, 0);
}
static inline int psz_record_erase(struct psz_context *cxt,