linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices
@ 2011-07-27 10:59 Andy Whitcroft
  2011-07-27 11:09 ` Andy Whitcroft
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Whitcroft @ 2011-07-27 10:59 UTC (permalink / raw)
  To: Chris Mason, linux-btrfs; +Cc: linux-kernel, Andy Whitcroft

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.

It seems more appropriate to indicate we have no writable space.  Note
that this does make df return 0 free blocks on a read-only device.
Whether that is reasonable is debatable.

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

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 15634d4..8d3f9b0 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -981,7 +981,10 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
 	int ret;
 
 	nr_devices = fs_info->fs_devices->rw_devices;
-	BUG_ON(!nr_devices);
+	if (!nr_devices) {
+		*free_bytes = 0;
+		return 0;
+	}
 
 	devices_info = kmalloc(sizeof(*devices_info) * nr_devices,
 			       GFP_NOFS);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices
@ 2011-07-27 11:01 Andy Whitcroft
  2011-07-27 14:25 ` Josef Bacik
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Whitcroft @ 2011-07-27 11:01 UTC (permalink / raw)
  To: Chris Mason, linux-btrfs; +Cc: linux-kernel, Andy Whitcroft

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.

It seems more appropriate to indicate we have no writable space.  Note
that this does make df return 0 free blocks on a read-only device.
Whether that is reasonable is debatable.

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

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 15634d4..8d3f9b0 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -981,7 +981,10 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
 	int ret;
 
 	nr_devices = fs_info->fs_devices->rw_devices;
-	BUG_ON(!nr_devices);
+	if (!nr_devices) {
+		*free_bytes = 0;
+		return 0;
+	}
 
 	devices_info = kmalloc(sizeof(*devices_info) * nr_devices,
 			       GFP_NOFS);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices
  2011-07-27 10:59 [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices Andy Whitcroft
@ 2011-07-27 11:09 ` Andy Whitcroft
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Whitcroft @ 2011-07-27 11:09 UTC (permalink / raw)
  To: Chris Mason, linux-btrfs; +Cc: linux-kernel, Andy Whitcroft

Bah, this one leaked out with the wrong bug number attached.  I have
resent it with correct attribution.

On Wed, Jul 27, 2011 at 11:59 AM, Andy Whitcroft <apw@canonical.com> wrote:

> BugLink: http://bugs.launchpad.net/bugs/803815
> Signed-off-by: Andy Whitcroft <apw@canonical.com>

-apw

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices
  2011-07-27 11:01 Andy Whitcroft
@ 2011-07-27 14:25 ` Josef Bacik
  0 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2011-07-27 14:25 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Chris Mason, linux-btrfs, linux-kernel

On 07/27/2011 07:01 AM, Andy Whitcroft wrote:
> 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.
> 
> It seems more appropriate to indicate we have no writable space.  Note
> that this does make df return 0 free blocks on a read-only device.
> Whether that is reasonable is debatable.

No it's not, it's wrong.  We should just look at the devices in general
and not just the rw_devices.  We can still get the right info out, if
you mount a ext* fs ro you still get the right output from df.  Thanks,

Josef

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-27 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-27 10:59 [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices Andy Whitcroft
2011-07-27 11:09 ` Andy Whitcroft
  -- strict thread matches above, loose matches on Subject: below --
2011-07-27 11:01 Andy Whitcroft
2011-07-27 14:25 ` Josef Bacik

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).