From patchwork Thu Feb 12 14:43:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 5820161 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 AE19DBF440 for ; Thu, 12 Feb 2015 14:44:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 946662022A for ; Thu, 12 Feb 2015 14:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 640FD201C0 for ; Thu, 12 Feb 2015 14:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755522AbbBLOnz (ORCPT ); Thu, 12 Feb 2015 09:43:55 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:31634 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755348AbbBLOnz (ORCPT ); Thu, 12 Feb 2015 09:43:55 -0500 Received: from pps.filterd (m0004347 [127.0.0.1]) by m0004347.ppops.net (8.14.5/8.14.5) with SMTP id t1CEgDLR007470 for ; Thu, 12 Feb 2015 06:43:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wit.ai; h=from : to : subject : date : message-id : mime-version : content-type; s=mx2; bh=dsmXQ0iwJW62W4c5805LEO4YS+ohieqUB2Twp6uWD3g=; b=VZ15q4lksQeJUyKtyr2mytkE45Nv9dTYzkeStW+ptj2y/Am7LuRwE2yy2irkGxRTVBwc LZosBw7gSsNfdiCZQiowh4dYHILNKp0F/VZgjkzeaf1o5KzssLJcCatpeEWLhiEr6tLS 4HPLXht3k4V+ZxMHQrOVMxZCGmD0cOgb10QVrCWdsxAGags6kWaWFS3HdmTzzrwkrx65 g+612WKaXPmEwTkxvlbn3sKYfuZqaJwjA42MCl3htTffsnrDeVS5YQPrIKUGwZWT17c/ QkwMY4LFW3EvqKTpGhmO2iGy7RCoC4vLwpbtD+L6YZ5zyFYfwYatEdGYKaNRQTZE2zAP IQ== 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=dsmXQ0iwJW62W4c5805LEO4YS+ohieqUB2Twp6uWD3g=; b=RuyHcm/xj+7LF6vRCFi+9uaYAiL+Qg8NA15ZEJSG2qhEsXhDruzBZsmqAl5E22rBRLtU e5EcW9NFJxKriia8CE1VFq3GsbBtc0cNx/4fq6Ue80+McLW5JjOsQldpkP6mKRH8xOx4 aCR3mrqoRESeD513Qx4O1NMEFru0NTMAHUU= Received: from mail.thefacebook.com ([199.201.64.23]) by m0004347.ppops.net with ESMTP id 1sgtnr8bqh-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Thu, 12 Feb 2015 06:43:54 -0800 Received: from localhost (192.168.57.29) by mail.thefacebook.com (192.168.16.16) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 12 Feb 2015 06:43:52 -0800 From: Josef Bacik To: Subject: [PATCH] Btrfs: abort the transaction if we fail to update the free space cache inode Date: Thu, 12 Feb 2015 09:43:51 -0500 Message-ID: <1423752231-16864-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [192.168.57.29] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-02-12_04:2015-02-12, 2015-02-12, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=5.55111512312578e-17 kscore.compositescore=0 circleOfTrustscore=502.112 compositescore=0.996334338755742 urlsuspect_oldscore=0.996334338755742 suspectscore=3 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=62764 rbsscore=0.996334338755742 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1502120148 X-FB-Internal: deliver 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 Our gluster boxes were hitting a problem where they'd run out of space when updating the block group cache and therefore wouldn't be able to update the free space inode. This is a problem because this is how we invalidate the cache and protect ourselves from errors further down the stack, so if this fails we have to abort the transaction so we make sure we don't end up with stale free space cache. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index eb30b90..071f515 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3211,6 +3211,8 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group, return 0; } + if (trans->aborted) + return 0; again: inode = lookup_free_space_inode(root, block_group, path); if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) { @@ -3246,6 +3248,20 @@ again: */ BTRFS_I(inode)->generation = 0; ret = btrfs_update_inode(trans, root, inode); + if (ret) { + /* + * So theoretically we could recover from this, simply set the + * super cache generation to 0 so we know to invalidate the + * cache, but then we'd have to keep track of the block groups + * that fail this way so we know we _have_ to reset this cache + * before the next commit or risk reading stale cache. So to + * limit our exposure to horrible edge cases lets just abort the + * transaction, this only happens in really bad situations + * anyway. + */ + btrfs_abort_transaction(trans, root, ret); + goto out_put; + } WARN_ON(ret); if (i_size_read(inode) > 0) {