From patchwork Fri May 27 17:03:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9138767 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 76D8D6075C for ; Fri, 27 May 2016 17:03:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 699F427B33 for ; Fri, 27 May 2016 17:03:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C71A28160; Fri, 27 May 2016 17:03:38 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 B241127B33 for ; Fri, 27 May 2016 17:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756346AbcE0RDX (ORCPT ); Fri, 27 May 2016 13:03:23 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:42261 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756324AbcE0RDQ (ORCPT ); Fri, 27 May 2016 13:03:16 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u4RH2PUW009189 for ; Fri, 27 May 2016 10:03:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=zBdKpo5onRZkJ4jkHo27Bgi5YAa66o1qrwVs9krmdFI=; b=h17aYqYOBFPxiRwG53G9v2wK32meK+HLkjuXvM2JojoV1pfM1C6hXoWjQCsLp/JMm99i 1kwheo8vzI/c6DAPqkLLpHMBQpwT14xCcIXy8I1X0PPHYTBNbDw+KEiXCECujOTE9Yic ZnApUsP7Fmjaj49fRVsb1M3JO98c/Y3WFgI= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 236s3wrgqf-1 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NOT) for ; Fri, 27 May 2016 10:03:15 -0700 Received: from na01-bn1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 27 May 2016 10:03:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tM7F6lgDaA4aS2YySBwO1ot2JArUIR4Gz9zg0j0WrTk=; b=jyvT/BSSkkkAPTx9pQ7/cRw7OTY/X+hM3V/WxZpj5i9SHr3RodWzScYMBOaI5pQkHqJxwJBHK2X3FycaUmCSqFqNJQaIVYdjukwDagC6ll0R1H77Vo9yvkbLTJXsziSB4THdTV3DRItN0W4cgEi1YDCGDxgv9iZiifUaGfp9ZPg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=fb.com; Received: from localhost (107.15.72.49) by CY1PR15MB0844.namprd15.prod.outlook.com (10.169.22.134) with Microsoft SMTP Server (TLS) id 15.1.501.7; Fri, 27 May 2016 17:03:12 +0000 From: Josef Bacik To: , Subject: [PATCH] Btrfs: don't BUG_ON() in btrfs_orphan_add Date: Fri, 27 May 2016 13:03:04 -0400 Message-ID: <1464368584-3531-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [107.15.72.49] X-ClientProxiedBy: CY1PR20CA0084.namprd20.prod.outlook.com (10.163.250.52) To CY1PR15MB0844.namprd15.prod.outlook.com (10.169.22.134) X-MS-Office365-Filtering-Correlation-Id: 25f920f9-331b-4a26-1fde-08d38650c9cc X-Microsoft-Exchange-Diagnostics: 1; CY1PR15MB0844; 2:eOqkgPyFdm8L8s9VfTboSVuKmjzVLAmNUPKywKJXfN72wd/dMOuIDo7GlKxWVeTLUdj6htt/T7KIVc0Gb5C/SdDnFWIVXm+/Ut3zBqkbxKRRvYr8EAV5ctuxLKUwjMbiBbhtwsKuTekHv5yjBjorN9jo/cVu7QxgS7CUw51XzpY25WV9oUFEY3CeK6qhmw3z; 3://etBMzCMKycVqtwm5KQ+o0d9y6O8y5cRQb3GYBdZTzKEr17vIEGQDVI+ua7SqCiCTSMbKzpe56FKMBqAnXFDcqrnIdeLdCVuof1cBHjzCfJPgnZog1pZN8IKpzl6c+J X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0844; X-Microsoft-Exchange-Diagnostics: 1; CY1PR15MB0844; 25:3b7li+oxwEt5G185WB/JCgzaGsUjQmrXxbYIe/xsHOh0Ru9YL/PLdkJxvAXWHHh54FSE3jkMw39Z32btos4rdq5je0c6dl0bZO/IQgP8MgSkO2C4rj23MlnIGr3ahByyq+zPCDZBqZpmhHKgC8Qdy7xOXIw/cpmmj/Zkh8SPqIjWEHbVpwDf7/sg/TgJD4udYrzsMZ4udDsTkQY4R0TOGWebKkBfOMd43lOB5jOBqnXzA+sogXAgcNDAb1tcutZ0EtunNAx4CsTIoSbhB1T3f4QO4HzMTCPoRSTCwTPHfJ7/kXrmJox8RlRLMyBGdYu1DQM2qoOaDjD/bD0ugJBS7fnxPrdzYZcCRotUF9yfM+wBe8CHyrmrWuIURb9JDhH20EgeTKeE1rB8VbSPzuxzcbJg2dbBLphyLwJDQJB3O6Ubn7uSrQDMhoptCRVpUIkUByr2qKI1S8dMitH0Ih0x9mAglSBwjryFlNf1dL2zXQaww0m8sKmeO2eL0bqpU3qAKgCPrnYK2Zyr5zWUITO3aInSHz0365NdKXLOAIN1mG0s7pkDKEL578lPU4XMhXYrJpL3CaReDirN16vWebWukvtgBefexdHA2Q+wmpwBAE0JSPtLNyOh6aZX+94y9Ueswm0KS51koHaGL+D392YUwx6b5qwd7M7P4MYVoZ580mBPg0cnnpeA19FetBoFIJfDhjQUZRYI96S0klrGuMC9XHePNGSYfrY4I0HDB8EhqU8=; 20:SIsnRlP6BIhA7dtceOVUjHf9xXehQ3YWYOMlfRnccxOidwOUInVGyRNUtEVL4sCiexxk2IJwdCzROcpPKEUjFqXyCT47JzOxi8IjH3JWZB7S1UmBaHoImtM4vtn7kCDCFtu2gaMAMPFY1MBifczZ2yF0XNCZwqYxI/4x9DGhNjE= X-LD-Processed: 8ae927fe-1255-47a7-a2af-5f3a069daaa2,ExtAddr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:CY1PR15MB0844; BCL:0; PCL:0; RULEID:; SRVR:CY1PR15MB0844; X-Microsoft-Exchange-Diagnostics: 1; CY1PR15MB0844; 4:5u3NLOFJtM9HMdbb4iQbqZa9Wpd5Snu7PW0Z+gPXGRty/8LcnzbmVkgXekDZ61Py+uHle6tbocdeaDJ1XJuipJl+G3jpEX3BIVTebrXyqy9d4+ijFUuoQJp20VLxxqv/JNRFRJcVOjadaqn++gdpULBbD6qxhWQtIGiuKUymKWH8xVvnPypkpLu2fQ6Ifwp24wvvbkrfc/pDi5+Wryws04JSkKFD6q7Rmk73CoZlYqVFLdByct17crZy7dFv1Qx1N8cg1bN5uqJoEAqGB0YEJ4muy3j2c+Nt6xfyCo1ffohl17WiFsHZwS09rUjYodqE9VgFn2eCYIbHFcqqyKSEIh6dzU21Rw50DRCd4/2alJxMtkz+FPLwxkMQ5Vgcr+y2Rpzn8me38z+gmFtyX/7j40s89Ozc73CjysO84+458lI= X-Forefront-PRVS: 09555FB1AD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(77096005)(5004730100002)(92566002)(81166006)(33646002)(8676002)(229853001)(86362001)(3846002)(36756003)(19580395003)(19580405001)(50986999)(586003)(6116002)(107886002)(5001770100001)(5008740100001)(189998001)(2906002)(76506005)(551934003)(5003940100001)(50226002)(42186005)(50466002)(48376002)(450100001)(66066001)(47776003)(4720700001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR15MB0844; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR15MB0844; 23:Htq7eF8zsnsOX5eXALRLsVyTbFXFHhQ+kZhnDH4P1DA6T67ju3bYWaR7fGKxm2U7U10vl62zd4Z1BlSXmDFOex5fjWRlu0XIxN1JcjlqubFRH0FbUcR8Ix9O6kBAfWEJ73+QuUD8X17V2SJre3n7YmUEjCAPoMVAFRFn0VuUJtas2//IiwrDEVza1IXiQRnGQ32CEwCBKC6PxD6NP+opZuN56BsUqQVrV9O48zCoyme4Jg9l4EbQx8lig8dDmJ7EIPFnKDzJtWc46UdutlzS4cn/EDbMHo5YqNxxFGbmeu8sDRIYEbJwJXWZ1aYB3z5lwJXYDFY7wIso2Fg8Cvi3fayGoOKFA4y+C5rtQx+a2P7mDr5YcQnRMtg2WVY4K5Uwqvwctx/FHn5rpujJU51TUmHxQWtJuwFfdAgzgrzoWOW2vbMVlyYDBpaBT/wz+7q7Qn+f5klAZICMBR4iCVYve/NI9j7ZqWqf2wsyruVEK9gCZm1z4flh1Z3H69eU7fR5wTHXIHnEUkSvkthh1L6nqLxdYs2IaqQojlaHO8Kqw06FW8azTmTwFAk32EoM4lDqULCh2uimZdYBYef4LmDL/T1DjRpSuSUqhq0ITDAuwGAWRk797Tai3JfYGczNIb7v8Q+MiXlR6MSt3y9OzCisilJjsX20LsP+4OLmdE0yZOBEdlOzh4a8lcI7VrrM9dFiLZyiZfAX7z5e5HwQ5YmNC1UmRke+imvRtOOf+xGGcdbtVrCrUphJIKepFWV4h0y15EHXkN4iZzhL0l5UejPp/Oga7+0CzkJDFybHcoteLNUH/ntNeHSEij6gi9cVQ4uyF5YMzOcAVS2fxrOOBdgcmgIXiuI8poASJagOu4lCEPgs5bDjdP7OzH4U0mhTbGdedxyRdDeBJJ6HpnXvYXbvV2Du8v6Rj33+63o7bCRd/ TlSf1N4yOrKqhROAYT0KO3q X-Microsoft-Exchange-Diagnostics: 1; CY1PR15MB0844; 5:02wNE1bnsduOo3wqcF5AqeLWf/Ugoqq2j4zzge1j6/uth4j29Z+BTQiRyWf0WKgGIVyKhk5QDXtyT6QS448Ax4IZkpS1nMwjemMUYxkANSXtIVKYC/dryMLtP8tPiy0loLcFuiwFaTtM6wkwdvhh9w==; 24:VGbFtZ9M2yepCrHJknpSfYxnQWlS1hsTSRUK7vDlSNW7sUo3jTJIYVx0ALK2lFwoalPRqbWqa/8JrqTitW/I1uTl75XiiU+ckCTngkCk3Lc=; 7:7zVqjKPepQUnGMiptTcbk5bGUkGuhbDqQRCUEvv+Ca4qF6hfDKiyxGfYXCmsisAPNrCoIxEeKzP0FNKLMXyvJe/lTVoZU2XvQsnpfufQchVaPwziL9U1/Hno8tlBy15FZHOasSsXooyxqBASoOEFS6ZIr03rC49VRs6orBSvQCm/+2Ji2tIRsblQKtHOHT7q; 20:6lqOHBD/rx8648zDcAgh9dXpFLSjZxjwTN9gi5YWRJ+MvmIihpp1LAjyjsnnaHdxbJGP3B17IW1F3fALjTXj11Upe2iUgyJDHc3Y0IFbnpgutIpmnqP8XkyUKkDqf166/wubBkT1nUnW1jlG44ogCLEhJf5AOdjXw3GLovQ89RY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2016 17:03:12.8444 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0844 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-05-27_10:, , signatures=0 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 This is just a screwup for developers, so change it to an ASSERT() so developers notice when things go wrong and deal with the error appropriately if ASSERT() isn't enabled. Thanks, Signed-off-by: Josef Bacik Reviewed-by: Mark Fasheh --- fs/btrfs/inode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e6dd4cc..3c367a8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3256,7 +3256,16 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) /* grab metadata reservation from transaction handle */ if (reserve) { ret = btrfs_orphan_reserve_metadata(trans, inode); - BUG_ON(ret); /* -ENOSPC in reservation; Logic error? JDM */ + ASSERT(!ret); + if (ret) { + atomic_dec(&root->orphan_inodes); + clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, + &BTRFS_I(inode)->runtime_flags); + if (insert) + clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, + &BTRFS_I(inode)->runtime_flags); + return ret; + } } /* insert an orphan item to track this unlinked/truncated file */