[syslinux] [GIT-PULL] ext4 inline data support

Paulo Cavalcanti pcacjr at zytor.com
Sat Mar 2 08:26:59 PST 2013


Hi,

This branch contains the new ext4's inline data support which has been
added recently to kernel 3.8.

In addition to inline data support, there are other patches that remove
trainling whitespaces and extra new lines in ext2fs code and the other
adds an assert() macro to Syslinux core.

I think it's worth mentioning that these changes were made against
master branch.

                Paulo

The following changes since commit e40ba6059aa9c6b5cefd01e277eafbe60c7752fd:

  menugen: Make it compatible with Py3k (2013-02-27 21:38:11 +0000)

are available in the git repository at:

  git://git.zytor.com/users/pcacjr/syslinux.git ext4-for-hpa

for you to fetch changes up to 23045314f5897652b3002d2f9c07840b01d308a4:

  ext4: Add inline data support (2013-03-02 13:10:09 -0300)

Signed-off-by: Paulo Cavalcanti <paulo.cavalcanti at linux.intel.com>

----------------------------------------------------------------
Paulo Cavalcanti (3):
      core: Add assert() macro
      ext2fs: Remove trailing whitespaces
      ext4: Add inline data support

 core/fs/ext2/bmap.c    |  5 +++--
 core/fs/ext2/ext2.c    | 34 ++++++++++++++++++++++++++++------
 core/fs/ext2/ext2_fs.h | 26 +++++++++++---------------
 core/include/assert.h  | 26 ++++++++++++++++++++++++++
 4 files changed, 68 insertions(+), 23 deletions(-)
 create mode 100644 core/include/assert.h

diff --git a/core/fs/ext2/bmap.c b/core/fs/ext2/bmap.c
index ef2bf64..a65b320 100644
--- a/core/fs/ext2/bmap.c
+++ b/core/fs/ext2/bmap.c
@@ -10,6 +10,7 @@
 #include <fs.h>
 #include <disk.h>
 #include <cache.h>
+#include "assert.h"
 #include "ext2_fs.h"
 
 static const struct ext4_extent_header *
@@ -178,7 +179,6 @@ bmap_traditional(struct inode *inode, block_t block, size_t *nblocks)
     return 0;
 }
 
-
 /**
  * Map the logical block to physic block where the file data stores.
  * In EXT4, there are two ways to handle the map process, extents and indirect.
@@ -203,7 +203,6 @@ block_t ext2_bmap(struct inode *inode, block_t block, size_t *nblocks)
     return ret;
 }
 
-
 /*
  * Next extent for getfssec
  */
@@ -215,6 +214,8 @@ int ext2_next_extent(struct inode *inode, uint32_t lstart)
     block_t block;
     size_t nblocks = 0;
 
+    assert(ext2_has_inline_data(inode) == 0);
+
     block = ext2_bmap(inode, lstart >> blktosec, &nblocks);
 
     if (!block)
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index 7988faa..9498480 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -5,6 +5,7 @@
 #include <minmax.h>
 #include "cache.h"
 #include "core.h"
+#include "assert.h"
 #include "disk.h"
 #include "fs.h"
 #include "ext2_fs.h"
@@ -66,7 +67,6 @@ static inline bool ext2_match_entry(const char *name, size_t len,
     return !memcmp(name, de->d_name, len);
 }
 
-
 /*
  * p is at least 6 bytes before the end of page
  */
@@ -144,7 +144,7 @@ ext2_get_inode(struct fs_info *fs, int inr)
 	(data + block_off * EXT2_SB(fs)->s_inode_size);
 }
 
-static void fill_inode(struct inode *inode, const struct ext2_inode *e_inode)
+static void fill_inode(struct inode *inode, const struct ext2_inode *e_inode, uint32_t inr)
 {
     inode->mode    = IFTODT(e_inode->i_mode);
     inode->size    = e_inode->i_size;
@@ -156,6 +156,7 @@ static void fill_inode(struct inode *inode, const struct ext2_inode *e_inode)
     inode->flags   = e_inode->i_flags;
     inode->file_acl = e_inode->i_file_acl;
     memcpy(PVT(inode)->i_block, e_inode->i_block, sizeof PVT(inode)->i_block);
+    PVT(inode)->i_ino = inr;
 }
 
 static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
@@ -169,11 +170,32 @@ static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
 
     if (!(inode = alloc_inode(fs, inr, sizeof(struct ext2_pvt_inode))))
 	return NULL;
-    fill_inode(inode, e_inode);
+    fill_inode(inode, e_inode, inr);
 
     return inode;
 }
 
+static uint32_t ext2_getfssec(struct file *file, char *buf, int sectors,
+			      bool *have_more)
+{
+    struct inode *inode = file->inode;
+    const struct ext2_inode *e2_inode;
+
+    if (!ext2_has_inline_data(inode))
+	return generic_getfssec(file, buf, sectors, have_more);
+
+    e2_inode = ext2_get_inode(file->fs, PVT(inode)->i_ino);
+    if (!e2_inode) {
+	printf("%s: Unable to find inode from ino %lu.\n", __func__,
+	       PVT(inode)->i_ino);
+	return 0;
+    }
+
+    memcpy(buf, &e2_inode->i_block, inode->size);
+
+    return inode->size;
+}
+
 static struct inode *ext2_iget_root(struct fs_info *fs)
 {
     return ext2_iget_by_inr(fs, EXT2_ROOT_INO);
@@ -187,7 +209,7 @@ static struct inode *ext2_iget(const char *dname, struct inode *parent)
     de = ext2_find_entry(fs, parent, dname);
     if (!de)
 	return NULL;
-    
+
     return ext2_iget_by_inr(fs, de->d_inode);
 }
 
@@ -217,7 +239,7 @@ static int cache_get_file(struct inode *inode, void *buf, size_t bytes)
 
     return 0;
 }
-	
+
 static int ext2_readlink(struct inode *inode, char *buf)
 {
     struct fs_info *fs = inode->fs;
@@ -326,7 +348,7 @@ const struct fs_ops ext2_fs_ops = {
     .fs_flags      = FS_THISIND | FS_USEMEM,
     .fs_init       = ext2_fs_init,
     .searchdir     = NULL,
-    .getfssec      = generic_getfssec,
+    .getfssec      = ext2_getfssec,
     .close_file    = generic_close_file,
     .mangle_name   = generic_mangle_name,
     .load_config   = generic_load_config,
diff --git a/core/fs/ext2/ext2_fs.h b/core/fs/ext2/ext2_fs.h
index 8adc9bb..62cbc4a 100644
--- a/core/fs/ext2/ext2_fs.h
+++ b/core/fs/ext2/ext2_fs.h
@@ -31,10 +31,12 @@
 #define	EXT2_TIND_BLOCK		(EXT2_DIND_BLOCK+1)
 #define	EXT2_N_BLOCKS		(EXT2_TIND_BLOCK+1)
 
-
 /* for EXT4 extent */
-#define EXT4_EXT_MAGIC     0xf30a
-#define EXT4_EXTENTS_FLAG  0x00080000
+#define EXT4_EXT_MAGIC        		0xf30a
+#define EXT4_EXTENTS_FLAG     		0x00080000
+
+/* for EXT4 inline data */
+#define EXT4_INLINE_DATA_FLAG		0x10000000
 
 /*
  * File types and file modes
@@ -57,11 +59,8 @@
 #define T_IFLNK		(S_IFLNK >> S_IFSHIFT)
 #define T_IFSOCK	(S_IFSOCK >> S_IFSHIFT)
 
-
 #define ext2_group_desc_lg2size 5
 
-
-
 /*
  * super block structure:
  * include/linux/ext2_fs.h
@@ -168,7 +167,6 @@ struct ext2_group_desc {
 #endif
 *******************************************************************************/
 
-
 /*
  * ext2 inode structure:
  */
@@ -221,11 +219,6 @@ struct ext2_dir_entry {
 					 ~EXT2_DIR_ROUND)
 *******************************************************************************/
 
-
-
-
-
-
 /*
  * This is the extent on-disk structure.
  * It's used at the bottom of the tree.
@@ -260,12 +253,9 @@ struct ext4_extent_header {
     uint32_t eh_generation;	/* generation of the tree */
 };
 
-
-
 #define EXT4_FIRST_EXTENT(header) ( (struct ext4_extent *)(header + 1) )
 #define EXT4_FIRST_INDEX(header)  ( (struct ext4_extent_idx *) (header + 1) )
 
-
 /*
  * The ext2 super block information in memory
  */
@@ -297,10 +287,16 @@ struct ext2_pvt_inode {
 	uint32_t i_block[EXT2_N_BLOCKS];
 	struct ext4_extent_header i_extent_hdr;
     };
+    uint32_t i_ino;
 };
 
 #define PVT(i) ((struct ext2_pvt_inode *)((i)->pvt))
 
+static inline int ext2_has_inline_data(struct inode *inode)
+{
+    return inode->flags & EXT4_INLINE_DATA_FLAG;
+}
+
 /*
  * functions
  */
diff --git a/core/include/assert.h b/core/include/assert.h
new file mode 100644
index 0000000..5655ed8
--- /dev/null
+++ b/core/include/assert.h
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2013 Intel Corporation; author: Paulo Cavalcanti
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef ASSERT_H_
+#define ASSERT_H_
+
+extern int __attribute__((format(printf, 1, 2)))
+assert_printf(const char *fmt, ...) asm("printf");
+
+#define assert(cond) \
+    do { \
+	if (!(cond)) \
+	    assert_printf("assert(%s) failed at %s line %d\n", #cond, \
+			  __FILE__, __LINE__); \
+    } while (0)
+
+#endif /* ASSERT_H_ */

-- 
Paulo Cavalcanti, Intel Open Source Technology Center
I speak only for myself.


More information about the Syslinux mailing list