1 / 26

Block Device

Outline. Block device operationsGeneric block device layerSkeleton of a block device driverReference. What will we learn ?. From this report, we learnThe details of how a block device worksll_rw_block() : trigger I/O transfer __make_request (): make request -> request queue task queue : plug/

dyami
Download Presentation

Block Device

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Block Device Q36921204 ??? Q36921115 ???

    2. Outline Block device operations Generic block device layer Skeleton of a block device driver Reference

    3. What will we learn ? From this report, we learn The details of how a block device works ll_rw_block() : trigger I/O transfer __make_request (): make request -> request queue task queue : plug/unplug use the mechanism request service routine : How to write a block device driver writing a module Init / exit implement the necessary operations block_device_operations request_fn_proc

    4. Common Block Device Operations In fs/block_dev.c struct file_operations def_blk_fops = { open: blkdev_open, release: blkdev_close, llseek: block_llseek, read: generic_file_read, write: generic_file_write, mmap: generic_file_mmap, fsync: block_fsync, ioctl: blkdev_ioctl, };

    5. Block Device Specific Operations Additional operations for block device only In include/linux/fs.h : struct block_device_operations { int (*open) (struct inode *, struct file *); int (*release) (struct inode *, struct file *); int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); int (*check_media_change) (kdev_t); int (*revalidate) (kdev_t); struct module *owner; }; In include/linux/blkdev.h : typedef void (request_fn_proc) (request_queue_t *q);

    9. Generic Block Device Layer Provides common functionality for all block devices in Linux Uniform interface (to file system) e.g. bread( ) block_prepare_write( ) block_read_full_page( ) ll_rw_block( ) buffer management and disk caching Block I/O requests scheduling Generates and queues actual I/O requests in a request queue (per device) Individual device driver services this queue (likely interrupt driven)

    10. Request Queue Data structure: in include/linux/blkdev.h Queue header: type request_queue_t typedef structure request_queue request_queue_t queue_head: double linked list of pending requests request_fn: pointer to request service routine Queue element: struct request cmd: read or write Number of request sectors, segments bh, bhtail: a list of buffer header Memory area (for I/O transfer)

    11. Request Queue

More Related