From patchwork Mon Aug 1 13:38:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 1026002 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p71DdAgl028298 for ; Mon, 1 Aug 2011 13:39:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753101Ab1HANif (ORCPT ); Mon, 1 Aug 2011 09:38:35 -0400 Received: from adelie.canonical.com ([91.189.90.139]:35694 "EHLO adelie.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978Ab1HANie (ORCPT ); Mon, 1 Aug 2011 09:38:34 -0400 Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QnshU-0005D6-O4; Mon, 01 Aug 2011 13:38:32 +0000 Received: from [85.210.144.167] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QnshU-0004yg-KE; Mon, 01 Aug 2011 13:38:32 +0000 From: Andy Whitcroft To: Chris Mason , linux-btrfs@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andy Whitcroft 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 Message-Id: <1312205910-13053-1-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 01 Aug 2011 13:39:11 +0000 (UTC) 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 Acked-by: Josef Bacik --- 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,