]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: fix oops when calling statfs on readonly device
authorLi Zefan <lizf@cn.fujitsu.com>
Mon, 28 Nov 2011 08:43:00 +0000 (16:43 +0800)
committerChris Mason <chris.mason@oracle.com>
Fri, 16 Dec 2011 19:40:56 +0000 (14:40 -0500)
commit83bc1000d6ca71c24b5bbd87ff4e9966aa178040
treed0bbf3bf51a08b86b6d590f83441a48c341e048d
parent791ad57ae08d39883dcbe3d1184d58d7539f41e2
Btrfs: fix oops when calling statfs on readonly device

To reproduce this bug:

  # dd if=/dev/zero of=img bs=1M count=256
  # mkfs.btrfs img
  # losetup -r /dev/loop1 img
  # mount /dev/loop1 /mnt
  OOPS!!

It triggered BUG_ON(!nr_devices) in btrfs_calc_avail_data_space().

To fix this, instead of checking write-only devices, we check all open
deivces:

  # df -h /dev/loop1
  Filesystem            Size  Used Avail Use% Mounted on
  /dev/loop1            250M   28K  238M   1% /mnt

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
(cherry picked from commit b772a86ea6d932ac29d5e50e67c977653c832f8a)
fs/btrfs/super.c