[Sheepdog] [PATCH 2/2] sheep: abstract out store IO interface

Christoph Hellwig hch at infradead.org
Wed Nov 16 09:31:18 CET 2011


On Wed, Nov 16, 2011 at 04:11:36PM +0800, Liu Yuan wrote:
> +struct store_driver {
> +	const char *driver_name;
> +	int (*init)(char *path);
> +	int (*open)(uint32_t epoch, uint64_t oid, int flags, int *ret);
> +	ssize_t (*write)(uint64_t oid, int fd, void *buf, int len, off_t offset);
> +	ssize_t (*read)(uint64_t oid, int fd, void *buf, int len, off_t offset);
> +	int (*close)(int fd);
> +};

Passing an fd round seems to make the interface fairly non-generic.

A void pointer would allow the driver to store whatever it needs
there (and simple drivers can still cast the fd into them without memory
allocation).

Also in the open routine I would:

 - return the return value, and the private data in the arguments, that
   makes the code a bit more readable
 - not pass posix open flags, but your own.  It seems like the only one
   for now would be the create new file flag.
 - shouldn't the check for short writes, and the error code translation
   side inside the write method?




More information about the sheepdog mailing list