From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam03on0090.outbound.protection.outlook.com ([104.47.42.90]:31424 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728492AbeIBRW6 (ORCPT ); Sun, 2 Sep 2018 13:22:58 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Yunlong Song , Jaegeuk Kim , Sasha Levin Subject: [PATCH AUTOSEL 4.14 27/89] f2fs: do not set free of current section Date: Sun, 2 Sep 2018 13:06:40 +0000 Message-ID: <20180902064918.183387-27-alexander.levin@microsoft.com> References: <20180902064918.183387-1-alexander.levin@microsoft.com> In-Reply-To: <20180902064918.183387-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Yunlong Song [ Upstream commit 3611ce9911267cb93d364bd71ddea6821278d11f ] For the case when sbi->segs_per_sec > 1, take section:segment =3D 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 --- fs/f2fs/segment.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 39ada30889b6..4dfb5080098f 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -414,6 +414,8 @@ static inline void __set_test_and_free(struct f2fs_sb_i= nfo *sbi, if (test_and_clear_bit(segno, free_i->free_segmap)) { free_i->free_segments++; =20 + if (IS_CURSEC(sbi, secno)) + goto skip_free; next =3D find_next_bit(free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno); if (next >=3D start_segno + sbi->segs_per_sec) { @@ -421,6 +423,7 @@ static inline void __set_test_and_free(struct f2fs_sb_i= nfo *sbi, free_i->free_sections++; } } +skip_free: spin_unlock(&free_i->segmap_lock); } =20 --=20 2.17.1