Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1812283imm; Thu, 12 Jul 2018 08:12:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBSqLBAd6QVZETi0EIdEnfv4yJM9El+BCpOOFKW+Uycet5F2hO/MFaLcC1K/a4cNjEllKD X-Received: by 2002:a17:902:6ac7:: with SMTP id i7-v6mr2657247plt.288.1531408353250; Thu, 12 Jul 2018 08:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531408353; cv=none; d=google.com; s=arc-20160816; b=Erk4XpAwEFSkmdzdFyHRzqSiCzVg7U8pkLGB3CoyLdRKTF0TSV73uIRwUtdd0qjsKu tjQ9zxu4TGC8nz0byUfgAWWmn6cUd64HpZlsa8AAQjUkJZmcXdlDvzEnAhclK3NljaaW olp4UqVEUZzuQnfU/Mdd0IAYff6JoUdIdwkPfqvUikHnpPNkCU4t/RhSGSL1jpAitBG0 eNwTY57iunf/DURhZBlTyzGuojuyRGtth2tahaxpAYK4BG+csgGOiQjeywaiH9aL9a0M qfI31DOnEvMw6R3vvKS9VI3wXeLGDdmjccNvJxFroKgg5+yN1pu6Ny3SgeVgVubo6uSS etbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=2d8rZBRAdh9gZ/3f6WQIKfjkEx4M0b+fLBKLmuJcx3w=; b=vdv1q8GqoIHhoy/PYKB752Sc5YQHWxftwGzy98k346JUnhs25YC5JhMCXYVx3Wkfkd jG2y7IvEUoQ4SFFqw0clVwTdciGb0gcb9CP7jlHiuWh6UsSgNu73Qq9p0bqyDr8urBSA ikiYc1sway8Gdgk777z9vbvXq2NYdVksojvae/rKEtyptF6FqBIxdOYUlPfvf2La+w7r oWiGUVh6vjVSPNkMEwLvD/F3UqckfL3J/9Wu5cTMxpvVwIevEAz9KLVuQXHkm337sPfz Dfn9HaJ5gUSOgv3JC7Q7rk9LYsp/5fSDlYx4oosZsAdYEv62+7mhpMXmccHBw05nMEmR BZpg== 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 f18-v6si20496319pgd.16.2018.07.12.08.12.06; Thu, 12 Jul 2018 08:12:33 -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 S1732703AbeGLPUf (ORCPT + 99 others); Thu, 12 Jul 2018 11:20:35 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9226 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732373AbeGLPUf (ORCPT ); Thu, 12 Jul 2018 11:20:35 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id B5EF4BE2E63D7; Thu, 12 Jul 2018 23:10:19 +0800 (CST) Received: from huawei.com (10.113.189.234) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.382.0; Thu, 12 Jul 2018 23:10:14 +0800 From: Yunlong Song To: , , , , CC: , , , , , Subject: [PATCH 1/5] f2fs: do not set free of current section Date: Thu, 12 Jul 2018 23:09:26 +0800 Message-ID: <1531408170-45758-2-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1531408170-45758-1-git-send-email-yunlong.song@huawei.com> References: <1531408170-45758-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.113.189.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/f2fs/segment.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index b5bd328..5049551 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -448,6 +448,8 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, 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) { @@ -455,6 +457,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, free_i->free_sections++; } } +skip_free: spin_unlock(&free_i->segmap_lock); } -- 1.8.5.2