Message ID | 1479150382-19273-2-git-send-email-jbacik@fb.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show
Return-Path: <linux-btrfs-owner@kernel.org> 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 EBFA2602F0 for <patchwork-linux-btrfs@patchwork.kernel.org>; Mon, 14 Nov 2016 19:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFF0728A66 for <patchwork-linux-btrfs@patchwork.kernel.org>; Mon, 14 Nov 2016 19:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D495028AA4; Mon, 14 Nov 2016 19:06:43 +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 5F1C528AC5 for <patchwork-linux-btrfs@patchwork.kernel.org>; Mon, 14 Nov 2016 19:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753758AbcKNTGi (ORCPT <rfc822;patchwork-linux-btrfs@patchwork.kernel.org>); Mon, 14 Nov 2016 14:06:38 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:49705 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933841AbcKNTGg (ORCPT <rfc822;linux-btrfs@vger.kernel.org>); Mon, 14 Nov 2016 14:06:36 -0500 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAEJ4NWr028058 for <linux-btrfs@vger.kernel.org>; Mon, 14 Nov 2016 11:06:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=CPkkylFBeBq2bJ4w2i188BB53sxdrQQbhE9iCZxWvHc=; b=BFmCfxdGetIcpjJUnRVXxMQgge4jp8NzWH+NWMWZOiT46HrnvKCRGqoVsuY5vAmjlG0b bSOOiyA7jFkGc6VN/KMbcLbmij8ZLp/1vl/7picWs8H0/L71rpULnndrTb5yZUghoF6/ 8A+zCkaqG9i/U6V0MoF86Uas7KAIgncrL1Q= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 26qjtr8445-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for <linux-btrfs@vger.kernel.org>; Mon, 14 Nov 2016 11:06:35 -0800 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.30) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 14 Nov 2016 14:06:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=isgQD+H5SP+HaHzUc7G32eCQI+SsQN2mHdS5oDbhGiI=; b=kOwyyhyD0qhWMokQlom5/zEIfOxauVX17d1O/Bwyao5yMdPtMtuN2Cd1zWBLIBcsk+u15RCDkz2T8niTWy4uecYAHP+PSPFRlizBZ+GWGU8CbOtrJ2l+k7AgXY4vJhg7aAM41klPdqitg4vw01Ukk7h7FBApDYhLPIQ9eXdBOXw= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by MWHPR15MB1326.namprd15.prod.outlook.com (10.175.3.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Mon, 14 Nov 2016 19:06:31 +0000 From: Josef Bacik <jbacik@fb.com> To: <linux-btrfs@vger.kernel.org>, <kernel-team@fb.com> Subject: [PATCH 2/2] Btrfs: abort transaction if fill_holes() fails Date: Mon, 14 Nov 2016 14:06:22 -0500 Message-ID: <1479150382-19273-2-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479150382-19273-1-git-send-email-jbacik@fb.com> References: <1479150382-19273-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: DM5PR18CA0051.namprd18.prod.outlook.com (10.168.111.141) To MWHPR15MB1326.namprd15.prod.outlook.com (10.175.3.140) X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1326; 2:V6n316o6zRwvOacZAVGKRe/Snehb2qZ1ZH5f5KzeAqzR2/c1rdKLtHc7pL+mEyhjNA7Xut8b+ndXMIRyC06+AcwBPb3fe9hsMiUeRNW3iJ07g5TW8LiJpLoyGhvoAOcyk7gPfnEWuebZtYG3k6Xb5Z9gqViEoyfGT4t2vRPQNPw=; 3:Yy/2+fz1JwaReGL10Me4f7lviR8B9NHIU9tCJQ//hyzEPlUQ0k1hmr1IhJxxUJ7lsvIMmNf5YXVATGJ6unLleTFP8I9S92kg1P19pbUJuBf/pgZIKot4D57QpnBOb/kKrWWHd1bCGl6IonBuoEXwAyrHtEaBszf60Nt1POVtEZk=; 25:pAsgLIrnZMz8s8isPDt+CLusjxzNi/PPxEG55mCXoCIoxASD1wmlynU16QKMSa74RRAH08ZVoUf5Y0AkvxZl9MHT69PzoQZXlpQkyqeO4Ym9WmusDqu9YD/zOj5pDwQrHxd9B9U6hkI3LE9wkrWaWLpyvEts/fUWKhGGa62ef7fIHkAsObGDthGsVZ+s2QOf4+oA6PXcIzfeR0q+3PXd+laoRM2jcXNl0qUSb5pbFdhJc+DXdURoArDh3469xVL/l05Uz69SwQ/7LL3R1Rpih4w8Qu0yNZeXJFMDxMs8vB/tKjy9lGrhbhJVY6Z5akVkpTcAAt2ODFmc8kppSdaBmsz5PuwikzkTBTMulfQngYoHzVLMjzOEz2X9StFyf7dJy2XMwrRzsZjCrjhdirHPXvXz6EqeP2dCfqqKoM6KDDs6Ji8QScGCuMyPiLaIXAC9 X-MS-Office365-Filtering-Correlation-Id: ac8d2276-ef15-48e6-feb3-08d40cc15861 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:MWHPR15MB1326; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1326; 31:Mr9S6922zkt221DtCz//U2DqtofyKP9rIQF32JNTPzgqzKHI7eDKNnwPHhXw5WZCePwLQUoBkV9TH6ciGnazmL0iWXwKdpCq/lDxM7hlwLl48kGL0OfElemeoLRB7ekL1x0EpnMADX5DGBko0XMQ7SCzHVSx7T60Wa+nzlCsdsaZuRvSqVmdcpFfpxAwvPJcdoBDkViRU4xvxkMrsscnEqVVTaZK4K7OrFxOo/YSn+1FcnNyfQYugujk4rrIPtmfJwX4M0jF92GcXyF7pw0fead6A90XVhqhRB//BUbyj+U=; 20:15nipbW6QQj1XScLJ2Y3Sgn8iDp7IkIXfeLvrYiyXNUYLdsf3oeCwgMWVK1/34pBFqZ4POiZTchTELFflREYBVz8zXhT97JiTPWmZak/RMJLEWqY8JQlCcgzwhnLW/GcLxswQ4ENWEYY6fnxUzdOgvq+/uRI4m1zb7zOM3J/xChL8z4eyn5SF4KpmV+pxu3NGCOFX70wutZUFsmbAqKeJEvplDLoihcP6PqTfvzfL0e64vcU4gUmL1nP1HKq7VBf X-Microsoft-Antispam-PRVS: <MWHPR15MB1326F09ABFA744A37DAA3487B9BC0@MWHPR15MB1326.namprd15.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6061324); SRVR:MWHPR15MB1326; BCL:0; PCL:0; RULEID:; SRVR:MWHPR15MB1326; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1326; 4:aH9fNDU+davp5HnpkcBJ7pWob354L0RG7b5CfPM+HrIXmB2iMgsCBdE4Xzxm4BrYT7sNH+gSDFdwMGE0dX9TaAzRgdpmJVdKN+zrZTflDyc11prU5w6XnLkOHfOi4C5IpVSFmqxfmFCMeDSvH9MT1TwD4s+V81oXl8mWy0Mq8owMFMcQNhSLmxOlq7xQmQuRgnbR78Sq1sWYB1I9vkYUsYDcyhqB8eqXWMnQTQosIbeozQuBbIVfcaurOZ88bm+W2046PG9VyDuGWQtfhAGwstmgwJ9Id+GjQeVGUgUR0dW0/TW1JU9I8FS73p9WGE/GtFkI+/cuBPXaweHQwYx1U312XjVP/O56OMkoenS6OIG/h9kJ51ZW63Ixb+9d+n0fZRKKrObjgIzY7vwAmgNwV6L+mHmgu7nkYe2VoliKybH+70K7xV4XcyPWsx0OkneP3efeGV5odjuzpfQbmX4Nvw== X-Forefront-PRVS: 0126A32F74 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(47776003)(8676002)(305945005)(81156014)(81166006)(97736004)(5001770100001)(7846002)(6666003)(77096005)(189998001)(7736002)(107886002)(48376002)(68736007)(50466002)(5660300001)(50226002)(551934003)(36756003)(105586002)(33646002)(101416001)(2906002)(76176999)(76506005)(50986999)(86362001)(42186005)(450100001)(2950100002)(6636002)(6116002)(106356001)(5003940100001)(92566002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR15MB1326; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR15MB1326; 23:mJNTxoljV6leZtJg9c7niPiFQ5D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fFEHKNTPxdMJCNVq2xUaTmfvkeusBSoWioS0Yoqx8e?= =?us-ascii?Q?zW7ie+tMpd9jZYYdChQ8FsSHOBuccYIeLb0R0fgvhstP2hftWS8cZsca3+YU?= =?us-ascii?Q?6ixTz5B9dbS4WsoZeVOqKgEVkPkvyEaOd2Zcx/SGAixiSX03eBHi/25fUuf2?= =?us-ascii?Q?4UNqn7mgbMhhPNBFW8IvOjpA+8+?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1326; 6:hR3wuKxTWaJHV0/HfPpylzvex6aycrHrw2S2hSar7pDmuF9cQsWGyUssAQ7I+2EeeDqURSBgo+cl4mfqRGRYl0f+aUAZqTjY95iC8eeN4Nu/Mah7QVJTol1HimQs15anrBtf7wYRvNEZ91UAbFve5c+RK2Ath9UA2NQFj/nQkhcgd8Yh5sYmXocJbz9g47UC4fRfhglRYKb8j/Fr+gJAGZKwkSh7FHPKU3m24jybcDFHljIXcEhrcX+5x68BP82O3ufqh6T7haniuE2Ayxqry28zl4CvK8KM+zQAH5lKUvyqzX3bNaAAjf6ZZ4OFNo87O703EB57UcQmOqmjT04xeg+5SrbRUNxjNJqick7za00=; 5:vXyr34uEGuQjUbBUQGMH9xJ5vI3BUpemrkTeqoFET/LD6uVkcF7Sc1dAQSvTqkYp3bgv0QIlNfXc7gbJ0SlV7eF1rMTY1J1F7cT+lgHUMHD14A/ZBvIFtNTegiNMpQ3+GnTJNjCWHmCaxy/gW0cnHw==; 24:WLUNj3lJtuwfm+NnMIYj3P6rgznQcUMJj1Uubdh3Yof5BGXF62tuGAWOAlp/Odb0BVDb2TdN8PFhGqR3/9+UbEY0m1FPvu6m6rb7r2agOXo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1326; 7:Qka6EMnbDS0+PMhnni8aRP9Fd3dpO1FxWBR8mLITyIfR6NUH5RytcDij+OabI4+k/4chehlnWxc6qiImZ/s688z9XCfKGFYNChx+j9Z+ZfiQPNQ3FIBu3ckzSNhUrHuppbUXXAHrL5pgGeGt80DszXGEiewsML1R5SmzVqNDgW4ptG3GcL8hQRmLBC0G5bkOxzW3ibALkjgQmZDytZu1f00H5oJsA/YIeNTN0/A27LwtAjuw9Ufhbm8Z0MeAm1b6bc4wK435nCBoSxNYNfY6+TXQ8vgyXu858RFIVY/BJq681j2zwEea6AZd2TSRW+q6VUSml2XaipCCBh+DrzeXvzFONiK58HB77ZmNhGA5wvI=; 20:ehX9/8YWlL26RkZlLtmD9vimidJzOCZPs3jukt1etzInQjw1x/kF6CW4Bf8t9x0in/WXVxWTTIshsFaSGe0TUzXcyTOCkiMixjGTHRZrC25hImLqj1Z0bKkrUCsPmIdTHpNEuoRpG5NEFKYf/Vk8zS3roH1QVZoxwXsJs9Zl7Zs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2016 19:06:31.4769 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1326 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-11-14_12:, , signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: <linux-btrfs.vger.kernel.org> X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 1c15a98..d6fc719 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2234,9 +2234,14 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode, key.offset = offset; ret = btrfs_search_slot(trans, root, &key, path, 0, 1); - if (ret < 0) + if (ret <= 0) { + /* We should have dropped this offset, so if we find it then + * something has gone horribly wrong. + */ + if (ret == 0) + ret = -EINVAL; return ret; - BUG_ON(!ret); + } leaf = path->nodes[0]; if (hole_mergeable(inode, leaf, path->slots[0]-1, offset, end)) { @@ -2539,6 +2544,12 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ret = fill_holes(trans, inode, path, cur_offset, drop_end); if (ret) { + /* If we failed then we didn't insert our hole + * entries for the area we dropped, so now the + * fs is corrupted, so we must abort the + * transaction. + */ + btrfs_abort_transaction(trans, ret); err = ret; break; } @@ -2603,6 +2614,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) if (cur_offset < ino_size && cur_offset < drop_end) { ret = fill_holes(trans, inode, path, cur_offset, drop_end); if (ret) { + /* Same comment as above. */ + btrfs_abort_transaction(trans, ret); err = ret; goto out_trans; }
At this point we will have dropped extent entries from the file, so if we fail to insert the new hole entries then we are leaving the fs in a corrupt state (albeit an easily fixed one). Abort the transaciton if this happens so we can avoid corrupting the fs. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> --- fs/btrfs/file.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)