Skip to contentSkip to conversation

LogFS take three

PATCH In review Jörn Engel 22 participants 87 messages May 15, 2007 – May 23, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LogFS take three

[ I have put everyone that gave comments to the last patch on Cc:. Hope that doesn't offend anyone. ]

Add LogFS, a scalable flash filesystem.

Motivation 1:

Linux currently has 1-2 flash filesystems to choose from, JFFS2 and YAFFS. The latter has never made a serious attempt of kernel integration, which may disqualify it to some.

The two main problems of JFFS2 are memory consumption and mount time. Unlike most filesystems, there is no tree structure of any sorts on the medium, so the complete medium needs to be scanned at mount time and a tree structure kept in-memory while the filesystem is mounted. With bigger devices, both mount time and memory consumption increase linearly.

JFFS2 has recently gained summary support, which helps reduce mount time by a constant factor. Linear scalability remains. YAFFS appears to be better by a constant factor, yet still scales linearly.

LogFS has an on-medium tree, fairly similar to Ext2 in structure, so mount times are O(1). In absolute terms, the OLPC system has mount times of ~3.3s for JFFS2 and ~60ms for LogFS.

Motivation 2:

Flash is becoming increasingly common in standard PC hardware. Nearly a dozen different manufacturers have announced Solid State Disks (SSDs), the OLPC and the Intel Classmate no longer contain hard disks and ASUS announced a flash-only Laptop series for regular consumers. And that doesn't even mention the ubiquitous USB-Sticks, SD-Cards, etc.

Flash behaves significantly different to hard disks. In order to use flash, the current standard practice is to add an emulation layer and an old-fashioned hard disk filesystem. As can be expected, this is eating up some of the benefits flash can offer over hard disks.

In principle it is possible to achieve better performance with a flash filesystem than with the current emulated approach. In practice our current flash filesystems are not even near that theoretical goal. LogFS in its current state is already closer.

---

 fs/Kconfig            |   26 +
 fs/Makefile           |    1 
 fs/logfs/Locking      |   45 ++
 fs/logfs/Makefile     |   14 
 fs/logfs/compr.c      |  107 ++++
 fs/logfs/dir.c        |  725 ++++++++++++++++++++++++++++++++
 fs/logfs/file.c       |   81 +++
 fs/logfs/gc.c         |  369 ++++++++++++++++
 fs/logfs/inode.c      |  521 +++++++++++++++++++++++
 fs/logfs/journal.c    |  731 ++++++++++++++++++++++++++++++++
 fs/logfs/logfs.h      |  373 ++++++++++++++++
 fs/logfs/memtree.c    |  267 ++++++++++++
 fs/logfs/progs/fsck.c |  332 ++++++++++++++
 fs/logfs/progs/mkfs.c |  334 +++++++++++++++
 fs/logfs/readwrite.c  | 1110 ++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/logfs/segment.c    |  553 ++++++++++++++++++++++++
 fs/logfs/super.c      |  419 ++++++++++++++++++
 include/linux/logfs.h |  477 +++++++++++++++++++++
 18 files changed, 6485 insertions(+)
fs/Kconfig renamed from fs/Kconfig~logfs +26 -0
@@ -1351,6 +1351,32 @@ config JFFS2_CMODE_SIZE
 
 endchoice
 
+config LOGFS
+	tristate "Log Filesystem (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	select ZLIB_INFLATE
+	select ZLIB_DEFLATE
+	help
+	  Flash filesystem aimed to scale efficiently to large devices.
+	  In comparison to JFFS2 it offers significantly faster mount
+	  times and potentially less RAM usage, although the latter has
+	  not been measured yet.
+
+	  In its current state it is still very experimental and should
+	  not be used for other than testing purposes.
+
+	  If unsure, say N.
+
+config LOGFS_FSCK
+	bool "Run LogFS fsck at mount time"
+	depends on LOGFS
+	help
+	  Run a full filesystem check on every mount.  If any errors are
+	  found, mounting the filesystem will fail.  This is a debug option
+	  for developers.
+
+	  If unsure, say N.
+
 config CRAMFS
 	tristate "Compressed ROM file system support (cramfs)"
 	depends on BLOCK
fs/Makefile renamed from fs/Makefile~logfs +1 -0
@@ -95,6 +95,7 @@ obj-$(CONFIG_NTFS_FS)		+= ntfs/
 obj-$(CONFIG_UFS_FS)		+= ufs/
 obj-$(CONFIG_EFS_FS)		+= efs/
 obj-$(CONFIG_JFFS2_FS)		+= jffs2/
+obj-$(CONFIG_LOGFS)		+= logfs/
 obj-$(CONFIG_AFFS_FS)		+= affs/
 obj-$(CONFIG_ROMFS_FS)		+= romfs/
 obj-$(CONFIG_QNX4FS_FS)		+= qnx4/
fs/logfs/Makefile new file +14 -0
@@ -0,0 +1,14 @@
+obj-$(CONFIG_LOGFS)	+= logfs.o
+
+logfs-y	+= compr.o
+logfs-y	+= dir.o
+logfs-y	+= file.o
+logfs-y	+= gc.o
+logfs-y	+= inode.o
+logfs-y	+= journal.o
+logfs-y	+= memtree.o
+logfs-y	+= readwrite.o
+logfs-y	+= segment.o
+logfs-y	+= super.o
+logfs-y	+= progs/fsck.o
+logfs-y	+= progs/mkfs.o
fs/logfs/logfs.h new file +373 -0

373 lines not on this page · raw message

fs/logfs/compr.c new file +107 -0

107 lines not on this page · raw message

fs/logfs/dir.c new file +725 -0

725 lines not on this page · raw message

fs/logfs/file.c new file +81 -0

81 lines not on this page · raw message

fs/logfs/gc.c new file +369 -0

369 lines not on this page · raw message

fs/logfs/inode.c new file +521 -0

521 lines not on this page · raw message

fs/logfs/journal.c new file +731 -0

731 lines not on this page · raw message

fs/logfs/memtree.c new file +267 -0

40 lines not on this page · raw message

fs/logfs/readwrite.c new file +1110 -0

1,110 lines not on this page · raw message

fs/logfs/segment.c new file +553 -0

553 lines not on this page · raw message

fs/logfs/super.c new file +419 -0

419 lines not on this page · raw message

fs/logfs/progs/fsck.c new file +332 -0

332 lines not on this page · raw message

fs/logfs/progs/mkfs.c new file +334 -0

334 lines not on this page · raw message

fs/logfs/Locking new file +45 -0

45 lines not on this page · raw message

include/linux/logfs.h new file +477 -0

477 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw

Review status (Re: [PATCH] LogFS take three)

Most of my homework is done. There are six items left plus another five I believe should not get changed.

Changed:
o Kconfig description updated
o Spaces converted to tabs in Makefile
o Sorted/seperated #includes
o structures are __packed instead of packed, #define removed
o removed TRACE()
o 32bit magic is u instead of ull now
o #defines aligned
o Removed obsolete #defines, documented rest
o LOGFS_SUPER and LOGFS_INODE are inline functions now
o removed alloc_disk_sum and free_disk_sum
o moved dir_callback up
o removed pointless cast from max() parameter
o moved LOGFS_LINK_MAX to header
o license headers
o removed logfs_writepage()
o introduced and documented LOGFS_SEGMENT_RESERVE
o documented completion dance in mtderase()
o removed isbad() check from mtderase()
o removed logfs_device_getpage() and logfs_cached_read()
o resurrected code to pick correct device
o removed beXX typedefs
o removed safe_read()
o removed wrapper in logfs_cleanup_gc()
o device_read() returns error
o renamed logfs_alloc_blocks() to match current implementation
o kerneldoc comments for structures
o removed logfs_compress_none and logfs_uncompress_none
o Split header
o move fsck behind debug option

Changed many times (and I sincerely hope not to have missed any):
o removed // comments, usually dead code
o added newline between variable declarations and code
o moved tail comments
o minor code cleanups
o changed comment style
o added loglevels to printk

Unchanged:
o enum for OBJ_TOP_JOURNAL and friends
Afaics all the potential enums end up being converted through cpu_to_64XX, I'll have to see if that causes more problems than the enums can hope to solve.
o generic function for logfs_type()
o generic helper for logfs_prepare_write()
o removed EOF
o error handling
o move rootdir generation back to mkfs

Won't happen (unless I get convinced to do otherwise):
o lowercase LOGFS_SUPER and LOGFS_INODE
These simply match the common pattern used is many Linux filesystems.
o remove "extern"
For structures, this keyword actually serves a purpose and makes sense. On the other hand, it is completely bogus for functions and I won't be bullied into adding bogus crud either.
o Move fs/logfs/Locking to Documentation/
At least JFFS2 has such documentation in its own directory as well. I can see good arguments for either side and no strong consensus. While I ultimately just don't case, doing nothing is a good option in cases of great uncertainty.
o change (void*) to "proper" cast
Neither variant is much better than the other. I'm open for suggestions to completely remove the casts, though.
o Change LOGFS_BUG() and LOGFS_BUG_ON() to inline functions These are macros for very much the same reasons BUG() and BUG_ON() are.

Jörn

Signature · 8 lines
To my face you have the audacity to advise me to become a thief - the worst
kind of thief that is conceivable, a thief of spiritual things, a thief of
ideas! It is insufferable, intolerable!
-- M. Binet in Scarabouche
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
In reply to Jörn Engel
Quoted 5 lines · Jörn Engel

[ I have put everyone that gave comments to the last patch on Cc:. Hope that doesn't offend anyone. ]

Add LogFS, a scalable flash filesystem.

Have you run sparse on this code?
I do not recall if you have written something about it.
I do not see any obvious things sparse would catch (just browsing quickly) but it's always a good thing to do.

+++ linux-2.6.21logfs/fs/logfs/progs/fsck.c 2007-05-15 00:54:22.000000000 +0200
@@ -0,0 +1,332 @@
+/*
+ * fs/logfs/prog/fsck.c - filesystem check
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * In principle this could get moved to userspace. However it might still
+ * make some sense to keep it in the kernel. It is a pure checker and will
+ * only report problems, not attempt to repair them.
+ */
+#include "../logfs.h"
+
If potential userspace tools needs to include ../logfs.h then there is something that ought to be moved to include/linux/logfs.h instead.

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
In reply to Jörn Engel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jörn" == Jörn Engel <[email protected]> writes:

Jörn> [ I have put everyone that gave comments to the last patch on Cc:. Hope Jörn> that doesn't offend anyone. ]

Jörn> Add LogFS, a scalable flash filesystem.

I've been semi watching this, and the only comment I really can give is that I hate the name. To me, logfs implies a filesystem for logging purposes, not for Flash hardware with wear leveling issues to be taken into account.

I admit, neither does JFFS2 or YAFFS really do justice either. And I do realize your filesystem design is pretty neat.

Also, having scanned through the code, I find the name "cookie" using in logfs_inode(), logfs_iput(), logfs_iget() to be badly named. It should really be something like *cached_inode, which would seem to give more natural semantics of

	if (cached_inode)
		do_cached_inode_ops(...)
	else
		do_inode_ops(...)

But hey, I'm not a kernel programmer, so feel free to discount comments.

John

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#10 lore raw
In reply to Sam Ravnborg
Quoted 8 lines · Sam Ravnborg
Quoted 5 lines · Jörn Engel

[ I have put everyone that gave comments to the last patch on Cc:. Hope that doesn't offend anyone. ]

Add LogFS, a scalable flash filesystem.

Have you run sparse on this code?

Several thousand times. :)

Quoted 3 lines

I do not recall if you have written something about it.
I do not see any obvious things sparse would catch (just browsing quickly) but it's always a good thing to do.

Absolutely! I added this line for sparse:
+#define __CHECK_ENDIAN__

Not sure how much of the kernel is endian-clean. Logfs should be.

Quoted 15 lines

+++ linux-2.6.21logfs/fs/logfs/progs/fsck.c 2007-05-15 00:54:22.000000000 +0200

fs/logfs/progs/fsck.c new file +13 -0
@@ -0,0 +1,332 @@
+/*
+ * fs/logfs/prog/fsck.c        - filesystem check
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * In principle this could get moved to userspace.  However it might still
+ * make some sense to keep it in the kernel.  It is a pure checker and will
+ * only report problems, not attempt to repair them.
+ */
+#include "../logfs.h"
+
Quoted 2 lines

If potential userspace tools needs to include ../logfs.h then there is something that ought to be moved to include/linux/logfs.h instead.

There shouldn't be anything left in ../logfs.h that is needed for userspace. But the kernel fsck is lame and calls into functions like iget(), which it pulls in from ../logfs.h.

Jörn

Signature · 6 lines
The only real mistake is the one from which we learn nothing.
-- John Powell
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
In reply to John Stoffel
Quoted 5 lines · John Stoffel

I've been semi watching this, and the only comment I really can give is that I hate the name. To me, logfs implies a filesystem for logging purposes, not for Flash hardware with wear leveling issues to be taken into account.

Yeah, well, ...

Two years ago when I started all this, I was looking for a good name. All I could come up with sounded stupid, so I picked "LogFS" as a code name. As soon as I find a better name, the code name should get replaced.

By now I still don't have anything better. All alternatives that were proposed are just as bad - with the added disadvantage of being new and not established yet. My hope of ever finding a better name is nearly zero.

Quoted 9 lines

Also, having scanned through the code, I find the name "cookie" using in logfs_inode(), logfs_iput(), logfs_iget() to be badly named. It should really be something like *cached_inode, which would seem to give more natural semantics of

	if (cached_inode)
		do_cached_inode_ops(...)
	else
		do_inode_ops(...)

Half-agreed. For callers, the name "cookie" makes sense. It is a transparent thing they should not tough and hand back unchanged. For logfs_iget() and logfs_iput() something like "is_cached" would be better.

Will change.

Jörn

Signature · 7 lines
Linux [...] existed just for discussion between people who wanted
to show off how geeky they were.
-- Rob Enderle
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#40 lore raw
In reply to Jörn Engel
Quoted 21 lines · On Tue, 15 May 2007 17:19:20 +0200 J__rn Engel <[email protected]> wrote:

Add LogFS, a scalable flash filesystem.

...

fs/Kconfig renamed from fs/Kconfig~logfs +16 -0
+config LOGFS
+	tristate "Log Filesystem (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	select ZLIB_INFLATE
+	select ZLIB_DEFLATE
+	help
+	  Flash filesystem aimed to scale efficiently to large devices.
+	  In comparison to JFFS2 it offers significantly faster mount
+	  times and potentially less RAM usage, although the latter has
+	  not been measured yet.
+
+	  In its current state it is still very experimental and should
+	  not be used for other than testing purposes.
+
+	  If unsure, say N.
+

fs/Kconfig config JFFS2_CMODE_SIZE · line 1379

Quoted 10 lines
fs/Kconfig renamed from fs/Kconfig~logfs +10 -0
+config LOGFS_FSCK
+	bool "Run LogFS fsck at mount time"
+	depends on LOGFS
+	help
+	  Run a full filesystem check on every mount.  If any errors are
+	  found, mounting the filesystem will fail.  This is a debug option
+	  for developers.
+
+	  If unsure, say N.
+

No dependency on MTD,

Quoted 14 lines
fs/logfs/logfs.h new file +13 -0
@@ -0,0 +1,373 @@
+/*
+ * fs/logfs/logfs.h
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * Private header for logfs.
+ */
+#ifndef fs_logfs_logfs_h
+#define fs_logfs_logfs_h
+
+#define __CHECK_ENDIAN__

fs/logfs/logfs.h line 23

Quoted 10 lines
fs/logfs/logfs.h new file +10 -0
+
+
+#include <linux/crc32.h>
+#include <linux/fs.h>
+#include <linux/kallsyms.h>
+#include <linux/kernel.h>
+#include <linux/logfs.h>
+#include <linux/pagemap.h>
+#include <linux/statfs.h>
+#include <linux/mtd/mtd.h>

But it includes an MTD header file.

Can this code be tested by people who don't have MTD hardware? We used to ahve a fake-mtd-on-a-blockdev thing, whcih was in a state of some disrepair. Maybe it got repaired. Or removed. I can't immediately locate it...

It's strange and a bit regrettable that an fs would have dependency on MTD, really.

Quoted 4 lines
fs/logfs/logfs.h new file +4 -0
+
+/**
+ * struct logfs_area - area management information
+ *

fs/logfs/logfs.h line 56

Quoted 10 lines
fs/logfs/logfs.h new file +10 -0
+ * @a_sb:			the superblock this area belongs to
+ * @a_is_open:			1 if the area is currently open, else 0
+ * @a_segno:			segment number of area
+ * @a_used_objects:		number of used objects (XXX: should get removed)
+ * @a_used_bytes:		number of used bytes
+ * @a_ops:			area operations (either journal or ostore)
+ * @a_wbuf:			write buffer
+ * @a_erase_count:		erase count
+ * @a_level:			GC level
+ */

ooh, documentation. Quick, merge it!

fs/logfs/logfs.h line 258

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+/* memtree.c */
+void btree_init(struct btree_head *head);
+void *btree_lookup(struct btree_head *head, long val);
+int btree_insert(struct btree_head *head, long val, void *ptr);
+int btree_remove(struct btree_head *head, long val);

These names are too generic. If we later add a btree library: blam.

fs/logfs/logfs.h line 264

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+
+/* readwrite.c */
+int logfs_inode_read(struct inode *inode, void *buf, size_t n, loff_t _pos);
+int logfs_inode_write(struct inode *inode, const void *buf, size_t n,
+		loff_t pos);

It's a bit rude stealing the logfs* namespace, but I guess you got there first ;)

Quoted 23 lines
fs/logfs/logfs.h new file +23 -0
+int logfs_readpage_nolock(struct page *page);
+int logfs_write_buf(struct inode *inode, pgoff_t index, void *buf);
+int logfs_delete(struct inode *inode, pgoff_t index);
+int logfs_rewrite_block(struct inode *inode, pgoff_t index, u64 ofs, int level);
+int logfs_is_valid_block(struct super_block *sb, u64 ofs, u64 ino, u64 pos);
+void logfs_truncate(struct inode *inode);
+u64 logfs_seek_data(struct inode *inode, u64 pos);
+
+int logfs_init_rw(struct logfs_super *super);
+void logfs_cleanup_rw(struct logfs_super *super);
+
+/* segment.c */
+int logfs_erase_segment(struct super_block *sb, u32 ofs);
+int wbuf_read(struct super_block *sb, u64 ofs, size_t len, void *buf);
+int logfs_segment_read(struct super_block *sb, void *buf, u64 ofs);
+s64 logfs_segment_write(struct inode *inode, void *buf, u64 pos, int level,
+		int alloc);
+int logfs_segment_delete(struct inode *inode, u64 ofs, u64 pos, int level);
+void logfs_set_blocks(struct inode *inode, u64 no);
+void __logfs_set_blocks(struct inode *inode);
+/* area handling */
+int logfs_init_areas(struct super_block *sb);
+void logfs_cleanup_areas(struct logfs_super *super);

fs/logfs/logfs.h line 298

Quoted 10 lines
fs/logfs/logfs.h new file +10 -0
+int logfs_open_area(struct logfs_area *area);
+void logfs_close_area(struct logfs_area *area);
+
+/* super.c */
+int mtdread(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+int mtdwrite(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+int mtderase(struct super_block *sb, loff_t ofs, size_t len);
+void logfs_crash_dump(struct super_block *sb);
+int all_ff(void *buf, size_t len);
+int logfs_statfs(struct dentry *dentry, struct kstatfs *stats);

Have you checked that all of this needs global scope?

fs/logfs/logfs.h line 305

Quoted 6 lines
fs/logfs/logfs.h new file +6 -0
+
+/* progs/fsck.c */
+#ifdef CONFIG_LOGFS_FSCK
+int logfs_fsck(struct super_block *sb);
+#else
+#define logfs_fsck(sb) ({ 0; })

static inline int logfs_fsck(struct super_block *sb)

{
	return 0;
}

is better: nicer to look at, has typechecking.

Quoted 16 lines
fs/logfs/logfs.h new file +15 -0
+#endif
 
+
+/* progs/mkfs.c */
+int logfs_mkfs(struct super_block *sb, struct logfs_disk_super *ds);
+
+
+#define LOGFS_BUG(sb) do {		\
+	struct super_block *__sb = sb;	\
+	logfs_crash_dump(__sb);		\
+	BUG();				\
+} while(0)
+
+#define LOGFS_BUG_ON(condition, sb) \
+	do { if (unlikely((condition)!=0)) LOGFS_BUG((sb)); } while(0)
+

fs/logfs/logfs.h line 331

Quoted 10 lines
fs/logfs/logfs.h new file +10 -0
+
+static inline struct logfs_super *LOGFS_SUPER(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+	return container_of(inode, struct logfs_inode, vfs_inode);
+}

Do these need to be uppercase?

Quoted 7 lines
fs/logfs/logfs.h new file +7 -0
+
+static inline __be32 logfs_crc32(void *data, size_t len, size_t skip)
+{
+	return cpu_to_be32(crc32(~0, data+skip, len-skip));
+}
+
+

fs/logfs/logfs.h line 349

Quoted 10 lines
fs/logfs/logfs.h new file +10 -0
+static inline u8 logfs_type(struct inode *inode)
+{
+	return (inode->i_mode >> 12) & 15;
+}
+
+
+static inline pgoff_t logfs_index(u64 pos)
+{
+	return pos / LOGFS_BLOCKSIZE;
+}

If the compiler goofs up here we'll end up trying to do a 64/32 divide and it won't link on 32-bit machines. It would be safer to do

	return pos >> LOGFS_BLOCKSHIFT;
Quoted 20 lines
fs/logfs/compr.c new file +17 -0
@@ -0,0 +1,107 @@
+/*
+ * fs/logfs/compr.c	- compression routines
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ */
+#include "logfs.h"
+#include <linux/vmalloc.h>
+#include <linux/zlib.h>
+
+#define COMPR_LEVEL 3
+
+static DEFINE_MUTEX(compr_mutex);
+static struct z_stream_s stream;
+
+

fs/logfs/compr.c line 67

Quoted 10 lines
fs/logfs/compr.c new file +7 -0
 
...
 
+
+int logfs_uncompress(void *in, void *out, size_t inlen, size_t outlen)
+{
+	int err, ret;
+
+	ret = -EIO;
+	mutex_lock(&compr_mutex);

A per-superblock lock and stream would be nicer.

Quoted 30 lines
fs/logfs/compr.c new file +24 -0
+	err = zlib_inflateInit(&stream);
+	if (err != Z_OK)
+		goto error;
+
+	stream.next_in = in;
+	stream.avail_in = inlen;
+	stream.total_in = 0;
+	stream.next_out = out;
+	stream.avail_out = outlen;
+	stream.total_out = 0;
+
+	err = zlib_inflate(&stream, Z_FINISH);
+	if (err != Z_STREAM_END)
+		goto error;
+
+	err = zlib_inflateEnd(&stream);
+	if (err != Z_OK)
+		goto error;
+
+	ret = 0;
+error:
+	mutex_unlock(&compr_mutex);
+	return ret;
+}
 
...

fs/logfs/dir.c line 10

Quoted 10 lines
fs/logfs/dir.c new file +10 -0
@@ -0,0 +1,725 @@
+}
+
+
+static inline loff_t file_end(struct inode *inode)
+{
+	return (i_size_read(inode) + inode->i_sb->s_blocksize - 1)
+		>> inode->i_sb->s_blocksize_bits;
+}
+static void logfs_set_name(struct logfs_disk_dentry *dd, struct qstr *name)
+{

The code has a strange mix of two-blank-lines-between-functions and no-blank-lines-between-functions. One blank line is usual.

Quoted 41 lines
fs/logfs/dir.c new file +38 -0
+	BUG_ON(name->len > LOGFS_MAX_NAMELEN);
+	dd->namelen = cpu_to_be16(name->len);
+	memcpy(dd->name, name->name, name->len);
+}
+static int logfs_write_dir(struct inode *dir, struct dentry *dentry,
+		struct inode *inode)
+{
+	struct logfs_disk_dentry dd;
+	int err;
+
+	memset(&dd, 0, sizeof(dd));
+	dd.ino = cpu_to_be64(inode->i_ino);
+	dd.type = logfs_type(inode);
+	logfs_set_name(&dd, &dentry->d_name);
+
+	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+	/*
+	 * FIXME: the file size should actually get aligned when writing,
+	 * not when reading.
+	 */
+	err = write_dir(dir, &dd, file_end(dir));
+	if (err)
+		return err;
+	d_instantiate(dentry, inode);
+	return 0;
+}
+
+
 
...
 
+
+	if (dest) {
+		/* symlink */
+		ret = logfs_inode_write(inode, dest, destlen, 0);
+	} else {
+		/* creat/mkdir/mknod */
+		ret = __logfs_write_inode(inode);
+	}
+	super->s_victim_ino = 0;
+	if (ret) {

fs/logfs/dir.c line 357

Quoted 10 lines
fs/logfs/dir.c new file +10 -0
+		if (!dest)
+			li->li_flags |= LOGFS_IF_STILLBORN;
+		/* FIXME: truncate symlink */
+		inode->i_nlink--;
+		iput(inode);
+		goto out;
+	}
+
+	if (inode->i_mode & S_IFDIR)
+		dir->i_nlink++;

You have helper functions for i_nlink++, which remember to do mark_inode_dirty()?

Quoted 11 lines
fs/logfs/dir.c new file +11 -0
+	ret = logfs_write_dir(dir, dentry, inode);
+
+	if (ret) {
+		if (inode->i_mode & S_IFDIR)
+			dir->i_nlink--;
+		logfs_remove_inode(inode);
+		iput(inode);
+	}
+out:
+	mutex_unlock(&super->s_victim_mutex);
+	return ret;

fs/logfs/dir.c line 432

Quoted 10 lines
fs/logfs/dir.c new file +7 -0
+}
+
 
...
 
+
+static struct inode_operations logfs_symlink_iops = {
+	.readlink	= generic_readlink,
+	.follow_link	= page_follow_link_light,
+};

Should be const.

fs/logfs/dir.c line 457

Quoted 4 lines
fs/logfs/dir.c new file +4 -0
+static int logfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	return generic_permission(inode, mask, NULL);
+}

Does this need to exist?

fs/logfs/dir.c line 721

Quoted 13 lines
fs/logfs/dir.c new file +13 -0
+
+struct inode_operations logfs_dir_iops = {
+	.create		= logfs_create,
+	.link		= logfs_link,
+	.lookup		= logfs_lookup,
+	.mkdir		= logfs_mkdir,
+	.mknod		= logfs_mknod,
+	.rename		= logfs_rename,
+	.rmdir		= logfs_rmdir,
+	.permission	= logfs_permission,
+	.symlink	= logfs_symlink,
+	.unlink		= logfs_unlink,
+};

const

fs/logfs/dir.c line 725

Quoted 4 lines
fs/logfs/dir.c new file +4 -0
+struct file_operations logfs_dir_fops = {
+	.readdir	= logfs_readdir,
+	.read		= generic_read_dir,
+};

const

Quoted 25 lines
fs/logfs/file.c new file +22 -0
@@ -0,0 +1,81 @@
+/*
+ * fs/logfs/file.c	- prepare_write, commit_write and friends
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ */
+#include "logfs.h"
+
+
+static int logfs_prepare_write(struct file *file, struct page *page,
+		unsigned start, unsigned end)
+{
+	if (PageUptodate(page))
+		return 0;
+
+	if ((start == 0) && (end == PAGE_CACHE_SIZE))
+		return 0;
+
+	return logfs_readpage_nolock(page);
+}
+

fs/logfs/file.c line 32

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+
+static int logfs_commit_write(struct file *file, struct page *page,
+		unsigned start, unsigned end)
+{
+	struct inode *inode = page->mapping->host;
+	pgoff_t index = page->index;
+	void *buf;
+	int ret;
+
+	BUG_ON(PAGE_CACHE_SIZE != inode->i_sb->s_blocksize);

This check can be done once, at mount time.

fs/logfs/file.c line 45

Quoted 13 lines
fs/logfs/file.c new file +13 -0
+	BUG_ON(page->index > I3_BLOCKS);
+
+	if (start == end)
+		return 0; /* FIXME: do we need to update inode? */
+
+	if (i_size_read(inode) < (index << PAGE_CACHE_SHIFT) + end) {
+		i_size_write(inode, (index << PAGE_CACHE_SHIFT) + end);
+		mark_inode_dirty(inode);
+	}
+
+	buf = kmap(page);
+	ret = logfs_write_buf(inode, index, buf);
+	kunmap(page);

kmap() is lame. The preferred approach would be to pass the page* down to the lower layers and to use kmap_atomic() at the lowest possible point.

Quoted 7 lines
fs/logfs/file.c new file +7 -0
+	return ret;
+}
+
+
+static int logfs_readpage(struct file *file, struct page *page)
+{
+	int ret;

fs/logfs/file.c line 62

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+
+	ret = logfs_readpage_nolock(page);
+	unlock_page(page);
+	return ret;
+}
+
+
+struct inode_operations logfs_reg_iops = {
+	.truncate	= logfs_truncate,
+};

const

fs/logfs/file.c line 73

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+
+struct file_operations logfs_reg_fops = {
+	.aio_read	= generic_file_aio_read,
+	.aio_write	= generic_file_aio_write,
+	.llseek		= generic_file_llseek,
+	.mmap		= generic_file_readonly_mmap,
+	.open		= generic_file_open,
+	.read		= do_sync_read,
+	.write		= do_sync_write,
+};

const

fs/logfs/file.c line 81

Quoted 7 lines
fs/logfs/file.c new file +7 -0
+
+struct address_space_operations logfs_reg_aops = {
+	.commit_write	= logfs_commit_write,
+	.prepare_write	= logfs_prepare_write,
+	.readpage	= logfs_readpage,
+	.set_page_dirty	= __set_page_dirty_nobuffers,
+};

const

Quoted 14 lines
fs/logfs/file.c new file +14 -0
+/*
+ * cookie is set to 1 if we hand out a cached inode, 0 otherwise.
+ * this allows logfs_iput to do the right thing later
+ */
+struct inode *logfs_iget(struct super_block *sb, ino_t ino, int *cookie)
+{
+	struct logfs_super *super = LOGFS_SUPER(sb);
+	struct logfs_inode *li;
+
+	if (ino == LOGFS_INO_MASTER)
+		return super->s_master_inode;
+
+	spin_lock(&inode_lock);
+	list_for_each_entry(li, &super->s_freeing_list, li_freeing_list)

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+		if (li->vfs_inode.i_ino == ino) {
+			spin_unlock(&inode_lock);
+			*cookie = 1;
+			return &li->vfs_inode;
+		}
+	spin_unlock(&inode_lock);
+
+	*cookie = 0;
+	return __logfs_iget(sb, ino);
+}

A filesystem playing with inode_lock: not good. What's going on here?

As a minimum, the reasons for this should be clearly spelled out in code comments, because this sticks out like a sore thumb.

Quoted 29 lines
fs/logfs/file.c new file +29 -0
+
+	li = kmem_cache_alloc(logfs_inode_cache, GFP_KERNEL);
+	if (!li)
+		return NULL;
+	logfs_init_inode(&li->vfs_inode);
+	return &li->vfs_inode;
+}
+
+
+struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino)
+{
+	struct inode *inode;
+
+	inode = logfs_alloc_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	logfs_init_inode(inode);
+	inode->i_mode = 0;
+	inode->i_ino = ino;
+	inode->i_sb = sb;
+
+	/* This is a blatant copy of alloc_inode code.  We'd need alloc_inode
+	 * to be nonstatic, alas. */
+	{
+		static const struct address_space_operations empty_aops;
+		struct address_space * const mapping = &inode->i_data;
+
+		mapping->a_ops = &empty_aops;

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+		mapping->host = inode;
+		mapping->flags = 0;
+		mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
+		mapping->assoc_mapping = NULL;
+		mapping->backing_dev_info = &default_backing_dev_info;
+		inode->i_mapping = mapping;
+	}
+
+	return inode;
+}

This function would benefit from some comments. What's it doing, and why is it special? I mean, new_inode() calls alloc_inode() anyway, so you're unable to use new_inode(). The reader wonders why.

Quoted 9 lines
fs/logfs/file.c new file +9 -0
+
+/*
+ * We depend on the kernel to hand us proper time here.  If it has more
+ * nanoseconds than fit in a second, something's fishy.  Either the currently
+ * running kernel is confused or we read a wrong value.  The latter could be
+ * because whoever wrote the value messed up or we have undetected data
+ * corruption.
+ * Whatever the case, give a warning.
+ */

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+static struct timespec be64_to_timespec(__be64 betime)
+{
+	u64 time = be64_to_cpu(betime);
+	struct timespec tsp;
+
+	tsp.tv_sec = time >> 32;
+	tsp.tv_nsec = time & 0xffffffff;
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return tsp;
+}

Could use ns_to_timespec(be64_to_cpu(betime)) here.

Should use >= NSEC_PER_SEC here.

fs/logfs/file.c

Quoted 8 lines
fs/logfs/file.c new file +8 -0
+
+static __be64 timespec_to_be64(struct timespec tsp)
+{
+	u64 time = ((u64)tsp.tv_sec << 32) + (tsp.tv_nsec & 0xffffffff);
+
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return cpu_to_be64(time);
+}

Dittos.

Quoted 19 lines
fs/logfs/file.c new file +19 -0
+/* called with inode_lock held */
+static void logfs_drop_inode(struct inode *inode)
+{
+	struct logfs_super *super = LOGFS_SUPER(inode->i_sb);
+	struct logfs_inode *li = LOGFS_INODE(inode);
+
+	list_move(&li->li_freeing_list, &super->s_freeing_list);
+	generic_drop_inode(inode);
+}
+
+
+static u64 logfs_get_ino(struct super_block *sb)
+{
+	struct logfs_super *super = LOGFS_SUPER(sb);
+	u64 ino;
+
+	/*
+	 * FIXME: ino allocation should work in two modes:
+	 * o nonsparse - ifile is mostly occupied, just append

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+	 * o sparse - ifile has lots of holes, fill them up
+	 *
+	 * SEEK_HOLE would obviously help a lot here.
+	 */
+	spin_lock(&super->s_ino_lock);
+	ino = super->s_last_ino;
+	super->s_last_ino++;
+	spin_unlock(&super->s_ino_lock);
+	return ino;
+}

Could use atomic64_add_return() here.

Quoted 19 lines
fs/logfs/file.c new file +19 -0
+
+struct inode *logfs_new_inode(struct inode *dir, int mode)
+{
+	struct super_block *sb = dir->i_sb;
+	struct inode *inode;
+
+	inode = new_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	logfs_init_inode(inode);
+
+	inode->i_mode = mode;
+	inode->i_ino = logfs_get_ino(sb);
+
+	insert_inode_hash(inode);
+
+	return inode;
+}

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+
+
+static void logfs_init_once(void *_li, struct kmem_cache *cachep,
+		unsigned long flags)
+{
+	struct logfs_inode *li = _li;
+	int i;
+
+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+			SLAB_CTOR_CONSTRUCTOR) {

This won't compile in mainline (SLAB_CTOR_VERIFY has gone)

And it won't compile in -mm (SLAB_CTOR_CONSTRUCTOR has gone).

Just remove the test altogether.

Quoted 9 lines
fs/logfs/file.c new file +9 -0
+		li->li_flags = 0;
+		li->li_used_bytes = 0;
+		for (i=0; i<LOGFS_EMBEDDED_FIELDS; i++)
+			li->li_data[i] = 0;
+		inode_init_once(&li->vfs_inode);
+	}
+
+}
+

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+
+struct super_operations logfs_super_operations = {
+	.alloc_inode	= logfs_alloc_inode,
+	.delete_inode	= logfs_delete_inode,
+	.destroy_inode	= logfs_destroy_inode,
+	.drop_inode	= logfs_drop_inode,
+	.read_inode	= logfs_read_inode,
+	.write_inode	= logfs_write_inode,
+	.statfs		= logfs_statfs,
+};

const

fs/logfs/file.c

Quoted 6 lines
fs/logfs/file.c new file +6 -0
+
+int logfs_init_inode_cache(void)
+{
+	logfs_inode_cache = kmem_cache_create("logfs_inode_cache",
+			sizeof(struct logfs_inode), 0, SLAB_RECLAIM_ACCOUNT,
+			logfs_init_once, NULL);

Use KMEM_CACHE() helper

fs/logfs/file.c

Quoted 10 lines
fs/logfs/file.c new file +10 -0
+	if (!logfs_inode_cache)
+		return -ENOMEM;
+	return 0;
+}
+
+
+void logfs_destroy_inode_cache(void)
+{
+	kmem_cache_destroy(logfs_inode_cache);
+}

<attention span ran out, sorry>

#66 lore raw
In reply to Jörn Engel

Please don't forget the immutable bit. ("man lsattr") Having both, BSD-style, would be even better. The immutable bit is important for working around software bugs and "features" that damage files.

I also can't find xattr support.

#41 lore raw
In reply to Andrew Morton
Quoted 5 lines · Andrew Morton
Quoted 5 lines
fs/Kconfig renamed from fs/Kconfig~logfs +5 -0
+
+config LOGFS_FSCK
+	bool "Run LogFS fsck at mount time"
+	depends on LOGFS
+	help
Quoted 8 lines

fs/Kconfig config JFFS2_CMODE_SIZE · line 1379

Quoted 6 lines
fs/Kconfig renamed from fs/Kconfig~logfs +6 -0
+	  Run a full filesystem check on every mount.  If any errors are
+	  found, mounting the filesystem will fail.  This is a debug option
+	  for developers.
+
+	  If unsure, say N.
+

No dependency on MTD,

Ack.

Quoted 4 lines

Can this code be tested by people who don't have MTD hardware? We used to ahve a fake-mtd-on-a-blockdev thing, whcih was in a state of some disrepair. Maybe it got repaired. Or removed. I can't immediately locate it...

Got removed. Block2mtd is the new one and works with logfs. At least my version of it does and I pushed my patches to David - not sure if they made it to mainline already. Mtdram should work as well.

Quoted 2 lines

It's strange and a bit regrettable that an fs would have dependency on MTD, really.

It is and changing this wouldn't be too hard. All device access goes through five functions (read, write, erase, is_bad and mark_bad). As soon as someone seriously cares I will add a struct logfs_device_ops and have a second set of these functions for block devices.

On hard disks it shouldn't make too much sense. The filesystem will fragment like a splinter bomb and be just as popular.

Quoted 1 line

ooh, documentation. Quick, merge it!

:)

Quoted 7 lines

fs/logfs/logfs.h line 258

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+/* memtree.c */
+void btree_init(struct btree_head *head);
+void *btree_lookup(struct btree_head *head, long val);
+int btree_insert(struct btree_head *head, long val, void *ptr);
+int btree_remove(struct btree_head *head, long val);

These names are too generic. If we later add a btree library: blam.

My plan was to move this code to lib/ sooner or later. If you consider it useful in its current state, I can do it immediatly. And if someone else merged a superior btree library I'd happily remove mine and use the new one instead.

Opinions?

Quoted 9 lines

fs/logfs/logfs.h line 298

Quoted 7 lines
fs/logfs/logfs.h new file +7 -0
+/* super.c */
+int mtdread(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+int mtdwrite(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+int mtderase(struct super_block *sb, loff_t ofs, size_t len);
+void logfs_crash_dump(struct super_block *sb);
+int all_ff(void *buf, size_t len);
+int logfs_statfs(struct dentry *dentry, struct kstatfs *stats);

Have you checked that all of this needs global scope?

Not within the last month. Will recheck.

Quoted 8 lines

fs/logfs/logfs.h line 305

Quoted 6 lines
fs/logfs/logfs.h new file +6 -0
+
+/* progs/fsck.c */
+#ifdef CONFIG_LOGFS_FSCK
+int logfs_fsck(struct super_block *sb);
+#else
+#define logfs_fsck(sb) ({ 0; })

static inline int logfs_fsck(struct super_block *sb)

Quoted 5 lines
{
	return 0;
}

is better: nicer to look at, has typechecking.

That's what I tried first. But the brick I carry on my neck decided to compile and link the read logfs_fsck() unconditionally and so this collided.

Will change the Makefile and this.

Quoted 11 lines

fs/logfs/logfs.h line 331

Quoted 9 lines
fs/logfs/logfs.h new file +9 -0
+static inline struct logfs_super *LOGFS_SUPER(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+	return container_of(inode, struct logfs_inode, vfs_inode);
+}

Do these need to be uppercase?

No more than EXT2_SB() or EXT2_I().

Since you are the second person to ask, I sense a majority vote to change the case.

Quoted 9 lines

fs/logfs/logfs.h line 349

Quoted 4 lines
fs/logfs/logfs.h new file +4 -0
+static inline pgoff_t logfs_index(u64 pos)
+{
+	return pos / LOGFS_BLOCKSIZE;
+}

If the compiler goofs up here we'll end up trying to do a 64/32 divide and it won't link on 32-bit machines. It would be safer to do

	return pos >> LOGFS_BLOCKSHIFT;

Will change.

Quoted 8 lines

fs/logfs/compr.c line 67

Quoted 6 lines
fs/logfs/compr.c new file +6 -0
+int logfs_uncompress(void *in, void *out, size_t inlen, size_t outlen)
+{
+	int err, ret;
+
+	ret = -EIO;
+	mutex_lock(&compr_mutex);

A per-superblock lock and stream would be nicer.

Yes and no. The zlib workspaces weigh about 300k. On any decent SMP machine, that hardly matters and getting the scalability is nice. For low-end embedded, that amount of memory per filesystem can matter.

I have no clue how many people would suffer one way or another.

Quoted 4 lines
Quoted 4 lines
fs/logfs/dir.c new file +4 -0
+
+
+static inline loff_t file_end(struct inode *inode)
+{
Quoted 8 lines

fs/logfs/dir.c line 298

Quoted 5 lines
fs/logfs/dir.c new file +5 -0
+	return (i_size_read(inode) + inode->i_sb->s_blocksize - 1)
+		>> inode->i_sb->s_blocksize_bits;
+}
+static void logfs_set_name(struct logfs_disk_dentry *dd, struct qstr *name)
+{

The code has a strange mix of two-blank-lines-between-functions and no-blank-lines-between-functions. One blank line is usual.

Will change.

Quoted 15 lines
Quoted 15 lines
fs/logfs/dir.c new file +15 -0
+
+	if (dest) {
+		/* symlink */
+		ret = logfs_inode_write(inode, dest, destlen, 0);
+	} else {
+		/* creat/mkdir/mknod */
+		ret = __logfs_write_inode(inode);
+	}
+	super->s_victim_ino = 0;
+	if (ret) {
+		if (!dest)
+			li->li_flags |= LOGFS_IF_STILLBORN;
+		/* FIXME: truncate symlink */
+		inode->i_nlink--;
+		iput(inode);
Quoted 8 lines

fs/logfs/dir.c line 357

Quoted 5 lines
fs/logfs/dir.c new file +5 -0
+		goto out;
+	}
+
+	if (inode->i_mode & S_IFDIR)
+		dir->i_nlink++;

You have helper functions for i_nlink++, which remember to do mark_inode_dirty()?

I do. Looks like I should use them here and in at least one other place. Will recheck them all.

Quoted 6 lines

fs/logfs/dir.c line 432

Quoted 4 lines
fs/logfs/dir.c new file +4 -0
+static struct inode_operations logfs_symlink_iops = {
+	.readlink	= generic_readlink,
+	.follow_link	= page_follow_link_light,
+};

Should be const.

As should be all oder struct foo_ops. Will do.

Quoted 6 lines

fs/logfs/dir.c line 457

Quoted 4 lines
fs/logfs/dir.c new file +4 -0
+static int logfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	return generic_permission(inode, mask, NULL);
+}

Does this need to exist?

It does not. Will remove.

Quoted 2 lines

const
const

Yep.

Quoted 4 lines

fs/logfs/file.c line 32

Quoted 2 lines
fs/logfs/file.c new file +2 -0
+
+	BUG_ON(PAGE_CACHE_SIZE != inode->i_sb->s_blocksize);

This check can be done once, at mount time.

Will do.

Quoted 6 lines

fs/logfs/file.c line 45

Quoted 3 lines
fs/logfs/file.c new file +3 -0
+	buf = kmap(page);
+	ret = logfs_write_buf(inode, index, buf);
+	kunmap(page);

kmap() is lame. The preferred approach would be to pass the page* down to the lower layers and to use kmap_atomic() at the lowest possible point.

Interesting. I'll have a look at this.

Quoted 3 lines

const
const
const

Yep.

Quoted 27 lines
Quoted 14 lines
fs/logfs/inode.c new file +14 -0
+/*
+ * cookie is set to 1 if we hand out a cached inode, 0 otherwise.
+ * this allows logfs_iput to do the right thing later
+ */
+struct inode *logfs_iget(struct super_block *sb, ino_t ino, int *cookie)
+{
+	struct logfs_super *super = LOGFS_SUPER(sb);
+	struct logfs_inode *li;
+
+	if (ino == LOGFS_INO_MASTER)
+		return super->s_master_inode;
+
+	spin_lock(&inode_lock);
+	list_for_each_entry(li, &super->s_freeing_list, li_freeing_list)

fs/logfs/inode.c line 82

Quoted 10 lines
fs/logfs/inode.c new file +10 -0
+		if (li->vfs_inode.i_ino == ino) {
+			spin_unlock(&inode_lock);
+			*cookie = 1;
+			return &li->vfs_inode;
+		}
+	spin_unlock(&inode_lock);
+
+	*cookie = 0;
+	return __logfs_iget(sb, ino);
+}

A filesystem playing with inode_lock: not good. What's going on here?

Quoted 2 lines

As a minimum, the reasons for this should be clearly spelled out in code comments, because this sticks out like a sore thumb.

There is an explanation in the top 30 lines of the file. Should I add a reference here?

Quoted 26 lines
Quoted 26 lines
fs/logfs/inode.c new file +26 -0
+struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino)
+{
+	struct inode *inode;
+
+	inode = logfs_alloc_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	logfs_init_inode(inode);
+	inode->i_mode = 0;
+	inode->i_ino = ino;
+	inode->i_sb = sb;
+
+	/* This is a blatant copy of alloc_inode code.  We'd need alloc_inode
+	 * to be nonstatic, alas. */
+	{
+		static const struct address_space_operations empty_aops;
+		struct address_space * const mapping = &inode->i_data;
+
+		mapping->a_ops = &empty_aops;
+		mapping->host = inode;
+		mapping->flags = 0;
+		mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
+		mapping->assoc_mapping = NULL;
+		mapping->backing_dev_info = &default_backing_dev_info;
+		inode->i_mapping = mapping;
Quoted 8 lines

fs/logfs/inode.c line 56

Quoted 4 lines
fs/logfs/inode.c new file +4 -0
+	}
+
+	return inode;
+}

This function would benefit from some comments. What's it doing, and why is it special? I mean, new_inode() calls alloc_inode() anyway, so you're unable to use new_inode(). The reader wonders why.

Inodes are stored in an inode file. The inode file's inode (master inode) caused me a bit of headache. It needs to be released as the very last, so that any regular inodes can still use it for writeback.

Doing so would gave the user an unpleasant message:

		if (invalidate_inodes(sb)) {
			printk("VFS: Busy inodes after unmount of %s. "
			   "Self-destruct in 5 seconds.  Have a nice day...\n",
			   sb->s_id);
		}

This function mainly exists to smuggle the master inode around this check. I didn't know any better way to deal with the problem.

Add this as comment or is there a better strategy I should persue?

Quoted 4 lines
Quoted 4 lines
fs/logfs/inode.c new file +4 -0
+static struct timespec be64_to_timespec(__be64 betime)
+{
+	u64 time = be64_to_cpu(betime);
+	struct timespec tsp;
Quoted 8 lines

fs/logfs/inode.c line 181

Quoted 6 lines
fs/logfs/inode.c new file +6 -0
+
+	tsp.tv_sec = time >> 32;
+	tsp.tv_nsec = time & 0xffffffff;
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return tsp;
+}

Could use ns_to_timespec(be64_to_cpu(betime)) here.

Would this help. Looks like the function does a division and adds any remainder to tsp.tv_sec. But any value for tsp.tv_nsec >= NSEC_PER_SEC is caused by either a bug or data corruption.

If the goal is to prevent illegal values, I could do something cheaper like:

	if (tsp.tv_nsec >= NSEC_PER_SEC)
		tsp.tv_nsec = 0;
Quoted 1 line

Should use >= NSEC_PER_SEC here.

Will do.

Quoted 10 lines

fs/logfs/inode.c line 190

Quoted 8 lines
fs/logfs/inode.c new file +8 -0
+
+static __be64 timespec_to_be64(struct timespec tsp)
+{
+	u64 time = ((u64)tsp.tv_sec << 32) + (tsp.tv_nsec & 0xffffffff);
+
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return cpu_to_be64(time);
+}

Dittos.

Yep.

Quoted 8 lines

fs/logfs/inode.c line 455

Quoted 6 lines
fs/logfs/inode.c new file +6 -0
+	spin_lock(&super->s_ino_lock);
+	ino = super->s_last_ino;
+	super->s_last_ino++;
+	spin_unlock(&super->s_ino_lock);
+	return ino;
+}

Could use atomic64_add_return() here.

tag not found: atomic64_add_return

That one seems to be missing from include/asm-i386/

Quoted 11 lines

fs/logfs/inode.c line 485

Quoted 8 lines
fs/logfs/inode.c new file +8 -0
+static void logfs_init_once(void *_li, struct kmem_cache *cachep,
+		unsigned long flags)
+{
+	struct logfs_inode *li = _li;
+	int i;
+
+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+			SLAB_CTOR_CONSTRUCTOR) {

This won't compile in mainline (SLAB_CTOR_VERIFY has gone)

Quoted 3 lines

And it won't compile in -mm (SLAB_CTOR_CONSTRUCTOR has gone).

Just remove the test altogether.

Will do.

Quoted 1 line

const

Yep.

Quoted 8 lines

fs/logfs/inode.c line 511

Quoted 6 lines
fs/logfs/inode.c new file +6 -0
+
+int logfs_init_inode_cache(void)
+{
+	logfs_inode_cache = kmem_cache_create("logfs_inode_cache",
+			sizeof(struct logfs_inode), 0, SLAB_RECLAIM_ACCOUNT,
+			logfs_init_once, NULL);

Use KMEM_CACHE() helper

Neat! Will do.

Quoted 1 line

<attention span ran out, sorry>

No worries! Thank you a lot for what you've found. It seems to include some bugs.

Jörn

Signature · 7 lines
It is better to die of hunger having lived without grief and fear,
than to live with a troubled spirit amid abundance.
-- Epictetus
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#67 lore raw
In reply to Albert Cahalan
Quoted 7 lines · Albert Cahalan

Please don't forget the immutable bit. ("man lsattr") Having both, BSD-style, would be even better. The immutable bit is important for working around software bugs and "features" that damage files.

I also can't find xattr support.

Not forgotten, just on a different list. Bugs beat features. :)

Jörn

Signature · 6 lines
Data expands to fill the space available for storage.
-- Parkinson's Law
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#42 lore raw
In reply to Jörn Engel
Quoted 25 lines · Jörn Engel
Quoted 16 lines
Quoted 16 lines
fs/logfs/dir.c new file +15 -0
+
+	if (dest) {
+		/* symlink */
+		ret = logfs_inode_write(inode, dest, destlen, 0);
+	} else {
+		/* creat/mkdir/mknod */
+		ret = __logfs_write_inode(inode);
+	}
+	super->s_victim_ino = 0;
+	if (ret) {
+		if (!dest)
+			li->li_flags |= LOGFS_IF_STILLBORN;
+		/* FIXME: truncate symlink */
+		inode->i_nlink--;
+		iput(inode);
Quoted 8 lines

fs/logfs/dir.c line 357

Quoted 5 lines
fs/logfs/dir.c new file +5 -0
+		goto out;
+	}
+
+	if (inode->i_mode & S_IFDIR)
+		dir->i_nlink++;

You have helper functions for i_nlink++, which remember to do mark_inode_dirty()?

Quoted 2 lines

I do. Looks like I should use them here and in at least one other place. Will recheck them all.

Actually, this code was correct. New inodes get written immediatly to ensure catching -ENOSPC at a place where errors can get returned. After leaving this function, the inode is not dirty. Either it has been written or it is marked LOGFS_IF_STILLBORN never will be.

Your intuition was still good. Link() did need the change you indicated.

Jörn

Signature · 2 lines
Joern's library part 14:
http://www.sandpile.org/
#71 lore raw
In reply to Jörn Engel

There are rather a lot of of FIXME comments, including scary stuff like

fs/logfs/dir.c line 558

Quoted 5 lines
fs/logfs/dir.c new file +5 -0
+	/*
+	 * FIXME: this cannot be right but it does "fix" a bug of i_count
+	 * dropping too low.  Needs more thought.
+	 */
+	atomic_inc(&old_dentry->d_inode->i_count);

and

fs/logfs/inode.c line 348

Quoted 9 lines
fs/logfs/inode.c new file +9 -0
+int __logfs_write_inode(struct inode *inode)
+{
+	/*
+	 * FIXME: Those two inodes are 512 bytes in total.  Not good to
+	 * have on the stack.  Possibly the best solution would be to bite
+	 * the bullet and do another format change before release and
+	 * shrink the inodes.
+	 */
+	struct logfs_disk_inode old, new;

are you going to change the format? or fix this some other way?

I think a sweep through the code searching for FIXME and at least rewriting all such comments to look like stuff that can be deferred would be warranted ;)

- R.

#13 lore raw
In reply to Jörn Engel
Quoted 14 lines · Jörn Engel
Quoted 5 lines · John Stoffel

I've been semi watching this, and the only comment I really can give is that I hate the name. To me, logfs implies a filesystem for logging purposes, not for Flash hardware with wear leveling issues to be taken into account.

Yeah, well, ...

Two years ago when I started all this, I was looking for a good name. All I could come up with sounded stupid, so I picked "LogFS" as a code name. As soon as I find a better name, the code name should get replaced.

Quoted 4 lines

By now I still don't have anything better. All alternatives that were proposed are just as bad - with the added disadvantage of being new and not established yet. My hope of ever finding a better name is nearly zero.

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Signature · 1 line
dwmw2
#43 lore raw
In reply to Jörn Engel
Quoted 11 lines · Jörn Engel
Quoted 2 lines · Andrew Morton

It's strange and a bit regrettable that an fs would have dependency on MTD, really.

It is and changing this wouldn't be too hard. All device access goes through five functions (read, write, erase, is_bad and mark_bad). As soon as someone seriously cares I will add a struct logfs_device_ops and have a second set of these functions for block devices.

On hard disks it shouldn't make too much sense. The filesystem will fragment like a splinter bomb and be just as popular.

On hard disks, yes, but as you suggested, there are lots of other flash devices interfaced as block devices. CompactFlash comes to mind, USB keys too. And on these ones, the most important is to reduce the number of writes and to support large sizes. I already see LogFS as an interesting alternative to JFFS2 on such devices, eventhough it does not (yet?) support compression.

Regards,
Willy

#73 lore raw
In reply to Jörn Engel

Hi Joern,

fs/logfs/logfs.h line 317

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+#define LOGFS_BUG(sb) do {           \
+     struct super_block *__sb = sb;  \
+     logfs_crash_dump(__sb);         \
+     BUG();                          \
+} while(0)

Note that BUG() can be a no-op so dumping something on disk might not make sense there. This seems useful, but you probably need to make this bit more generic so that using BUG() proper in your filesystem code does the right thing. Inventing your own wrapper should be avoided.

fs/logfs/logfs.h line 331

Quoted 9 lines
fs/logfs/logfs.h new file +9 -0
+static inline struct logfs_super *LOGFS_SUPER(struct super_block *sb)
+{
+     return sb->s_fs_info;
+}
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+     return container_of(inode, struct logfs_inode, vfs_inode);
+}

No need for upper case in function names.

fs/logfs/compr.c line 24

Quoted 7 lines
fs/logfs/compr.c new file +7 -0
+int logfs_memcpy(void *in, void *out, size_t inlen, size_t outlen)
+{
+     if (outlen < inlen)
+             return -EIO;
+     memcpy(out, in, inlen);
+     return inlen;
+}

Please drop this wrapper function. It's better to open-code the error handling in the callers (there are total of three of them).

fs/logfs/segment.c line 16

Quoted 3 lines
fs/logfs/segment.c new file +3 -0
+/* FIXME: combine with per-sb journal variant */
+static unsigned char compressor_buf[LOGFS_MAX_OBJECTSIZE];
+static DEFINE_MUTEX(compr_mutex);

This looks fishy. All reads and writes are serialized by compr_mutex because they share a scratch buffer for compression and uncompression?

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* FIXME: all this mess should get replaced by using the page cache */
+static void fixup_from_wbuf(struct super_block *sb, struct logfs_area 

*area,

fs/logfs/segment.c line 230

Quoted 2 lines
fs/logfs/segment.c new file +2 -0
+             void *read, u64 ofs, size_t readlen)
+{

Indeed. And I think you're getting some more trouble because of this...

Quoted 6 lines
fs/logfs/segment.c new file +6 -0
+int logfs_segment_read(struct super_block *sb, void *buf, u64 ofs)
+{
+     struct logfs_object_header *h;
+     u16 len;
+     int err, bs = sb->s_blocksize;
+

fs/logfs/segment.c

Quoted 10 lines
fs/logfs/segment.c new file +10 -0
+     mutex_lock(&compr_mutex);
+     err = wbuf_read(sb, ofs, bs + LOGFS_HEADERSIZE, compressor_buf);
+     if (err)
+             goto out;
+     h = (void*)compressor_buf;
+     len = be16_to_cpu(h->len);
+
+     switch (h->compr) {
+     case COMPR_NONE:
+             logfs_memcpy(compressor_buf + LOGFS_HEADERSIZE, buf, bs, 

bs);

Quoted 1 line

+ break;

Seems wasteful to first read the data in a scratch buffer and then memcpy() it immediately for the COMPR_NONE case. Any reason why we can't read a full struct page, for example, and simply use that if we don't need to uncompress anything?

Review

Quoted 2 lines
(quoted diff) +2 -0
+     case COMPR_ZLIB:
+             err = logfs_uncompress(compressor_buf + LOGFS_HEADERSIZE, 

buf,

fs/logfs/segment.c line 303

Quoted 3 lines
fs/logfs/segment.c new file +3 -0
+                             len, bs);
+             BUG_ON(err);
+             break;

Not claiming to undestand your on-disk format, but wouldn't it make more sense if we knew whether a given segment is compressed or not _before_ we actually read it?

#68 lore raw
In reply to Albert Cahalan
Quoted 6 lines · Albert Cahalan

Please don't forget the immutable bit. ("man lsattr") Having both, BSD-style, would be even better. The immutable bit is important for working around software bugs and "features" that damage files.

I also can't find xattr support.

Imho,

Given that the filesystem is still 'experimental', I'd concentrate on getting it stable before worrying about immutable and xattrs unless they are easy. (Immutable is easy).

In 13 years of using Linux in all sorts of ways I've never yet to use either feature. They would be good to have, but stability in a filesystem is much more useful.

I'm biased of course: if LogFS were stable and well tested, I'd be using it right now in my embedded thingy - and that doesn't even bother with uids :-)

-- Jamie

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#44 lore raw
In reply to Willy Tarreau
Quoted 7 lines · Willy Tarreau

On hard disks, yes, but as you suggested, there are lots of other flash devices interfaced as block devices. CompactFlash comes to mind, USB keys too. And on these ones, the most important is to reduce the number of writes and to support large sizes. I already see LogFS as an interesting alternative to JFFS2 on such devices, eventhough it does not (yet?) support compression.

It does support compression now. That part was finished, erm, about two weeks ago.

Logfs on Smartmedia format (I assume most CompactFlash, USB, SD and MMC media use that) will currently cause a nasty interaction. Unlike JFFS2, logfs will alternately write to several eraseblocks. On real flash, alternating between half-finished blocks is free.

Smartmedia standard requires to finish the last block before moving to the next. So the logfs write pattern will cause it to add an erase/write overhead of - depending on erase size and compression - 4x to 512x. Pretty bad.

If Smartmedia was really stupid, there would be no overhead at all. Any manucaturers listening should seriously think about allowing raw flash access to their devices. ;)

Jörn

Signature · 8 lines
To recognize individual spam features you have to try to get into the
mind of the spammer, and frankly I want to spend as little time inside
the minds of spammers as possible.
-- Paul Graham
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw
In reply to David Woodhouse
Quoted 3 lines · David Woodhouse

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Did you ever see akpm's facial expression when he tried to pronounce "JFFS2"? ;)

Jörn

Signature · 4 lines
Fancy algorithms are slow when n is small, and n is usually small.
Fancy algorithms have big constants. Until you know that n is
frequently going to be big, don't get fancy.
-- Rob Pike
#15 lore raw
Quoted 6 lines · Jörn Engel
Quoted 2 lines · David Woodhouse

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Did you ever see akpm's facial expression when he tried to pronounce "JFFS2"? ;)

JFFS3 is a good, meaningful name to anyone familiar with JFFS2.

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

-- Jamie

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#16 lore raw
Quoted 5 lines · Jamie Lokier
Quoted 4 lines · Jörn Engel
Quoted 2 lines · David Woodhouse

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Quoted 7 lines
Quoted 2 lines

Did you ever see akpm's facial expression when he tried to pronounce "JFFS2"? ;)

JFFS3 is a good, meaningful name to anyone familiar with JFFS2.

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

The problem is that JFFS2 will always be faster in terms of I/O speed anyway, just because it does not have to maintain on-flash indexing data structures. But yes, it is slow in mount and in building big inodes, so the "faster" is confusing.

Signature · 7 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#72 lore raw
In reply to Roland Dreier
Quoted 8 lines · Roland Dreier

There are rather a lot of of FIXME comments, including scary stuff like

fs/logfs/dir.c line 558

Quoted 5 lines
fs/logfs/dir.c new file +5 -0
+	/*
+	 * FIXME: this cannot be right but it does "fix" a bug of i_count
+	 * dropping too low.  Needs more thought.
+	 */
+	atomic_inc(&old_dentry->d_inode->i_count);

Any thoughts on this would be appreciated.

Quoted 13 lines

and

fs/logfs/inode.c line 348

Quoted 9 lines
fs/logfs/inode.c new file +9 -0
+int __logfs_write_inode(struct inode *inode)
+{
+	/*
+	 * FIXME: Those two inodes are 512 bytes in total.  Not good to
+	 * have on the stack.  Possibly the best solution would be to bite
+	 * the bullet and do another format change before release and
+	 * shrink the inodes.
+	 */
+	struct logfs_disk_inode old, new;

are you going to change the format? or fix this some other way?

I would love to put my inodes on a diet. It is just a matter of time and priorities. To me the 512 bytes on the stack are unfortunate, but not a show stopper. Crash behaviour is, so that has priority.

Quoted 3 lines

I think a sweep through the code searching for FIXME and at least rewriting all such comments to look like stuff that can be deferred would be warranted ;)

Are you asking me to hide known problems under a rug? ;)

Will see if I can easily fix some of these. In particular the eat-your-data FIXME that can cause LogFS to not survive a crash.

Jörn

Signature · 8 lines
Correctness comes second.
Features come third.
Performance comes last.
Maintainability is easily forgotten.
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#19 lore raw
In reply to Jamie Lokier
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Grouping four or more consonants to name anything will cause similar expressions on people's faces. Numbers don't help much either.

Ext2 is a great name, because "ext" actually is a pronouncable syllable. MinixFS, ChunkFS, TileFS are great too. XFS and JFS are ok, at least they only have three consonants. But FFS exists, so I'd rather go for a syllable.

Jörn

Signature · 2 lines
Joern's library part 5:
http://www.faqs.org/faqs/compression-faq/part2/section-9.html
#20 lore raw
Quoted 7 lines · J??rn Engel
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Quoted 7 lines

Grouping four or more consonants to name anything will cause similar expressions on people's faces. Numbers don't help much either.

Ext2 is a great name, because "ext" actually is a pronouncable syllable. MinixFS, ChunkFS, TileFS are great too. XFS and JFS are ok, at least they only have three consonants. But FFS exists, so I'd rather go for a syllable.

FlashFS?

Signature · 7 lines
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
    	- High Court Judge Michael Kirby

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#49 lore raw
In reply to Andrew Morton
Quoted 6 lines · Andrew Morton

But it includes an MTD header file.

Can this code be tested by people who don't have MTD hardware? We used to ahve a fake-mtd-on-a-blockdev thing, whcih was in a state of some disrepair. Maybe it got repaired. Or removed. I can't immediately locate it...

There's block2mtd, as Jörn pointed out. There's also 'nandsim' and 'mtdram', which will vmalloc some space and use that to emulate NAND or NOR flash, respectively.

Quoted 2 lines

It's strange and a bit regrettable that an fs would have dependency on MTD, really.

Why? Other file systems has dependencies on BLOCK or on NET. It seems entirely normal to me.

Signature · 1 line
dwmw2
#69 lore raw
In reply to Jamie Lokier
Quoted 3 lines · Jamie Lokier

Given that the filesystem is still 'experimental', I'd concentrate on getting it stable before worrying about immutable and xattrs unless they are easy.

We will run into trouble if the on-disk format is not flexible enough to accommodate xattrs (think reiser3 here). So I'd worry about it before merging to mainline.

#17 lore raw
In reply to Artem Bityutskiy
Quoted 11 lines · Artem Bityutskiy
Quoted 10 lines · Jamie Lokier
Quoted 6 lines · Jörn Engel
Quoted 2 lines · David Woodhouse

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Did you ever see akpm's facial expression when he tried to pronounce "JFFS2"? ;)

JFFS3 is a good, meaningful name to anyone familiar with JFFS2.

Quoted 7 lines
Quoted 2 lines

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

The problem is that JFFS2 will always be faster in terms of I/O speed anyway, just because it does not have to maintain on-flash indexing data structures. But yes, it is slow in mount and in building big inodes, so the "faster" is confusing.

Is LogFS really slower than JFFS2 in practice?

I would have guessed reads to be a similar speed, tree updates to be a similar speed to journal updates for sustained non-fsyncing writes, and the difference unimportant for tiny individual commits whose index updates are not merged with any other. I've not thought about it much though.

-- Jamie

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#74 lore raw
In reply to Pekka J Enberg
Quoted 11 lines · Pekka J Enberg

fs/logfs/logfs.h line 317

Quoted 6 lines
fs/logfs/logfs.h new file +5 -0
+#define LOGFS_BUG(sb) do {           \
+     struct super_block *__sb = sb;  \
+     logfs_crash_dump(__sb);         \
+     BUG();                          \
+} while(0)

Note that BUG() can be a no-op so dumping something on disk might not make sense there. This seems useful, but you probably need to make this bit more generic so that using BUG() proper in your filesystem code does the right thing. Inventing your own wrapper should be avoided.

Hmm. I am not sure how this could be generic and still make sense.

LogFS has some unused write-once space in the superblock segment. Embedded people always have problems debugging and were suggesting using this to store debug information. That allows me to ask for a filesystem image and get both the offending image plus a crash dump. It also allows me to abort mounting if I ever see an existing crash dump (not implemented yet). "First failure data capture" was an old IBM slogal and the "first" really makes a difference.

So how should I deal with BUG() as a no-op? I _think_ it should not make a difference. People choosing that option should know that their kernels will continue running with errors and can potentially do any kind of damage. My wrapper doesn't seem to change that one way or another.

What I _should_ do is make the filesystem read-only after this point. That would actually be quite simple. Onto my list.

Quoted 11 lines

fs/logfs/logfs.h line 331

Quoted 9 lines
fs/logfs/logfs.h new file +9 -0
+static inline struct logfs_super *LOGFS_SUPER(struct super_block *sb)
+{
+     return sb->s_fs_info;
+}
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+     return container_of(inode, struct logfs_inode, vfs_inode);
+}

No need for upper case in function names.

Will change.

Quoted 10 lines

fs/logfs/compr.c line 24

Quoted 7 lines
fs/logfs/compr.c new file +7 -0
+int logfs_memcpy(void *in, void *out, size_t inlen, size_t outlen)
+{
+     if (outlen < inlen)
+             return -EIO;
+     memcpy(out, in, inlen);
+     return inlen;
+}

Please drop this wrapper function. It's better to open-code the error handling in the callers (there are total of three of them).

Is it? The advantage of having the wrapper is that the compression case and the non-compressed case look identical and the code just repeats the same pattern twice.

I'll try to open-code it and see how it looks.

Quoted 6 lines

fs/logfs/segment.c line 16

Quoted 3 lines
fs/logfs/segment.c new file +3 -0
+/* FIXME: combine with per-sb journal variant */
+static unsigned char compressor_buf[LOGFS_MAX_OBJECTSIZE];
+static DEFINE_MUTEX(compr_mutex);

This looks fishy. All reads and writes are serialized by compr_mutex because they share a scratch buffer for compression and uncompression?

s/fishy/lame/

Will move to superblock.

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* FIXME: all this mess should get replaced by using the page cache */
+static void fixup_from_wbuf(struct super_block *sb, struct logfs_area 

*area,

fs/logfs/segment.c line 230

Quoted 2 lines
fs/logfs/segment.c new file +2 -0
+             void *read, u64 ofs, size_t readlen)
+{

Indeed. And I think you're getting some more trouble because of this...

More trouble?

Sadly squeezing bugs out of that beast was easier than wrapping my brain around the proper solution. And now it works and has moved to a less urgent position in my todo list.

Quoted 17 lines
Quoted 6 lines
fs/logfs/segment.c new file +6 -0
+int logfs_segment_read(struct super_block *sb, void *buf, u64 ofs)
+{
+     struct logfs_object_header *h;
+     u16 len;
+     int err, bs = sb->s_blocksize;
+

fs/logfs/segment.c

Quoted 10 lines
fs/logfs/segment.c new file +10 -0
+     mutex_lock(&compr_mutex);
+     err = wbuf_read(sb, ofs, bs + LOGFS_HEADERSIZE, compressor_buf);
+     if (err)
+             goto out;
+     h = (void*)compressor_buf;
+     len = be16_to_cpu(h->len);
+
+     switch (h->compr) {
+     case COMPR_NONE:
+             logfs_memcpy(compressor_buf + LOGFS_HEADERSIZE, buf, bs, 

bs);

Quoted 6 lines
Quoted 1 line

+ break;

Seems wasteful to first read the data in a scratch buffer and then memcpy() it immediately for the COMPR_NONE case. Any reason why we can't read a full struct page, for example, and simply use that if we don't need to uncompress anything?

No technical reason. Just a case of "make it work now and optimize later".

Quoted 10 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     case COMPR_ZLIB:
+             err = logfs_uncompress(compressor_buf + LOGFS_HEADERSIZE, 

buf,

fs/logfs/segment.c line 303

Quoted 3 lines
fs/logfs/segment.c new file +3 -0
+                             len, bs);
+             BUG_ON(err);
+             break;

Not claiming to undestand your on-disk format, but wouldn't it make more sense if we knew whether a given segment is compressed or not _before_ we actually read it?

[ Objects are the units that get compressed. Segments can contain both compressed and uncompressed objects. ]

It is a trade-off. Each object has a 24 Byte header plus X Bytes of data. Whether the data is compressed or not is indicated in the header. So we have to do one of two things. Either:
- read the complete object, then either uncompress or memcpy, or
- read just the header, then either read uncompressed data or read compressed data and uncompress.

The former does an unnecessary memcpy() in the uncompressed case. The latter does an extra IO operation. I haven't done any benchmarks to see which variant is faster on which hardware.

An advantage of the second approach is that no buffer and no mutex is needed in the uncompressed case. That could help read performance on an SMP system. I'll put it on my list, just not at the top. Ok?

Jörn

Signature · 3 lines
When in doubt, punt.  When somebody actually complains, go back and fix it...
The 90% solution is a good thing.
-- Rob Landley
#22 lore raw
In reply to Jörn Engel
Quoted 6 lines · Jörn Engel
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Do you think 'eieio' is a good set? IBM's work too...

We do not get new filesystem each couple of month, so stealing so good name as 'logfs' is not that bad I think.

Signature · 1 line
	Evgeniy Polyakov
#75 lore raw
In reply to Jörn Engel
Quoted 9 lines · Jörn Engel
Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* FIXME: all this mess should get replaced by using the page cache */
+static void fixup_from_wbuf(struct super_block *sb, struct logfs_area

*area,

fs/logfs/segment.c line 230

Quoted 2 lines
fs/logfs/segment.c new file +2 -0
+             void *read, u64 ofs, size_t readlen)
+{

Indeed. And I think you're getting some more trouble because of this...

More trouble?

Forgot to add (see below). Seems logfs_segment_read would be simpler too if you fixed this.

Quoted 5 lines

[ Objects are the units that get compressed. Segments can contain both compressed and uncompressed objects. ]

It is a trade-off. Each object has a 24 Byte header plus X Bytes of data. Whether the data is compressed or not is indicated in the header.

Was my point really. Why do segments contain both compressed and uncompressed objects?
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#76 lore raw
Quoted 2 lines · Pekka Enberg

Forgot to add (see below). Seems logfs_segment_read would be simpler too if you fixed this.

Blah. Just to be clear: I forgot to add a "(see below)" text in the original review comment.

#18 lore raw
In reply to Jamie Lokier
Quoted 2 lines · Jamie Lokier

Is LogFS really slower than JFFS2 in practice?

Not sure. I ran a benchmark before adding compression support in QEMU with a lightning-fast device. So the results should differ quite a bit from practice.

http://logfs.org/~joern/logfs/benchmark/benchmark_overview

LogFS was actually faster than JFFS2. So for that particular unrealistic benchmark, updating the LogFS tree was less expensive than trying (and failing) to compress and calculating the CRC was for JFFS2.

With compression finished, I would expect LogFS numbers to degrade. If file data had checksums (not done yet, should be optional for users to decide) even more so.

Quoted 5 lines

I would have guessed reads to be a similar speed, tree updates to be a similar speed to journal updates for sustained non-fsyncing writes, and the difference unimportant for tiny individual commits whose index updates are not merged with any other. I've not thought about it much though.

LogFS isn't that good yet. Right now, writing 10 adjacent blocks to a file requires 10 tree updates instead of 1. Not full updates though, just up to the inode.

Quite surprisingly, read speed in the benchmark was significantly better for LogFS, even after substracting mount time. I don't know if all of that can be explained with CRC checks or there is more to it.

Jörn

Signature · 3 lines
I can say that I spend most of my time fixing bugs even if I have lots
of new features to implement in mind, but I give bugs more priority.
-- Andrea Arcangeli, 2000
#23 lore raw
In reply to Evgeniy Polyakov
Quoted 9 lines · Evgeniy Polyakov
Quoted 6 lines · Jörn Engel
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Do you think 'eieio' is a good set? IBM's work too...

I will let someone else comment on that one.

http://www.uwsg.iu.edu/hypermail/linux/kernel/0110.1/1294.html

Jörn

Signature · 4 lines
There are two ways of constructing a software design: one way is to make
it so simple that there are obviously no deficiencies, and the other is
to make it so complicated that there are no obvious deficiencies.
-- C. A. R. Hoare
#70 lore raw
In reply to Pekka Enberg
Quoted 8 lines · Pekka Enberg
Quoted 3 lines · Jamie Lokier

Given that the filesystem is still 'experimental', I'd concentrate on getting it stable before worrying about immutable and xattrs unless they are easy.

We will run into trouble if the on-disk format is not flexible enough to accommodate xattrs (think reiser3 here). So I'd worry about it before merging to mainline.

Adding xattrs would be fairly simple. Inodes just need one extra pointer for that.

Luckily inodes no longer need to be padded to 128 or 256 bytes. They are individually compressed, so their size is not limited to powers of two.

Jörn

Signature · 4 lines
To recognize individual spam features you have to try to get into the
mind of the spammer, and frankly I want to spend as little time inside
the minds of spammers as possible.
-- Paul Graham
#77 lore raw
In reply to Pekka Enberg
Quoted 6 lines · Pekka Enberg
Quoted 2 lines · Jörn Engel

More trouble?

Forgot to add (see below). Seems logfs_segment_read would be simpler too if you fixed this.

Would it? I think that code would still be needed, although possibly in a different function.

There are two minor drawbacks to using the page cache, btw:
- Indirect blocks need some mapping too. So either I need to steal a bit from the inode space or from the fpos space.
- OOM handling is a bit more complicated. I would need a mempool for that.

Quoted 8 lines
Quoted 5 lines

[ Objects are the units that get compressed. Segments can contain both compressed and uncompressed objects. ]

It is a trade-off. Each object has a 24 Byte header plus X Bytes of data. Whether the data is compressed or not is indicated in the header.

Was my point really. Why do segments contain both compressed and uncompressed objects?

Compressing random data will actually enlarge it. If that happens I simply store the verbatim uncompressed data instead and mark it as such.

There is also demand for a user-controlled bit in the inode to disable compression completely. All those .jpg, .mpg, .mp3, etc. just waste time by trying and failing to compress them.

Jörn

Signature · 8 lines
Write programs that do one thing and do it well. Write programs to work
together. Write programs to handle text streams, because that is a
universal interface.
-- Doug MacIlroy
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#25 lore raw
In reply to Jörn Engel
Quoted 3 lines · Jamie Lokier
Quoted 3 lines

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

Jörn> How many of you have worked for IBM before? Vowels are not evil. ;)

Nope, they're not. I just think that LogFS isn't descriptive enough, or more accurately, is the *wrong* description of this filesystem.

flashfs works for me. It's longer, but hey, that's ok. Even flshfs might work. Oh wait, flesh? flash? flush? Too confusing... :-)

John

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#26 lore raw
Quoted 7 lines · John Stoffel

Jörn> On Wed, 16 May 2007 12:34:34 +0100, Jamie Lokier wrote:

Jörn> How many of you have worked for IBM before? Vowels are not evil. ;)

Nope, they're not. I just think that LogFS isn't descriptive enough, or more accurately, is the *wrong* description of this filesystem.

That was the whole point. JFFS2, the journaling flash filesystem, is a strictly log-structured filesystem. LogFS has a journal.

It is also the filesystem that tries to scale logarithmically, as Arnd has noted. Maybe I should call it Log2 to emphesize this point. Log1 would be horrible scalability.

Quoted 2 lines

flashfs works for me. It's longer, but hey, that's ok. Even flshfs might work. Oh wait, flesh? flash? flush? Too confusing... :-)

Maybe. FFS or flash filesystem already exists. And YAFFS, yet another flash filesystem, would be older than flashfs.

My experience is that no matter which name I pick, people will complain anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Plus today:
FFFS
flashfs
fredfs
bob
shizzle

Imo they all suck. LogFS also sucks, but it allows me to make a stupid joke and keep my logfs.org domain.

Jörn

Signature · 4 lines
There are two ways of constructing a software design: one way is to make
it so simple that there are obviously no deficiencies, and the other is
to make it so complicated that there are no obvious deficiencies.
-- C. A. R. Hoare
#27 lore raw
Quoted 13 lines · Jörn Engel

My experience is that no matter which name I pick, people will complain
anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Can we call it jörnfs? :)

Signature · 1 line
dwmw2
#28 lore raw
Quoted 15 lines · David Woodhouse
Quoted 13 lines · Jörn Engel

My experience is that no matter which name I pick, people will complain
anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Quoted 1 line

Can we call it jörnfs? :)

And it is essential to preserve "ö" and let Pavel enjoy :-)

Signature · 7 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#29 lore raw
In reply to David Woodhouse
Quoted 15 lines · David Woodhouse
Quoted 13 lines · Jörn Engel

My experience is that no matter which name I pick, people will complain
anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Quoted 1 line

Can we call it jörnfs? :)

However if Jörn is accused of murder, it will have little chance of being merged :-).
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#33 lore raw
In reply to Jörn Engel
Quoted 2 lines · J??rn Engel

Imo they all suck. LogFS also sucks, but it allows me to make a stupid joke and keep my logfs.org domain.

Well if stupid jokes are a goer there's always gordonfs. :)

*hides*

Signature · 3 lines
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
    	- High Court Judge Michael Kirby
#50 lore raw
In reply to David Woodhouse
Quoted 5 lines · On Wed, 16 May 2007 20:07:18 +0800 David Woodhouse <[email protected]> wrote:
Quoted 2 lines

It's strange and a bit regrettable that an fs would have dependency on MTD, really.

Why? Other file systems has dependencies on BLOCK or on NET. It seems entirely normal to me.

Reduced testability, mainly. Also potentially reduced usefulness.

#51 lore raw
Quoted 1 line · Andrew Morton

Reduced testability, mainly. Also potentially reduced usefulness.

CONFIG_MTD has never been a barrier to testability. JFFS2 depends on MTD and had _most_ of its early testing and development done on the 'fake' mtdram device.

Utility is a factor of the underlying design -- a filesystem designed for flash really isn't suited to block devices.

Signature · 1 line
dwmw2
#52 lore raw
Quoted 3 lines · David Woodhouse

Utility is a factor of the underlying design -- a filesystem designed for flash really isn't suited to block devices.

I can think of at least three examples where LogFS would indeed make sense on block devices.

Jörn

Signature · 6 lines
Happiness isn't having what you want, it's wanting what you have.
-- unknown
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#81 lore raw
In reply to Jörn Engel

Hi!

In kernel fsck....

Quoted 4 lines
fs/logfs/progs/fsck.c new file +1 -0
@@ -0,0 +1,332 @@
+/*

fs/logfs/progs/fsck.c line 11

Quoted 10 lines
fs/logfs/progs/fsck.c new file +10 -0
+ * fs/logfs/prog/fsck.c	- filesystem check
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * In principle this could get moved to userspace.  However it might still
+ * make some sense to keep it in the kernel.  It is a pure checker and will
+ * only report problems, not attempt to repair them.
+ */

Is there version that repairs?

fs/logfs/progs/fsck.c line 43

Quoted 7 lines
fs/logfs/progs/fsck.c new file +7 -0
+	/* Some segments are reserved.  Just pretend they were all valid */
+	reserved = btree_lookup(&super->s_reserved_segments, segno);
+	if (reserved)
+		return 0;
+
+	err = wbuf_read(sb, dev_ofs(sb, segno, 0), sizeof(sh), &sh);
+	BUG_ON(err);

BUG is not right thing to do for media error.

fs/logfs/progs/fsck.c line 27

Quoted 9 lines
fs/logfs/progs/fsck.c new file +9 -0
+/*
+ * fs/logfs/prog/mkfs.c	- filesystem generation
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * Should get moved to userspace.
+ */

Indeed.

fs/logfs/progs/fsck.c line 30

Quoted 3 lines
fs/logfs/progs/fsck.c new file +3 -0
+
+#if 0
+/* rootdir */

Please just delete it, not comment it out like this.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#82 lore raw
Quoted 19 lines · Pavel Machek

In kernel fsck....

Quoted 4 lines
fs/logfs/progs/fsck.c new file +1 -0
@@ -0,0 +1,332 @@
+/*

fs/logfs/progs/fsck.c line 11

Quoted 10 lines
fs/logfs/progs/fsck.c new file +10 -0
+ * fs/logfs/prog/fsck.c	- filesystem check
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ *
+ * In principle this could get moved to userspace.  However it might still
+ * make some sense to keep it in the kernel.  It is a pure checker and will
+ * only report problems, not attempt to repair them.
+ */

Is there version that repairs?

No.

Quoted 1 line

BUG is not right thing to do for media error.

I know. Top 3 items of my todo list are:
- Handle system crashes
- Add second journal
- Error handling

Quoted 5 lines

fs/logfs/progs/fsck.c line 14

Quoted 3 lines
fs/logfs/progs/fsck.c new file +3 -0
+
+#if 0
+/* rootdir */

Please just delete it, not comment it out like this.

That will get resurrected, even before the move to userspace. I had to change the filesystem format for compression support and this is an artifact of the transition phase.

Jörn

Signature · 6 lines
Ninety percent of everything is crap.
-- Sturgeon's Law
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#54 lore raw
In reply to a message not in the archive
Quoted 4 lines · Dongjun Shin

The current trend of flash-based device is to hide the flash-specific details from the host OS. The flash memory is encapsulated in a package
which contains a dedicated controller where a small piece of software (F/W or FTL) runs and makes the storage shown as a block device to the host.

Yes. These things are almost always implemented _very_ badly by the same kind of crack-smoking hobo they drag in off the streets to write BIOSen.

It's bog-roll technology; if you fancy a laugh try doing some real reliability tests on them time some. Powerfail testing is a good one.

This kind of thing is OK for disposable storage such as in digital cameras, where it doesn't matter that it's no more reliable than a floppy disc, but for real long-term storage it's really a bad idea.

Quoted 3 lines

IMHO, for a flash-optimized filesystem to be useful and widely-used, it would be better to run on a block device and to be designed to run efficiently on top of the FTL. (ex. log-structured filesystem on general block device)

There's little point in optimising a file system _specifically_ for devices which in often aren't reliable enough to keep your data anyway. You might as well use ramfs.

It's unfortunate really -- there's no _fundamental_ reason why FTL has to be done so badly; it's just that it almost always is. Direct access to the flash from Linux is _always_ going to be better in practice -- and that way you avoid the problems with dual journalling, along with the problems with the underlying FTL continuing to keep (and copy around during GC) sectors which the top-level filesystem has actually deallocated, etc.

Signature · 1 line
dwmw2
#55 lore raw
Quoted 11 lines · David Woodhouse

Yes. These things are almost always implemented _very_ badly by the same kind of crack-smoking hobo they drag in off the streets to write BIOSen.

It's bog-roll technology; if you fancy a laugh try doing some real reliability tests on them time some. Powerfail testing is a good one.

This kind of thing is OK for disposable storage such as in digital cameras, where it doesn't matter that it's no more reliable than a floppy disc, but for real long-term storage it's really a bad idea.

There are so many flash-based storage and some disposable storages, as you pointed out, have poor quality. I think it's mainly because these are not designed for good quality, but for lowering the price.

These kind of devices are not ready for things like power failure because their use case is far from that. For example, removing flash card while taking pictures using digital camera is not a common use case. (there should be a written notice that this kind of action is against the warranty)

Quoted 5 lines

There's little point in optimising a file system _specifically_ for devices which in often aren't reliable enough to keep your data anyway. You might as well use ramfs.

Quoted 8 lines

It's unfortunate really -- there's no _fundamental_ reason why FTL has to be done so badly; it's just that it almost always is. Direct access to the flash from Linux is _always_ going to be better in practice -- and that way you avoid the problems with dual journalling, along with the problems with the underlying FTL continuing to keep (and copy around during GC) sectors which the top-level filesystem has actually deallocated, etc.

There are, of course, cases where direct access are better. However, as the demand for capacity, reliability and high performance for the flash storage increases, the use of FTL with embedded controller would be inevitable.

- The complexity/cost of host-side SW (like JFFS2/MTD) will increase due to the use of multiple flash in parallel and the use of high degree ECC algorithm. There are other things like bad block handling and wear-leveling issues which has been recently touched by UBI with added SW complexity.

- In contrast to the embedded environment where CPU and flash is directly connected, the I/O path between CPU and flash in PC environment is longer. The latency for SW handshaking between CPU and flash will also be longer, which would make the performance optimization harder.

As I mentioned, some techniques like log-structured filesystem could perform generally better on any kind of flash-based storage with FTL. Although there are many kinds of FTL, it is commonly true that it performs well under workload where sequential write is dominant.

I also expect that FTL for PC environment will have better quality spec than the disposable storage.

Dongjun

#56 lore raw
Quoted 9 lines · Dongjun Shin

There are, of course, cases where direct access are better. However, as the demand for capacity, reliability and high performance for the flash storage increases, the use of FTL with embedded controller would be inevitable.

- The complexity/cost of host-side SW (like JFFS2/MTD) will increase due to the use of multiple flash in parallel and the use of high degree ECC algorithm. There are other things like bad block handling and wear-leveling issues which has been recently touched by UBI with added SW complexity.

You don't get rid of that complexity by offloading it to a µcontroller.

The only thing you achieve that way is making sure it's quite likely to be done badly, and making it impossible to debug.

Quoted 4 lines

- In contrast to the embedded environment where CPU and flash is directly connected, the I/O path between CPU and flash in PC environment is longer. The latency for SW handshaking between CPU and flash will also be longer, which would make the performance optimization harder.

Do it the naïve way with a single byte push/pull and waggling the control lines separately, and what you say is true -- but you can have flash controllers which assist with data transfer but still give you essentially 'raw' access to the chip.

With the CAFÉ controller designed for the OLPC machine, we can spew data across the PCI bus just as fast as we can suck it off the flash chip.

Quoted 4 lines

As I mentioned, some techniques like log-structured filesystem could perform generally better on any kind of flash-based storage with FTL. Although there are many kinds of FTL, it is commonly true that it performs well under workload where sequential write is dominant.

Yes, it's certainly possible that we _could_ write a file system which is specifically targeted at FTL -- I was just wondering why anyone would _bother_ :)

I've seen an interesting file system which does have a kind of FTL internally as its lowest layer, and which build on that using 'virtual' sectors for file extents. Now that _does_ have its advantages -- but it doesn't go as far as pretending to be a 'normal' block device; it's its own special thing for internal use within that file system.

Quoted 2 lines

I also expect that FTL for PC environment will have better quality spec than the disposable storage.

There really is no reason why FTL has to be done badly; just as there's no _reason_ why hardware vendors have to give us crappy bsVendorCode. Nevertheless, that's the way the world tends to be. So good luck shipping with that :)

Signature · 1 line
dwmw2
#30 lore raw
In reply to Kevin Bowling
Quoted 15 lines
Quoted 15 lines
Quoted 2 lines

My experience is that no matter which name I pick,

people will

Quoted 11 lines

complain
anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Quoted 5 lines
Quoted 1 line

Can we call it jörnfs? :)

However if Jörn is accused of murder, it will have little chance of
being merged :-).

Nah, it would lead to Jorn disappearing misteriously and _Pavel_ accused of murder ;-).

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#31 lore raw
Quoted 2 lines · Pavel Machek

Nah, it would lead to Jorn disappearing misteriously and _Pavel_ accused of murder ;-).

Are you suggesting that you would murder Jörn (you misspelled his name) merely for the heinous crime of using his own name?

Your Luddism was already quite excessive, but now you really _are_ taking it to extremes. :)

Signature · 1 line
dwmw2
#39 lore raw
In reply to Jörn Engel
Quoted 6 lines · Jörn Engel
Quoted 5 lines

I've been semi watching this, and the only comment I really can give is that I hate the name.  To me, logfs implies a filesystem for logging purposes, not for Flash hardware with wear leveling issues to be taken into account.

Quoted 7 lines

Yeah, well, ...

Two years ago when I started all this, I was looking for a good name. All I could come up with sounded stupid, so I picked "LogFS" as a code name.  As soon as I find a better name, the code name should get replaced.

When doing a google search on logfs, there are less than five results among the first 100 that don't refer to your work. The other two listed in there are also log-structured file systems: The inferno flash file system (http://inferno-os.googlecode.com/svn/trunk/liblogfs/) and the (discontinued) file system named lfs from the 2005 google summer of code.

I'd say the name should stay, changing it now can only add more confusion.

	Arnd <><

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#57 lore raw
In reply to David Woodhouse
Quoted 9 lines · David Woodhouse
Quoted 5 lines

As I mentioned, some techniques like log-structured filesystem could perform generally better on any kind of flash-based storage with FTL. Although there are many kinds of FTL, it is commonly true that it performs well under workload where sequential write is dominant.

Yes, it's certainly possible that we _could_ write a file system which is specifically targeted at FTL -- I was just wondering why anyone would _bother_ :)

Haven't you done that already? JFFS2 write behaviour is the best-case scenario for any FTL. When the delta cache is finished, LogFS will be pretty close to that as well.

Not sure if anyone would specifically target FTL. Being well-suited for those beasts is just a side-effect.

The FTL is still a net loss. Without that FAT enabling layer a real flash filesystem would be more efficient.

Jörn

Signature · 6 lines
Prosperity makes friends, adversity tries them.
-- Publilius Syrus
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#83 lore raw
In reply to Jörn Engel
Quoted 1 line · Jörn Engel

Add LogFS, a scalable flash filesystem.

Hi Jörn,

Sorry for not commenting earlier, there were so many discussions on version two that I wanted to wait for the fallout of that instead of duplicating all the comments.

Here are a few things I notice while going through the third version:

fs/logfs/logfs.h line 41

Quoted 12 lines
fs/logfs/logfs.h new file +12 -0
+/*
+ * Private errno for accessed beyond end-of-file.  Only used internally to
+ * logfs.  If this ever gets exposed to userspace or even other parts of the
+ * kernel, it is a bug.  256 was chosen as a number sufficiently above all
+ * used errno #defines.
+ *
+ * It can be argued that this is a hack and should be replaced with something
+ * else.  My last attempt to do this failed spectacularly and there are more
+ * urgent problems that users actually care about.  This will remain for the
+ * moment.  Patches are wellcome, of course.
+ */
+#define EOF	256

It should at least be in the kernel-only errno range between 512 and 4095, that way it can eventually be added to include/linux/errno.h.

Quoted 10 lines

+ * Target rename works in three atomic steps:
+ * 1. Attach old inode to new dentry (remember old dentry and new inode)
+ * 2. Remove old dentry (still remember the new inode)
+ * 3. Remove new inode
+ *
+ * Here we remember both an inode an a dentry. If we get interrupted
+ * between steps 1 and 2, we delete both the dentry and the inode. If
+ * we get interrupted between steps 2 and 3, we delete just the inode.
+ * In either case, the remaining objects are deleted on next mount. From
+ * a users point of view, the operation succeeded.

This description had me confused for a while: why would you remove the new inode. Maybe change the text to say 'target inode' or 'victim inode'?

fs/logfs/dir.c line 377

Quoted 6 lines
fs/logfs/dir.c new file +6 -0
+static int logfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+	struct inode *inode;
+
+	if (dir->i_nlink >= LOGFS_LINK_MAX)
+		return -EMLINK;

Why is i_nlink limited? Don't you run out of space for inodes before overflowing?

Quoted 9 lines

+ * In principle, this function should loop forever, looking for GC candidates
+ * and moving data. LogFS is designed in such a way that this loop is
+ * guaranteed to terminate.
+ *
+ * Limiting the loop to four iterations serves purely to catch cases when
+ * these guarantees have failed. An actual endless loop is an obvious bug
+ * and should be reported as such.
+ *
+ * But there is another nasty twist to this. As I have described in my LCA

Quoted 8 lines

+ * presentation, Garbage collection would have to limit itself to higher
+ * levels if the number of available free segments goes down. This code
+ * doesn't and should fail spectacularly. Yet - hard as I tried I haven't
+ * been able to make it fail (short of a bug elsewhere).
+ *
+ * So in a way this code is intentionally wrong as a desperate cry for a
+ * better testcase. And I do expect to get blamed for it one day. :(
+ */

Could you bug the code to reserve fewer segments for GC than you really need, in order to stress test GC?

Quoted 11 lines
fs/logfs/inode.c new file +11 -0
+static struct inode *logfs_alloc_inode(struct super_block *sb)
+{
+	struct logfs_inode *li;
+
+	li = kmem_cache_alloc(logfs_inode_cache, GFP_KERNEL);
+	if (!li)
+		return NULL;
+	logfs_init_inode(&li->vfs_inode);
+	return &li->vfs_inode;
+}
+

fs/logfs/inode.c line 140

Quoted 10 lines
fs/logfs/inode.c new file +10 -0
+
+struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino)
+{
+	struct inode *inode;
+
+	inode = logfs_alloc_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	logfs_init_inode(inode);

logfs_alloc_inode() returns an initialized inode, so no need to call logfs_init_inode() again, right?

fs/logfs/inode.c line 190

Quoted 7 lines
fs/logfs/inode.c new file +7 -0
+static __be64 timespec_to_be64(struct timespec tsp)
+{
+	u64 time = ((u64)tsp.tv_sec << 32) + (tsp.tv_nsec & 0xffffffff);
+
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return cpu_to_be64(time);
+}

Why not just store 64 bit nanoseconds? that would avoid the problem with ns overflow and the year-2038 bug. OTOH, that would require a 64 bit integer division when reading the data, so it gets you a runtime overhead.

fs/logfs/inode.c line 327

Quoted 11 lines
fs/logfs/inode.c new file +11 -0
+static void logfs_read_inode(struct inode *inode)
+{
+	int ret;
+
+	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);
+
+	ret = __logfs_read_inode(inode);
+
+	/* What else can we do here? */
+	BUG_ON(ret);
+}

ext2 returns make_bad_inode(inode) in this case, which seems to be a better solution than crashing.

Quoted 11 lines
fs/logfs/inode.c new file +11 -0
+int __logfs_write_inode(struct inode *inode)
+{
+	/*
+	 * FIXME: Those two inodes are 512 bytes in total.  Not good to
+	 * have on the stack.  Possibly the best solution would be to bite
+	 * the bullet and do another format change before release and
+	 * shrink the inodes.
+	 */
+	struct logfs_disk_inode old, new;
+
+	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);

fs/logfs/inode.c line 360

Quoted 10 lines
fs/logfs/inode.c new file +10 -0
+
+	/* read and compare the inode first.  If it hasn't changed, don't
+	 * bother writing it. */
+	logfs_inode_to_disk(inode, &new);
+	if (logfs_read_disk_inode(&old, inode))
+		return logfs_write_disk_inode(&new, inode);
+	if (memcmp(&old, &new, sizeof(old)))
+		return logfs_write_disk_inode(&new, inode);
+	return 0;
+}

Instead of the memcmp, you could do a new logfs_cmp_disk_inode function, so this code turns into

{
	struct logfs_inode_to_disk dinode;
	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);

	/* nothing to do if identical */
	if (!logfs_read_disk_inode(&dinode, inode) &&
            !logfs_cmp_disk_inode(&dinode, inode)
		return 0;

	/* write changed data */
	logfs_inode_to_disk(inode, &dinode);
	return logfs_write_disk_inode(&dinode, inode);
}

This at least gets the wasted stack size down to a single inode structure.

fs/logfs/journal.c line 283

Quoted 2 lines
fs/logfs/journal.c new file +2 -0
+static void *unpack(void *from, void *to)
+{

Almost all your static functions start with logfs_, why not this one?

Quoted 5 lines

+ * Second trick is to special-case the key "0" or NUL. As seen above, this
+ * value indicates an unused slot, so such a value should not be stored in the
+ * tree itself. Instead it is stored in the null_ptr field in the btree_head.
+ */
+#include "logfs.h"

Maybe split out the btree bits to a different header, that would make it really self-contained.

Quoted 1 line

+#define BTREE_NODES 16 /* 32bit, 128 byte cacheline */

And this should probably go to the header as well if you want it to end up in include/linux/btree.h

Quoted 1 line

+/* TODO: might make sense to turn inode into embedded again */

I'd guess that the only interesting case is truncate to zero length. If that is the same as truncate to embedded, it's probably good to implement that.

Quoted 9 lines
fs/logfs/super.c new file +9 -0
+
+
+int mtdread(struct super_block *sb, loff_t ofs, size_t len, void *buf)
+{
+	struct mtd_info *mtd = LOGFS_SUPER(sb)->s_mtd;
+	size_t retlen;
+	int ret;
+
+	ret = mtd->read(mtd, ofs, len, &retlen, buf);

fs/logfs/super.c line 31

Quoted 10 lines
fs/logfs/super.c new file +10 -0
+	BUG_ON(ret == -EINVAL);
+	if (ret)
+		return ret;
+
+	/* Not sure if we should loop instead. */
+	if (retlen != len)
+		return -EIO;
+
+	return 0;
+}

mtdread is not a good name for a global function specific to one file system, it should really be logfs_mtdread(). I'm also not sure if super.c is the right file for the mtd access functions.

Quoted 5 lines
fs/logfs/super.c new file +5 -0
+/*
+ * For as long as I can remember (since about 2001) mtd->erase has been an
+ * asynchronous interface lacking the first driver to actually use the
+ * asynchronous properties.  So just to prevent the first implementor of such
+ * a thing from breaking logfs in 2350, we do the usual pointless dance to

fs/logfs/super.c line 71

Quoted 10 lines
fs/logfs/super.c new file +10 -0
+ * declare a completion variable and wait for completion before returning
+ * from mtderase().  What an excercise in futility!
+ */
+static DECLARE_COMPLETION(logfs_erase_complete);
+
+
+static void logfs_erase_callback(struct erase_info *ei)
+{
+	complete(&logfs_erase_complete);
+}

Is this safe if you have multiple file systems mounted on different mtd devices, and both call the callback at the same time?

fs/logfs/super.c line 152

Quoted 12 lines
fs/logfs/super.c new file +12 -0
+
+
+int all_ff(void *buf, size_t len)
+{
+	unsigned char *c = buf;
+	int i;
+
+	for (i=0; i<len; i++)
+		if (c[i] != 0xff)
+			return 0;
+	return 1;
+}

Again not a good name for a global symbol

Quoted 9 lines
fs/logfs/progs/mkfs.c new file +9 -0
+static u64 segment_offset[OFS_COUNT];
+
+static u64 fssize;
+static u64 no_segs;
+static u64 free_blocks;
+
+static u32 segsize;
+static u32 blocksize;
+static int segshift;

fs/logfs/progs/mkfs.c line 38

Quoted 10 lines
fs/logfs/progs/mkfs.c new file +10 -0
+static int blockshift;
+static int writeshift;
+
+static u32 blocks_per_seg;
+static u16 version;
+
+static __be32 bb_array[1024];
+static int bb_count;
+
+

How do you serialize access to these variables?

Quoted 19 lines
include/linux/logfs.h new file +19 -0
+/*
+ * Number of blocks at various levels of indirection.  Each inode originally
+ * had 9 block pointers.  Later the inode size was doubled and there are now
+ * 9+16 pointers - the notation is just historical.
+ *
+ * I0_BLOCKS is the number of direct block pointer in each inode.  The
+ * remaining five pointers are for indirect pointers, up to 5x indirect.
+ * Only 3x is tested and supported at the moment.  5x would allow for truly
+ * humongous files if the need ever arises.
+ * I1_BLOCKS is the number of blocks behind a 1x indirect block,
+ * I2_BLOCKS is the number of blocks behind a 2x indirect block, not counting
+ * the 1x indirect blocks.  etc.
+ */
+#define I0_BLOCKS		(4+16)
+#define I1_BLOCKS		LOGFS_BLOCK_FACTOR
+#define I2_BLOCKS		(LOGFS_BLOCK_FACTOR * I1_BLOCKS)
+#define I3_BLOCKS		(LOGFS_BLOCK_FACTOR * I2_BLOCKS)
+#define I4_BLOCKS		(LOGFS_BLOCK_FACTOR * I3_BLOCKS)
+#define I5_BLOCKS		(LOGFS_BLOCK_FACTOR * I4_BLOCKS)

include/linux/logfs.h line 106

Quoted 10 lines
include/linux/logfs.h new file +10 -0
+
+/* The indices in the block array where the Nx indirect block pointers reside */
+#define I1_INDEX		(4+16)
+#define I2_INDEX		(5+16)
+#define I3_INDEX		(6+16)
+#define I4_INDEX		(7+16)
+#define I5_INDEX		(8+16)
+
+/* The total number of block pointers in each inode */
+#define LOGFS_EMBEDDED_FIELDS	(9+16)

Now that the inodes are compressed, is there still a benefit of having the uncompressed size be a power of two? I don't remember the exact tradeoffs that we discussed for this, but IIRC the biggest problem with making them larger is filling up the journal, and there is no benefit in larger inodes unless you get to the point where embedded files are a win (at 4KiB uncompressed inodes), while with really small inodes you don't have enough space for direct block pointers.

Still, something tells me that it should either go down to something like LOGFS_EMBEDDED_FIELDS == 16, or up to make sizeof (logfs_disk_inode) == block_size, in which case embedded files should be loaded into the page cache instead of the logfs_inode.

include/linux/logfs.h line 166

Quoted 5 lines
include/linux/logfs.h new file +5 -0
+/* FIXME: why do these not work? */
+#if 0
+BUILD_BUG_ON(sizeof(struct logfs_object_header) != LOGFS_HEADERSIZE);
+BUILD_BUG_ON(sizeof(struct logfs_segment_header) != LOGFS_HEADERSIZE);
+#endif

Because BUILD_BUG_ON only works inside of a function. You could put them into a dummy inline function.

	Arnd <><

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

In reply to Jörn Engel

Hi Jörn.

Is logfs 32bit fs or 674bit, since although you use 64bit values for offsets, area management and strange converstions like described below from offset into segment number are performed in 32bit?
Is it enough for SSD for example to be 32bit only? Or if it is 64bit, could you please explain logic behind area management?

I've found that you store segment numbers as 32bit values (for example in prepare_write()), and convert requested 64bit offset into segment number via superblock's s_segshift.
This conversation seems confusing to me in case of real 64bit offsets. For example this one obtained via prepare_write:

7  1 logfs_prepare_write    78  fs/logfs/file.c
8  2 logfs_readpage_nolock    20  fs/logfs/file.c
9  1 logfs_read_block   351  fs/logfs/readwrite.c
10  1 logfs_read_loop   139  fs/logfs/readwrite.c
11  2 logfs_segment_read   108  fs/logfs/readwrite.c
12  1 wbuf_read         289 

u32 segno = ofs >> super->s_segshift;

ofs is originally obtained from inode's li_data array, which is filled with raw segment numbers which can be 64bit (here is another issue, since logfs_segment_write() returns signed, so essentially logfs is 63bit filesystem).

But here I've came to area management in logfs, and found that it is 32bit only, for example __logfs_segment_write()/__logfs_get_free_bytes() returns signed 32 bit value (so it is reduced to 31 bit), which is then placed into li_data as 64bit value. The latter (__logfs_get_free_bytes()) truncates 64bit data value obtained via dev_ofs() into signed 32 bit value.

Signature · 5 lines
	Evgeniy Polyakov

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#3 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

Quoted 6 lines · Evgeniy Polyakov

Is logfs 32bit fs or 674bit, since although you use 64bit values for offsets, area management and strange converstions like described below from offset into segment number are performed in 32bit?
Is it enough for SSD for example to be 32bit only? Or if it is 64bit, could you please explain logic behind area management?

Ignoring bugs and signed return values for error handling, it is either 64bit or 32+32bit.

Inode numbers and file positions are 64bit. Offsets are 64bit as well. In a couple of places, offsets are also 32+32bit. Basically the high bits contain the segment number, the lower bits the offset within a segment.

Side note: It would be nicer if the high 32bit were segment number. Instead the number of bits depends on segment size. Guess I should change that while the format isn't fixed yet.

An "area" is a segment that is currently being written. Data is appended to this segment as it comes in, until the segment is full. Any functions dealing with areas only need a 32bit offset, which is the offset within the area, not the absolute device offset.

Writes within an area are also buffered. New data first goes into the write buffer (wbuf) and only when this is full is it flushed to the device. NAND flash and some NOR flashes require such buffering. When writing to the device, the 32bit segno and the 32bit in-segment offset need to get converted back to a 64bit device offset.

Quoted 3 lines

I've found that you store segment numbers as 32bit values (for example in prepare_write()), and convert requested 64bit offset into segment number via superblock's s_segshift.

Yes, as described above.

Quoted 10 lines

This conversation seems confusing to me in case of real 64bit offsets. For example this one obtained via prepare_write:

7  1 logfs_prepare_write    78  fs/logfs/file.c
8  2 logfs_readpage_nolock    20  fs/logfs/file.c
9  1 logfs_read_block   351  fs/logfs/readwrite.c
10  1 logfs_read_loop   139  fs/logfs/readwrite.c
11  2 logfs_segment_read   108  fs/logfs/readwrite.c
12  1 wbuf_read         289 
Quoted 6 lines

u32 segno = ofs >> super->s_segshift;

ofs is originally obtained from inode's li_data array, which is filled with raw segment numbers which can be 64bit (here is another issue, since logfs_segment_write() returns signed, so essentially logfs is 63bit filesystem).

The filesystem format is 64bit. The current code can only deal with 63bit. Eric Sandeen just fixed ext2 to actually deal with 32bit numbers and the same is possible for logfs. If anyone ever cares...

Quoted 6 lines

But here I've came to area management in logfs, and found that it is 32bit only, for example __logfs_segment_write()/__logfs_get_free_bytes() returns signed 32 bit value (so it is reduced to 31 bit), which is then placed into li_data as 64bit value. The latter (__logfs_get_free_bytes()) truncates 64bit data value obtained via dev_ofs() into signed 32 bit value.

That indeed is a bug. __logfs_get_free_bytes() should return s64 instead of s32. Will fix immediatly.

If anyone can find similar bugs, the bounty is a beer or non-alcoholic beverage of choice. :)

Jörn

Signature · 8 lines
To announce that there must be no criticism of the President, or that we
are to stand by the President, right or wrong, is not only unpatriotic
and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt, Kansas City Star, 1918
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#34 lore raw
In reply to Jörn Engel
Quoted 3 lines · Jörn Engel

My experience is that no matter which name I pick, people will complain anyway. Previous suggestions included:

[...]

Quoted 10 lines

Plus today:
FFFS
flashfs
fredfs
bob
shizzle

Imo they all suck. LogFS also sucks, but it allows me to make a stupid joke and keep my logfs.org domain.

Try woodfs! (log - wood - get it?)
But finding names can be so tiresome, just give it a Borg-style designation - "filesystem 125" or so. fs2007q1, being this quartal's new filesystem.

Jan

Signature · 3 lines
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#38 lore raw
In reply to Jörn Engel
Quoted 7 lines · Jörn Engel
Quoted 3 lines · David Woodhouse

Personally I'd just go for 'JFFS3'. After all, it has a better claim to the name than either of its predecessors :)

Did you ever see akpm's facial expression when he tried to pronounce "JFFS2"? ;)

Is there something special with [dʒeɪ ɛf ɛf ɛs tuː]?

Jan

Signature · 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw
In reply to Jörn Engel
Quoted 10 lines · Jörn Engel
Quoted 9 lines · Evgeniy Polyakov
Quoted 6 lines · Jörn Engel
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Do you think 'eieio' is a good set? IBM's work too...

C'mon, UIO does not cut IIO either ;-)

Jan

Signature · 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#21 lore raw
In reply to CaT
Quoted 11 lines · CaT
Quoted 10 lines · J??rn Engel
Quoted 3 lines · Jamie Lokier

But if akpm can't pronounce it, how about FFFS for faster flash filesystem.... ;-)

How many of you have worked for IBM before? Vowels are not evil. ;)

Grouping four or more consonants to name anything will cause similar expressions on people's faces. Numbers don't help much either.

Quoted 6 lines
Quoted 4 lines

Ext2 is a great name, because "ext" actually is a pronouncable syllable. MinixFS, ChunkFS, TileFS are great too. XFS and JFS are ok, at least they only have three consonants. But FFS exists, so I'd rather go for a syllable.

FlashFS?

Or just try once dropping all those redundant 'fs' suffixes. bdev, proc, cpuset, devpts, mqueue, fuse(blk|ctl), vfat, iso9660, etc. Then there's much more space for innovative names.

Jan

#45 lore raw
In reply to Jörn Engel
Quoted 9 lines · Jörn Engel
Quoted 8 lines

fs/logfs/logfs.h line 258

Quoted 6 lines
fs/logfs/logfs.h new file +5 -0
+/* memtree.c */
+void btree_init(struct btree_head *head);
+void *btree_lookup(struct btree_head *head, long val);
+int btree_insert(struct btree_head *head, long val, void *ptr);
+int btree_remove(struct btree_head *head, long val);

These names are too generic. If we later add a btree library: blam.

Quoted 6 lines

My plan was to move this code to lib/ sooner or later. If you consider it useful in its current state, I can do it immediatly. And if someone else merged a superior btree library I'd happily remove mine and use the new one instead.

Opinions?

Why would we need another btree, when there is lib/rbtree.c? Or does yours do something fundamentally different?

Jan

Signature · 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#46 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines

My plan was to move this code to lib/ sooner or later. If you consider it useful in its current state, I can do it immediatly. And if someone else merged a superior btree library I'd happily remove mine and use the new one instead.

Opinions?

Why would we need another btree, when there is lib/rbtree.c? Or does yours do something fundamentally different?

It is not red-black tree, it is b+ tree.

Quoted 1 line

Jan

Signature · 1 line
	Evgeniy Polyakov
#84 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann
Quoted 1 line · Jörn Engel

Add LogFS, a scalable flash filesystem.

Sorry for not commenting earlier, there were so many discussions on version two that I wanted to wait for the fallout of that instead of duplicating all the comments.

You are the last person that has to be sorry. ;)

Quoted 17 lines

Here are a few things I notice while going through the third version:

fs/logfs/logfs.h line 41

Quoted 12 lines
fs/logfs/logfs.h new file +12 -0
+/*
+ * Private errno for accessed beyond end-of-file.  Only used internally to
+ * logfs.  If this ever gets exposed to userspace or even other parts of the
+ * kernel, it is a bug.  256 was chosen as a number sufficiently above all
+ * used errno #defines.
+ *
+ * It can be argued that this is a hack and should be replaced with something
+ * else.  My last attempt to do this failed spectacularly and there are more
+ * urgent problems that users actually care about.  This will remain for the
+ * moment.  Patches are wellcome, of course.
+ */
+#define EOF	256

It should at least be in the kernel-only errno range between 512 and 4095, that way it can eventually be added to include/linux/errno.h.

Fair enough. 512 it is.

Quoted 11 lines
Quoted 10 lines

+ * Target rename works in three atomic steps:
+ * 1. Attach old inode to new dentry (remember old dentry and new inode)
+ * 2. Remove old dentry (still remember the new inode)
+ * 3. Remove new inode
+ *
+ * Here we remember both an inode an a dentry. If we get interrupted
+ * between steps 1 and 2, we delete both the dentry and the inode. If
+ * we get interrupted between steps 2 and 3, we delete just the inode.
+ * In either case, the remaining objects are deleted on next mount. From
+ * a users point of view, the operation succeeded.

Quoted 2 lines

This description had me confused for a while: why would you remove the new inode. Maybe change the text to say 'target inode' or 'victim inode'?

'Victim inode' sounds good. Will do.

Quoted 9 lines

fs/logfs/dir.c line 377

Quoted 6 lines
fs/logfs/dir.c new file +6 -0
+static int logfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+	struct inode *inode;
+
+	if (dir->i_nlink >= LOGFS_LINK_MAX)
+		return -EMLINK;

Why is i_nlink limited? Don't you run out of space for inodes before overflowing?

I don't know. With the current limit of 2^31, a sufficiently large device can reach the limit. And it is imaginable that overflowing the s32 number space can expose security holes. Not that I actually know, the check is pure paranoia.

Quoted 18 lines
Quoted 9 lines

+ * In principle, this function should loop forever, looking for GC candidates
+ * and moving data. LogFS is designed in such a way that this loop is
+ * guaranteed to terminate.
+ *
+ * Limiting the loop to four iterations serves purely to catch cases when
+ * these guarantees have failed. An actual endless loop is an obvious bug
+ * and should be reported as such.
+ *
+ * But there is another nasty twist to this. As I have described in my LCA

Quoted 8 lines

+ * presentation, Garbage collection would have to limit itself to higher
+ * levels if the number of available free segments goes down. This code
+ * doesn't and should fail spectacularly. Yet - hard as I tried I haven't
+ * been able to make it fail (short of a bug elsewhere).
+ *
+ * So in a way this code is intentionally wrong as a desperate cry for a
+ * better testcase. And I do expect to get blamed for it one day. :(
+ */

Quoted 2 lines

Could you bug the code to reserve fewer segments for GC than you really need, in order to stress test GC?

I could. Wear leveling will cause changes in the area, so I'll have a closer look when implementing that.

Quoted 16 lines
Quoted 16 lines
fs/logfs/inode.c new file +16 -0
+static struct inode *logfs_alloc_inode(struct super_block *sb)
+{
+	struct logfs_inode *li;
+
+	li = kmem_cache_alloc(logfs_inode_cache, GFP_KERNEL);
+	if (!li)
+		return NULL;
+	logfs_init_inode(&li->vfs_inode);
+	return &li->vfs_inode;
+}
+
+
+struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino)
+{
+	struct inode *inode;
+
Quoted 8 lines

fs/logfs/inode.c line 140

Quoted 5 lines
fs/logfs/inode.c new file +5 -0
+	inode = logfs_alloc_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	logfs_init_inode(inode);

logfs_alloc_inode() returns an initialized inode, so no need to call logfs_init_inode() again, right?

Right. Will change.

Quoted 4 lines
Quoted 4 lines
fs/logfs/inode.c new file +4 -0
+static __be64 timespec_to_be64(struct timespec tsp)
+{
+	u64 time = ((u64)tsp.tv_sec << 32) + (tsp.tv_nsec & 0xffffffff);
+
Quoted 8 lines

fs/logfs/inode.c line 190

Quoted 3 lines
fs/logfs/inode.c new file +3 -0
+	WARN_ON(tsp.tv_nsec > 999999999);
+	return cpu_to_be64(time);
+}

Why not just store 64 bit nanoseconds? that would avoid the problem with ns overflow and the year-2038 bug. OTOH, that would require a 64 bit integer division when reading the data, so it gets you a runtime overhead.

I like the idea. Do conversion function exist both way?

What I don't get is the year-2038 bug. Isn't that the 31bit limit, while 32bit would last to 2106?

Quoted 6 lines
Quoted 6 lines
fs/logfs/inode.c new file +6 -0
+static void logfs_read_inode(struct inode *inode)
+{
+	int ret;
+
+	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);
+
Quoted 8 lines

fs/logfs/inode.c line 327

Quoted 5 lines
fs/logfs/inode.c new file +5 -0
+	ret = __logfs_read_inode(inode);
+
+	/* What else can we do here? */
+	BUG_ON(ret);
+}

ext2 returns make_bad_inode(inode) in this case, which seems to be a better solution than crashing.

Excellent! Will do.

Quoted 39 lines
Quoted 11 lines
fs/logfs/inode.c new file +11 -0
+int __logfs_write_inode(struct inode *inode)
+{
+	/*
+	 * FIXME: Those two inodes are 512 bytes in total.  Not good to
+	 * have on the stack.  Possibly the best solution would be to bite
+	 * the bullet and do another format change before release and
+	 * shrink the inodes.
+	 */
+	struct logfs_disk_inode old, new;
+
+	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);

fs/logfs/inode.c line 360

Quoted 10 lines
fs/logfs/inode.c new file +10 -0
+
+	/* read and compare the inode first.  If it hasn't changed, don't
+	 * bother writing it. */
+	logfs_inode_to_disk(inode, &new);
+	if (logfs_read_disk_inode(&old, inode))
+		return logfs_write_disk_inode(&new, inode);
+	if (memcmp(&old, &new, sizeof(old)))
+		return logfs_write_disk_inode(&new, inode);
+	return 0;
+}

Instead of the memcmp, you could do a new logfs_cmp_disk_inode function, so this code turns into

{
	struct logfs_inode_to_disk dinode;
	BUG_ON(inode->i_ino == LOGFS_INO_MASTER);

	/* nothing to do if identical */
	if (!logfs_read_disk_inode(&dinode, inode) &&
            !logfs_cmp_disk_inode(&dinode, inode)
		return 0;

	/* write changed data */
	logfs_inode_to_disk(inode, &dinode);
	return logfs_write_disk_inode(&dinode, inode);
}
Quoted 1 line

This at least gets the wasted stack size down to a single inode structure.

Sounds good. Will do.

Quoted 4 lines

fs/logfs/journal.c line 283

Quoted 2 lines
fs/logfs/journal.c new file +2 -0
+static void *unpack(void *from, void *to)
+{

Almost all your static functions start with logfs_, why not this one?

Because after a while I discovered how silly it is to start every function with logfs_. That prefix doesn't add much unless the function has global scope. What I didn't do was remove the prefix from older functions.

Quoted 6 lines
Quoted 5 lines

+ * Second trick is to special-case the key "0" or NUL. As seen above, this
+ * value indicates an unused slot, so such a value should not be stored in the
+ * tree itself. Instead it is stored in the null_ptr field in the btree_head.
+ */
+#include "logfs.h"

Quoted 7 lines

Maybe split out the btree bits to a different header, that would make it really self-contained.

Quoted 1 line

+#define BTREE_NODES 16 /* 32bit, 128 byte cacheline */

And this should probably go to the header as well if you want it to end up in include/linux/btree.h

Looks like Peter Zijlstra is already working on a btree library. His code is more complete and likely faster than mine:
http://programming.kicks-ass.net/kernel-patches/concurrent-pagecache/21-rc6/cpc-test.patch

My secret hope is that his code is merged soon and I can just remove mine.

Quoted 5 lines
Quoted 1 line

+/* TODO: might make sense to turn inode into embedded again */

I'd guess that the only interesting case is truncate to zero length. If that is the same as truncate to embedded, it's probably good to implement that.

Truncate to zero sounds like the 99.99% solution. I like it.

Quoted 15 lines
Quoted 15 lines
fs/logfs/super.c new file +15 -0
+
+
+int mtdread(struct super_block *sb, loff_t ofs, size_t len, void *buf)
+{
+	struct mtd_info *mtd = LOGFS_SUPER(sb)->s_mtd;
+	size_t retlen;
+	int ret;
+
+	ret = mtd->read(mtd, ofs, len, &retlen, buf);
+	BUG_ON(ret == -EINVAL);
+	if (ret)
+		return ret;
+
+	/* Not sure if we should loop instead. */
+	if (retlen != len)
Quoted 8 lines

fs/logfs/inode.c line 278

Quoted 4 lines
fs/logfs/inode.c new file +4 -0
+		return -EIO;
+
+	return 0;
+}

mtdread is not a good name for a global function specific to one file system, it should really be logfs_mtdread(). I'm also not sure if super.c is the right file for the mtd access functions.

super.c is a dump space for functions that don't have a good place otherwise. Maybe the accessor functions should go into mtd.c.

What would make more sense than renaming them is to hide them in a struct logfs_device_ops and only have static functions. Then another set can be named bdread(), bdwrite(), etc. and live in bd.c.

Quoted 10 lines
Quoted 10 lines
fs/logfs/super.c new file +10 -0
+/*
+ * For as long as I can remember (since about 2001) mtd->erase has been an
+ * asynchronous interface lacking the first driver to actually use the
+ * asynchronous properties.  So just to prevent the first implementor of such
+ * a thing from breaking logfs in 2350, we do the usual pointless dance to
+ * declare a completion variable and wait for completion before returning
+ * from mtderase().  What an excercise in futility!
+ */
+static DECLARE_COMPLETION(logfs_erase_complete);
+
Quoted 8 lines

fs/logfs/super.c line 71

Quoted 5 lines
fs/logfs/super.c new file +5 -0
+
+static void logfs_erase_callback(struct erase_info *ei)
+{
+	complete(&logfs_erase_complete);
+}

Is this safe if you have multiple file systems mounted on different mtd devices, and both call the callback at the same time?

I doubt it. Guess I'll just remove the completion thing and wait for LogFS to be broken in 2350 instead.

Quoted 6 lines
Quoted 6 lines
fs/logfs/super.c new file +6 -0
+
+
+int all_ff(void *buf, size_t len)
+{
+	unsigned char *c = buf;
+	int i;
Quoted 8 lines

fs/logfs/super.c line 152

Quoted 6 lines
fs/logfs/super.c new file +6 -0
+
+	for (i=0; i<len; i++)
+		if (c[i] != 0xff)
+			return 0;
+	return 1;
+}

Again not a good name for a global symbol

What would a better name be? I had expected to find a similar function somewhere in lib/string.c, right between memcmp() and memscan(). JFFS2 has some similar home-brewn code. Maybe others as well. Maybe a function like this should go in lib/string.c?

/**
* memchr_inv - Find a character in an area of memory.
* @s: The memory area
* @c: The byte to search for
* @n: The size of the area.
*
* returns the address of the first character other than @c, or %NULL
* if the whole buffer contains just @c.
*/
int memchr_inv(const void *s, int c, size_t n)

{
	const unsigned char *p = s;
	while (n-- != 0) {
		if ((unsigned char)c != *p++) {
			return (void *)(p - 1);
		}
	}
	return NULL;
}
Quoted 13 lines
Quoted 13 lines
fs/logfs/progs/mkfs.c new file +13 -0
+static u64 segment_offset[OFS_COUNT];
+
+static u64 fssize;
+static u64 no_segs;
+static u64 free_blocks;
+
+static u32 segsize;
+static u32 blocksize;
+static int segshift;
+static int blockshift;
+static int writeshift;
+
+static u32 blocks_per_seg;
Quoted 8 lines

fs/logfs/progs/mkfs.c line 38

Quoted 6 lines
fs/logfs/progs/mkfs.c new file +6 -0
+static u16 version;
+
+static __be32 bb_array[1024];
+static int bb_count;
+
+

How do you serialize access to these variables?

I don't. Note to self: move this to userspace to avoid any further embarrassment.

Quoted 39 lines
Quoted 19 lines
include/linux/logfs.h new file +19 -0
+/*
+ * Number of blocks at various levels of indirection.  Each inode originally
+ * had 9 block pointers.  Later the inode size was doubled and there are now
+ * 9+16 pointers - the notation is just historical.
+ *
+ * I0_BLOCKS is the number of direct block pointer in each inode.  The
+ * remaining five pointers are for indirect pointers, up to 5x indirect.
+ * Only 3x is tested and supported at the moment.  5x would allow for truly
+ * humongous files if the need ever arises.
+ * I1_BLOCKS is the number of blocks behind a 1x indirect block,
+ * I2_BLOCKS is the number of blocks behind a 2x indirect block, not counting
+ * the 1x indirect blocks.  etc.
+ */
+#define I0_BLOCKS		(4+16)
+#define I1_BLOCKS		LOGFS_BLOCK_FACTOR
+#define I2_BLOCKS		(LOGFS_BLOCK_FACTOR * I1_BLOCKS)
+#define I3_BLOCKS		(LOGFS_BLOCK_FACTOR * I2_BLOCKS)
+#define I4_BLOCKS		(LOGFS_BLOCK_FACTOR * I3_BLOCKS)
+#define I5_BLOCKS		(LOGFS_BLOCK_FACTOR * I4_BLOCKS)

include/linux/logfs.h line 106

Quoted 10 lines
include/linux/logfs.h new file +10 -0
+
+/* The indices in the block array where the Nx indirect block pointers reside */
+#define I1_INDEX		(4+16)
+#define I2_INDEX		(5+16)
+#define I3_INDEX		(6+16)
+#define I4_INDEX		(7+16)
+#define I5_INDEX		(8+16)
+
+/* The total number of block pointers in each inode */
+#define LOGFS_EMBEDDED_FIELDS	(9+16)

Now that the inodes are compressed, is there still a benefit of having the uncompressed size be a power of two? I don't remember the exact tradeoffs that we discussed for this, but IIRC the biggest problem with making them larger is filling up the journal, and there is no benefit in larger inodes unless you get to the point where embedded files are a win (at 4KiB uncompressed inodes), while with really small inodes you don't have enough space for direct block pointers.

Quoted 4 lines

Still, something tells me that it should either go down to something like LOGFS_EMBEDDED_FIELDS == 16, or up to make sizeof (logfs_disk_inode) == block_size, in which case embedded files should be loaded into the page cache instead of the logfs_inode.

It should go down to LOGFS_EMBEDDED_FIELDS == 17, I believe. 16 direct pointers are nice, as there are also 16 special inodes. And a single indirect pointer is sufficient if the inode also has a height field. If an access beyond 64KiB has to go through double indirection instead of single indirection, that will hardly show up in benchmarks let alone real life.

Part of me would like to make such a change now before the format is fixed. Another part wants to finally release LogFS and rather keep the inodes as-is than have people suffer JFFS2 limitations much longer.

The change will happen either way. Whether it should follow with an INCOMPAT feature flag or be done now is the only question.

Quoted 8 lines

include/linux/logfs.h line 166

Quoted 5 lines
include/linux/logfs.h new file +5 -0
+/* FIXME: why do these not work? */
+#if 0
+BUILD_BUG_ON(sizeof(struct logfs_object_header) != LOGFS_HEADERSIZE);
+BUILD_BUG_ON(sizeof(struct logfs_segment_header) != LOGFS_HEADERSIZE);
+#endif

Because BUILD_BUG_ON only works inside of a function. You could put them into a dummy inline function.

Ok, will do.

Jörn

Signature · 8 lines
To announce that there must be no criticism of the President, or that we
are to stand by the President, right or wrong, is not only unpatriotic
and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt, Kansas City Star, 1918
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#58 lore raw
In reply to Dongjun Shin

Hi!

Quoted 25 lines
Quoted 10 lines

Yes. These things are almost always implemented _very_ badly by the same
kind of crack-smoking hobo they drag in off the streets to write BIOSen.

It's bog-roll technology; if you fancy a laugh try doing some real
reliability tests on them time some. Powerfail testing is a good one.

Quoted 7 lines

This kind of thing is OK for disposable storage such as in digital
cameras, where it doesn't matter that it's no more reliable than a
floppy disc, but for real long-term storage it's really a bad idea.

There are so many flash-based storage and some disposable storages,
as you pointed out, have poor quality. I think it's mainly because these
are not designed for good quality, but for lowering the price.

Quoted 9 lines

These kind of devices are not ready for things like power failure because
their use case is far from that. For example, removing flash card
while taking pictures using digital camera is not a common use case.
(there should be a written notice that this kind of action is against
the warranty)

Hmm.. so operating your camera on batteries should be against the warranty, since batteries commonly run empty while storing pictures?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#78 lore raw
In reply to Jörn Engel
Quoted 6 lines · Jörn Engel

Compressing random data will actually enlarge it. If that happens I simply store the verbatim uncompressed data instead and mark it as such.

There is also demand for a user-controlled bit in the inode to disable compression completely. All those .jpg, .mpg, .mp3, etc. just waste time by trying and failing to compress them.

So any sane way to enable compression is on per-inode basis which makes me still wonder why you need per-object compression. -
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#85 lore raw
In reply to Jörn Engel
Quoted 10 lines · Jörn Engel
Quoted 5 lines

Why not just store 64 bit nanoseconds? that would avoid the problem with ns overflow and the year-2038 bug. OTOH, that would require a 64 bit integer division when reading the data, so it gets you a runtime overhead.

I like the idea.  Do conversion function exist both way?

What I don't get is the year-2038 bug.  Isn't that the 31bit limit, while 32bit would last to 2106?

You're right, you don't hit the 2038 bug here, because you use an unsigned variable. The bug exists elsewhere because time_t tv_sec is signed.

Just using nanoseconds probably doesn't gain you much after all then. You could however just have separate 32 bit fields in the inode for seconds and nanoseconds, that will result in the exact same layout that you have right now, but won't require a conversion function.

	Arnd <><
#86 lore raw
Quoted 6 lines · Arnd Bergmann

Just using nanoseconds probably doesn't gain you much after all then. You could however just have separate 32 bit fields in the inode for seconds and nanoseconds, that will result in the exact same layout that you have right now, but won't require a conversion function.

I could also have a 30bit and a 34bit field. 30bit is enough for nanoseconds. So many options.

Jörn

Signature · 2 lines
Time? What's that? Time is only worth what you do with it.
-- Theo de Raadt
#79 lore raw
In reply to Pekka Enberg
Quoted 11 lines · Pekka Enberg
Quoted 6 lines · Jörn Engel

Compressing random data will actually enlarge it.  If that happens I simply store the verbatim uncompressed data instead and mark it as such.

There is also demand for a user-controlled bit in the inode to disable compression completely.  All those .jpg, .mpg, .mp3, etc. just waste time by trying and failing to compress them.

So any sane way to enable compression is on per-inode basis which makes me still wonder why you need per-object compression.

1. it doesn't require user interaction, the file system will do the right thing most of the time.

2. enlarging data is a very bad thing because it makes the behaviour of the fs unpredictable. With uncompressed objects, you have a guaranteed upper bound on the size.

	Arnd <><

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#80 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 3 lines · Pekka Enberg

So any sane way to enable compression is on per-inode basis which makes me still wonder why you need per-object compression.

1. it doesn't require user interaction, the file system will do the right thing most of the time.

2. enlarging data is a very bad thing because it makes the behaviour of the fs unpredictable. With uncompressed objects, you have a guaranteed upper bound on the size.

Correct. The compression decision is always per-object. Per-inode is a hint from userspace that a compression attempt would be futile.

A compression algorithm that compresses any data is provably impossible. Some data will always cause expansion instead of compression. Some algorithms have a well-known upper bound on the expansion, others don't. So LogFS instead creates its own upper bound by reserving one byte in the header for the compression type.

And while one bit would suffice as a compressed/uncompressed flag, having a byte allows to support more than one compression algorithm. LZO looks promising and is on its way into the kernel. Others may come in the future.

Jörn

Signature · 8 lines
My second remark is that our intellectual powers are rather geared to
master static relations and that our powers to visualize processes
evolving in time are relatively poorly developed.
-- Edsger W. Dijkstra
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#87 lore raw
In reply to Jörn Engel
Quoted 6 lines · Jörn Engel
Quoted 1 line

Almost all your static functions start with logfs_, why not this one?

Because after a while I discovered how silly it is to start every function with logfs_. That prefix doesn't add much unless the function has global scope. What I didn't do was remove the prefix from older functions.

It's handy when debugging or showing detailed backtraces. Not that I'm advocating it (or not), just something I've noticed in other programs.

-- Jamie

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#59 lore raw
In reply to Pavel Machek

Hi,

Quoted 7 lines · Pavel Machek

Hi!

Hmm.. so operating your camera on batteries should be against the warranty, since batteries commonly run empty while storing pictures?

AFAIK, the camera stops writing to the flash card and automatically turns off when it's low on battery (before empty).

#47 lore raw
In reply to Evgeniy Polyakov
Quoted 8 lines · Evgeniy Polyakov
Quoted 5 lines · Jan Engelhardt
Quoted 3 lines

My plan was to move this code to lib/ sooner or later. If you consider it useful in its current state, I can do it immediatly. And if someone else merged a superior btree library I'd happily remove mine and use the new one instead.

Opinions?

Why would we need another btree, when there is lib/rbtree.c? Or does yours do something fundamentally different?

It is not red-black tree, it is b+ tree.

It might be better to use the prefix "bptree" to help prevent confusion. A quick google search on "bp-tree" reveals only the perl B+-tree module "Tree::BPTree", a U-Maryland Java CS project on B+-trees, and a news article about a "BP tree-top protest".

Cheers,
Kyle Moffett

#48 lore raw
Quoted 11 lines · Kyle Moffett
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Opinions?

Why would we need another btree, when there is lib/rbtree.c? Or does yours do something fundamentally different?

It is not red-black tree, it is b+ tree.

It might be better to use the prefix "bptree" to help prevent confusion. A quick google search on "bp-tree" reveals only the perl B+-tree module "Tree::BPTree", a U-Maryland Java CS project on B+-trees, and a news article about a "BP tree-top protest".

BP heh.. How about "struct bplustree"?

Jan

#60 lore raw
In reply to Dongjun Shin
Quoted 7 lines · Dongjun Shin
Quoted 3 lines · Pavel Machek

Hmm.. so operating your camera on batteries should be against the warranty, since batteries commonly run empty while storing pictures?

AFAIK, the camera stops writing to the flash card and automatically turns off when it's low on battery (before empty).

But then, one should also consider the case where a cam is connected to AC and someone inadvertently trips on the power cord.

Jan

#61 lore raw
Quoted 5 lines · Jan Engelhardt
Quoted 2 lines

AFAIK, the camera stops writing to the flash card and automatically turns off when it's low on battery (before empty).

But then, one should also consider the case where a cam is connected to AC and someone inadvertently trips on the power cord.

So you stick a bloody great cap on board to give you enough time to shut it down cleanly. I've known people do this -- and it helps, but the devices still manage to crap themselves occasionally even then.

They're _disposable_. As are your data :)

Signature · 1 line
dwmw2
#63 lore raw
In reply to Andrew Morton
Quoted 11 lines · Andrew Morton

fs/logfs/logfs.h line 331

Quoted 9 lines
fs/logfs/logfs.h new file +9 -0
+static inline struct logfs_super *LOGFS_SUPER(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+	return container_of(inode, struct logfs_inode, vfs_inode);
+}

Do these need to be uppercase?

I'm trying to keep it clear in my head...

When do you need to say __always_inline and when can you get away with just saying "static inline"?

(I'm attempting to write documentation on a topic I don't understand. Best way to learn it, I've found...)

Quoted 6 lines
Quoted 3 lines

+     buf = kmap(page);
+     ret = logfs_write_buf(inode, index, buf);
+     kunmap(page);

kmap() is lame.  The preferred approach would be to pass the page* down to the lower layers and to use kmap_atomic() at the lowest possible point.

Um, would I read about this in DMA-mapping.txt or cachetlb.txt? (I don't think it's fujitsu/frv/mmu-layout.txt)

Rob

#64 lore raw
Quoted 8 lines · Rob Landley
Quoted 7 lines

fs/logfs/logfs.h line 331

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+	return container_of(inode, struct logfs_inode, vfs_inode);
+}

Do these need to be uppercase?

Quoted 4 lines

I'm trying to keep it clear in my head...

When do you need to say __always_inline and when can you get away with just saying "static inline"?

When using "static inline", the compiler may ignore the inline keyword (it's just a hint), and leave the function as a standalone function.

When CONFIG_FORCED_INLINING is active, and it is by default, inline is always substituted by __always_inline, to be on the safe side. Some code needs to be always inline; but not all code has been checked whether it is safe to go from __always_inline to inline.

Jan

#32 lore raw
In reply to Kevin Bowling
Quoted 16 lines · Kevin Bowling
Quoted 15 lines · David Woodhouse
Quoted 13 lines · Jörn Engel

My experience is that no matter which name I pick, people will complain
anyway. Previous suggestions included:
jffs3
jefs
engelfs
poofs
crapfs
sweetfs
cutefs
dynamic journaling fs - djofs
tfsfkal - the file system formerly known as logfs

Quoted 4 lines
Quoted 1 line

Can we call it jörnfs? :)

However if Jörn is accused of murder, it will have little chance of being merged :-).

WRT that, seems that Nina had a lover who is a confessed serial killer. I'm surprised the case hasn't been adapter for 'Boston legal' and 'Law and Order' like other high profile crimes.

I see nothing wrong with jörnfs, and there's room for numbers at the end...

Signature · 3 lines
Bill Davidsen <[email protected]>
  "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot
#35 lore raw
In reply to Jörn Engel
Quoted 9 lines · Jörn Engel
Quoted 7 lines · John Stoffel

Jörn> On Wed, 16 May 2007 12:34:34 +0100, Jamie Lokier wrote:

Jörn> How many of you have worked for IBM before? Vowels are not evil. ;)

Nope, they're not. I just think that LogFS isn't descriptive enough, or more accurately, is the *wrong* description of this filesystem.

Quoted 6 lines

That was the whole point. JFFS2, the journaling flash filesystem, is a strictly log-structured filesystem. LogFS has a journal.

It is also the filesystem that tries to scale logarithmically, as Arnd has noted. Maybe I should call it Log2 to emphesize this point. Log1 would be horrible scalability.

So, log2fs... Sounds great to me.

[snip]

Regards: David

Signature · 7 lines
 /) David Weinehall <[email protected]> /) Northern lights wander      (\
//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\)  http://www.acc.umu.se/~tao/    (/   Full colour fire           (/
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#62 lore raw
In reply to Dongjun Shin
Quoted 4 lines · Dongjun Shin

There are so many flash-based storage and some disposable storages, as you pointed out, have poor quality. I think it's mainly because these are not designed for good quality, but for lowering the price.

The reliability seems to be appropriate to the common use. I'm doubious that computer storage was a big design factor until the last few years. A good argument for buying large sizes, they are more likely to be recent design.

Quoted 6 lines

These kind of devices are not ready for things like power failure because their use case is far from that. For example, removing flash card while taking pictures using digital camera is not a common use case. (there should be a written notice that this kind of action is against the warranty)

They do well in such use, if you equate battery death to pulling the card (it may not be). I have tested that feature and not had a failure of any but the last item. Clearly not recommended, but sometimes unplanned needs arise.

Quoted 5 lines

- In contrast to the embedded environment where CPU and flash is directly connected, the I/O path between CPU and flash in PC environment is longer. The latency for SW handshaking between CPU and flash will also be longer, which would make the performance optimization harder.

Quoted 7 lines

As I mentioned, some techniques like log-structured filesystem could perform generally better on any kind of flash-based storage with FTL. Although there are many kinds of FTL, it is commonly true that it performs well under workload where sequential write is dominant.

I also expect that FTL for PC environment will have better quality spec than the disposable storage.

The recent technology announcements from Intel are encouraging in that respect.

Signature · 3 lines
Bill Davidsen <[email protected]>
  "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot
#36 lore raw
In reply to David Weinehall
Quoted 5 lines · David Weinehall
Quoted 3 lines

It is also the filesystem that tries to scale logarithmically, as Arnd has noted. Maybe I should call it Log2 to emphesize this point. Log1 would be horrible scalability.

So, log2fs... Sounds great to me.

Why Log2? Logarithmic scaling is just logarithmic scaling. Does the filesystem use 2-ary trees or anything else which gives particular meaning to 2?

-- Jamie

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#37 lore raw
Quoted 5 lines · Jamie Lokier
Quoted 1 line

So, log2fs... Sounds great to me.

Why Log2? Logarithmic scaling is just logarithmic scaling. Does the filesystem use 2-ary trees or anything else which gives particular meaning to 2?

Sizes used in on-disk format are rounded to the nearest power-of-two.

Quoted 1 line

-- Jamie

Signature · 5 lines
	Evgeniy Polyakov

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#65 lore raw
In reply to Jan Engelhardt
Quoted 15 lines · Jan Engelhardt
Quoted 8 lines · Rob Landley
Quoted 7 lines

fs/logfs/logfs.h line 331

Quoted 5 lines
fs/logfs/logfs.h new file +5 -0
+
+static inline struct logfs_inode *LOGFS_INODE(struct inode *inode)
+{
+	return container_of(inode, struct logfs_inode, vfs_inode);
+}

Do these need to be uppercase?

Quoted 4 lines

I'm trying to keep it clear in my head...

When do you need to say __always_inline and when can you get away with just saying "static inline"?

Quoted 7 lines

When using "static inline", the compiler may ignore the inline keyword (it's just a hint), and leave the function as a standalone function.

When CONFIG_FORCED_INLINING is active, and it is by default, inline is always substituted by __always_inline, to be on the safe side. Some code needs to be always inline; but not all code has been checked whether it is safe to go from __always_inline to inline.

I've seen patches go by using __always_inline directly. Is there some janitorial effort to examine each instance of the the inline keyword and either replace it with "__always_inline" or remove it?

Right now "inline" seems to be about as useful as the "register" keyword. You don't feed hints to a compiler like gcc, you hit it with a two-by-four and thumbscrews if you want to get its' attention.

Rob

#4 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

In reply to Jörn Engel
Quoted 8 lines · Jörn Engel
Quoted 6 lines · Evgeniy Polyakov

Is logfs 32bit fs or 674bit, since although you use 64bit values for offsets, area management and strange converstions like described below from offset into segment number are performed in 32bit?
Is it enough for SSD for example to be 32bit only? Or if it is 64bit, could you please explain logic behind area management?

Quoted 7 lines

Ignoring bugs and signed return values for error handling, it is either 64bit or 32+32bit.

Inode numbers and file positions are 64bit. Offsets are 64bit as well. In a couple of places, offsets are also 32+32bit. Basically the high bits contain the segment number, the lower bits the offset within a segment.

In that case segment size must be more than 32 bits, or below transformation will not be correct? segsize is long, but should be u64 I think.

static void fixup_from_wbuf(struct super_block *sb, struct logfs_area
*area, void *read, u64 ofs, size_t readlen)

u32 read_start = ofs & (super->s_segsize - 1);
u32 read_end = read_start + readlen;

And this can overflow, since readlen is size_t.
It is wbuf fixup, but I saw that somewhere else.
Although, according to your description, it should be 32bit, sum can be more than 32 bit.

Quoted 2 lines

If anyone can find similar bugs, the bounty is a beer or non-alcoholic beverage of choice. :)

Stop kiling your kidneys, your health and promote such antisocial style of life, start drinking vodka instead.

Quoted 1 line

Jörn

Signature · 5 lines
	Evgeniy Polyakov

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#5 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

Quoted 3 lines · Evgeniy Polyakov

In that case segment size must be more than 32 bits, or below transformation will not be correct?

Must it? If segment size is just 20bit then the filesystem may only be 52bit. Or 51bit when using signed values.

Quoted 1 line

segsize is long, but should be u64 I think.

It could be s32 as well.

Quoted 7 lines

static void fixup_from_wbuf(struct super_block *sb, struct logfs_area
*area, void *read, u64 ofs, size_t readlen)

u32 read_start = ofs & (super->s_segsize - 1);
u32 read_end = read_start + readlen;

And this can overflow, since readlen is size_t.

Theoretically yes. Practically readlen is bounded to sb->blocksize plus one header. I'll start worrying about that when blocksize approaches 32bit limit.

Quoted 5 lines
Quoted 2 lines

If anyone can find similar bugs, the bounty is a beer or non-alcoholic beverage of choice. :)

Stop kiling your kidneys, your health and promote such antisocial style of life, start drinking vodka instead.

I'm just a German. Forgive me if I drink lesser beverages.

Jörn

Signature · 6 lines
Eighty percent of success is showing up.
-- Woody Allen
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

Quoted 7 lines · Jörn Engel
Quoted 3 lines · Evgeniy Polyakov

In that case segment size must be more than 32 bits, or below transformation will not be correct?

Must it? If segment size is just 20bit then the filesystem may only be 52bit. Or 51bit when using signed values.

And what if it is 33 bits? Or it is not allowed?

Quoted 3 lines
Quoted 1 line

segsize is long, but should be u64 I think.

It could be s32 as well.

It is a matter of definition - if segment size is allowed to be more than 32 bits, then below transformation is not correct, otherwise segment size should not use additional 32bits on 64bit platform, since it is long.

Quoted 12 lines
Quoted 7 lines

static void fixup_from_wbuf(struct super_block *sb, struct logfs_area
*area, void *read, u64 ofs, size_t readlen)

u32 read_start = ofs & (super->s_segsize - 1);
u32 read_end = read_start + readlen;

And this can overflow, since readlen is size_t.

Theoretically yes. Practically readlen is bounded to sb->blocksize plus one header. I'll start worrying about that when blocksize approaches 32bit limit.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If anyone can find similar bugs, the bounty is a beer or non-alcoholic beverage of choice. :)

Stop kiling your kidneys, your health and promote such antisocial style of life, start drinking vodka instead.

I'm just a German. Forgive me if I drink lesser beverages.

You should definitely change that.

Btw, what about this piece:

int logfs_erase_segment(struct super_block *sb, u32 index)

{
	struct logfs_super *super = LOGFS_SUPER(sb);

	super->s_gec++;

	return mtderase(sb, index << super->s_segshift, super->s_segsize);
}

index << super->s_segshift might overflow, mtderase expects loff_t there, since index can be arbitrary segment number, is it possible, that overflow really occurs?

Quoted 5 lines

Jörn

Signature · 2 lines
Eighty percent of success is showing up.
-- Woody Allen
Signature · 1 line
	Evgeniy Polyakov
#7 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

Quoted 4 lines · Evgeniy Polyakov
Quoted 1 line · Jörn Engel

On Sun, 20 May 2007 21:30:52 +0400, Evgeniy Polyakov wrote:

And what if it is 33 bits? Or it is not allowed?

Not allowed. Both number and size of segments may never exceed 32bit.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

segsize is long, but should be u64 I think.

It could be s32 as well.

It is a matter of definition - if segment size is allowed to be more than 32 bits, then below transformation is not correct, otherwise segment size should not use additional 32bits on 64bit platform, since it is long.

I guess I could save 4 Bytes there.

Quoted 3 lines
Quoted 1 line

I'm just a German. Forgive me if I drink lesser beverages.

You should definitely change that.

Change being German? Not a bad idea, actually.

Quoted 11 lines

Btw, what about this piece:

int logfs_erase_segment(struct super_block *sb, u32 index)

{
	struct logfs_super *super = LOGFS_SUPER(sb);

	super->s_gec++;

	return mtderase(sb, index << super->s_segshift, super->s_segsize);
}
Quoted 3 lines

index << super->s_segshift might overflow, mtderase expects loff_t there, since index can be arbitrary segment number, is it possible, that overflow really occurs?

Indeed it is. You just earned your second beer^Wvodka.

Jörn

Signature · 7 lines
The wise man seeks everything in himself; the ignorant man tries to get
everything from somebody else.
-- unknown

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#8 lore raw

Re: Review status (Re: [PATCH] LogFS take three)

Quoted 5 lines · Jörn Engel
Quoted 3 lines
Quoted 1 line

I'm just a German. Forgive me if I drink lesser beverages.

You should definitely change that.

Change being German? Not a bad idea, actually.

You cook up really tasty shnaps, in small quantities it is good for health in infinite volumes.

Quoted 8 lines
Quoted 8 lines

Btw, what about this piece:

int logfs_erase_segment(struct super_block *sb, u32 index)

{
	struct logfs_super *super = LOGFS_SUPER(sb);

	super->s_gec++;
Quoted 8 lines
Quoted 6 lines
	return mtderase(sb, index << super->s_segshift, super->s_segsize);
}

index << super->s_segshift might overflow, mtderase expects loff_t there, since index can be arbitrary segment number, is it possible, that overflow really occurs?

Indeed it is. You just earned your second beer^Wvodka.

Actually this code looks less encrypted than ext2 for, which definitely a good sign from reviewer's point of view.

Quoted 1 line

Jörn

Signature · 1 line
	Evgeniy Polyakov