Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2146027imm; Mon, 16 Jul 2018 03:05:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfhEUd2RvvdervS5NQypWD7XZR/dv+xRD7sCQnbm5iGTaP7mtI+kOJ7vPviRmHlVAswDNSd X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr13941432pgv.307.1531735538845; Mon, 16 Jul 2018 03:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531735538; cv=none; d=google.com; s=arc-20160816; b=e/faNoZ2ByPHOe+JNQ94e76xcKA3aV1G5xy3eCz5s/u1iBqk4z6WJxX1BxjLAtPeE4 blujp9Ghp9iRcCaPQ1TnJONn6PPC/X9/lz51V0bq+jZcuMB/C4s+6TxqTGaqIINd05HB xteQcg0hVTS/CT9EI9ALpLayrbn62qSleQRmwu51Wpw3u+K/l/Bw4ig6GKYwP6Y/phWv cqCA2E2dexowCNHCaC00h57rEM/xo11Uujh1WSeVvd3SnuDV6L24IhbX0A6Mp6zYPu5T WH5UFJa1HMjmrz4CJ7PsTFZZTXcSPwCbIiQKyt6wZdkrhyNqzr6LUwdHQ/jTOOSgcJda K1sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=KvcMeM0/Rxc0zzOXY1RofVJTEPu47QEaOshnacPXpes=; b=A87Lw4kmDyglQPZZx0l18FHx34Qq0lbYgH28R9otMFfJBcC2UGENBmGA2NN+3i5Qq+ ttsGEL4n1c3R5cJqmjXHeI+zbxqDhf7BodHViIMP7TtKcBSzFKvdY0XmAcqQOjVcu1I7 /v0/8LkOv5vvV5zYAXE4bMwofscCCKzOmTp0Uv6Vkg5HrGImHO2LRklxaUgbKHqY4KjE DdwCsFnP4P4gYXnlnc33m8LofMzvbeX+ehgRtxETlE4gjBll4q6JszerqUrgUb39JqFj hDrVskja1uIBpVOpTQl1hOVTw3VRWl6+7PRlirugBVe9ycohHjRA5pUiJ+dT2hfdG6om eUqQ== 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 85-v6si32203581pfm.264.2018.07.16.03.05.23; Mon, 16 Jul 2018 03:05:38 -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 S1729881AbeGPKar (ORCPT + 99 others); Mon, 16 Jul 2018 06:30:47 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9676 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727857AbeGPKar (ORCPT ); Mon, 16 Jul 2018 06:30:47 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C508D39ACEA5A; Mon, 16 Jul 2018 18:03:52 +0800 (CST) Received: from huawei.com (10.113.189.234) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Mon, 16 Jul 2018 18:03:48 +0800 From: Yunlong Song To: , , , , CC: , , , , , Subject: [PATCH v2] f2fs: clear the remaining prefree_map of the section Date: Mon, 16 Jul 2018 18:03:41 +0800 Message-ID: <1531735421-73669-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 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 with lfs mode, 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index cfff7cf..5dc1d5cc 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1729,6 +1729,15 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, if (!test_opt(sbi, DISCARD)) continue; + if (test_opt(sbi, LFS) && sbi->segs_per_sec > 1) { + start = rounddown(start, sbi->segs_per_sec); + i = end; + end = roundup(end, sbi->segs_per_sec); + while (++i < end) + if (test_and_clear_bit(i, prefree_map)) + dirty_i->nr_dirty[PRE]--; + } + if (force && start >= cpc->trim_start && (end - 1) <= cpc->trim_end) continue; -- 1.8.5.2