From patchwork Thu Dec 3 16:51:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Lyakas X-Patchwork-Id: 7761781 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 C5C77BEEE1 for ; Thu, 3 Dec 2015 16:51:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC38A2045E for ; Thu, 3 Dec 2015 16:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E25CB20434 for ; Thu, 3 Dec 2015 16:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbbLCQvF (ORCPT ); Thu, 3 Dec 2015 11:51:05 -0500 Received: from mail-yk0-f182.google.com ([209.85.160.182]:33009 "EHLO mail-yk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbbLCQvE (ORCPT ); Thu, 3 Dec 2015 11:51:04 -0500 Received: by ykdv3 with SMTP id v3so92615332ykd.0 for ; Thu, 03 Dec 2015 08:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zadarastorage-com.20150623.gappssmtp.com; s=20150623; h=mime-version:date:message-id:subject:from:to:content-type; bh=B4zaltts9PtU5NTlhexKgPpgdHGMFkcEq1UVgtXnphE=; b=ESVA/O1VVzGfXOdBiJlwKC3TyYgPEGi7d6kOGkuo2rz4nUHGfrGsy17WsThjnv1W3N GTj+x+6Xr9lHS6JOZFo+INzlo0/QLomTK2pwLJaoOF0yBKO1Z8Igr2jLx2++i9wqyvCU OQZjW40KP+MlieSzeFwd9J7c9SvkmkaFmtRL0Yn0XJOlcZodoIEMhw/aUcZBg4mit31S PZyoTQkoqrv/D+NCzKwrhGdg3xwV7JQVPL4njOLePlS7++CNRx+6EJwtLRwcpE1NPZDR bWwQqpYLjtVetRccTLf2+Fdo8iCZvklkbFoMr+Zl9Lb2wNCODgh5uB4Op8+mP9PA4cRD V2Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=B4zaltts9PtU5NTlhexKgPpgdHGMFkcEq1UVgtXnphE=; b=dnDc7PFP/dGdMPxETXu7zvnZCSq6FpEAliT7YGPO7C9UeSEVPpL1MV3mOEnhJH/jLZ d2H60JNbU+fa7c7wjpJjsxvQw4t2g0IgzbBTAnfUXrSswYj5W4jcffL5j6B4+J44rg50 fooj24zTKCAgKb3YOQxo+gtMKpnEX2dNjTPfLaOyeCc5ghEF8gNH6SShCkqMOIrDqHdM 5+h5mvjje5qOrJmE7vaS7jxWk0vhmrGMdr5LPKXSiVJnIusjrc8Fcg3D/OH/gppr4r0Z lvp/pjdW5MbsKDfZQ327wFes3MQiF5JmiLCXOmjYyLVEZX0obpJ5XQT+1nGU4rdHgaPB +YUg== X-Gm-Message-State: ALoCoQmkuz8VcdZrjJQUsbJuv4cxiJWHM77csvkQVB1KWqcNmy7wvjNfYs4tyzoG/XVhlsrDFP4r MIME-Version: 1.0 X-Received: by 10.129.4.137 with SMTP id 131mr8238313ywe.169.1449161463182; Thu, 03 Dec 2015 08:51:03 -0800 (PST) Received: by 10.37.55.130 with HTTP; Thu, 3 Dec 2015 08:51:03 -0800 (PST) Date: Thu, 3 Dec 2015 18:51:03 +0200 Message-ID: Subject: [RFC PATCH] btrfs: flush_space: treat return value of do_chunk_alloc properly From: Alex Lyakas To: linux-btrfs Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 do_chunk_alloc returns 1 when it succeeds to allocate a new chunk. But flush_space will not convert this to 0, and will also return 1. As a result, reserve_metadata_bytes will think that flush_space failed, and may potentially return this value "1" to the caller (depends how reserve_metadata_bytes was called). The caller will also treat this as an error. For example, btrfs_block_rsv_refill does: int ret = -ENOSPC; ... ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush); if (!ret) { block_rsv_add_bytes(block_rsv, num_bytes, 0); return 0; } return ret; So it will return -ENOSPC. Reviewed-by: Josef Bacik --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4b89680..1ba3f0d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4727,7 +4727,7 @@ static int flush_space(struct btrfs_root *root, btrfs_get_alloc_profile(root, 0), CHUNK_ALLOC_NO_FORCE); btrfs_end_transaction(trans, root); - if (ret == -ENOSPC) + if (ret > 0 || ret == -ENOSPC) ret = 0; break; case COMMIT_TRANS: