From patchwork Tue Nov 3 03:23:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7540221 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 727EABF90C for ; Tue, 3 Nov 2015 07:03:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E0AA2088C for ; Tue, 3 Nov 2015 07:03:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B77A20890 for ; Tue, 3 Nov 2015 07:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754030AbbKCHBL (ORCPT ); Tue, 3 Nov 2015 02:01:11 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:56691 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752252AbbKCHBI (ORCPT ); Tue, 3 Nov 2015 02:01:08 -0500 Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Nov 2015 15:00:50 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id tA33Onkv022157 for ; Tue, 3 Nov 2015 11:24:50 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 3 Nov 2015 11:25:25 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 1/2] btrfs-progs: mkfs: Round device size down to sectorsize Date: Tue, 3 Nov 2015 11:23:36 +0800 Message-ID: <4372105ede489b71eec1af7720117900ddb6e427.1446520971.git.zhaolei@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.1 MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When do following command in a vm, whose disks are created by qemu-img create -f raw 11 2.6G: # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf # btrfs-show-super /dev/vdd /dev/vde /dev/vdf | grep dev_item.total_bytes dev_item.total_bytes 2791727104 dev_item.total_bytes 2791729152 dev_item.total_bytes 2791729152 We can see that the first device's size is little smaller. And it fails xfstests btrfs/011. Reason: First device's size is rounded down to sectorsize in make_btrfs(), but other devices are not. Fix: Round down remain devices' size in btrfs_add_to_fsid(). Reported-by: Qu Wenruo Signed-off-by: Zhao Lei --- utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils.c b/utils.c index d17291a..b7752df 100644 --- a/utils.c +++ b/utils.c @@ -736,6 +736,8 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, u64 num_devs; int ret; + device_total_bytes = (device_total_bytes / sectorsize) * sectorsize; + device = kzalloc(sizeof(*device), GFP_NOFS); if (!device) goto err_nomem;