From patchwork Tue Aug 2 18:59:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 1029912 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p72IxsCB003969 for ; Tue, 2 Aug 2011 18:59:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755007Ab1HBS7w (ORCPT ); Tue, 2 Aug 2011 14:59:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754968Ab1HBS7v (ORCPT ); Tue, 2 Aug 2011 14:59:51 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p72IxpOA001751 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Aug 2011 14:59:51 -0400 Received: from localhost.localdomain.com (vpn-9-5.rdu.redhat.com [10.11.9.5]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p72IxoiU002987 for ; Tue, 2 Aug 2011 14:59:51 -0400 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: release reservations properly when doing inline extents Date: Tue, 2 Aug 2011 14:59:49 -0400 Message-Id: <1312311589-16394-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 (demeter2.kernel.org [140.211.167.43]); Tue, 02 Aug 2011 18:59:55 +0000 (UTC) We were only releasing our metadata reservations when doing inline extents, which isn't correct since we don't need our data reservation either. So call btrfs_delalloc_release_space() instead of btrfs_delalloc_release_metadata(). This would have been caught earlier but we don't check for bytes_may_use still being set on unmount, so add that to the WARN_ON() condition so we can catch this sort of thing in the future. This would cause us to leak space and run into early ENOSPC problems. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 3 ++- fs/btrfs/inode.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a3e61eb..d003508 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6915,7 +6915,8 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) struct btrfs_space_info, list); if (space_info->bytes_pinned > 0 || - space_info->bytes_reserved > 0) { + space_info->bytes_reserved > 0 || + space_info->bytes_may_use > 0) { WARN_ON(1); dump_space_info(space_info, 0, 0); } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 68884ba..e449a1f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -255,7 +255,7 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans, inline_len, compressed_size, compress_type, compressed_pages); BUG_ON(ret); - btrfs_delalloc_release_metadata(inode, end + 1 - start); + btrfs_delalloc_release_space(inode, end + 1 - start); btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0); return 0; }