Re: [PATCH 8/8] Add yaffs2 file system: VFS glue code, hook into kernel tree building

Previous thread: [PATCH 1/2] media: Remove unnecessary casts of usb_get_intfdata by Joe Perches on Tuesday, November 30, 2010 - 2:42 pm. (2 messages)

Next thread: Its winter in the northern hemisphere (aka various 2.6.37 regeressions) by Tim Sander on Tuesday, November 30, 2010 - 2:58 pm. (2 messages)
From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

This is the third submission of a yaffs2 patchset.

I would like to thank everyone that has given comments so far. They
have been most helpful.

I would like to thank CELF and Google for sponsoring the effort to get
yaffs2 mainlined.

This code is patched from 3788df745cd72e035c0c991157cb727a8ecb1f17
at git://www.aleph1.co.uk/yaffs2.

This patch set takes onboard almost all the comments provided since the
last set of patches. Most noteably :
* Removal of kernel locking
* Removal of some debugging  /proc entries
* Use of kernel hweight8/32() functions.

This code ran various tests for the whole night with no problems seen.

Comments/feedback welcome, but I'm hopefully getting pretty close to
acceptance :-).


-- Charles
--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_allocator.c |  397 +++++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_allocator.h |   30 ++++
 fs/yaffs2/yaffs_attribs.c   |  124 ++++++++++++++
 fs/yaffs2/yaffs_attribs.h   |   28 +++
 fs/yaffs2/yaffs_bitmap.c    |  104 +++++++++++
 fs/yaffs2/yaffs_bitmap.h    |   33 ++++
 6 files changed, 716 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_allocator.c
 create mode 100644 fs/yaffs2/yaffs_allocator.h
 create mode 100644 fs/yaffs2/yaffs_attribs.c
 create mode 100644 fs/yaffs2/yaffs_attribs.h
 create mode 100644 fs/yaffs2/yaffs_bitmap.c
 create mode 100644 fs/yaffs2/yaffs_bitmap.h

diff --git a/fs/yaffs2/yaffs_allocator.c b/fs/yaffs2/yaffs_allocator.c
new file mode 100644
index 0000000..b9fe31e
--- /dev/null
+++ b/fs/yaffs2/yaffs_allocator.c
@@ -0,0 +1,397 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yaffs_allocator.h"
+#include "yaffs_guts.h"
+#include "yaffs_trace.h"
+#include "yportenv.h"
+
+#ifdef CONFIG_YAFFS_YMALLOC_ALLOCATOR
+
+void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev)
+{
+	dev = dev;
+}
+
+void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev)
+{
+	dev = dev;
+}
+
+struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev)
+{
+	return (struct yaffs_tnode *)YMALLOC(dev->tnode_size);
+}
+
+void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
+{
+	dev = dev;
+	YFREE(tn);
+}
+
+void yaffs_init_raw_objs(struct yaffs_dev *dev)
+{
+	dev = dev;
+}
+
+void yaffs_deinit_raw_objs(struct ...
From: Marcin Slusarz
Date: Thursday, December 2, 2010 - 11:14 am

Funny bug.

Marcin

--

From: Charles Manning
Date: Thursday, December 2, 2010 - 12:20 pm

Thanks.

I shall fix this in yaffs git right away.

The power of open source!
--

From: kevin granade
Date: Thursday, December 2, 2010 - 1:48 pm

Actually, how about using the standard hamming weight function?
This adds a dependency on linux/bitops.h, but seems to be carefully
crafted to be as fast as possible based on the available hardware.

int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk)
{
       u8 *blk_bits = yaffs_block_bits(dev, blk);
       int i, n = 0;

       for (i = 0; i < dev->chunk_bit_stride; i++, blk_bits++)
               n += hweight8(*blk_bits);

       return n;
}

--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_checkptrw.c |  420 +++++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_checkptrw.h |   33 ++++
 fs/yaffs2/yaffs_ecc.c       |  298 ++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_ecc.h       |   44 +++++
 4 files changed, 795 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_checkptrw.c
 create mode 100644 fs/yaffs2/yaffs_checkptrw.h
 create mode 100644 fs/yaffs2/yaffs_ecc.c
 create mode 100644 fs/yaffs2/yaffs_ecc.h

diff --git a/fs/yaffs2/yaffs_checkptrw.c b/fs/yaffs2/yaffs_checkptrw.c
new file mode 100644
index 0000000..02b8ce6
--- /dev/null
+++ b/fs/yaffs2/yaffs_checkptrw.c
@@ -0,0 +1,420 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yaffs_checkptrw.h"
+#include "yaffs_getblockinfo.h"
+
+static int yaffs2_checkpt_space_ok(struct yaffs_dev *dev)
+{
+	int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks;
+
+	T(YAFFS_TRACE_CHECKPOINT,
+	  (TSTR("checkpt blocks available = %d" TENDSTR), blocks_avail));
+
+	return (blocks_avail <= 0) ? 0 : 1;
+}
+
+static int yaffs_checkpt_erase(struct yaffs_dev *dev)
+{
+	int i;
+
+	if (!dev->param.erase_fn)
+		return 0;
+	T(YAFFS_TRACE_CHECKPOINT, (TSTR("checking blocks %d to %d" TENDSTR),
+				   dev->internal_start_block,
+				   dev->internal_end_block));
+
+	for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
+		struct yaffs_block_info *bi = yaffs_get_block_info(dev, i);
+		if (bi->block_state == YAFFS_BLOCK_STATE_CHECKPOINT) {
+			T(YAFFS_TRACE_CHECKPOINT,
+			  ...
From: Jesper Juhl
Date: Sunday, December 5, 2010 - 2:55 pm

Just a few small comments below.



Why not get rid of the redundant local variable and simply do

  *sum = (dev->checkpt_sum << 8) | (dev->checkpt_xor & 0xFF);

??



'data' is a 'const void *' and this casts away const. Probably fine, just 
makes my toes curl.



here you are not casting away const, but since 'data' is a void pointer 
the cast is just completely superfluous and should just go away.



Nitpicking, but this should be 

  if (dev->checkpt_cur_block < 0) {
    ok = 0;
  } else {
  ...

curly brace on both branches since it's used on one of them (according to 
CodingStyle).



1) nitpicking about curly braces again (see above).
2) try grep'ing the source for "todo", "xxx", "fixme" and similar, then 
check the age of those comments. If things like this are not addressed (by 
other than a "todo" comment) on initial commit they stand a good chance of 
never getting addressed...


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_guts.c   | 5236 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_guts.h   |  915 ++++++++
 fs/yaffs2/yaffs_yaffs1.c |  437 ++++
 fs/yaffs2/yaffs_yaffs1.h |   22 +
 fs/yaffs2/yaffs_yaffs2.c | 1620 ++++++++++++++
 fs/yaffs2/yaffs_yaffs2.h |   39 +
 6 files changed, 8269 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_guts.c
 create mode 100644 fs/yaffs2/yaffs_guts.h
 create mode 100644 fs/yaffs2/yaffs_yaffs1.c
 create mode 100644 fs/yaffs2/yaffs_yaffs1.h
 create mode 100644 fs/yaffs2/yaffs_yaffs2.c
 create mode 100644 fs/yaffs2/yaffs_yaffs2.h

diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
new file mode 100644
index 0000000..c56e060
--- /dev/null
+++ b/fs/yaffs2/yaffs_guts.c
@@ -0,0 +1,5236 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yportenv.h"
+#include "yaffs_trace.h"
+
+#include "yaffs_guts.h"
+#include "yaffs_tagsvalidity.h"
+#include "yaffs_getblockinfo.h"
+
+#include "yaffs_tagscompat.h"
+
+#include "yaffs_nand.h"
+
+#include "yaffs_yaffs1.h"
+#include "yaffs_yaffs2.h"
+#include "yaffs_bitmap.h"
+#include "yaffs_verify.h"
+
+#include "yaffs_nand.h"
+#include "yaffs_packedtags2.h"
+
+#include "yaffs_nameval.h"
+#include "yaffs_allocator.h"
+
+#include "yaffs_attribs.h"
+
+/* Note YAFFS_GC_GOOD_ENOUGH must be <= YAFFS_GC_PASSIVE_THRESHOLD */
+#define YAFFS_GC_GOOD_ENOUGH 2
+#define YAFFS_GC_PASSIVE_THRESHOLD 4
+
+#include "yaffs_ecc.h"
+
+/* Robustification (if it ever comes about...) */
+static void ...
From: Arnd Bergmann
Date: Tuesday, November 30, 2010 - 3:23 pm

On Tuesday 30 November 2010 22:57:29 Charles Manning wrote:


It would be better to reorder the functions in each file so that
you don't need forward declarations. This generally makes reading
the code easier because it is what people expect to see. It

The tracing functions are rather obscure. I would recommend dropping
them all for now, in order to get the code included. At a later

In general, don't wrap standard kernel API functions with your
own abstractions, just use kmalloc here for instance.

It is rather annoying when you want to understand code and it
calls nonstandard functions that do almost the same that the
standard API does.

If you find something lacking in the existing API, feel free
to make suggestions for improving it. Either it is a good idea
and everyone will be happy about the useful new interface,
or it is a bad idea and you shouldn't be using it in the first
place.

	Arnd
--

From: Arnd Bergmann
Date: Monday, December 6, 2010 - 5:55 am

There is not much point in changing the legacy code that's already in
the kernel, but let's try to keep it clean for new code. We have a lot
of bad examples for coding style that we wouldn't merge these days.


I don't think the yaffs_trace() function would be much better than the T()
macro, I was talking more about the fact that you have your own nonstandard
tracing infrastructure than the ugliness of the interface.

The point of pulling it out now would be force you to rethink the
tracing. If you think that you'd arrive at the same conclusion, just
save the diff between the code with and without tracing so you can
submit that patch again later.

Having some sort of tracing is clearly useful, but it's also not essential
for the basic yaffs2 operation. We want to keep a consistent way of
presenting trace points across the kernel, so as long as you do it
differently, your code is going to be viewed with some suspicion.



Ok. Maybe rename YCHAR to ychar to make it stick out less, and add a comment
to the definition why you need it then.

	Arnd
--

From: Charles Manning
Date: Monday, December 6, 2010 - 3:13 pm

Arnd thanks for your input, I appreciate it immensely.

Is this objection to forward declarations just your personal taste or is this 
a real issue?

I can't find any references to forward declarations in any of the coding style 
docs. I would therefore expect it to be an issue of little consequence. 
Perhaps I did not look in the right places.

It is perhaps also worth considering that yaffs has been in use for 8 years 
and is more widely used than many of the file systems already in the kernel  

Looking in Linus' tree, all of those contain custom tracing of the form I 

Can do.

Thanks.

-- Charles
--

From: Jesper Juhl
Date: Monday, December 6, 2010 - 3:16 pm

I can only speak for myself here (which obviously makes this comment a 
"personal taste thing).  I personally hate all those forward declarations 
and whenever I'm modifying kernel code I try to see if I can move stuff 
around to get rid of some.
We have to live with what's already in the tree, but there's no reason to 
add more gunk. It's easy to just re-order functions to get rid of the 
forward declarations, so why not just do that - makes it so much nicer to 

I don't think it's written in stone anywhere, it's just one of those 

In terms of mainline Linux kernel inclusion it does not.


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--

From: Arnd Bergmann
Date: Monday, December 6, 2010 - 4:03 pm

It's not very important and a lot of people don't care, though I have never
seen anyone argue in favour of adding forward declarations. I consider
it similar to the argument about function sizes: We don't have a hard
limit about how many lines a function is allowed to have, and there are
some cases where it makes sense to have a really long function, but
you can tell how much effort people put into making code readable when
you see a multi-page function that could easily be split into reasonable
smaller ones. Code readability is mostly subjective, just like taste, but

I see this argument a lot about code that gets upstream after a long time.
My counterargument to this is that often enough the reason for being outside
of mainline is that the code was written in obscure ways to start with ;-)

In general, the initial merge of new code is the only time we can really
influence code from other people. Once it gets merged, I'm going to have
a really hard time making the maintainers change it again in fundamental

Hmm, yes I guess that's right...

I was specifically talking about the include/trace/* based trace events
as something to look at, not the random printk based tracing stuff.
Maybe Steven or Frederic can give some more insight on that.

	Arnd
--

From: Steven Rostedt
Date: Monday, December 6, 2010 - 5:47 pm

What are all those T() functions? Some look like they should be replaced
with printk(KERN_* "") functions, some others for tracing (I guess the
ones with YAFFS_TRACE_TRACING).

ext4, gfs and xfs all have converted to the TRACE_EVENT() methods. When
you have this, you get tracing for free. The work with both ftrace and
perf. You can look at the samples/trace_events/ code for examples.

Note, if you use TRACE_EVENT() and you want to debug even more, you can
simply add trace_printk() and that will also appear in your tracing
output.

-- Steve


--

From: Charles Manning
Date: Monday, December 6, 2010 - 9:12 pm

Yes those are very ugly. That is why I proposed changing them to 

yaffs_trace(bit, "format", args).

That gives printk tracing which I can select on the fly by enabling the 
selected bits in the bitmask. eg. If I want to see the OS calls and the mtd 
accesses then I enable YAFFS_TRACE_MTD and YAFFS_TRACE_OS and only those 
grace groups get spat out.

People find this very handy, especially during system integration, so I am 
loath to lose it. It is simple and it works.

Will it not be acceptable to just leave in the printk-style messages and 

From what I see, ext4 uses both trace_event and wrapped printk tracing, some 
right alongside eachother so it is a duplication - not a replacement.

YAFFS has approx 500 trace lines in it. Some of those would make sense to 
attach to TRACE_EVENT() , but most not. trace/events/ext4.h has 1172 lines 
for around 28 events (== 40-odd lines per event).

Still reading everything I can find on this  (inc, your LWN articles) to get 
an understanding of what capabilities these give me and what heuristic should 
be used to define trace points vs printks.

-- Charles

--

From: Steven Rostedt
Date: Tuesday, December 7, 2010 - 7:49 am

[ Adding Ted to Cc ]


Adding the TRACE_EVENT() code is also simple too ;)

With TRACE_EVENT() you will get the advantage of jump_lables (with newer
compilers). That is, there's no "if (bit & SOME_MASK) trace();" logic. A
nop is placed in the code and no compares are needed. When tracing is
enabled, the nop is changed to a jmp to the trace.

If you still use your own tracer, you could still use the internal

Printks go to the console. You should not do that unless it is an error
that the admin should notice. There's also levels of printks that you
can do:

KERN_ERR, KERN_WARING, KERN_INFO, KERN_DEBUG, etc.

But again, these go to the users console and into the message logs. If
it is something that is a high activity this can slow down the system as
printk's are synchronous. That is, they don't continue work until they
finished writing. If you have a serial console, that could really slow
things down.

printk's should not be used for real debugging anyway. But putting it
into a tracepoint, then it opens up lots of options.

Your T(YAFFS_TRACE_ALWAYS, ...) look like good candidates for printks.

TRACE_EVENTS() are those that just want to analyze what is happening in
the system.

-- Steve
 

--

From: Charles Manning
Date: Tuesday, December 7, 2010 - 1:43 pm

For 500 traces?

Please remember that yaffs is typically used in embedded systems - not big 
iron servers . Typical kernel sizes are between 1 and 3MB. Pretty much all 
the big iron features get turned off.

From your LWN article it would seem that adding TRACE_EVENT() would podge up 

Yaffs is used in embedded systems (eg. phones). There is no operator. The only 
people that ever look at dmesg and the log are engineers during 

That is exactly why I use the bitmasks to be able to be able to select sets of 
messages to be enabled. [btw: Enabling sets of traces seems to be a feature 
that TRACE_EVENT() lacks, or perhaps I have not read enough].

The trace mask allows you to set up a test case very easily and delivers the 

All, well almost all, embedded systems have printk. Many don't have TRACE.

People using yaffs do not want to lose what they already have and like the way 
tracing is set up.

What I propose is just rewriting the current trace mechanism so the code looks 
cleaner.

-- Charles






--

From: Steven Rostedt
Date: Tuesday, December 7, 2010 - 3:49 pm

OK, then use pr_debug(), these can even be compiled out of the kernel

You can group trace_events into TRACE_SYSTEMS, and then enable a bunch
of events under which system they are in. I thought about making this

Fine, as it seems special purpose for embedded devices.

-- Steve


--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_mtdif.c  |   54 ++++++++
 fs/yaffs2/yaffs_mtdif.h  |   23 ++++
 fs/yaffs2/yaffs_mtdif1.c |  331 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_mtdif1.h |   29 ++++
 fs/yaffs2/yaffs_mtdif2.c |  226 +++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_mtdif2.h |   29 ++++
 fs/yaffs2/yaffs_nand.c   |  128 ++++++++++++++++++
 fs/yaffs2/yaffs_nand.h   |   38 ++++++
 8 files changed, 858 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_mtdif.c
 create mode 100644 fs/yaffs2/yaffs_mtdif.h
 create mode 100644 fs/yaffs2/yaffs_mtdif1.c
 create mode 100644 fs/yaffs2/yaffs_mtdif1.h
 create mode 100644 fs/yaffs2/yaffs_mtdif2.c
 create mode 100644 fs/yaffs2/yaffs_mtdif2.h
 create mode 100644 fs/yaffs2/yaffs_nand.c
 create mode 100644 fs/yaffs2/yaffs_nand.h

diff --git a/fs/yaffs2/yaffs_mtdif.c b/fs/yaffs2/yaffs_mtdif.c
new file mode 100644
index 0000000..7cf53b3
--- /dev/null
+++ b/fs/yaffs2/yaffs_mtdif.c
@@ -0,0 +1,54 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yportenv.h"
+
+#include "yaffs_mtdif.h"
+
+#include "linux/mtd/mtd.h"
+#include "linux/types.h"
+#include "linux/time.h"
+#include "linux/mtd/nand.h"
+
+#include "yaffs_linux.h"
+
+int nandmtd_erase_block(struct yaffs_dev *dev, int block_no)
+{
+	struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
+	u32 addr =
+	    ((loff_t) block_no) * dev->param.total_bytes_per_chunk
+	    * dev->param.chunks_per_block;
+	struct erase_info ei;
+
+	int retval = 0;
+
+	ei.mtd = mtd;
+	ei.addr = addr;
+	ei.len = ...
From: Jesper Juhl
Date: Sunday, December 5, 2010 - 3:42 pm

Personal preference thing I guess, but I couldn't help thinking 

  return mtd->erase(mtd, &ei) ? YAFFS_FAIL : YAFFS_OK;




Pointless parenthesis.



Again the blank lines between includes - why?
I can see grouping the "linux/..." includes and the rest and then put a 
blank line between the two, but the above just looks like a waste of 
vertical screen space to me.


spaces used for indentation where tabs should have been.



How about 

int yaffs_erase_block(struct yaffs_dev *dev, int flash_block)
{
     flash_block -= dev->block_offset;
     dev->n_erasures++;
     return dev->param.erase_fn(dev, flash_block);
}



-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_getblockinfo.h |   36 +++
 fs/yaffs2/yaffs_linux.h        |   41 +++
 fs/yaffs2/yaffs_tagsvalidity.c |   27 ++
 fs/yaffs2/yaffs_tagsvalidity.h |   23 ++
 fs/yaffs2/yaffs_trace.h        |   59 +++++
 fs/yaffs2/yaffs_verify.c       |  546 ++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_verify.h       |   43 ++++
 fs/yaffs2/yportenv.h           |   91 +++++++
 8 files changed, 866 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_getblockinfo.h
 create mode 100644 fs/yaffs2/yaffs_linux.h
 create mode 100644 fs/yaffs2/yaffs_tagsvalidity.c
 create mode 100644 fs/yaffs2/yaffs_tagsvalidity.h
 create mode 100644 fs/yaffs2/yaffs_trace.h
 create mode 100644 fs/yaffs2/yaffs_verify.c
 create mode 100644 fs/yaffs2/yaffs_verify.h
 create mode 100644 fs/yaffs2/yportenv.h

diff --git a/fs/yaffs2/yaffs_getblockinfo.h b/fs/yaffs2/yaffs_getblockinfo.h
new file mode 100644
index 0000000..108c361
--- /dev/null
+++ b/fs/yaffs2/yaffs_getblockinfo.h
@@ -0,0 +1,36 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __YAFFS_GETBLOCKINFO_H__
+#define __YAFFS_GETBLOCKINFO_H__
+
+#include "yaffs_guts.h"
+#include "yaffs_trace.h"
+
+/* Function to manipulate block info */
+static Y_INLINE struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev
+							      *dev, int blk)
+{
+	if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
+		T(YAFFS_TRACE_ERROR,
+		  (TSTR
+		   ("**>> yaffs: ...
From: Ryan Mallon
Date: Thursday, December 2, 2010 - 1:00 pm

You should try and remove the wrappers for as many of these as possible.
I know the wrappers are there for portability to other operating



This macro name should possibly be changed since its name implies that
it does the same thing as BUG().

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--

From: Charles Manning
Date: Sunday, December 5, 2010 - 2:20 pm

Thus far I have tried to keep all the code directly compilable for WinCE and 
Linux.

I did some investigation over the weekend and I am pretty sure that if I 
preserve just a few of these macros, YCHAR in particular, I can eliminate 
almost everything else and just run the code through a sed script to generate 
the WiNCE version.

I'll do that for the next release.

Charles
--

From: Ryan Mallon
Date: Sunday, December 5, 2010 - 2:45 pm

Could YCHAR and YUCHAR be replaced by s8 and u8?

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--

From: Pekka Enberg
Date: Tuesday, December 7, 2010 - 8:06 am

Please drop these wrapper macros.
--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 MAINTAINERS           |    8 +
 fs/Kconfig            |    1 +
 fs/Makefile           |    1 +
 fs/yaffs2/Kconfig     |  161 +++
 fs/yaffs2/Makefile    |   17 +
 fs/yaffs2/yaffs_vfs.c | 2917 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 3105 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/Kconfig
 create mode 100644 fs/yaffs2/Makefile
 create mode 100644 fs/yaffs2/yaffs_vfs.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b3be8b3..67c9155 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6666,6 +6666,14 @@ S:	Maintained
 F:	drivers/net/hamradio/yam*
 F:	include/linux/yam.h
 
+YAFFS2 FILESYSTEM
+M:	Charles Manning <cdhmanning@gmail.com>
+L:	yaffs@lists.aleph1.co.uk
+S:	Maintained
+F:	fs/yaffs2/
+T:	git git://www.aleph1.co.uk/yaffs2
+W:	http://www.yaffs.net/
+
 YEALINK PHONE DRIVER
 M:	Henk Vergonet <Henk.Vergonet@gmail.com>
 L:	usbb2k-api-dev@nongnu.org
diff --git a/fs/Kconfig b/fs/Kconfig
index 771f457..069abb1 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -176,6 +176,7 @@ source "fs/hfsplus/Kconfig"
 source "fs/befs/Kconfig"
 source "fs/bfs/Kconfig"
 source "fs/efs/Kconfig"
+source "fs/yaffs2/Kconfig"
 source "fs/jffs2/Kconfig"
 # UBIFS File system configuration
 source "fs/ubifs/Kconfig"
diff --git a/fs/Makefile b/fs/Makefile
index a7f7cef..e370ea5 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -121,3 +121,4 @@ obj-$(CONFIG_BTRFS_FS)		+= btrfs/
 obj-$(CONFIG_GFS2_FS)           += gfs2/
 obj-$(CONFIG_EXOFS_FS)          += exofs/
 obj-$(CONFIG_CEPH_FS)		+= ceph/
+obj-$(CONFIG_YAFFS_FS)		+= yaffs2/
diff --git a/fs/yaffs2/Kconfig b/fs/yaffs2/Kconfig
new file mode 100644
index 0000000..6354140
--- /dev/null
+++ b/fs/yaffs2/Kconfig
@@ -0,0 +1,161 @@
+#
+# YAFFS file system configurations
+#
+
+config YAFFS_FS
+	tristate "YAFFS2 file system support"
+	default n
+	depends on MTD_BLOCK
+	select YAFFS_YAFFS1
+	select YAFFS_YAFFS2
+	help
+	  YAFFS2, or Yet Another ...
From: Nick Piggin
Date: Tuesday, November 30, 2010 - 10:30 pm

You should never be testing page flags by hand, outside mm code.

Why aren't you using PageUptodate()?
--

From: Ryan Mallon
Date: Thursday, December 2, 2010 - 1:35 pm

How much additional code do the YAFFS1 and YAFFS2 options add? If the
added size is minimal maybe its better to remove these options and just

Could this option be removed and have the default behaviour auto-detect
when specifying "yaffs", and have "yaffs1" and "yaffs2" specify the

Some of the Kconfig options are enabling features and some are disabling
features which is a bit confusing.

This option, and some of the others, looks like it could be replaced by
a sysfs tuneable to set the refresh_period. This would give much greater


Why would you disable this config option?

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_nameval.c |  201 +++++++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_nameval.h |   28 ++++++
 2 files changed, 229 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_nameval.c
 create mode 100644 fs/yaffs2/yaffs_nameval.h

diff --git a/fs/yaffs2/yaffs_nameval.c b/fs/yaffs2/yaffs_nameval.c
new file mode 100644
index 0000000..d8c548a
--- /dev/null
+++ b/fs/yaffs2/yaffs_nameval.c
@@ -0,0 +1,201 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This simple implementation of a name-value store assumes a small number of values and fits
+ * into a small finite buffer.
+ *
+ * Each attribute is stored as a record:
+ *  sizeof(int) bytes   record size.
+ *  strnlen+1 bytes name null terminated.
+ *  nbytes    value.
+ *  ----------
+ *  total size  stored in record size 
+ *
+ * This code has not been tested with unicode yet.
+ */
+
+#include "yaffs_nameval.h"
+
+#include "yportenv.h"
+
+static int nval_find(const char *xb, int xb_size, const YCHAR * name,
+		     int *exist_size)
+{
+	int pos = 0;
+	int size;
+
+	memcpy(&size, xb, sizeof(int));
+	while (size > 0 && (size < xb_size) && (pos + size < xb_size)) {
+		if (yaffs_strncmp
+		    ((YCHAR *) (xb + pos + sizeof(int)), name, size) == 0) {
+			if (exist_size)
+				*exist_size = size;
+			return pos;
+		}
+		pos += size;
+		if (pos < xb_size - sizeof(int))
+			memcpy(&size, xb + pos, sizeof(int));
+		else
+			size = 0;
+	}
+	if (exist_size)
+		*exist_size = 0;
+	return -1;
+}
+
+static int ...
From: Jesper Juhl
Date: Sunday, December 5, 2010 - 3:20 pm

A few minor comments can be found below.



Why not get rid of the 'else' branch and simply write this as 

int nval_del(char *xb, int xb_size, const YCHAR *name)
{
     int pos = nval_find(xb, xb_size, name, NULL);
     int size;  
     
     if (pos >= 0 && pos < xb_size) {
             /* Find size, shift rest over this record, then zero out the rest of buffer */
             memcpy(&size, xb + pos, sizeof(int));
             memcpy(xb + pos, xb + pos + size, xb_size - (pos + size));
             memset(xb + (xb_size - size), 0, size);
             return 0;
     }
     return -ENODATA;
                                                 ^^^^^

Why this insistance on making pointer variables look like 
multiplication...?
  int* foo; // prefered by many C++ people
  int *foo; // prefered by many C people
  int * foo; // just plain ugly
Trivial little nit. The line above this comment is indented with spaces, 

-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--

From: Charles Manning
Date: Tuesday, November 30, 2010 - 2:57 pm

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
 fs/yaffs2/yaffs_packedtags1.c |   53 +++++
 fs/yaffs2/yaffs_packedtags1.h |   39 ++++
 fs/yaffs2/yaffs_packedtags2.c |  197 +++++++++++++++++++
 fs/yaffs2/yaffs_packedtags2.h |   47 +++++
 fs/yaffs2/yaffs_tagscompat.c  |  429 +++++++++++++++++++++++++++++++++++++++++
 fs/yaffs2/yaffs_tagscompat.h  |   36 ++++
 6 files changed, 801 insertions(+), 0 deletions(-)
 create mode 100644 fs/yaffs2/yaffs_packedtags1.c
 create mode 100644 fs/yaffs2/yaffs_packedtags1.h
 create mode 100644 fs/yaffs2/yaffs_packedtags2.c
 create mode 100644 fs/yaffs2/yaffs_packedtags2.h
 create mode 100644 fs/yaffs2/yaffs_tagscompat.c
 create mode 100644 fs/yaffs2/yaffs_tagscompat.h

diff --git a/fs/yaffs2/yaffs_packedtags1.c b/fs/yaffs2/yaffs_packedtags1.c
new file mode 100644
index 0000000..a77f095
--- /dev/null
+++ b/fs/yaffs2/yaffs_packedtags1.c
@@ -0,0 +1,53 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yaffs_packedtags1.h"
+#include "yportenv.h"
+
+void yaffs_pack_tags1(struct yaffs_packed_tags1 *pt,
+		      const struct yaffs_ext_tags *t)
+{
+	pt->chunk_id = t->chunk_id;
+	pt->serial_number = t->serial_number;
+	pt->n_bytes = t->n_bytes;
+	pt->obj_id = t->obj_id;
+	pt->ecc = 0;
+	pt->deleted = (t->is_deleted) ? 0 : 1;
+	pt->unused_stuff = 0;
+	pt->should_be_ff = 0xFFFFFFFF;
+
+}
+
+void yaffs_unpack_tags1(struct yaffs_ext_tags *t,
+			const struct yaffs_packed_tags1 *pt)
+{
+	static const u8 all_ff[] =
+	    { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff
+	};
+
+	if (memcmp(all_ff, ...
From: Jesper Juhl
Date: Sunday, December 5, 2010 - 3:12 pm

A few small comments inline below.





static int yaffs_wr_nand(struct yaffs_dev *dev,
                      int nand_chunk, const u8 *data,

static int yaffs_rd_chunk_nand(struct yaffs_dev *dev,
                            int nand_chunk,
                            u8 *data,
                            struct yaffs_spare *spare,
                            enum yaffs_ecc_result *ecc_result,

int yaffs_tags_compat_wr(struct yaffs_dev *dev,
                      int nand_chunk,

int yaffs_tags_compat_rd(struct yaffs_dev *dev,
                      int nand_chunk,

Why does this function have a blank line at the beginning and at the end? 
Just remove those.

On a more serious note; while reviewing these patches I've seen a lot of 
functions that return int but only ever return a single fixed value. I can 
see the point of this for some of them since they are ment to be assigned 
to function pointers that expect a specific signature, but for some I'm 

int yaffs_tags_compat_query_block(struct yaffs_dev *dev,
                               int block_no,
                               enum yaffs_block_state *state,

int yaffs_tags_compat_wr(struct yaffs_dev *dev,
                      int nand_chunk,

int yaffs_tags_compat_rd(struct yaffs_dev *dev,
                      int nand_chunk,

int yaffs_tags_compat_query_block(struct yaffs_dev *dev,
                               int block_no,
                               enum yaffs_block_state *state,

-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--

Previous thread: [PATCH 1/2] media: Remove unnecessary casts of usb_get_intfdata by Joe Perches on Tuesday, November 30, 2010 - 2:42 pm. (2 messages)

Next thread: Its winter in the northern hemisphere (aka various 2.6.37 regeressions) by Tim Sander on Tuesday, November 30, 2010 - 2:58 pm. (2 messages)