[sheepdog] [PATCH v2 2/4] sheepdev: linux kernel module of block device driver for sheepdog

Liu Yuan namei.unix at gmail.com
Mon Jan 7 09:20:22 CET 2013


On 01/07/2013 02:42 PM, levin li wrote:
> From: levin li <xingke.lwp at taobao.com>
> 
> This module provides function for users to take sheepdog VDIs as block
> devices in linux, users can register a VDI to its kernel space, it just
> like that a new hard disk is added to the computer, users can create
> partitions for the disk, format the disk or mount the disk, it provides
> users a efficient way to use sheepdog as distributed storage system.
> 
> The usage is easy, after install the module sheepdev.ko, it creates a proc
> entry '/proc/entry', you can write into the proc entry file to control
> the driver.
> 
> Add a new block device from an existing sheepdog VDI:
> 
> # echo "add 127.0.0.1:7070 linux" > /proc/sheep
> 
> It would create a block device /dev/sheepa, you can format/mount this device:
> 
> # mkfs.ext4 /dev/sheepa
> # mount -t ext4 /sheep/sheepa test
> 
> Remove a block device from the kernel:
> 
> # echo "del sheepa" > /proc/sheep

would better use of format of 'del vdi:tag'.

> 
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
>  sheepdev/connect.c |  178 ++++++++++++
>  sheepdev/device.c  |  774 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  sheepdev/proc.c    |  158 +++++++++++
>  sheepdev/sheep.c   |  176 ++++++++++++
>  sheepdev/sheep.h   |  119 ++++++++

use sheepdev.h instead of sheep.h.

+static int process_request(void *data)

this function is too big. I think you'd better split it up into
read/write and use a wrapper read functions for e.g,
int process_request(void *data) {
   if (!write)
      return do_read_request(...)

   ...handle write...  #modularize write/update if possible
   ...handle inode update if necessary...
}

fold static void sd_init_req(struct sd_req *req, uint8_t opcode) into
the source code. This isn't necessary because it doesn't reduce the code
nor clarify the code.

Last, current driver can't run VDI as a local block device from QEMU yet.

Thanks,
Yuan



More information about the sheepdog mailing list