Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@redhat.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] fix free space leak
Date: Fri, 14 Nov 2008 16:33:32 -0500	[thread overview]
Message-ID: <20081114213332.GD19225@unused.rdu.redhat.com> (raw)

Hello,

In my batch delete/update/insert patch I introduced a free space leak.  The
extent that we do the original search on in free_extents is never pinned, so we
always update the block saying that it has free space, but the free space never
actually gets added to the free space tree, since op->del will always be 0 and
it's never actually added to the pinned extents tree.  This patch fixes this
problem by making sure we call pin_down_bytes on the pending extent op and set
op->del to the return value of pin_down_bytes so update_block_group is called
with the right value.  This seems to fix the case where we were getting ENOSPC
when there was plenty of space available.  Thank you,

Signed-off-by: Josef Bacik <jbacik@redhat.com>

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6eb56a0..93726ae 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -999,6 +999,14 @@ search:
 		path->slots[0] = extent_slot;
 		bytes_freed = op->num_bytes;
 
+		mutex_lock(&info->pinned_mutex);
+		ret = pin_down_bytes(trans, extent_root, op->bytenr,
+				     op->num_bytes, op->level >=
+				     BTRFS_FIRST_FREE_OBJECTID);
+		mutex_unlock(&info->pinned_mutex);
+		BUG_ON(ret < 0);
+		op->del = ret;
+
 		/*
 		 * we need to see if we can delete multiple things at once, so
 		 * start looping through the list of extents we are wanting to

             reply	other threads:[~2008-11-14 21:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-14 21:33 Josef Bacik [this message]
2008-11-15 15:33 ` [PATCH] fix free space leak Mitch Harder (aka DontPanic)
     [not found] <1226931587.31480.3.camel@localhost>
2008-11-17 14:21 ` Lee Trager

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081114213332.GD19225@unused.rdu.redhat.com \
    --to=jbacik@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox