提交 a11141c6 编写于 作者: Y Yu Kuai 提交者: Zheng Zengkai

eulerfs: add interfaces for page wear

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I40JRR
CVE: NA

--------------------------------------

Page wears are preallocated ints for all pages, each of the ints
records the number of writes to the page. This is used to
coarse-grainedly show the degree of wear.
Signed-off-by: NMingkai Dong <dongmingkai1@huawei.com>
Signed-off-by: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 243afcee
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "wear.h"
#include <linux/vmalloc.h>
#include "euler.h"
void wear_init(struct super_block *sb)
{
struct eufs_sb_info *sbi = EUFS_SB(sb);
if (!wear_control)
return;
sbi->page_wears = vmalloc(sizeof(struct page_wear) * sbi->npages);
memset(sbi->page_wears, 0, sizeof(struct page_wear) * sbi->npages);
}
void wear_fini(struct super_block *sb)
{
struct eufs_sb_info *sbi = EUFS_SB(sb);
if (!wear_control)
return;
if (sbi->page_wears)
vfree(sbi->page_wears);
sbi->page_wears = NULL;
}
/* Return whether it's in a good state */
bool wear_inc(struct super_block *sb, void *page)
{
struct eufs_sb_info *sbi = EUFS_SB(sb);
if (!wear_control)
return true;
return sbi->page_wears[(page - sbi->data_start) / PAGE_SIZE].wear++ <=
wear_threshold;
}
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef EUFS_WEAR_H
#define EUFS_WEAR_H
#include <linux/fs.h>
extern int wear_threshold;
extern int wear_control;
struct page_wear {
int wear;
};
void wear_init(struct super_block *sb);
void wear_fini(struct super_block *sb);
bool wear_inc(struct super_block *sb, void *page);
#endif /* EUFS_WEAR_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册