From patchwork Tue May 22 03:51:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Jinxiang X-Patchwork-Id: 10417297 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 92FFA6032A for ; Tue, 22 May 2018 03:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 823E6288D4 for ; Tue, 22 May 2018 03:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73B9028A5F; Tue, 22 May 2018 03:51:52 +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, 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 E2D9A288D4 for ; Tue, 22 May 2018 03:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeEVDvu (ORCPT ); Mon, 21 May 2018 23:51:50 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:52824 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751719AbeEVDvs (ORCPT ); Mon, 21 May 2018 23:51:48 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="40191483" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 May 2018 11:51:47 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id BB8A948AE92A; Tue, 22 May 2018 11:51:44 +0800 (CST) Received: from ubuntu.g08.fujitsu.local (10.167.226.132) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Tue, 22 May 2018 11:51:48 +0800 From: Gu Jinxiang To: CC: Subject: [PATCH] btrfs: handle failures of set_extent_bits in add_excluded_extent Date: Tue, 22 May 2018 11:51:39 +0800 Message-ID: <1526961099-5922-1-git-send-email-gujx@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.132] X-yoursite-MailScanner-ID: BB8A948AE92A.A8B19 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: gujx@cn.fujitsu.com 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 set_extent_bits may return 0/-EEXIST, so return the result in add_excluded_extent. And handle the failures in upper callers. Caller of add_excluded_extent and failure process currently: exclude_super_stripes <- btrfs_make_block_group //handles the failure <- btrfs_read_block_groups //handles the failure __exclude_logged_extent <- btrfs_exclude_logged_extents <- btrfs_alloc_logged_file_extent //propagate failure to upper caller Add logic of propagate return value of __exclude_logged_extent to btrfs_exclude_logged_extents. Signed-off-by: Gu Jinxiang --- fs/btrfs/extent-tree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 75cfb80d2551..28fd71579141 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -215,11 +215,16 @@ static int add_excluded_extent(struct btrfs_fs_info *fs_info, u64 start, u64 num_bytes) { u64 end = start + num_bytes - 1; - set_extent_bits(&fs_info->freed_extents[0], + int ret = 0; + + ret = set_extent_bits(&fs_info->freed_extents[0], start, end, EXTENT_UPTODATE); - set_extent_bits(&fs_info->freed_extents[1], + if (ret) + goto out; + ret = set_extent_bits(&fs_info->freed_extents[1], start, end, EXTENT_UPTODATE); - return 0; +out: + return ret; } static void free_excluded_extents(struct btrfs_fs_info *fs_info, @@ -6463,6 +6468,7 @@ int btrfs_exclude_logged_extents(struct btrfs_fs_info *fs_info, struct btrfs_key key; int found_type; int i; + int ret = 0; if (!btrfs_fs_incompat(fs_info, MIXED_GROUPS)) return 0; @@ -6479,10 +6485,14 @@ int btrfs_exclude_logged_extents(struct btrfs_fs_info *fs_info, continue; key.objectid = btrfs_file_extent_disk_bytenr(eb, item); key.offset = btrfs_file_extent_disk_num_bytes(eb, item); - __exclude_logged_extent(fs_info, key.objectid, key.offset); + ret = __exclude_logged_extent(fs_info, key.objectid, + key.offset); + if (ret) + goto out; } - return 0; +out: + return ret; } static void