Andy Whitcroft
2011-Aug-01 13:38 UTC
[PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Josef Bacik
2011-Aug-01 15:24 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
On 08/01/2011 09:38 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. > > 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>Acked-by: Josef Bacik <josef@redhat.com> Thanks, Josef
Jonathan Nieder
2011-Nov-28 12:11 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
Hi, 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![...]> BugLink: http://bugs.launchpad.net/bugs/816770 > Signed-off-by: Andy Whitcroft <apw@canonical.com> > ---Fixes http://bugs.debian.org/649847 Tested-by: Ivan Vilata i Balaguer <ivan@selidor.net> This patch fixes a regression introduced by 6d07bcec969a ("btrfs: fix wrong free space information of btrfs"), which hit mainline in v2.6.38-rc1. Josef Bacik acked the patch, but I can''t seem to find it in linux-next, linux-btrfs, or Josef''s btrfs-work tree. Maybe it was just forgotten. What can I do to help this patch get unstuck?> 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 >
Andy Whitcroft
2011-Nov-28 12:24 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
On Mon, Nov 28, 2011 at 06:11:06AM -0600, Jonathan Nieder wrote:> Hi, > > 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! > [...] > > BugLink: http://bugs.launchpad.net/bugs/816770 > > Signed-off-by: Andy Whitcroft <apw@canonical.com> > > --- > > Fixes http://bugs.debian.org/649847 > Tested-by: Ivan Vilata i Balaguer <ivan@selidor.net> > > This patch fixes a regression introduced by 6d07bcec969a ("btrfs: fix > wrong free space information of btrfs"), which hit mainline in > v2.6.38-rc1. Josef Bacik acked the patch, but I can''t seem to find it > in linux-next, linux-btrfs, or Josef''s btrfs-work tree. Maybe it was > just forgotten. > > What can I do to help this patch get unstuck?I had completely forgotten about this one. I wonder where it did get to. I seem to remember testing this in house successfully. -apw
Li Zefan
2011-Nov-29 01:26 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
Andy Whitcroft wrote:> On Mon, Nov 28, 2011 at 06:11:06AM -0600, Jonathan Nieder wrote: >> Hi, >> >> 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! >> [...] >>> BugLink: http://bugs.launchpad.net/bugs/816770 >>> Signed-off-by: Andy Whitcroft <apw@canonical.com> >>> --- >> >> Fixes http://bugs.debian.org/649847 >> Tested-by: Ivan Vilata i Balaguer <ivan@selidor.net> >> >> This patch fixes a regression introduced by 6d07bcec969a ("btrfs: fix >> wrong free space information of btrfs"), which hit mainline in >> v2.6.38-rc1. Josef Bacik acked the patch, but I can''t seem to find it >> in linux-next, linux-btrfs, or Josef''s btrfs-work tree. Maybe it was >> just forgotten. >> >> What can I do to help this patch get unstuck? > > I had completely forgotten about this one. I wonder where it did get > to. I seem to remember testing this in house successfully. >This patch has the same problem with your previous one, that it will set f_bavail to 0. I''ve sent out a new patch yesterday.
Miao Xie
2011-Nov-29 01:55 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
On mon, 28 Nov 2011 06:11:06 -0600, Jonathan Nieder wrote:> Hi, > > 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! > [...] >> BugLink: http://bugs.launchpad.net/bugs/816770 >> Signed-off-by: Andy Whitcroft <apw@canonical.com> >> --- > > Fixes http://bugs.debian.org/649847 > Tested-by: Ivan Vilata i Balaguer <ivan@selidor.net> > > This patch fixes a regression introduced by 6d07bcec969a ("btrfs: fix > wrong free space information of btrfs"), which hit mainline in > v2.6.38-rc1. Josef Bacik acked the patch, but I can''t seem to find it > in linux-next, linux-btrfs, or Josef''s btrfs-work tree. Maybe it was > just forgotten. > > What can I do to help this patch get unstuck?I think We should make this behaviour similar to the traditional file systems, such as ext3/4. That is the available space should show the size of all the free space which we may used to store the file data, even we mount it on the read-only mode. This patch didn''t fix the problem completely. Thanks Miao>> 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 >> > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ >
Jonathan Nieder
2011-Nov-29 06:01 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
Li Zefan wrote:> This patch has the same problem with your previous one, that it will set > f_bavail to 0. I''ve sent out a new patch yesterday.Thanks for the quick feedback. That makes sense. (The new patch is at [1], for reference.) [1] http://thread.gmane.org/gmane.comp.file-systems.btrfs/14584 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Andy Whitcroft
2011-Nov-30 15:40 UTC
Re: [PATCH 1/1] btrfs: btrfs_calc_avail_data_space cope with no read/write devices V2
On Tue, Nov 29, 2011 at 09:26:01AM +0800, Li Zefan wrote:> This patch has the same problem with your previous one, that it will set > f_bavail to 0. I''ve sent out a new patch yesterday.Ahh, sounds great thanks. Often a patch is a good way to start a discussion to a more correct patch. Specially when one is not an expert in the area. -apw