Re: [Patch 05/18] fs/logfs/logfs.h

2007-06-06 Thread Paulo Marques

Jörn Engel wrote:

--- /dev/null   2007-03-13 19:15:28.862769062 +0100
+++ linux-2.6.21logfs/fs/logfs/logfs.h  2007-06-03 19:34:07.0 +0200
@@ -0,0 +1,398 @@
+/*
+ * 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__
+
+
+#include 
+#include 
+#include 


Including kallsyms.h is not really needed in this header file, is it?

I don't have time / knowledge to review the rest of the code, but I 
always keep an eye out for kallsyms usage...


--
Paulo Marques - www.grupopie.com

"Very funny Scotty. Now beam up my clothes."
-
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


Re: [Patch 05/18] fs/logfs/logfs.h

2007-06-06 Thread Jörn Engel
On Wed, 6 June 2007 12:29:13 +0100, Paulo Marques wrote:
> Jörn Engel wrote:
> >--- /dev/null2007-03-13 19:15:28.862769062 +0100
> >+++ linux-2.6.21logfs/fs/logfs/logfs.h   2007-06-03 
> >19:34:07.0 +0200
> >@@ -0,0 +1,398 @@
> >+/*
> >+ * 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__
> >+
> >+
> >+#include 
> >+#include 
> >+#include 
> 
> Including kallsyms.h is not really needed in this header file, is it?

Another piece of historic cruft to remove.  Thanks for spotting.

Jörn

-- 
Joern's library part 5:
http://www.faqs.org/faqs/compression-faq/part2/section-9.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


Re: [Patch 05/18] fs/logfs/logfs.h

2007-06-04 Thread Jan Engelhardt

>On Sunday 03 June 2007, Jörn Engel wrote:
>> +/**
>> + * struct logfs_device_ops - device access operations
>> + *
>> + * @read:  read from the device
>> + * @write: write to the device
>> + * @erase: erase part of the device
>> + */
>> +struct logfs_device_ops {
>> +   int (*read)(struct super_block *sb, loff_t ofs, size_t len, void 
>> *buf);
>> +   int (*write)(struct super_block *sb, loff_t ofs, size_t len, void 
>> *buf);
>> +   int (*erase)(struct super_block *sb, loff_t ofs, size_t len);
>> +};
>
>I wonder if there is a way to document the prototypes of these function
>pointers with kerneldoc, other than having a typedef for each.
>
>What brought me to this point is that I first assumed they would return
>the number of bytes transferred, like read/write file operations, where
>your functions return zero on success.

read/write functions returning bytes written would return ssize_t,
just as vfs_read and vfs_write do.



Jan
-- 
-
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


Re: [Patch 05/18] fs/logfs/logfs.h

2007-06-04 Thread Jörn Engel
On Sun, 3 June 2007 23:50:55 +0200, Arnd Bergmann wrote:
> On Sunday 03 June 2007, Jörn Engel wrote:
> > +/**
> > + * struct logfs_device_ops - device access operations
> > + *
> > + * @read:  read from the device
> > + * @write: write to the device
> > + * @erase: erase part of the device
> > + */
> > +struct logfs_device_ops {
> > +   int (*read)(struct super_block *sb, loff_t ofs, size_t len, void 
> > *buf);
> > +   int (*write)(struct super_block *sb, loff_t ofs, size_t len, void 
> > *buf);
> > +   int (*erase)(struct super_block *sb, loff_t ofs, size_t len);
> > +};
> 
> I wonder if there is a way to document the prototypes of these function
> pointers with kerneldoc, other than having a typedef for each.
> 
> What brought me to this point is that I first assumed they would return
> the number of bytes transferred, like read/write file operations, where
> your functions return zero on success.

I can just add a comment about the return code in the struct
documentation.  For the foreseeable future there will be exactly two
instances of this structure.  It's not as if every driver would
implement this.

Jörn

-- 
A defeated army first battles and then seeks victory.
-- Sun Tzu
-
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


[Patch 05/18] fs/logfs/logfs.h

2007-06-03 Thread Jörn Engel
--- /dev/null   2007-03-13 19:15:28.862769062 +0100
+++ linux-2.6.21logfs/fs/logfs/logfs.h  2007-06-03 19:34:07.0 +0200
@@ -0,0 +1,398 @@
+/*
+ * 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__
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+static inline void build_bug_on_needs_a_function(void)
+{
+   BUILD_BUG_ON(sizeof(struct logfs_object_header) != LOGFS_HEADERSIZE);
+   BUILD_BUG_ON(sizeof(struct logfs_segment_header) != LOGFS_HEADERSIZE);
+}
+
+
+/* FIXME: This should really be somewhere in the 64bit area. */
+#define LOGFS_LINK_MAX (1<<30)
+
+
+/*
+ * 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(512)
+
+
+/* Read-only filesystem */
+#define LOGFS_SB_FLAG_RO   1
+
+
+/**
+ * struct logfs_area - area management information
+ *
+ * @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
+ */
+struct logfs_area { /* a segment open for writing */
+   struct super_block *a_sb;
+   int a_is_open;
+   u32 a_segno;
+   u32 a_used_objects;
+   u32 a_used_bytes;
+   const struct logfs_area_ops *a_ops;
+   void*a_wbuf;
+   u32 a_erase_count;
+   u8  a_level;
+};
+
+
+/**
+ * struct logfs_area_ops - area operations
+ *
+ * @get_free_segment:  fill area->ofs with the offset of a free segment
+ * @get_erase_count:   fill area->erase_count (needs area->ofs)
+ * @erase_segment: erase and setup segment
+ * @finish_area:   flush buffers, etc.
+ */
+struct logfs_area_ops {
+   void(*get_free_segment)(struct logfs_area *area);
+   void(*get_erase_count)(struct logfs_area *area);
+   int (*erase_segment)(struct logfs_area *area);
+   void(*finish_area)(struct logfs_area *area);
+};
+
+
+/**
+ * struct logfs_device_ops - device access operations
+ *
+ * @read:  read from the device
+ * @write: write to the device
+ * @erase: erase part of the device
+ */
+struct logfs_device_ops {
+   int (*read)(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+   int (*write)(struct super_block *sb, loff_t ofs, size_t len, void *buf);
+   int (*erase)(struct super_block *sb, loff_t ofs, size_t len);
+};
+
+
+/**
+ * struct gc_candidate - "candidate" segment to be garbage collected next
+ *
+ * @list:  list (either free of low)
+ * @erase_count:   erase count of segment
+ * @valid: number of valid bytes
+ * @write_time:GEC at time of writing
+ * @segno: segment number
+ *
+ * Candidates can be on two lists.  The free list contains electees rather
+ * than candidates - segments that no longer contain any valid data.  The
+ * low list contains candidates to be picked for GC.  It should be kept
+ * short.  It is not required to always pick a perfect candidate.  In the
+ * worst case GC will have to move more data than absolutely necessary.
+ */
+struct gc_candidate {
+   struct list_head list;
+   u32 erase_count;
+   u32 valid;
+   u64 write_time;
+   u32 segno;
+};
+
+
+/**
+ * struct logfs_journal_entry - temporary structure used during journal scan
+ *
+ * @used:
+ * @version:   normalized version
+ * @len:   length
+ * @offset:offset
+ */
+struct logfs_journal_entry {
+   int used;
+   s16 version;
+   u16 len;
+   u64 offset;
+};
+
+
+struct logfs_super {
+   struct mtd_info *s_mtd; /* underlying device */
+   struct block_device *s_bdev;/* underlying device */
+   const struct logfs_device_ops *s_devops;/* d