From patchwork Fri Jul 1 15:27:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yury V. Zaytsev" X-Patchwork-Id: 102914 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 72219B6F59 for ; Sat, 2 Jul 2011 01:27:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756625Ab1GAP1f (ORCPT ); Fri, 1 Jul 2011 11:27:35 -0400 Received: from mailgateway3.uni-freiburg.de ([132.230.2.213]:37144 "EHLO mailgateway3.uni-freiburg.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756566Ab1GAP1f (ORCPT ); Fri, 1 Jul 2011 11:27:35 -0400 Delivery-date: Fri, 01 Jul 2011 17:27:35 +0200 Received: from bcf.uni-freiburg.de ([132.230.2.123] helo=uni-freiburg.de) port 44558 by mailgateway3.uni-freiburg.de with esmtp (Exim 4.68 #1 built 28-Nov-2007 14:57:47 running on Gentoo) id 1Qcfcy-0007bj-Dc; Fri, 01 Jul 2011 17:27:32 +0200 Received: from [132.230.177.2] (account yuriy.zaytsev@bcf.uni-freiburg.de HELO [192.168.177.198]) by uni-freiburg.de (CommuniGate Pro SMTP 5.3.11) with ESMTPSA id 162593420; Fri, 01 Jul 2011 17:27:31 +0200 Subject: [PATCH v2] mke2fs: check that auto-detected blocksize <= sys_page_size From: "Yury V. Zaytsev" To: Ted Ts'o Cc: Amir Goldstein , Lukas Czerner , linux-ext4@vger.kernel.org Date: Fri, 01 Jul 2011 17:27:31 +0200 Message-ID: <1309534051.9412.58.camel@newpride> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Block size can be specified manually via the -b option or deduced automatically. Unfortunately, the check that it is still smaller than the system page size is only performed right after the command line options are parsed. Therefore, if buggy or inappropriately installed/configured hardware hints that larger block sizes have to be used, mkfs will silently create a file system which can not be mounted on the system in question. By moving the check beyond the last assignment to blocksize it is now ensured, that mkfs will issue a warning even if inappropriate blocksize was auto-detected. The new behavior can be easily tested, by exporting the following variables before running mkfs: export MKE2FS_DEVICE_SECTSIZE=8912 export MKE2FS_DEVICE_PHYS_SECTSIZE=8912 Signed-off-by: Yury V. Zaytsev Reviewed-by: Lukas Czerner --- misc/mke2fs.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 05cbbce..8faf12a 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1514,17 +1514,6 @@ profile_error: ext2fs_close(jfs); } - if (blocksize > sys_page_size) { - if (!force) { - com_err(program_name, 0, - _("%d-byte blocks too big for system (max %d)"), - blocksize, sys_page_size); - proceed_question(); - } - fprintf(stderr, _("Warning: %d-byte blocks too big for system " - "(max %d), forced to continue\n"), - blocksize, sys_page_size); - } if (optind < argc) { fs_blocks_count = parse_num_blocks2(argv[optind++], fs_param.s_log_block_size); @@ -1833,6 +1822,19 @@ profile_error: blocksize = EXT2_BLOCK_SIZE(&fs_param); + /* This check should happen beyond the last assignment to blocksize */ + if (blocksize > sys_page_size) { + if (!force) { + com_err(program_name, 0, + _("%d-byte blocks too big for system (max %d)"), + blocksize, sys_page_size); + proceed_question(); + } + fprintf(stderr, _("Warning: %d-byte blocks too big for system " + "(max %d), forced to continue\n"), + blocksize, sys_page_size); + } + lazy_itable_init = 0; if (access("/sys/fs/ext4/features/lazy_itable_init", R_OK) == 0) lazy_itable_init = 1;