mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@canonical.com>
To: Chris Mason <chris.mason@oracle.com>, linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>
Subject: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
Date: Mon,  1 Aug 2011 14:38:30 +0100	[thread overview]
Message-ID: <1312205910-13053-1-git-send-email-apw@canonical.com> (raw)

When we mount a btrfs filesystem from read-only media there will be no
read/write devices; for example mounting an SD card with its lock enabled.
This triggers an immediate BUG during mount:

  kernel BUG at .../fs/btrfs/super.c:984!

This is triggered by statfs when calculating the free space in the
filesytem.  We bug if the number of read/write devices is 0.

This check seems spurious as the information collected is valid regardless
of whether the devices are read-only or not.  As the count is used to
size the sort array it seems more correct to switch it to the number of
open devices.

BugLink: http://bugs.launchpad.net/bugs/816770
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 fs/btrfs/super.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 15634d4..ae4367a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -980,7 +980,7 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
 	int i = 0, nr_devices;
 	int ret;
 
-	nr_devices = fs_info->fs_devices->rw_devices;
+	nr_devices = fs_info->fs_devices->open_devices;
 	BUG_ON(!nr_devices);
 
 	devices_info = kmalloc(sizeof(*devices_info) * nr_devices,
-- 
1.7.4.1


             reply	other threads:[~2011-08-01 13:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 13:38 Andy Whitcroft [this message]
2011-08-01 15:24 ` Josef Bacik
2011-11-28 12:11 ` Jonathan Nieder
2011-11-28 12:24   ` Andy Whitcroft
2011-11-29  1:26     ` Li Zefan
2011-11-29  6:01       ` Jonathan Nieder
2011-11-30 15:40       ` Andy Whitcroft
2011-11-29  1:55   ` Miao Xie

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=1312205910-13053-1-git-send-email-apw@canonical.com \
    --to=apw@canonical.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®