Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2584717ybh; Mon, 5 Aug 2019 03:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHs1YSoxCPEcS3e+EvlAnephEvpAXuicb7mGXD+4tr9B0SnbKPYyHPKYL2inRI0mYXgxJW X-Received: by 2002:a17:902:110b:: with SMTP id d11mr149837361pla.213.1565000919024; Mon, 05 Aug 2019 03:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565000919; cv=none; d=google.com; s=arc-20160816; b=wi1j943cBY2JeO1HH7I8KvMQ1yQzLi6xwQGbvo7jGtOTEQzaD1Y8yvVS9VKgdN/pPw hFSzP7tNTovjyuA4TAe5uYP7HE/Qa+BuIDG7BfiDCFiNTq7O1Qn+EE6Uo4etWg6LjAQT 07B34DsDJx90UPjZ5j2lSfcmROcNgRbIjpB39+4hOeUkfCItlXDObWEzCIIoPZqiE5p6 Zn9TtvNLdOkJMx3AHqyDWFcZXioI2EAQHf0mbAoyRktwpNeaPeJrfo+Oy+Ig5kj+sX3S rHtAbc801BtLmoYrcsomzHUEnHdWRB+3ipwNO7LlVYiH23ABGIaeJjFTMNZD0HXnxnwo 6yyA== 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; bh=e/OKHnn2MLByBkZ1uLB6jQtCJoqtUOK0oh0PeCsCYAo=; b=mD9gj1KKmgQWPyYm1s/gWwhRuy5a05Z4YGF56qXyMmdWDCiocZWe3pvqIJybXYXT3N 50GEWOh50pbcn1wMJKkBUvkoYMAWYbPR1gE4vWRwOB0gFLlvTwTQEtnME6EmEz6dJdFo c3CkTLdPKoF6qIepYIxSsYDSzUzePjj60Xorgh3PDI2R+zxXliJPlF/d47TTjb/WxH+Z DpWJBa9wHSZUMZ0K65kYZqnpM4rHCaRQKayAsTSYjNgPB1XFar1/a4bfEH3bytHLS7T/ 2K+avGnpzLzdDxJy33x/w1muoowlAG0YXZhDadnDmO6eLfdyChgT3SYr7uyTLAjx5xe2 a/ig== 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 s189si42684294pgb.272.2019.08.05.03.28.23; Mon, 05 Aug 2019 03:28:39 -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 S1728337AbfHEK1j (ORCPT + 99 others); Mon, 5 Aug 2019 06:27:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3759 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727328AbfHEK1i (ORCPT ); Mon, 5 Aug 2019 06:27:38 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E864EAC6A14037319C23; Mon, 5 Aug 2019 18:27:36 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 18:27:28 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH v2] f2fs: fix wrong available node count calculation Date: Mon, 5 Aug 2019 18:27:25 +0800 Message-ID: <20190805102725.27834-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In mkfs, we have counted quota file's node number in cp.valid_node_count, so we have to avoid wrong substraction of quota node number in .available_nid/.avail_node_count calculation. f2fs_write_check_point_pack() { .. set_cp(valid_node_count, 1 + c.quota_inum + c.lpf_inum); Fixes: 292c196a3695 ("reserve nid resource for quota sysfile") Fixes: 7b63f72f73af ("f2fs: fix to do sanity check on valid node/block count") Signed-off-by: Chao Yu --- fs/f2fs/node.c | 2 +- fs/f2fs/super.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index a18b2a895771..d9ba1db2d01e 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2964,7 +2964,7 @@ static int init_node_manager(struct f2fs_sb_info *sbi) /* not used nids: 0, node, meta, (and root counted as valid node) */ nm_i->available_nids = nm_i->max_nid - sbi->total_valid_node_count - - sbi->nquota_files - F2FS_RESERVED_NODE_NUM; + F2FS_RESERVED_NODE_NUM; nm_i->nid_cnt[FREE_NID] = 0; nm_i->nid_cnt[PREALLOC_NID] = 0; nm_i->nat_cnt = 0; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 6a7f1166d068..118a31f90a37 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1297,8 +1297,7 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) else buf->f_bavail = 0; - avail_node_count = sbi->total_node_count - sbi->nquota_files - - F2FS_RESERVED_NODE_NUM; + avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; if (avail_node_count > user_block_count) { buf->f_files = user_block_count; @@ -2750,8 +2749,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) } valid_node_count = le32_to_cpu(ckpt->valid_node_count); - avail_node_count = sbi->total_node_count - sbi->nquota_files - - F2FS_RESERVED_NODE_NUM; + avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; if (valid_node_count > avail_node_count) { f2fs_err(sbi, "Wrong valid_node_count: %u, avail_node_count: %u", valid_node_count, avail_node_count); -- 2.18.0.rc1