From patchwork Tue Oct 1 01:27:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 279286 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 21AA12C0097 for ; Tue, 1 Oct 2013 11:27:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755406Ab3JAB1d (ORCPT ); Mon, 30 Sep 2013 21:27:33 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:22434 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755345Ab3JAB1d (ORCPT ); Mon, 30 Sep 2013 21:27:33 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r911RUeY021699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Oct 2013 01:27:30 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r911RTln008163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 1 Oct 2013 01:27:29 GMT Received: from abhmt112.oracle.com (abhmt112.oracle.com [141.146.116.64]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r911RTkJ008158; Tue, 1 Oct 2013 01:27:29 GMT Received: from localhost (/10.137.226.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Sep 2013 18:27:28 -0700 Subject: [PATCH 07/31] libext2fs: When writing a file that has a i_size > 2GB, set the large_file feature flag and update the superblock. To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org Date: Mon, 30 Sep 2013 18:27:28 -0700 Message-ID: <20131001012728.28415.89082.stgit@birch.djwong.org> In-Reply-To: <20131001012642.28415.89353.stgit@birch.djwong.org> References: <20131001012642.28415.89353.stgit@birch.djwong.org> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If someone tries to write a file that is larger than 2GB, we need to set the large_file feature flag to affirm that i_size_hi can hold meaningful contents. (I don't see anything checking large_file except e2fsck...) Signed-off-by: Darrick J. Wong --- lib/ext2fs/fileio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c index 1f7002c..ae5cbf1 100644 --- a/lib/ext2fs/fileio.c +++ b/lib/ext2fs/fileio.c @@ -389,6 +389,18 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size) old_truncate = ((old_size + file->fs->blocksize - 1) >> EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1; + /* If we're writing a large file, set the large_file flag */ + if (LINUX_S_ISREG(file->inode.i_mode) && + EXT2_I_SIZE(&file->inode) > 0x7FFFFFFULL && + (!EXT2_HAS_RO_COMPAT_FEATURE(file->fs->super, + EXT2_FEATURE_RO_COMPAT_LARGE_FILE) || + file->fs->super->s_rev_level == EXT2_GOOD_OLD_REV)) { + file->fs->super->s_feature_ro_compat |= + EXT2_FEATURE_RO_COMPAT_LARGE_FILE; + ext2fs_update_dynamic_rev(file->fs); + ext2fs_mark_super_dirty(file->fs); + } + file->inode.i_size = size & 0xffffffff; file->inode.i_size_high = (size >> 32); if (file->ino) {