presenter : kilroy 1. introduction experiment 1 - simulate a virtual disk device experiment 2 -...

16
Presenter : kilroy 1

Upload: reynold-phelps

Post on 03-Jan-2016

228 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Presenter : kilroy

1

Page 2: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

IntroductionExperiment 1

- Simulate a virtual disk deviceExperiment 2

- Nand-flash simulation for wear leveling algo.Conclusion

2

Page 3: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

What those experiments Why those experimentsWelcome our new machineMain object

3

Page 4: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

What to do Simulate a disk device

How to doUsing a block device driver

ObjectUnderstanding more about device

drivers

4

Page 5: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

5

Page 6: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Quick function Reference #include <linux/fs.h> int register_blkdev(unsigned int major, const char

*name); int unregister_blkdev(unsigned int major, const char

*name); struct block_device_operations #include <linux/genhd.h> struct gendisk *alloc_disk(int minors); void add_disk(struct gendisk *gd); void set_capacity(struct gendisk *gd, sector_t sectors); void add_disk(struct gendisk *gd);

6

Page 7: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

#include <linux/blkdev.h>request_queue_t blk_init_queue(request_fn_proc

*request, spinlock_t *lock);struct request *elv_next_request(request_queue_t

*queue);void end_request(struct request *req, int

success);#include <mm/vmalloc.h>void *vmalloc(unsigned long size);

7

Page 8: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Structure block_device_operations in <linux/fs>

8

Page 9: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Implement function what we need:sbull_init()sbull_exit()sbull_open() sbull_release() sbull_request()sbull_transfer()

9

Page 10: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Nand-falsh simulation Simulate a nand type flash in memory Design an experiment that observing the wear leveling

erase count Two parts, one for ext2 one for jffs2

Two steps Understanding the way of erasing Experiment

Environment 64MB nand type flash 512B page size

10

Page 11: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Step 1:Trace code..

At ..linux/drivers/mtd/nandnand_base.c is the keyFunction nand_erase_nand

11

Page 12: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Function nand_erase_nand 1.check if address align on block bounday

2.check if length align on block bounday3.check the erase will pass the end of device4.shift to get first page5.calculate pages in each block6.check if write protected7.check whether refresh BBT8.erase operation (page by page)   -check if have bad block   -Invalidate the page cache   -see if operation failed and additional status checks are available   -see if block erase succeeded    -check if cross a chip boundary

12

Page 13: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Step 2:Experiment design

Observe form kernel debug messageUsing nandsim to simulateCounting & ploting

13

Page 14: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Experiment 2 result

14

Page 15: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Experiment 2 result

15

Page 16: Presenter : kilroy 1. Introduction Experiment 1 - Simulate a virtual disk device Experiment 2 - Nand-flash simulation for wear leveling algo. Conclusion

Working log will be your good friendGood habit Bug & balk recordShare your problem & result to othersKeep your schedule in mind

Experience form experiment