Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1811503imm; Thu, 12 Jul 2018 08:11:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe18VM/6JaI8DsWwN5K7I1Qh8yU6Vu9yZaM+aHZOFN1FFqY3Ftfpu9sIZ1k/5XB0In3+hYP X-Received: by 2002:a62:4147:: with SMTP id o68-v6mr1375373pfa.111.1531408313343; Thu, 12 Jul 2018 08:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531408313; cv=none; d=google.com; s=arc-20160816; b=F55PlrJRXp4h5ADeqDlybzC1vU353Xld5XvLaMYSeSkA8o00ivH7DBG/TV2JDJprQl XeZ2jIS1TY29oy4IjIPGEPCzkVFA9rPSK0RjHuc2WiW/bKYlLT6d+FYl7IftCarwtkIX DreiZQX4Bb0yUKEYZ2Li0fHCse1Glmyk7kXsJzGdYXZuzi6ogD/h3mFipcTkaFCxIbIf FiKbUzgm9Qthq6ET513RVmyMJ+sCAC6uRXl0Fib0XjDDTanbC6y9GMMESXcQG/S3B6YJ K3/HDeUZoSHYAnrqOgEyd1gFH8mUqUlIRd1SuM+bMUmdJ7novdQbNN+DJ9N0zoPdnYqy tb+Q== 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=Hlo5t8ppG2otuYzPoOZy9texDXPT64DfovbpoScXh+g=; b=pT8BlC6jBXfRLlO+lyMdoXlBBnulHwA4kfXMXRrhjG0Jyqu+iWy91Unlw1XCfTjTGE shisNjwlODYC26KqJZuPZk7NCSI9dqq8nrwxbpt5l4EQwbNnyzrS9lY+sEe8VLSJ03/B OtI7wLjFv8m+/KEg+11fF9sAPqG9pgpbL2bSy1Tt8x5Jaxn5Uicd5/82AWscZlDpDF2p rJdPpXXc77+sIchv0rh65Jl/BSOlwrcXQXf4zLvJsi6qGL8mqrM0joTSUglls0C7nKTn OS0WhBAl7C4nkOJlBt0fBXq4SX0ggd6NkSEB2boCSMy6NeP6/Mn0QYJkAAAI3lxK+V// 5zBQ== 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 g16-v6si2729368pgk.465.2018.07.12.08.11.22; Thu, 12 Jul 2018 08:11:53 -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 S1732722AbeGLPUi (ORCPT + 99 others); Thu, 12 Jul 2018 11:20:38 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9612 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732531AbeGLPUh (ORCPT ); Thu, 12 Jul 2018 11:20:37 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 349C3BBE64380; Thu, 12 Jul 2018 23:10:25 +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:20 +0800 From: Yunlong Song To: , , , , CC: , , , , , Subject: [PATCH 2/5] f2fs: clear the remaining prefree_map of the section Date: Thu, 12 Jul 2018 23:09:27 +0800 Message-ID: <1531408170-45758-3-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 the section prefree_map is ...previous section | current section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, after start = start_segno + sbi->segs_per_sec, start = x + 5, then it will skip x + 3 and x + 4, but their bitmap is still set, which will cause duplicated f2fs_issue_discard of this same section in the next write_checkpoint, so fix it. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 47b6595..fd38b61 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, start = start_segno + sbi->segs_per_sec; if (start < end) goto next; - else - end = start - 1; + else { + start_segno = start; + + while (1) { + start = find_next_bit(prefree_map, start_segno, + end + 1); + if (start >= start_segno) + break; + end = find_next_zero_bit(prefree_map, start_segno, + start + 1); + for (i = start; i < end; i++) + clear_bit(i, prefree_map); + dirty_i->nr_dirty[PRE] -= end - start; + } + + end = start_segno - 1; + } } mutex_unlock(&dirty_i->seglist_lock); -- 1.8.5.2