From patchwork Wed Jun 16 08:30:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikanth Karthikesan X-Patchwork-Id: 106422 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 o5G8Sx8l012175 for ; Wed, 16 Jun 2010 08:28:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647Ab0FPI26 (ORCPT ); Wed, 16 Jun 2010 04:28:58 -0400 Received: from cantor.suse.de ([195.135.220.2]:47102 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094Ab0FPI24 (ORCPT ); Wed, 16 Jun 2010 04:28:56 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 0C97B74609; Wed, 16 Jun 2010 10:28:56 +0200 (CEST) From: Nikanth Karthikesan Organization: suse.de To: Chris Mason Subject: [PATCH btrfs-unstable#master] Prevent creation of files larger than RLIMIT_FSIZE using fallocate Date: Wed, 16 Jun 2010 14:00:53 +0530 User-Agent: KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; ) Cc: linux-btrfs@vger.kernel.org, "Amit K. Arora" MIME-Version: 1.0 Message-Id: <201006161400.53879.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]); Wed, 16 Jun 2010 08:29:00 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f08427c..7870f4f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6842,6 +6842,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)