Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4536689imm; Mon, 17 Sep 2018 16:04:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbGZrX+7jFuD9U26/XW4J1+HyMSb6COzS3qCixd23OkOkOYviRYPEKKYn3SX26gcNsH9ftH X-Received: by 2002:a63:5d4b:: with SMTP id o11-v6mr24514609pgm.349.1537225484309; Mon, 17 Sep 2018 16:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225484; cv=none; d=google.com; s=arc-20160816; b=qv7GF41/GW1efAKmQTYo+IXb2Ege/nDUR5eItpEswWRtSyVyHKWRqyYujU/3hcgIS0 wZBzAC3gqMW/jn+oCksSTXFsh5kfigHmISj5C/jFbWyO633WBidh0B/NtrswVPTD4G0U R21rVUEDDXp3Kq3oZeNmN/7h6jZgqso1PoFPye6LDPbVP3XsXB3W2z8M0/3nOwDs0o9+ fVdbEi+OeGsArjUjxpXBCFX+AszzQCQ8Tltzs4iFC0AEhFPlxFH7Fj7MGIisRWZeh8EL t+et61xB2ODiYLdpANwqbrLaZA+2i/Q2wOaQgRWk0ioD4XlxkNKVRxp+khx8Ev3l7tME 8YGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=f3u13WfsOiy46mYQOJjWz42W4IjRhrpzRoKMqAXytB4=; b=kkONx995iK5p9BERv23HUdQNVnp8/FNE1XqGyhYvvuhun4MaY3NXn58Nqh2sGqqHBf 4v/DFB/oKuu3k/l1gESvx9tLByR0AIILk0RgMb+19Hk019W7WaQ3Pl9hli8KR6LHUjGA r7tkg1ADRTSq6gekXFPw2qM0iISU25lAvnwnOxbTIbdZ+l7Pk/QK6GjP7KHZvVW+mkLL ohzOIhlKs8lnZsW/SDUo0UKgqhjPdn/Duhnqdvmd34yRc8U3GdWIAYaIluyOz+yjG/Zr yDSegM6L6+szhZ039/5YZ3NlhwWDcBghCY3x1ceTZo0nmkEWDLLmxXV1caKM/jLJBylc VrGw== 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 b9-v6si16011966pfi.99.2018.09.17.16.04.29; Mon, 17 Sep 2018 16:04:44 -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 S1730783AbeIREdo (ORCPT + 99 others); Tue, 18 Sep 2018 00:33:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49090 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbeIREdn (ORCPT ); Tue, 18 Sep 2018 00:33:43 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 891FCC49; Mon, 17 Sep 2018 23:04:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunlong Song , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.14 044/126] f2fs: do not set free of current section Date: Tue, 18 Sep 2018 00:41:32 +0200 Message-Id: <20180917211707.554836447@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yunlong Song [ Upstream commit 3611ce9911267cb93d364bd71ddea6821278d11f ] For the case when sbi->segs_per_sec > 1, take section:segment = 5 for example, if segment 1 is just used and allocate new segment 2, and the blocks of segment 1 is invalidated, at this time, the previous code will use __set_test_and_free to free the free_secmap and free_sections++, this is not correct since it is still a current section, so fix it. Signed-off-by: Yunlong Song Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/segment.h | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -414,6 +414,8 @@ static inline void __set_test_and_free(s if (test_and_clear_bit(segno, free_i->free_segmap)) { free_i->free_segments++; + if (IS_CURSEC(sbi, secno)) + goto skip_free; next = find_next_bit(free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno); if (next >= start_segno + sbi->segs_per_sec) { @@ -421,6 +423,7 @@ static inline void __set_test_and_free(s free_i->free_sections++; } } +skip_free: spin_unlock(&free_i->segmap_lock); }