Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2274115imm; Thu, 7 Jun 2018 08:03:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJDLrFLIreh1C/nSLUCuTggnUCAun/h4mW4RqT7Bey0vc0TwkQuQGxhwGTWmXzbxgaRsfmf X-Received: by 2002:a17:902:b786:: with SMTP id e6-v6mr2463589pls.260.1528383798669; Thu, 07 Jun 2018 08:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383798; cv=none; d=google.com; s=arc-20160816; b=L0fO4Jf7IXiCh1f6WOySAWFUfqoKtZM2+upEvh3RcYlgeReHkWI321ND4AoertVVEZ 1EFtWfNoL0OZ86eRbCs21Mf2IGl64bdxps974UhXu+nq9+oTcDd8+Wef/fftrVlr2mSl dvu9qb3rGByOnYmDW7qsQbla847QViIyvhyAj8yYOjaV26jSpqzt5hCV+Ovm4Pp5zeZa Dvl+oYoCzT8M0jISj10xO3RaoexTr69ZfNTZGPbFYiUyUnbf8CIOt8uU/xMcs5p8kGte ux03tkRJulIy+2HK40yWXA6i925Uww7ARXO+VOmZr0lv5t0fCTrSSQs4G/kCoiKBNcm4 48hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=06XCtIYId1tT2ZOoRFALEWrDAkyZgXfb0ihpqf295vM=; b=VE/HXdy/fvXGy23dPwsQoBV1r1uuTpc4IfqacAAiCU4uUxD96ouLBaaIyg2xhomf5d 8OShq23aby03xjg01BWYDuVsK/SX/yHuaroL28wMuYxmvKagz240AZwi6wSsZQBTMSg+ ANVilyb8omANNr7ofvnIg7ujMpzu1TiFNoaMlUvy7f/RnDuyS4A9b3uMu/4y39GWUMkP NvlWRXKdZUJT/ce/Plnff3ZLOqECwb+FJrAqVqiRkcUxajEs1z2FWKba//SMiTTueryB mpeQxip51euVSsUZXpGwK8WKet7bs1KEZE7ljiRHRhF9Jb/d+xkIAiR/gcenDLMNZb8a Uv3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si20606887pgq.387.2018.06.07.08.03.04; Thu, 07 Jun 2018 08:03:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934945AbeFGPBq (ORCPT + 99 others); Thu, 7 Jun 2018 11:01:46 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41400 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934986AbeFGPBg (ORCPT ); Thu, 7 Jun 2018 11:01:36 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbj-0005Zn-8y; Thu, 07 Jun 2018 15:09:43 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb5-0002yV-9l; Thu, 07 Jun 2018 15:09:03 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Liu Bo" , "Josef Bacik" , "David Sterba" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 188/410] Btrfs: fix extent state leak from tree log In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Liu Bo commit 55237a5f2431a72435e3ed39e4306e973c0446b7 upstream. It's possible that btrfs_sync_log() bails out after one of the two btrfs_write_marked_extents() which convert extent state's state bit into EXTENT_NEED_WAIT from EXTENT_DIRTY/EXTENT_NEW, however only EXTENT_DIRTY and EXTENT_NEW are searched by free_log_tree() so that those extent states with EXTENT_NEED_WAIT lead to memory leak. Signed-off-by: Liu Bo Reviewed-by: Josef Bacik Signed-off-by: David Sterba [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/btrfs/tree-log.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2731,13 +2731,14 @@ static void free_log_tree(struct btrfs_t while (1) { ret = find_first_extent_bit(&log->dirty_log_pages, - 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW, + 0, &start, &end, + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT, NULL); if (ret) break; clear_extent_bits(&log->dirty_log_pages, start, end, - EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS); + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT, GFP_NOFS); } /*