From patchwork Fri Aug 10 05:53:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 10562255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00A8E1804 for ; Fri, 10 Aug 2018 05:50:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7D442B415 for ; Fri, 10 Aug 2018 05:50:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC5FA2B7FC; Fri, 10 Aug 2018 05:50:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 754972B7EC for ; Fri, 10 Aug 2018 05:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbeHJISG (ORCPT ); Fri, 10 Aug 2018 04:18:06 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57538 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725746AbeHJISG (ORCPT ); Fri, 10 Aug 2018 04:18:06 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7A5n3DN109389 for ; Fri, 10 Aug 2018 05:49:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=dAKUy9vVCL/IEKO36UHjNuMCaQnqikV4mhV4pw5TVQ8=; b=f/eA40W8cDinHX4qJN84CLUzCgLX/IEKFqBfaZg+6N37HJ8yucTgk/T+jYlRruVKDYel 6m96b5sdhJTjwrvCYCXe0+lwVMLWlZMf56FWi4q2gcYxdiJ3fE68zS4D3EE6zH6duLo6 PASg04b5oaxducQZXm7/UswlDqW85SGL6nbH81lXhUmJOw99JqJiE8M4ISV45J4d84GL 3n4NJdV3VJwuECvGBGBL4W84/V0xf6kRGR3WO6giArraPGgc2dBNXlCLfqYDoyPmlPP7 yx3YmFE/gtqrO2yTO/XHsvYjEcVw+XIDEgH1klZVgpVATMO6rsz1Tlhh/atl3GhmmVAp jA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2kn4sq5skc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 10 Aug 2018 05:49:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7A5njRj013728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 10 Aug 2018 05:49:46 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7A5njpj020188 for ; Fri, 10 Aug 2018 05:49:45 GMT Received: from tp.sg.oracle.com (/10.186.49.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Aug 2018 22:49:45 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/2] btrfs: assert for num_devices below 0 Date: Fri, 10 Aug 2018 13:53:20 +0800 Message-Id: <20180810055321.19730-3-anand.jain@oracle.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180810055321.19730-1-anand.jain@oracle.com> References: <20180810055321.19730-1-anand.jain@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8980 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=835 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808100062 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 In preparation to add helper function to deduce the num_devices with replace running, use assert instead of bug_on and warn_on. Signed-off-by: Anand Jain Reviewed-by: David Sterba --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b6d9b6a6fba7..0062615a79be 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1877,7 +1877,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, num_devices = fs_devices->num_devices; btrfs_dev_replace_read_lock(&fs_info->dev_replace); if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) { - WARN_ON(num_devices < 1); + ASSERT(num_devices > 0); num_devices--; } btrfs_dev_replace_read_unlock(&fs_info->dev_replace); @@ -3752,7 +3752,7 @@ int btrfs_balance(struct btrfs_fs_info *fs_info, num_devices = fs_info->fs_devices->num_devices; btrfs_dev_replace_read_lock(&fs_info->dev_replace); if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) { - BUG_ON(num_devices < 1); + ASSERT(num_devices > 0); num_devices--; } btrfs_dev_replace_read_unlock(&fs_info->dev_replace);