linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hao.bigrat@gmail.com
To: linux-ext4@vger.kernel.org
Cc: Robin Dong <sanbai@taobao.com>, Ted Ts'o <tytso@mit.edu>
Subject: [PATCH bigalloc] e2fsprogs: change root-inode to extent-mapped
Date: Wed, 20 Jul 2011 13:38:31 +0800	[thread overview]
Message-ID: <1311140311-20242-1-git-send-email-hao.bigrat@gmail.com> (raw)

From: Robin Dong <sanbai@taobao.com>

After creating more than 1000 files in root directory on ext4 of bigalloc,
the kernel reports many error messages like:

[181126.730911] EXT4-fs error (device sda4): ext4_ind_map_blocks:1015: inode #2: comm falloc: Can't allocate blocks for non-extent mapped inodes with bigalloc
[181126.735945] EXT4-fs error (device sda4): ext4_ind_map_blocks:1015: inode #2: comm falloc: Can't allocate blocks for non-extent mapped inodes with bigalloc

because the root inode of a new ext4 filesystem is type of block-mapped
even use mke2fs with "-O extent,bigalloc".

So change root inode to extent-mapped when do "mke2fs" if the option has "extent".

Signed-off-by: Robin Dong <sanbai@taobao.com>
Cc: Ted Ts'o <tytso@mit.edu>
---
 lib/ext2fs/mkdir.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c
index 86c65da..d4b8d37 100644
--- a/lib/ext2fs/mkdir.c
+++ b/lib/ext2fs/mkdir.c
@@ -39,6 +39,9 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
 	ext2_ino_t		scratch_ino;
 	blk64_t			blk;
 	char			*block = 0;
+	int			max;
+	struct ext3_extent	*ex;
+	struct ext3_extent_header *eh;
 
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
@@ -84,7 +87,23 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
 	inode.i_uid = inode.i_gid = 0;
 	ext2fs_iblk_set(fs, &inode, 1);
 	/* FIXME-64 */
-	inode.i_block[0] = blk;
+	if (fs->super->s_feature_incompat &
+	    EXT3_FEATURE_INCOMPAT_EXTENTS) {
+		eh = (struct ext3_extent_header *) &inode.i_block[0];
+		eh->eh_depth = 0;
+		eh->eh_entries = 1;
+		eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
+		max = (sizeof(inode.i_block) - sizeof(*eh)) /
+			sizeof(struct ext3_extent);
+		eh->eh_max =  ext2fs_cpu_to_le16(max);
+		ex = EXT_FIRST_EXTENT(eh);
+		ex->ee_block = 0;
+		ex->ee_start = ext2fs_cpu_to_le32(blk & 0xFFFFFFFF);
+		ex->ee_start_hi = ext2fs_cpu_to_le16(blk >> 32);
+		ex->ee_len = 1;
+		inode.i_flags |= EXT4_EXTENTS_FL;
+	} else
+		inode.i_block[0] = blk;
 	inode.i_links_count = 2;
 	inode.i_size = fs->blocksize;
 
-- 
1.7.3.2


             reply	other threads:[~2011-07-20  5:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20  5:38 hao.bigrat [this message]
2011-07-20 14:28 ` [PATCH bigalloc] e2fsprogs: change root-inode to extent-mapped Theodore Tso
2011-07-20 15:52 ` Andreas Dilger
2011-07-20 17:49   ` Ted Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311140311-20242-1-git-send-email-hao.bigrat@gmail.com \
    --to=hao.bigrat@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sanbai@taobao.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).