22
Statistic Module Shuanglong Zhang 04/23/2013

Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Embed Size (px)

Citation preview

Page 1: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Statistic Module

Shuanglong Zhang

04/23/2013

Page 2: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Overview

• Device Mapper

• procfs

• bio control

Page 3: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Device Mapper

• A mechanism from linux 2.6

• The base of LVM, RAID

• dm-linear dm-statistic

Page 4: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control
Page 5: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control
Page 6: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Can be infinite iteration

Don't do this!

Page 7: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

My implementation

dm-statistic

Page 8: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

procfs

• Used to "communicate" with user space

• /proc/statistic

• /proc/jiffies

• A drawback of procfs

Page 9: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Drawback

• Can not exceed one page size

• How to deal with large data

• seq_file

Page 10: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

seq_file interface

• Deal with large data, work with procfs

• Abstract those data to a mount of items– (array, list, hash)

• Simplify the read operation

Page 11: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

static struct seq_operations seq_ops = { .start = statistic_seq_start, .next = statistic_seq_next, .stop = statistic_seq_stop, .show = statistic_seq_show};start->show->next->show->...->next->show->stop

Page 12: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

static struct file_operations seq_fops = { .owner= THIS_MODULE, .open = statistic_open, .read = seq_read, //.write = seq_write, .llseek = seq_lseek, .release = seq_release,};

Page 13: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

static int statistic_open(struct inode *inode, struct file *file)

{

return (seq_open(file, &seq_ops));

}

Page 14: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Control on bio

• Diffrent ways to do it– These kind of control can happen at any

stage from a request begins to it ends.

- VFS

- FS

- DM

- BLOCK

Page 15: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

In device mapper

• A bio comes in

• Map the bio to the dest– delay it if necessary(read, full)– until there is another room for a bio

• Go into block layer

Page 16: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Delay

• Create another list for write bio

• Track back to x bios or 1 second

• Wait till there is less then x bios in past second

controled by a module parameter

Page 17: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

User space tool

• dmsetup

• statistic

Page 18: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

dmsetup

• dmsetup [linear/stripe/statistic] /dev/sda10

• dmsetup remove /dev/mapper/statistic

• use sudo!

Page 19: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

statistic

• Get the statistic info from /proc/statistic

• Two ways of querying– last x second– from x second to y second

• Total, Read, Write

Page 20: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Left Problems

• module parameter

• ioctl function(reset base_time)

• more info on bio

Page 21: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Demo

Page 22: Statistic Module Shuanglong Zhang 04/23/2013. Overview Device Mapper procfs bio control

Q & A