linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs-progs: fix free space cache checks
Date: Wed, 29 May 2013 09:09:55 -0400	[thread overview]
Message-ID: <1369832995-2935-1-git-send-email-jbacik@fusionio.com> (raw)

This fixes two bugs with the free space cache checker.  First is we apparently
always use root->sectorsize for our unit in the kernel so we have to do that in
progs otherwise bitmaps turn out to not look right if we have leafsize !=
sectorsize.  The second is a small issue if we had skinny metadata extents set,
we wouldn't advance last properly because we unconditionally use key.offset
instead of root->leafsize.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
 cmds-check.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index 7bb68ce..288b36e 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2853,7 +2853,10 @@ static int verify_space_cache(struct btrfs_root *root,
 		}
 
 		if (last == key.objectid) {
-			last = key.objectid + key.offset;
+			if (key.type == BTRFS_EXTENT_ITEM_KEY)
+				last = key.objectid + key.offset;
+			else
+				last = key.objectid + root->leafsize;
 			path->slots[0]++;
 			continue;
 		}
@@ -2906,15 +2909,8 @@ static int check_space_cache(struct btrfs_root *root)
 
 		start = cache->key.objectid + cache->key.offset;
 		if (!cache->free_space_ctl) {
-			int sectorsize;
-
-			if (cache->flags & (BTRFS_BLOCK_GROUP_METADATA |
-					    BTRFS_BLOCK_GROUP_SYSTEM))
-				sectorsize = root->leafsize;
-			else
-				sectorsize = root->sectorsize;
-
-			if (btrfs_init_free_space_ctl(cache, sectorsize)) {
+			if (btrfs_init_free_space_ctl(cache,
+						      root->sectorsize)) {
 				ret = -ENOMEM;
 				break;
 			}
-- 
1.7.7.6


                 reply	other threads:[~2013-05-29 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1369832995-2935-1-git-send-email-jbacik@fusionio.com \
    --to=jbacik@fusionio.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).