From patchwork Tue May 4 05:44:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikanth Karthikesan X-Patchwork-Id: 96677 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o445hSa2011647 for ; Tue, 4 May 2010 05:43:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753223Ab0EDFnW (ORCPT ); Tue, 4 May 2010 01:43:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53660 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751217Ab0EDFnV (ORCPT ); Tue, 4 May 2010 01:43:21 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 44FFE86391; Tue, 4 May 2010 07:43:19 +0200 (CEST) From: Nikanth Karthikesan Organization: suse.de To: Chris Mason Subject: [PATCH] btrfs: Prevent creation of files larger than RLIMIT_FSIZE using fallocate Date: Tue, 4 May 2010 11:14:57 +0530 User-Agent: KMail/1.12.4 (Linux/2.6.34-rc5-0.1-desktop; KDE/4.3.5; x86_64; ; ) Cc: "Amit K. Arora" , Andrew Morton , coly.li@suse.de, Nick Piggin , Alexander Viro , linux-fsdevel@vger.kernel.org, "Theodore Ts'o" , Andreas Dilger , linux-ext4@vger.kernel.org, Eelis , Amit Arora , Christoph Hellwig , linux-btrfs@vger.kernel.org References: <201004281854.49730.knikanth@suse.de> <201005030953.45157.knikanth@suse.de> <20100503065945.GA13756@amitarora.in.ibm.com> In-Reply-To: <20100503065945.GA13756@amitarora.in.ibm.com> MIME-Version: 1.0 Message-Id: <201005041114.57957.knikanth@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 04 May 2010 05:43:28 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2bfdc64..a1d8fbc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5829,6 +5829,11 @@ static long btrfs_fallocate(struct inode *inode, int mode, btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start); mutex_lock(&inode->i_mutex); + + ret = inode_newsize_ok(inode, (offset + len)); + if (ret) + goto out; + if (alloc_start > inode->i_size) { ret = btrfs_cont_expand(inode, alloc_start); if (ret)