当前位置:首页 >> 新能源

智汇华云 | flashcache理论及实践

来源:新能源   2023年03月07日 12:15

定义布置

两个工作链表。结合device mapper预定义,特别是dm.c可以想到,在线程flashcache_create应用软件创建flashcache装置时,时会线程 flashcache_ctl算子,可执行创建应用软件,它时会创建一工作链表_delay_clean,主要负责管理对整个cache装置的小便块搬运,由 flashcache_clean_set在特定条件下线程(见预定义),通过flashcache_clean_all可执行对所有sets的扫描与搬运。 另外一个工作链表,_kq_xxx,在flashcache_init中都,由flashcache子系统读取时可执行,通过对5个job链表来进行 处理过程,可执行元数据资料的新版本与顺利进行处理过程算子、念过闪存后的SSD载入、以及对继续前进链表的处理过程,主要就是负责管理念过写成后的处理过程工作原属直觉处理过程子系统,即“念过写成后处理过程 子系统”,由闪存或SSD念过写成后完全相同才会被调动。

调动的时机可以看flashcache_map算子,处理过程直觉则主要在算子flashcache_io_callback核心说明,the same block的继续前进链表应该为自力,如果不为自力,则同样时会线程flashcache_do_handler,可执行对继续前进链表的处理过程。

5、数据资料调动

对念过,分派到bio,首先,根据 bio->bi_sector,即芯片的格式化号,得到SSD上的set。其次,在set内匹配应该击毁,如果击毁,则将芯片的格式化号转换为SSD的 格式化号,然后将此bio向SSD提请,来进行念过取;如果仍未击毁,则首先向芯片转子提请bio,从芯片念过数据资料,念过取顺利进行后,由程序在算子启动回写成SSD操控,将 bio的格式化号转换为SSD的=格式化号,然后向SSD转子程序提请,将芯片念过取的数据资料载入SSD。对写成,同文件系统页缓冲,并不直接载入芯片,而是载入 SSD,同时,保持一个阀值,一般为20%,在小便块数目达到此数值时,写成回闪存。

6、内存微式 flashcache支持三种内存微式:

Writeback : 对于载入,首先时会载入到Cache中都,同时将对于block的元数据资料dirty bit,但是并才时会立即载入后备的device

Writethrough : 对于载入,载入到Cache中都,同时也时会将数据资料载入backing device,想到写成backing device,仍要写成

Writearound : 载入的时候,绕过Cache,直接载入backing device,即SSD只当念过内存

二、重新安装应用程序

1、升级应用程序

# rpm -ivh kernel-4.4.199-1.x86_64.rpm

# rpm -ivh kernel-devel-4.4.199-1.x86_64.rpm

2、生成grub

# grub2-set-default 0 CoCo grub2-mkconfig -o /etc/grub2.cfg

3、重启

# reboot

三、重新安装flashcache 1、重新安装依赖于应用软件

# yum install -y git make gcc

2、电子书flashcache源码

# git clone

3、编译重新安装

# cd flashcache/

# make

# make install

4、读取应用程序子系统

# modprobe flashcache

检查

# lsmod | grep flashcache

flashcache 106496 1

dm_mod 110592 11 dm_log,dm_mirror,flashcache

5、自动读取应用程序子系统新建文件/etc/sysconfig/modules/flashcache.modules内容如下

#! /bin/sh

/sbin/modinfo -F filename flashcache> /dev/null 2>Co1

if [ $? -eq 0 ]; then

/sbin/modprobe flashcache

fi

给与特权

# chmod +x /etc/sysconfig/modules/flashcache.modules

6、创建内存装置

# flashcache_create -p back -b 4k cachedev /dev/sdc /dev/sdb

cachedev cachedev, ssd_devname /dev/sdc, disk_devname /dev/sdb cache mode WRITE_BACK

block_size 8, md_block_size 8, cache_size 0

Flashcache metadata will use 440MB of your 32172MB main memory

值真是明:

-p:内存微式 writeback,writethrough,writearound三种。

-s:内存一般来真是,可选项,如果仍未自行决定则整个SSD装置被使用内存,绑定的计数一个单位是格式化(sectors),但是可以接受k/m/g一个单位。

-b:自行决定块一般来真是,可选项,绑定为4KB,需为2的基准。绑定一个单位为格式化。也可以用K作为一个单位,一般选4KB。

-f:强制创建,不来进行检查

警惕: 加速的ssd和后前端HDD闪存可以是一个的区也可以是一块闪存

7、格式化闪存

# mkfs.xfs /dev/mapper/cachedev

8、拍照才会

# ll /proc/flashcache/sdc+sdb/

total 0

-r---r---r--- 1 root root 0 Dec 16 14:05 flashcache_errors #flashcache 卷的错误信息报告

-r---r---r--- 1 root root 0 Dec 16 14:05 flashcache_iosize_hist

-r---r---r--- 1 root root 0 Dec 16 14:05 flashcache_pidlists

-r---r---r--- 1 root root 0 Dec 16 14:05 flashcache_stats #flashcache 卷的统计数字信息报告

9、拍照具体的念过写成和击毁率信息

# dmsetup status cachedev

0 419430400 flashcache stats:

reads(391120), writes(45940753)

read hits(337167), read hit percent(86)

write hits(20875155) write hit percent(45)

dirty write hits(20807737) dirty write hit percent(45)

replacement(11844), write replacement(183083)

write invalidates(5), read invalidates(19)

pending enqueues(33090), pending inval(33090)

metadata dirties(20621560), metadata cleans(1832026)

metadata batch(22220959) metadata ssd writes(232627)

cleanings(1832026) fallow cleanings(0)

no room(4520223) front merge(124207) back merge(1697772)

force_clean_block(0)

disk reads(53953), disk writes(6344364) ssd reads(2169176) ssd writes(41674210)

uncached reads(41405), uncached writes(4512356), uncached IO requeue(0)

disk read errors(0), disk write errors(0) ssd read errors(0) ssd write errors(0)

uncached sequential reads(0), uncached sequential writes(0)

pid_adds(0), pid_dels(0), pid_drops(0) pid_expiry(0)

lru hot blocks(10444544), lru warm blocks(10444544)

lru promotions(0), lru demotions(0)

10、拍照应用程序信息

# sysctl -a | grep flashcache

dev.flashcache.sdc+sdb.cache_all = 1

dev.flashcache.sdc+sdb.clean_on_read_miss = 0

dev.flashcache.sdc+sdb.clean_on_write_miss = 0

dev.flashcache.sdc+sdb.dirty_thresh_pct = 20

dev.flashcache.sdc+sdb.do_pid_expiry = 0

dev.flashcache.sdc+sdb.do_sync = 0

dev.flashcache.sdc+sdb.fallow_clean_speed = 2

dev.flashcache.sdc+sdb.fallow_delay = 900

dev.flashcache.sdc+sdb.fast_remove = 0

dev.flashcache.sdc+sdb.io_latency_hist = 0

dev.flashcache.sdc+sdb.lru_hot_pct = 75

dev.flashcache.sdc+sdb.lru_promote_thresh = 2

dev.flashcache.sdc+sdb.max_clean_ios_set = 2

dev.flashcache.sdc+sdb.max_clean_ios_total = 4

dev.flashcache.sdc+sdb.max_pids = 100

dev.flashcache.sdc+sdb.new_style_write_merge = 0

dev.flashcache.sdc+sdb.pid_expiry_secs = 60

dev.flashcache.sdc+sdb.reclaim_policy = 0

dev.flashcache.sdc+sdb.skip_seq_thresh_kb = 0

dev.flashcache.sdc+sdb.stop_sync = 0

dev.flashcache.sdc+sdb.zero_stats = 0

11、重新安装才会查询应用软件

# cp /root/flashcache-master/utils/flashstat /bin/

# chmod +x /bin/flashstat

# flashstat

sysctl: reading key "net.ipv6.conf.all.stable_secret"

sysctl: reading key "net.ipv6.conf.default.stable_secret"

sysctl: reading key "net.ipv6.conf.eth0.stable_secret"

sysctl: reading key "net.ipv6.conf.lo.stable_secret"

======================================================================================================

Flashstat: a tool for flashcache status per second

Author : NinGoo

Version : 0.3

======================================================================================================

SSD Device: /dev/sdc Disk Device: /dev/sdb Cache Mode: WRITE_BACK

Capacity: 81598M Block Size: 4K Meta Block Size: 4096b

Total Blocks: 20889088 Cached Blocks: 159897 Cached Percent: 0

Set Numbers: 512 Dirty Blocks: 125921 Dirty Percent: 0

cache_all: 1 reclaim_policy: FIFO dirty_thresh_pct: 20

max_clean_ios_set: 2 max_clean_ios_total: 4 skip_seq_thresh: 0K

======================================================================================================

time read/s write/s diskr/s diskw/s ssdr/s ssdw/s uread/s uwrit/s metaw/s clean/s repl/s wrepl/s hit% whit% dwhit%

12-16 14:32:33 0 98813 0 0 0 99355 0 0 541 0 0 0 0|63 0|0 0|0

12-16 14:32:34 0 112569 0 0 0 113211 0 0 636 0 0 0 0|63 0|0 0|0

12-16 14:32:35 0 111352 0 0 0 112019 0 0 666 0 0 0 0|63 0|0 0|0

12-16 14:32:36 0 84825 0 0 0 85362 0 0 543 0 0 0 0|63 0|0 0|0

12-16 14:32:38 0 102305 0 0 0 102848 0 0 537 0 0 0 0|63 0|0 0|0

12-16 14:32:39 0 109665 0 0 0 110322 0 0 662 0 0 0 0|63 0|0 0|0

12-16 14:32:40 0 158722 0 0 0 159609 0 0 887 0 0 0 0|63 0|0 0|0

12、卸载

# dmsetup info cachedev

Name: cachedev

State: ACTIVE

Read Ahead: 256

Tables present: LIVE

Open count: 0

Event number: 0

Major, minor: 253, 2 #从装置号2

Number of targets: 1

# dmsetup remove /dev/dm-2

# flashcache_destroy /dev/sdc

flashcache_destroy: Destroying Flashcache found on /dev/sdc. Any data will be lost !!

# dmsetup remove cachedev

# flashcache_destroy /dev/sdc -f

四、巧遇的问题

1、重启之后装置没了

# modprobe flashcache

# modprobe -r flashcache

# flashcache_load /dev/sdc

广州看白癜风哪个医院比较好
湖北男科专科医院
广西白癜风医院哪家治疗最好
河北白癜风医院去哪家好
艾拉莫德片的效果好吗
友情链接