Xen Disk I/O: from guest domain to real devices

本文详细介绍了Xen虚拟环境中块设备驱动的工作原理及其实现细节,包括关键的数据结构如blkfront_info,以及核心函数如blkif_open、do_blkif_request等。通过剖析源代码,展示了读写操作的具体流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

static struct block_device_operations xlvbd_block_fops ={
.owner = THIS_MODULE,
.open = blkif_open,
.release = blkif_release,
.ioctl = blkif_ioctl,
.getgeo = blkif_getgeo
};

/*
* We have one of these PER vbd, whether ide, scsi or 'other'.
* They hang in private_data off the gendisk structure.
* We may end up putting all kinds of interesting stuff here :-)
*/
struct blkfront_info {
struct xenbus_device *xbdev;
dev_t dev;
struct gendisk *gd;
int vdevice;
blkif_vdev_t handle;
int connected;
int ring_ref;
blkif_front_ring_t ring;
struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
unsigned int irq;
struct xlbd_major_info *mi;
request_queue_t *rq;
struct work_struct work;
struct gnttab_free_callback callback;
struct blk_shadow shadow[BLK_RING_SIZE];
unsigned long shadow_free;
int feature_barrier;
int is_ready;
int users;
};

struct xenbus_device {
const char *devicetype;
const char *nodename;
const char *otherend;
int otherend_id;
struct xenbus_watch otherend_watch;
struct device dev;
enum xenbus_state state;
struct completion down;
};

1. "open"

(struct file_operations)->open
blkdev_open
do_open
(struct gendisk)->(struct block_device_operations)->open
blkif_open

2. "read"

(struct file_operations)->read
generic_file_read
__generic_file_aio_read
do_generic_file_read
do_generic_mapping_read
(struct address_space)->(struct address_space_operations)->readpage
ext2_readpage
mpage_readpage
do_mpage_readpage
mpage_bio_submit
submit_bio
generic_make_request
(struct request_queue)->make_request_fn
__make_request-----<<<<<<<---ELEVATOR scheduler applies here
__generic_unplug_device
(struct request_queue)->request_fn
do_blkif_request---<<<<<<<---XEN blkfront applies here
blkif_queue_request(blkfront.c)
flush_requests
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&info->ring, notify);
notify_remote_via_irq()
notify_remote_via_evtchn()
VOID(HYPERVISOR_event_channel_op(EVTCHNOP_send, &send));
evtchn_send()
--evtchn_set_pending
---vcpu_mark_events_pending

-------------------------------------------------
==xlvbd_init_blk_queue(vbd.c)
==blk_init_queue(do_blkif_request, &blkif_io_lock);
==blk_init_queue_node(ll_rw_blk.c)
===(struct request_queue)->request_fn = do_blkif_request
===(struct request_queue)->make_request_fn= __make_request;
-------------------------------------------------

3. "write"

generic_file_write
__generic_file_write_nolock
__generic_file_aio_write_nolock
generic_file_buffered_write
(struct address_space)->(struct address_space_operations)->commit_write
blkdev_commit_write
block_commit_write
__block_commit_write

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值