From patchwork Wed Jul 20 05:38:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dong X-Patchwork-Id: 105582 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 939E7B6F71 for ; Wed, 20 Jul 2011 15:38:52 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649Ab1GTFip (ORCPT ); Wed, 20 Jul 2011 01:38:45 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:47431 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752547Ab1GTFio (ORCPT ); Wed, 20 Jul 2011 01:38:44 -0400 Received: by iwn6 with SMTP id 6so4673176iwn.19 for ; Tue, 19 Jul 2011 22:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=o2Pw9JAJXP4TzibfzTleZd/qaIJLBYNStyx3+walFdU=; b=E8yaqKE57oGC35fYN7BVdQHjcnoTeWl7ECyqJcMny7oOjvh/65/4KWccUstLNZVu/q 6s8ki5iTOzzv3BNHywFvYATAPHRWqS0EiPxWVg/DcpD3o/ygz5/yZ3SUG9ZAE/Lqb9EJ 6uP/QgxSgeCLNb69A33toubnA0aIH8Z6gxi2A= Received: by 10.231.5.69 with SMTP id 5mr7566005ibu.127.1311140323948; Tue, 19 Jul 2011 22:38:43 -0700 (PDT) Received: from localhost.localdomain ([110.75.120.250]) by mx.google.com with ESMTPS id er13sm1868794ibb.36.2011.07.19.22.38.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jul 2011 22:38:42 -0700 (PDT) From: hao.bigrat@gmail.com To: linux-ext4@vger.kernel.org Cc: Robin Dong , Ted Ts'o Subject: [PATCH bigalloc] e2fsprogs: change root-inode to extent-mapped Date: Wed, 20 Jul 2011 13:38:31 +0800 Message-Id: <1311140311-20242-1-git-send-email-hao.bigrat@gmail.com> X-Mailer: git-send-email 1.7.3.2 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Robin Dong 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 Cc: Ted Ts'o --- 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;