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

Liu Yuan namei.unix at gmail.com
Wed Nov 16 10:02:39 CET 2011


On 11/16/2011 04:31 PM, Christoph Hellwig wrote:

> 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).
> 


Okay. I don't like fd either. Even more, I don't like open/rw/close
group to interface with a kv-store.

Void pointer is a nice way to return something back if store driver
doesn't care fd.

Anyway, I hope this interface is just provisional.

> 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?
> 


Okay, I'll submit V2.

Thanks,
Yuan



More information about the sheepdog mailing list