From patchwork Fri Sep 29 07:20:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 9977155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B1CF6034B for ; Fri, 29 Sep 2017 07:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0593629612 for ; Fri, 29 Sep 2017 07:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC595297F1; Fri, 29 Sep 2017 07:21:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15FFD29612 for ; Fri, 29 Sep 2017 07:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751801AbdI2HVU (ORCPT ); Fri, 29 Sep 2017 03:21:20 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:40801 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbdI2HVS (ORCPT ); Fri, 29 Sep 2017 03:21:18 -0400 X-IronPort-AV: E=Sophos;i="5.42,451,1500912000"; d="scan'208";a="157763424" Received: from mail-bl2nam02lp0088.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.88]) by ob1.hgst.iphmx.com with ESMTP; 29 Sep 2017 15:21:17 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=JwufcAS1g9Hi2A1YUrDWRy4VbtDDga2SbVUVGgbC3bs=; b=FcLv+zCuhXr4Q9ACxR/TKU6Y7BHx4YZMqJSc3/X4tlfHu6ZsGIpw6qR5Z9t3j+uWggu/HL6XX7ZCI4ZAD3msObjSmMDy97ukPNkV92ku+U5DNeGq3iENGbQOfMJIaGZ8AQZgqaXuvfmQyMfJDaxHD83znkn4Kjbe9q1PhXBTbKE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Naohiro.Aota@wdc.com; Received: from naota.dhcp.fujisawa.hgst.com (199.255.44.171) by CY4PR04MB0662.namprd04.prod.outlook.com (10.172.136.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Fri, 29 Sep 2017 07:21:14 +0000 Subject: [PATCH] btrfs: fix max chunk size on dup From: Naohiro Aota To: linux-btrfs@vger.kernel.org Cc: jbacik@fb.com, clm@fb.com, dsterba@suse.com Date: Fri, 29 Sep 2017 16:20:51 +0900 Message-ID: <150666965116.9802.15216393306253897797.stgit@naota.dhcp.fujisawa.hgst.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [199.255.44.171] X-ClientProxiedBy: BN6PR16CA0045.namprd16.prod.outlook.com (10.172.26.31) To CY4PR04MB0662.namprd04.prod.outlook.com (10.172.136.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 769f1182-ae5d-4cd1-6468-08d5070aac38 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:CY4PR04MB0662; X-Microsoft-Exchange-Di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shGsENHGsRuEmMa7+/lKNTHp41IAgHrHGmS6PtOqNqfiCddAAL3ahmtvx3D1uARURn7ei/xiHx3SHQ+pfDYbMO+/I7m1qNj+eYpEH+woWi5HjsmvjIlKVx04bjhR2kyagNovhFHMESXF23iyrQYWxMvApylolCitkLbZKg5cT82NcpBofsDVRaxrzxQWfmlf+hu9K4/cImNyQSjYAak8IVsW1KI/0hH6ujIlKILy14DW3LiMkmc9sB3OBY67nAijrCE0Hmc3ZVrP/jHUebqh55PH6tNE/frTm2Wa+6lRRqrwlP3gUNo3hYwBwWUQDoREwA4tgep2ldvmrTCkfgiFT6DWLap43oVZJObU311Qf3QmiUra37JaqwbzY/MnFMn7xSnOv; 4:hjIfvvcgfVq796i4XwA8y5Z9cqmJhciEgYai2jb1ek42mEYmZLbnn3KMDPXS6p6e8FGfIln9UX8AUr8sXQYdLRhK0lvEmncOYfTjg7BihL/1dVCdUYAXceHPO2vbIFLmGd6lP2MO9ExoXOzEOJCKsR8Nvc/izFwQLXIU7XWk5+sG5qW9EL0HzmeKAoxYzkz0Wzee06B4x2u6mi3+eMK4J0YbuUr1TErJYU/zCH1gaH4TKHnL5jkx48FxyEke4aR0 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR04MB0662; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR04MB0662; X-Forefront-PRVS: 0445A82F82 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(346002)(376002)(199003)(189002)(33646002)(5660300001)(2906002)(8936002)(97736004)(6666003)(58126008)(230700001)(16526017)(25786009)(478600001)(6116002)(3846002)(83506001)(4326008)(50466002)(6506006)(68736007)(53936002)(106356001)(54356999)(7736002)(103116003)(50986999)(305945005)(23676002)(9686003)(55016002)(86362001)(66066001)(2351001)(6916009)(316002)(72206003)(81166006)(81156014)(189998001)(105586002)(8676002)(2361001)(47776003)(101416001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR04MB0662; H:naota.dhcp.fujisawa.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA0TUIwNjYyOzIzOjhQMDM0TWtPSXZ5ZlJtZ0I0MEdOZ0tUemY5?= =?utf-8?B?UHVkUG1POGdFV0xyem9rSnIzOWFPRnVSNldMYkNKbEtJSG42UWZ2T05tUDBw?= =?utf-8?B?M1NzbXJIdEpNT0M5MkE2RUxpZ2pnRXpxN3c0UnJqMWYzMHI0YkZnK3RsbzJE?= =?utf-8?B?a3VZOHplMzYrL0w5V3J3aCs5OFZCVW9MUk93MUlGblptKzBNN2tJQ1l0bUNU?= =?utf-8?B?RzVxVWdsZVBVaXM3eDBISWNNeUJKYmtRUDJ1VDdpYU5ySG5KUmwxTUZXWU04?= =?utf-8?B?UStGYTJpQkZ4VjFUcGE5VW5KUlBNbTdJNUFwTWd3c1VYUTNORFNtY3B3VTV2?= =?utf-8?B?NHg4aDJiQWFTc1RaN1d5eTJJaXovVXQ5d2hHZ0hpOFNlbGtjelNCZWdJZG5F?= =?utf-8?B?ZmE1bVUvUUdDSVJmK1JwT2F1TnJGaFl6WDBpOG41SkJ5akxwcXZBQjFJMDll?= =?utf-8?B?T0pGa1VPQ2ZaakhYTmtRZEFWRVB2aWh4QmxtS2hCM3VpcTJEdUY3aGpEc0ta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yk9GNTdURkxMeGVmU3pqVHJl?= =?utf-8?B?a2ZkTFdDNElBOWhCSkpEYzg5Qm5COTkxN1pFT1VXSThpcGVjMmVRaFhBb091?= =?utf-8?Q?9kHUUuMuKVfnLn/kXZgE45vh0=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR04MB0662; 6:N+SkzJme6RqCfshtIMSXtTzuSujcHIBsOFZHGcj76UhFNx5xSW96K+AwtiZzzdiXZbNj/ti6EzEelpLNPoIthhdkvpqnq/SD4jfloLweUPaEs9ciMjhyyI1AU2ecF4RKklFBwoTTmwmfYzLufYupdbr6xBIUsgk2EnhEKsrwctcf0lJ40u3ELaRPDZSjh7fC71v39aB2iRh/UYV9yYHCSSyVy0ODewzouUN+l/E6/CtCw0tlUgSm7YzV6HczSmCYPa+iY619l50MU83sUeZdTxonNgshFqbWGYan9lFitTm5dB9SH/kvTGojDkJ8pOsXYg3rWsvaRlSiY8qZGI5deg==; 5:qeYf1Son3rHpSM8lq1lzuaK70kJiENf1SAykmaoVhRqKBveorIrt2/+3LZHAJdEBIRufY+Ve+Aj7oPT5PW/o+OmmbzdUIbZZs/n5FoiDXBxlZh+jtMGUq4uCUuBvJsGS2+pWST/DfeQ3Qrxja582TQ==; 24:k2ccIButPT4z20NClrAVOENjjsc0LnnqXkMvYohGsE2uYuyMRd9h4OZxZ2v8BhRECxuI9J0LKQhp51MZEIh2xJw8BxUJxNFwKdwyW5+pjro=; 7:2fumso8MMMaawejPVJ+pCGEA4EXTARD+mlRDwEalx/gmCyRUoG+rOk2D9EUuZT2rVqAH+UrhrYhn+Vd6ofIGFA1TQqTrLAVj3HnHtPhfuCJbKriM6RVimpshAgHWd9KmwVXdiQ/7Bu/0pJJvsdfLEE/jDSQXQwzDdZwtXP/wZtumAw1d3IqatMxd6wNeCDjr952UNqvtPFgCfg5du/sBL0N/SwaJ26NjaaRdrG7OKtY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR04MB0662; 20:ocviW0v5QlbaBHQdWrkyKzoowZK/g6SYxE/fQjypYeSeEijSwKDjmhY1VpEFfnfplAkgGQvwPBlehK2NxwCLD5jqtV5TLf5tDQNilCVx2hrWYuHctttPY1Gk7bjV/UvbeZZzO16eHoWMeGoP1RH39wpnyWjffJCpmTqeLzFUVhs= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2017 07:21:14.9018 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR04MB0662 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Balancing a fresh METADATA=dup btrfs file system (with size < 50G) generates a 128MB sized block group. While we set max_stripe_size = max_chunk_size = 256MB, we get this half sized block group: $ btrfs ins dump-t -t CHUNK_TREE btrfs.img|grep length length 8388608 owner 2 stripe_len 65536 type DATA length 33554432 owner 2 stripe_len 65536 type SYSTEM|DUP length 134217728 owner 2 stripe_len 65536 type METADATA|DUP Before commit 86db25785a6e ("Btrfs: fix max chunk size on raid5/6"), we used "stripe_size * ndevs > max_chunk_size * ncopies" to check the max chunk size. Since stripe_size = 256MB * dev_stripes (= 2) = 512MB, ndevs = 1, max_chunk_size = 256MB, and ncopies = 2, we allowed 256MB METADATA|DUP block group. But now, we use "stripe_size * data_stripes > max_chunk_size". Since data_stripes = 1 on DUP, it disallows the block group to have > 128MB. What missing here is "dev_stripes". Proper logical space used by the block group is "stripe_size * data_stripes / dev_stripes". Tweak the equations to use the right value. Signed-off-by: Naohiro Aota --- fs/btrfs/volumes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 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 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0e8f16c305df..d1ac3e1fb753 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4751,10 +4751,11 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, * is really going to be in terms of logical address space, * and compare that answer with the max chunk size */ - if (stripe_size * data_stripes > max_chunk_size) { + if (stripe_size * data_stripes > max_chunk_size * dev_stripes) { u64 mask = (1ULL << 24) - 1; - stripe_size = div_u64(max_chunk_size, data_stripes); + stripe_size = div_u64(max_chunk_size * dev_stripes, + data_stripes); /* bump the answer up to a 16MB boundary */ stripe_size = (stripe_size + mask) & ~mask;