From: Li Zefan <lizf@cn.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: lidongyang@novell.com
Subject: [PATCH 2/2] Btrfs: fix space leak when trimming free extents
Date: Tue, 21 Jun 2011 13:50:10 +0800 [thread overview]
Message-ID: <4E003112.9050702@cn.fujitsu.com> (raw)
In-Reply-To: <4E0030DF.4080704@cn.fujitsu.com>
When the end of an extent exceeds the end of the specified range,
the extent will be accidentally truncated.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/free-space-cache.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 292c0d9..185cf8e 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2509,8 +2509,15 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
bytes = min(entry->bytes, end - start);
if (bytes < minlen)
goto next;
+
unlink_free_space(ctl, entry);
- kmem_cache_free(btrfs_free_space_cachep, entry);
+ if (bytes < entry->bytes) {
+ entry->offset = entry->offset + bytes;
+ entry->bytes = entry->bytes - bytes;
+ link_free_space(ctl, entry);
+ } else {
+ kmem_cache_free(btrfs_free_space_cachep, entry);
+ }
}
spin_unlock(&ctl->tree_lock);
-- 1.7.3.1
next prev parent reply other threads:[~2011-06-21 5:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-21 5:49 [PATCH 1/2] Btrfs: fix space leak when skipping small extents during trimming Li Zefan
2011-06-21 5:50 ` Li Zefan [this message]
2011-06-21 9:45 ` [PATCH 2/2] Btrfs: fix space leak when trimming free extents Li Dongyang
2011-07-05 4:07 ` [PATCH 1/2] Btrfs: fix space leak when skipping small extents during trimming Li Dongyang
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=4E003112.9050702@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=lidongyang@novell.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;
as well as URLs for NNTP newsgroup(s).