From patchwork Mon Aug 29 15:19:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 1109032 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7TF2o6m017292 for ; Mon, 29 Aug 2011 15:57:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753928Ab1H2PTK (ORCPT ); Mon, 29 Aug 2011 11:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753654Ab1H2PTI (ORCPT ); Mon, 29 Aug 2011 11:19:08 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7TFJ8l0004669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Aug 2011 11:19:08 -0400 Received: from localhost.localdomain.com (vpn-11-28.rdu.redhat.com [10.11.11.28]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7TFJ7lW001888 for ; Mon, 29 Aug 2011 11:19:08 -0400 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: don't use delalloc block rsv for free space inodes Date: Mon, 29 Aug 2011 11:19:07 -0400 Message-Id: <1314631147-13434-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 29 Aug 2011 15:57:51 +0000 (UTC) In tracking down this "not enough space" warning with checksums, it seems that we were running out of space partly because we do not reserve space for our free space inodes. Since this is technically metadata anyway go ahead and use the global_block_rsv for our free space inodes. We shouldn't be modifying too much other metadata since this will be a preallocated extent and that was already accounted for earlier. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 32 ++++++++++++-------------------- 1 files changed, 12 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0ee0677..bb65b13 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1717,7 +1717,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) struct extent_state *cached_state = NULL; int compress_type = 0; int ret; - bool nolock; ret = btrfs_dec_test_ordered_pending(inode, &ordered_extent, start, end - start + 1); @@ -1725,18 +1724,20 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) return 0; BUG_ON(!ordered_extent); - nolock = btrfs_is_free_space_inode(root, inode); + if (btrfs_is_free_space_inode(root, inode)) { + trans = btrfs_join_transaction_nolock(root); + BUG_ON(IS_ERR(trans)); + trans->block_rsv = &root->fs_info->global_block_rsv; + } else{ + trans = btrfs_join_transaction(root); + BUG_ON(IS_ERR(trans)); + trans->block_rsv = &root->fs_info->delalloc_block_rsv; + } if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { BUG_ON(!list_empty(&ordered_extent->list)); ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); if (!ret) { - if (nolock) - trans = btrfs_join_transaction_nolock(root); - else - trans = btrfs_join_transaction(root); - BUG_ON(IS_ERR(trans)); - trans->block_rsv = &root->fs_info->delalloc_block_rsv; ret = btrfs_update_inode(trans, root, inode); BUG_ON(ret); } @@ -1747,13 +1748,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) ordered_extent->file_offset + ordered_extent->len - 1, 0, &cached_state, GFP_NOFS); - if (nolock) - trans = btrfs_join_transaction_nolock(root); - else - trans = btrfs_join_transaction(root); - BUG_ON(IS_ERR(trans)); - trans->block_rsv = &root->fs_info->delalloc_block_rsv; - if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags)) compress_type = ordered_extent->compress_type; if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { @@ -1792,13 +1786,11 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) } ret = 0; out: - if (nolock) { - if (trans) - btrfs_end_transaction_nolock(trans, root); + if (btrfs_is_free_space_inode(root, inode)) { + btrfs_end_transaction_nolock(trans, root); } else { btrfs_delalloc_release_metadata(inode, ordered_extent->len); - if (trans) - btrfs_end_transaction(trans, root); + btrfs_end_transaction(trans, root); } /* once for us */