From patchwork Wed Oct 17 09:13:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10645179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4A4913B0 for ; Wed, 17 Oct 2018 09:14:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFF672A201 for ; Wed, 17 Oct 2018 09:14:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2ED72A210; Wed, 17 Oct 2018 09:14:13 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5DD002A201 for ; Wed, 17 Oct 2018 09:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbeJQRIx (ORCPT ); Wed, 17 Oct 2018 13:08:53 -0400 Received: from smtp12.smtpout.orange.fr ([80.12.242.134]:42864 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbeJQRIx (ORCPT ); Wed, 17 Oct 2018 13:08:53 -0400 Received: from ubuntu-CJ.clients.t30.sncf.fr ([109.190.253.13]) by mwinf5d23 with ME id oZE01y00A0J6jfR03ZE0HA; Wed, 17 Oct 2018 11:14:05 +0200 X-ME-Helo: ubuntu-CJ.clients.t30.sncf.fr X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 17 Oct 2018 11:14:05 +0200 X-ME-IP: 109.190.253.13 From: Christophe JAILLET To: clm@fb.com, jbacik@fb.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] btrfs: Fix the return value in case of error in 'btrfs_mark_extent_written()' Date: Wed, 17 Oct 2018 11:13:59 +0200 Message-Id: <20181017091359.3763-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.17.1 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 We return 0 unconditionally in most of the error handling paths of 'btrfs_mark_extent_written()'. However, 'ret' is set to some error codes in several error handling paths. Return 'ret' instead to propagate the error code. Fixes: 9c8e63db1de9 ("Btrfs: kill BUG_ON()'s in btrfs_mark_extent_written") Signed-off-by: Christophe JAILLET --- This patch proposal is purely speculative. I'm not sure at all that returning 'ret' is correct (but it looks like it is :) ) What puzzles me is when 'ret' is set, 'btrfs_abort_transaction()' is also called. However, the only caller of 'btrfs_mark_extent_written()' (i.e. 'btrfs_finish_ordered_io()') also calls 'btrfs_abort_transaction()' if an error is returned. So returning an error code here, would lead to a double call to this abort function. I'm usure of if it is correct and/or intented. If returning 'ret' is correct, should we also axe the 'btrfs_abort_transaction()' calls here, and leave the caller do the clean-up? Before the commit in the Fixes tag, we were BUGing_ON in case of errror. So propagating the error was pointless. --- fs/btrfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 15b925142793..cac0bd744de3 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1374,7 +1374,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, } out: btrfs_free_path(path); - return 0; + return ret; } /*