From patchwork Tue Aug 25 17:09:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 7072221 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 D68D8C05AC for ; Tue, 25 Aug 2015 17:09:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1241F2075A for ; Tue, 25 Aug 2015 17:09:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38D6C20755 for ; Tue, 25 Aug 2015 17:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755668AbbHYRJr (ORCPT ); Tue, 25 Aug 2015 13:09:47 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:15534 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbbHYRJq (ORCPT ); Tue, 25 Aug 2015 13:09:46 -0400 Received: from pps.filterd (m0044012 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t7PH7M4t027847 for ; Tue, 25 Aug 2015 10:09:46 -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=D3EHYr6JcO+PgWab4fomYwKrzSXk05xI+aGahmS4lVc=; b=ExAqSK4uQ+f3fL3uOQSO8sOUKWwosrR6Kyv5kn6sNKQG9rGiOL0vlTxgLFjPJZusU0U4 E+Er7tvKvj6R/kBNi7aJ7GlZBEF0crA2Gnbe0ut13zcDKbEZGOsueA5Krp9mjmlnw1PK F1h13B8BtYGvMoWTeOdG3bIMnvssbyUJTUg= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 1wgv4202a1-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Tue, 25 Aug 2015 10:09:46 -0700 Received: from localhost (192.168.52.123) by mail.thefacebook.com (192.168.16.14) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 25 Aug 2015 10:09:44 -0700 From: Josef Bacik To: Subject: [PATCH] Btrfs: deal with error on secondary log properly Date: Tue, 25 Aug 2015 13:09:43 -0400 Message-ID: <1440522583-32120-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-08-25_07:2015-08-24, 2015-08-25, 1970-01-01 signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 If we have an fsync at the same time in two seperate subvolumes we could end up with the tree log pointing at invalid blocks. We need to notice if our writeout failed in anyway, if it did then we need to do a full transaction commit and return an error on the subvolume that gave us the io error. Thanks, Signed-off-by: Josef Bacik Reviewed-by: Liu Bo --- fs/btrfs/file.c | 4 ++++ fs/btrfs/tree-log.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b823fac..c8f49f5 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2054,6 +2054,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) if (!ret) { ret = btrfs_end_transaction(trans, root); goto out; + } else if (ctx.io_err) { + btrfs_end_transaction(trans, root); + ret = ctx.io_err; + goto out; } } if (!full_sync) { diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 1bbaace..b4f15f5 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2857,6 +2857,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, ret = btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); btrfs_wait_logged_extents(trans, log, log_transid); + if (ret) { + btrfs_set_log_full_commit(root->fs_info, trans); + ctx->io_err = ret; + } wait_log_commit(log_root_tree, root_log_ctx.log_transid); mutex_unlock(&log_root_tree->log_mutex);