From patchwork Thu May 29 22:31:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4267531 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F36F79F1D6 for ; Thu, 29 May 2014 21:32:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04C7D2035E for ; Thu, 29 May 2014 21:32:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EB13202F2 for ; Thu, 29 May 2014 21:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932393AbaE2Vb6 (ORCPT ); Thu, 29 May 2014 17:31:58 -0400 Received: from mail-we0-f179.google.com ([74.125.82.179]:43729 "EHLO mail-we0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755299AbaE2Vb5 (ORCPT ); Thu, 29 May 2014 17:31:57 -0400 Received: by mail-we0-f179.google.com with SMTP id q59so1091025wes.10 for ; Thu, 29 May 2014 14:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9+KGuPTQjurgmzzCmYJf15LuqIHQ572pzldabwo0GYc=; b=J1lf9BtrBoaIZXDDOXr086liOHAqxwFB1ypihmDtqmPdFqGhLqNIcoRO//FrGErank vPdwzyMMCWfwIjSG3EJ2Nal8g41S0STaQUObWe1A/D4vuTd8p9Xmqc7MaxLfyFLP8nMX /C3HCl/wLZaBBbu02lGsuqanqahG20KNw27vXnEj93XWRxtyqGrrVV8qilihZ71/9/cA d/0CZFOO7WTGO9dTMiS12lZAF7VUmwYM7NT0+rWjfQTORnIRcZm7FFfPBBANR9oi4Um5 N/S+LuoBLTjDMoF+qYlr+1J79gDun2QV9U3aMJt2aldOOKfNi00YVhb+0Alc5IWoxQGa SGxg== X-Received: by 10.180.78.71 with SMTP id z7mr158074wiw.14.1401399116247; Thu, 29 May 2014 14:31:56 -0700 (PDT) Received: from debian-vm3.lan (bl13-158-17.dsl.telepac.pt. [85.246.158.17]) by mx.google.com with ESMTPSA id d6sm308570wiz.4.2014.05.29.14.31.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 May 2014 14:31:55 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH v2] Btrfs: fix transaction leak during fsync call Date: Thu, 29 May 2014 23:31:39 +0100 Message-Id: <1401402699-27056-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401392024-5906-1-git-send-email-fdmanana@gmail.com> References: <1401392024-5906-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 btrfs_log_dentry_safe() returns an error, we set ret to 1 and fall through with the goal of committing the transaction. However, in the case where the inode doesn't need a full sync, we would call btrfs_wait_ordered_range() against the target range for our inode, and if it returned an error, we would return without commiting or ending the transaction. Signed-off-by: Filipe David Borba Manana --- V2: Leave the call to btrfs_wait_ordered_range(), it's needed if the fs is mounted with -o no_flushoncommit. fs/btrfs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index e46bfaf..5a00597 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2025,8 +2025,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) if (!full_sync) { ret = btrfs_wait_ordered_range(inode, start, end - start + 1); - if (ret) + if (ret) { + btrfs_end_transaction(trans, root); goto out; + } } ret = btrfs_commit_transaction(trans, root); } else {