Skip to contentSkip to conversation

persistent store (version 2) (part 1 of 2)

RFC In review Luck, Tony 5 participants 10 messages Dec 1, 2010 – Dec 2, 2010

Subsystems (2)
lore
Share & tools
lore

Luck, Tony

author reviewer
#0 lore raw

RFC 1/1 persistent store (version 2) (part 1 of 2)

Here's version 2 with most of the fixes suggested in the discussion for version 1 (see http://marc.info/?l=linux-arch&m=129045078803118&w=2).

Stuff that I haven't done:

1) Still has the "daft" echo filename > erase to clear entries from the persistent store. I looked hard at /sys and can't see how to get a notification for an unlink(2). If I'm missing something, would somebody please send me a clue. If this is a fatal flaw - then this will have to move to debugfs (or turn into its own filesystem type). But I'd really prefer to not give up the convenience of /sys

2) Did not implement Jim's suggestion to save OOPs ... I'm not at all sure how to let the user configure this. mtdoops.c has a module parameter for it - but I gave up on letting pstore be a module ... it needs to be initialized before the platform driver, and there doesn't seem to be much point in having it be unloadable.

I did write the ERST platform hooks (they are part 2 of 2, but I'd advise the faint of heart not to look too closely at the ACPI/APEI'isms involved). Here's a sample of what it looks like (with a debug call to panic() from the pstore_erase() function added for testing purposes):

$ cd /sys/firmware/pstore
$ ls -l
total 0
-r--r--r-- 1 root root 7896 Nov 30 15:38 dmesg-1
--w------- 1 root root    0 Nov 30 15:38 erase
$ cat dmesg-1 | tail -12
<4>[  201.840197] mtrr: type mismatch for 90000000,2000000 old: write-back new: write-combining
<0>[ 1044.792139] Kernel panic - not syncing: Testing pstore
<4>[ 1044.792147] Pid: 7634, comm: bash Not tainted 2.6.36-rc6 #13
<4>[ 1044.792150] Call Trace:
<4>[ 1044.792166]  [<ffffffff815c7266>] panic+0xbc/0x1c6
<4>[ 1044.792176]  [<ffffffff810e6c50>] ? get_write_access+0x1e/0x50
<4>[ 1044.792182]  [<ffffffff810ea77d>] ? do_filp_open+0x1f4/0x594
<4>[ 1044.792193]  [<ffffffff814d72f5>] pstore_erase+0x41/0x14f
<4>[ 1044.792199]  [<ffffffff8112fbf2>] write+0x11e/0x160
<4>[ 1044.792208]  [<ffffffff810dec87>] vfs_write+0xb3/0x13a
<4>[ 1044.792213]  [<ffffffff810deddc>] sys_write+0x4c/0x73
<4>[ 1044.792222]  [<ffffffff81002bdb>] system_call_fastpath+0x16/0x1b

-Tony

---

drivers/firmware/Kconfig +12 -0
index e8b6a13..a5575a1 100644
@@ -134,4 +134,16 @@ config ISCSI_IBFT
 	  detect iSCSI boot parameters dynamically during system boot, say Y.
 	  Otherwise, say N.
 
+config PSTORE
+	bool "Persistant store support via /sys"
+	default n
+	help
+	  This option enables generic access to platform level persistent
+	  storage via /sys/firmware/pstore.  Only useful if you have a
+	  platform level driver that registers with pstore to provide
+	  the data, so you probably should just go say "Y" (or "M") to
+	  a platform specific persistent store driver (e.g. ACPI_APEI on
+	  X86) which will select this for you.  If you don't have a platform
+	  persistent store driver, say N.
+
 endmenu
drivers/firmware/Makefile +1 -0
index 1c3c173..ba19784 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_DMIID)		+= dmi-id.o
 obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
 obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
 obj-$(CONFIG_FIRMWARE_MEMMAP)	+= memmap.o
+obj-$(CONFIG_PSTORE)		+= pstore.o
drivers/firmware/pstore.c new file +294 -0

294 lines not on this page · raw message

include/linux/pstore.h new file +54 -0

54 lines not on this page · raw message

#1 lore raw
Quoted 18 lines · Tony

Here's version 2 with most of the fixes suggested in the discussion for version 1 (see http://marc.info/?l=linux-arch&m=129045078803118&w=2).

Stuff that I haven't done:

1) Still has the "daft" echo filename > erase to clear entries from the persistent store. I looked hard at /sys and can't see how to get a notification for an unlink(2). If I'm missing something, would somebody please send me a clue. If this is a fatal flaw - then this will have to move to debugfs (or turn into its own filesystem type). But I'd really prefer to not give up the convenience of /sys

2) Did not implement Jim's suggestion to save OOPs ... I'm not at all sure how to let the user configure this. mtdoops.c has a module parameter for it - but I gave up on letting pstore be a module ... it needs to be initialized before the platform driver, and there doesn't seem to be much point in having it be unloadable.

Quoted 6 lines

I did write the ERST platform hooks (they are part 2 of 2, but I'd advise the faint of heart not to look too closely at the ACPI/APEI'isms involved). Here's a sample of what it looks like (with a debug call to panic() from the pstore_erase() function added for testing purposes):

$ cd /sys/firmware/pstore

As you are adding new sysfs files, you are required to document them in Documentation/ABI/ as well.

thanks,

greg k-h

author reviewer
#2 lore raw
Quoted 2 lines

As you are adding new sysfs files, you are required to document them in Documentation/ABI/ as well.

Is this what you need?

-Tony

---

Documentation/ABI/testing/sysfs-pstore new file +35 -0
new file mode 100644
index 0000000..083fcf7
@@ -0,0 +1,35 @@
+Where:		/sys/firmware/pstore/...
+Date:		January 2011
+Kernel Version: 2.6.38
+Contact:	[email protected]
+Description:	Generic interface to platform dependent persistent storage.
+
+		Platforms that provide a mechanism to preserve some data
+		across system reboots can register with this driver to
+		provide a generic interface to show records captured in
+		the dying moments.  In the case of a panic() the last part
+		of the console log is captured, but other interesting
+		data can also be saved.
+
+		$ ls -l /sys/firmware/pstore
+		total 0
+		-r--r--r-- 1 root root 7896 Nov 30 15:38 dmesg-1
+		--w------- 1 root root    0 Nov 30 15:38 erase
+
+		Different users of this interface will result in different
+		filename prefixes.  Currently two are defined:
+
+		"dmesg"	- saved console log
+		"mce"	- architecture dependent data from fatal h/w error
+
+		The "erase" file is used to signal that a file has been
+		read and that the underlying platform driver can reclaim
+		the space in the persistent store. Just write the name of
+		the file to be removed to the "erase" file:
+
+		$ echo dmesg-1 > /sys/firmware/pstore/erase
+
+		The expectation is that all files in /sys/firmware/pstore
+		will be saved elsewhere and erased from persistent store
+		soon after boot to free up space ready for the next
+		catastrophe.
#3 lore raw
Quoted 4 lines · Tony
Quoted 2 lines

As you are adding new sysfs files, you are required to document them in Documentation/ABI/ as well.

Is this what you need?

Yes, looks good, thanks.

greg k-h

#4 lore raw
In reply to Luck, Tony
Quoted 2 lines · Tony

Here's version 2 with most of the fixes suggested in the discussion for version 1 (see http://marc.info/?l=linux-arch&m=129045078803118&w=2).

I haven't really thought about the overall concept, but I saw stuff to nitpick at.

Quoted 74 lines

Stuff that I haven't done:

1) Still has the "daft" echo filename > erase to clear entries from the persistent store. I looked hard at /sys and can't see how to get a notification for an unlink(2). If I'm missing something, would somebody please send me a clue. If this is a fatal flaw - then this will have to move to debugfs (or turn into its own filesystem type). But I'd really prefer to not give up the convenience of /sys

2) Did not implement Jim's suggestion to save OOPs ... I'm not at all sure how to let the user configure this. mtdoops.c has a module parameter for it - but I gave up on letting pstore be a module ... it needs to be initialized before the platform driver, and there doesn't seem to be much point in having it be unloadable.

I did write the ERST platform hooks (they are part 2 of 2, but I'd advise the faint of heart not to look too closely at the ACPI/APEI'isms involved). Here's a sample of what it looks like (with a debug call to panic() from the pstore_erase() function added for testing purposes):

$ cd /sys/firmware/pstore
$ ls -l
total 0
-r--r--r-- 1 root root 7896 Nov 30 15:38 dmesg-1
--w------- 1 root root    0 Nov 30 15:38 erase
$ cat dmesg-1 | tail -12
<4>[  201.840197] mtrr: type mismatch for 90000000,2000000 old: write-back new: write-combining
<0>[ 1044.792139] Kernel panic - not syncing: Testing pstore
<4>[ 1044.792147] Pid: 7634, comm: bash Not tainted 2.6.36-rc6 #13
<4>[ 1044.792150] Call Trace:
<4>[ 1044.792166]  [<ffffffff815c7266>] panic+0xbc/0x1c6
<4>[ 1044.792176]  [<ffffffff810e6c50>] ? get_write_access+0x1e/0x50
<4>[ 1044.792182]  [<ffffffff810ea77d>] ? do_filp_open+0x1f4/0x594
<4>[ 1044.792193]  [<ffffffff814d72f5>] pstore_erase+0x41/0x14f
<4>[ 1044.792199]  [<ffffffff8112fbf2>] write+0x11e/0x160
<4>[ 1044.792208]  [<ffffffff810dec87>] vfs_write+0xb3/0x13a
<4>[ 1044.792213]  [<ffffffff810deddc>] sys_write+0x4c/0x73
<4>[ 1044.792222]  [<ffffffff81002bdb>] system_call_fastpath+0x16/0x1b

...

drivers/firmware/pstore.c new file +29 -0
@@ -0,0 +1,294 @@
+/*
+ * Persistent Storage - pstore.c
+ *
+ * Copyright (C) 2010 Intel Corporation <[email protected]>
+ *
+ * This code is the generic layer to export data records from platform
+ * level persistent storage via sysfs.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/atomic.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmsg_dump.h>
+#include <linux/module.h>
+#include <linux/pstore.h>

drivers/firmware/pstore.c line 39

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+MODULE_AUTHOR("Tony Luck <[email protected]>");
+MODULE_DESCRIPTION("sysfs interface to persistent storage");
+MODULE_LICENSE("GPL");
+
+static DEFINE_SPINLOCK(pstore_lock);

It'd be nice to know what pstore_lock actually locks.

drivers/firmware/pstore.c line 41

Quoted 2 lines
drivers/firmware/pstore.c new file +2 -0
+static LIST_HEAD(pstore_list);
+static struct kset *pstore_kset;

It locks psinfo (at least), so I'd suggest that all things which pstore_lock locks be collected immediately after its definition.

Quoted 19 lines
drivers/firmware/pstore.c new file +18 -0
+#define	PSTORE_NAMELEN	16
+
+struct pstore_entry {
+	struct	bin_attribute attr;
+	char	name[PSTORE_NAMELEN];
+	u64	id;
+	int	type;
+	int	size;
+	struct	list_head list;
+	char	data[];
+};
+
+static int pstore_create_sysfs_entry(struct pstore_entry *new_pstore);
+
+static struct pstore_info *psinfo;
+
+static char *pstore_buf;
+
 

drivers/firmware/pstore.c line 102

Quoted 10 lines
drivers/firmware/pstore.c new file +8 -0
...
 
+/*
+ * platform specific persistent storage driver registers with
+ * us here. Read out all the records right away and install
+ * them in /sys.  Register with kmsg_dump to save last part
+ * of console log on panic.
+ */
+int
+pstore_register(struct pstore_info *psi)

bah, ia64 coding style leaking into core kernel.

Quoted 4 lines
drivers/firmware/pstore.c new file +4 -0
+{
+	struct pstore_entry	*new_pstore;
+	unsigned long		size, ps_maxsize;
+	u64			id;

drivers/firmware/pstore.c line 116

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+	int			rc = 0, type;
+
+	spin_lock(&pstore_lock);
+	if (psinfo) {
+		spin_unlock(&pstore_lock);
+		return -EBUSY;
+	}
+	if (!psi->reader || !psi->writer || !psi->eraser) {
+		spin_unlock(&pstore_lock);
+		return -EINVAL;

It doesn't seem appropriate to check this here. It's a programming error! Just install the thing and let the kernel oops - the programmer will notice.

drivers/firmware/pstore.c line 124

Quoted 8 lines
drivers/firmware/pstore.c new file +8 -0
+	}
+	psinfo = psi;
+	spin_unlock(&pstore_lock);
+
+	ps_maxsize = psi->header_size + psi->data_size + psi->footer_size;
+	pstore_buf = kzalloc(ps_maxsize, GFP_KERNEL);
+	if (!pstore_buf)
+		return -ENOMEM;

Here the state of the driver gets screwed up. We've installed the psinfo and we're unable to install a new one, but the one which we installed is only partially constructed. And it will cause oopses if we actually try to use it.

Quoted 17 lines
drivers/firmware/pstore.c new file +17 -0
+	for (;;) {
+		if (psi->reader(&id, &type, pstore_buf, &size) <= 0)
+			break;
+		new_pstore = kzalloc(sizeof(struct pstore_entry) + size,
+				     GFP_KERNEL);
+		if (!new_pstore) {
+			rc = -ENOMEM;
+			break;
+		}
+		new_pstore->id = id;
+		new_pstore->type = type;
+		new_pstore->size = size;
+		memcpy(new_pstore->data, pstore_buf + psi->header_size, size);
+		if (pstore_create_sysfs_entry(new_pstore)) {
+			kfree(new_pstore);
+			rc =  -EINVAL;
+			break;

drivers/firmware/pstore.c line 152

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+		}
+	}
+
+	kobject_uevent(&pstore_kset->kobj, KOBJ_ADD);
+
+	kmsg_dump_register(&pstore_dumper);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(pstore_register);

So I'd suggest that this function *fully* back out if anything fails. That means restoring psinfo. And fixing the error-path memory leaks which might be there (I didn't check too hard).

Bonus points for implementing it with only one `return' statement ;)

Quoted 7 lines

...

+/*
+ * Erase records by writing their filename to the "erase" file. E.g.
+ * # echo "dmesg-0" > erase
+ */

Since when are "records" identified by "filenames"?

filenames refer to files! And lo, that's what we have here. A filesystem! The files are created by the kernel and are read and unlinked by userspace.

So why not implement this whole thing as a proper filesystem?

Quoted 14 lines
drivers/firmware/pstore.c new file +14 -0
+static ssize_t pstore_erase(struct file *filp, struct kobject *kobj,
+			    struct bin_attribute *bin_attr,
+			    char *buf, loff_t pos, size_t count)
+{
+	struct pstore_entry *search_pstore, *n;
+	int len1, len2, found = 0;
+
+	len1 = count;
+	if (buf[len1 - 1] == '\n')
+		len1--;
+
+	spin_lock(&pstore_lock);
+
+	/*

drivers/firmware/pstore.c line 207

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+	 * Find this record
+	 */
+	list_for_each_entry_safe(search_pstore, n, &pstore_list, list) {
+		len2 = strlen(search_pstore->name);
+		if (len1 == len2 && memcmp(buf, search_pstore->name,
+					   len1) == 0) {
+			found = 1;
+			break;
+		}
+	}

hm, what's going on here.

Can that line really have a trailing \n?

Part of this code assumes that we're using null-terminated strings but other parts don't do it that way.

All seems a bit confusing and messed up. Might be improved via appropriate use of strim() and sysfs_streq(). Would definitely be improved via a comment explaining what's going on here!

drivers/firmware/pstore.c line 214

Quoted 7 lines
drivers/firmware/pstore.c new file +7 -0
+	if (!found) {
+		spin_unlock(&pstore_lock);
+		return -EINVAL;
+	}
+
+	if (psinfo->eraser(search_pstore->id)) {
+		spin_unlock(&pstore_lock);

I just discovered something else which pstore_lock locks.

drivers/firmware/pstore.c line 215

Quoted 1 line
drivers/firmware/pstore.c new file +1 -0
+		return -EIO;

A single return site per function is better. Multiple-returns often lead to locking errors and memory leaks as the code evolves.

Quoted 41 lines
drivers/firmware/pstore.c new file +41 -0
+	}
+
+	list_del(&search_pstore->list);
+
+	spin_unlock(&pstore_lock);
+
+	sysfs_remove_bin_file(&pstore_kset->kobj, &search_pstore->attr);
+
+	kfree(search_pstore);
+
+	return count;
+}
+
+static struct bin_attribute attr_erase = {
+	.attr = {.name = "erase", .mode = 0200},
+	.write = pstore_erase,
+};
+
+static int
+pstore_create_sysfs_entry(struct pstore_entry *new_pstore)
+{
+	static	atomic_t	next;
+	int	error, seq;
+
+	seq = atomic_add_return(1, &next);
+
+	switch (new_pstore->type) {
+	case PSTORE_TYPE_DMESG:
+		sprintf(new_pstore->name, "dmesg-%d", seq);
+		break;
+	case PSTORE_TYPE_MCE:
+		sprintf(new_pstore->name, "mce-%d", seq);
+		break;
+	default:
+		sprintf(new_pstore->name, "type%d-%d", new_pstore->type, seq);
+		break;
+	}
+
+	sysfs_attr_init(&new_pstore->attr.attr);
+	new_pstore->attr.size = new_pstore->size;
+	new_pstore->attr.read = pstore_show;

drivers/firmware/pstore.c line 266

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+	new_pstore->attr.attr.name = new_pstore->name;
+	new_pstore->attr.attr.mode = 0444;
+	error = sysfs_create_bin_file(&pstore_kset->kobj, &new_pstore->attr);
+	if (!error) {
+		spin_lock(&pstore_lock);
+		list_add(&new_pstore->list, &pstore_list);
+		spin_unlock(&pstore_lock);
+	}
+	return error;
+}

Wait. It *is* a filesystem.

<looks back at the changelog>

Nope, that was secret info.

So why can't I remove these "records" with rm?

Quoted 7 lines

...

drivers/firmware/pstore.c new file +4 -0
+#if defined(CONFIG_PSTORE) || defined(CONFIG_PSTORE_MODULE)
+extern int pstore_register(struct pstore_info *);
+extern int pstore_write(int type, char *buf, unsigned long size);
+#else

drivers/firmware/pstore.c

Quoted 10 lines
drivers/firmware/pstore.c new file +10 -0
+static inline int
+pstore_register(struct pstore_info *psi)
+{
+	return -ENODEV;
+}
+static inline int
+pstore_write(int type, char *buf, unsigned long size)
+{
+	return -ENODEV;
+}

write() takes a size_t.

Quoted 3 lines
drivers/firmware/pstore.c new file +3 -0
+#endif
+
+#endif /*_LINUX_PSTORE_H*/
author reviewer
#5 lore raw
Quoted 5 lines

filenames refer to files! And lo, that's what we have here. A filesystem! The files are created by the kernel and are read and unlinked by userspace.

So why not implement this whole thing as a proper filesystem?

...

Quoted 1 line

Wait. It *is* a filesystem.

...

Quoted 1 line

So why can't I remove these "records" with rm?

Because I tried to use /sys for this and couldn't find a way to get notified about "unlink". Alan Cox called this bit "daft" in v1 (and I agreed with him). Peter Anvin gave me some pointers on how easy this would be to do as a real filesystem ... so v3 will be out in a little while with this insanity removed.

I'll roll in fixes to address your other comments too.

Thanks for the review.

-Tony

#6 lore raw
Quoted 8 lines · Tony
Quoted 5 lines

filenames refer to files! And lo, that's what we have here. A filesystem! The files are created by the kernel and are read and unlinked by userspace.

So why not implement this whole thing as a proper filesystem?

...

Quoted 1 line

Wait. It *is* a filesystem.

...

Quoted 8 lines
Quoted 1 line

So why can't I remove these "records" with rm?

Because I tried to use /sys for this and couldn't find a way to get notified about "unlink". Alan Cox called this bit "daft" in v1 (and I agreed with him). Peter Anvin gave me some pointers on how easy this would be to do as a real filesystem ... so v3 will be out in a little while with this insanity removed.

OK. Yes, the correct answer is usually "create a new filesystem driver" ;)

<greps>

gad, there are over 200 register_filesystem() callsites.

One thing which does leap out of the v2 implementation is the hardwired assumption that there is one store kernel-wide. I suppose that's OK as a version-1 implementation detail thing, but we should avoid hardwiring that assumption into the presentation of v1's userspace interfaces.

author reviewer
#7 lore raw
Quoted 4 lines · Andrew Morton

One thing which does leap out of the v2 implementation is the hardwired assumption that there is one store kernel-wide.  I suppose that's OK as a version-1 implementation detail thing, but we should avoid hardwiring that assumption into the presentation of v1's userspace interfaces.

I think that user space should be able to survive the change to multiple storage devices. We can just read all the records from all the devices and present each one as a file. We just need to remember where they came from so we cal call the right erase function when the user unlinks the file. Unless there is some reason why we'd want to make it visible to the user which storage was being used? But even then, the user interface wouldn't change we could just have each device register a string to be included in the filename. Users could look at it if they cared, or ignore it if they don't care. The "type" of the data should stay at the front of the name so userspace can do "for f in dmesg*" to look at al the saved console logs, and it wouldn't matter if the files were "dmesg-0", "dmesg-1" or "dmesg-erst-0", "dmesg-erst-1". I can't quite see why anyone would care which device was used, but the option to provide it would be there without breaking apps that used the v1 interface.

The tricky part of multiple devices is the write side ... how to decide which records should be stored in which device. I can imagine lots of possibilities (store by type, round-robin, use one until full then move on, look at the size of the data to be stored and save in the device with the smallest record size that could hold the data, ...) but I'm just making stuff up - I don't know how someone with two or more devices would actually want to assign them ... hence I'm leaving this as an exercise to someone with more than one device :-)

-Tony

#8 lore raw
Quoted 10 lines · Tony Luck

was being used? But even then, the user interface wouldn't change we could just have each device register a string to be included in the filename. Users could look at it if they cared, or ignore it if they don't care. The "type" of the data should stay at the front of the name so userspace can do "for f in dmesg*" to look at al the saved console logs, and it wouldn't matter if the files were "dmesg-0", "dmesg-1" or "dmesg-erst-0", "dmesg-erst-1". I can't quite see why anyone would care which device was used, but the option to provide it would be there without breaking apps that used the v1 interface.

Hmmm I may throw the devicename into the filename anyway ... I still can't see why anyone would care where it came from, but doing this would allow for consistent filenames across reboots. My old code just stuck sequential numbers on the end of the filenames to make sure it didn't get collisions. But this means that someone might be looking at /dev/pstore/dmesg-1 when the system panics. After the reboot they see two files: the old one and a new one. But the old code didn't guarantee that the old one would still be "dmesg-1", it might be "dmesg-2" and "dmesg-1" might now have the latest panic (ordering is at the whim of the underlying storage, and if it operates in a LIFO way this could happen).

If I name the file "dmesg-{storename}-{recordid}" then unerased entries will get the same name next time - which may avoid some confusion.

-Tony

#9 lore raw
In reply to Luck, Tony

Hi, Tony,

include/linux/pstore.h line 36

Quoted 8 lines · Tony
include/linux/pstore.h new file +8 -0
+struct pstore_info {
+	unsigned long	header_size;
+	unsigned long	data_size;
+	unsigned long	footer_size;
+	int	(*reader)(u64 *id, int *type, void *buf, unsigned long *size);
+	int	(*writer)(int type, void *buf, unsigned long size);
+	int	(*eraser)(u64 id);
+};

How about rename these 3 functions to read, write and erase?

Best Regards,
Huang Ying