From patchwork Fri Mar 30 22:11:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10318431 Return-Path: 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 D11DE602A7 for ; Fri, 30 Mar 2018 22:12:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6B782A677 for ; Fri, 30 Mar 2018 22:12:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB0D22A6BE; Fri, 30 Mar 2018 22:12:15 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 5A06F2A6BC for ; Fri, 30 Mar 2018 22:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbeC3WMN (ORCPT ); Fri, 30 Mar 2018 18:12:13 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:47824 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752346AbeC3WMM (ORCPT ); Fri, 30 Mar 2018 18:12:12 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R211e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e01429; MF=bo.liu@linux.alibaba.com; NM=1; PH=DS; RN=1; SR=0; TI=SMTPD_---0T-O.svh_1522447920; Received: from localhost(mailfrom:bo.liu@linux.alibaba.com fp:106.11.235.185) by smtp.aliyun-inc.com(127.0.0.1); Sat, 31 Mar 2018 06:12:00 +0800 From: Liu Bo To: Subject: [PATCH] Btrfs: do not abort transaction when failing to insert hole extent Date: Sat, 31 Mar 2018 06:11:55 +0800 Message-Id: <1522447918-19147-1-git-send-email-bo.liu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.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 This is running in a typical write path, not inside a critical path where we have to abort the running transaction, so it's OK to return errors to callers and eventually to userspace. Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c7b75dd..b9310f8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4939,16 +4939,13 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode, ret = btrfs_drop_extents(trans, root, inode, offset, offset + len, 1); if (ret) { - btrfs_abort_transaction(trans, ret); btrfs_end_transaction(trans); return ret; } ret = btrfs_insert_file_extent(trans, root, btrfs_ino(BTRFS_I(inode)), offset, 0, 0, len, 0, len, 0, 0, 0); - if (ret) - btrfs_abort_transaction(trans, ret); - else + if (!ret) btrfs_update_inode(trans, root, inode); btrfs_end_transaction(trans); return ret;