<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi all</div><div><br></div><div>As we discussed in the last IRC meeting, I would like to propose an initial design</div><div>of libsheepdog. </div><div><br></div><div>It is just quite initial, to avoid of waisting much time on wrong things.</div><div><br></div><div>Please feel free to raise your suggestions.</div><div><br></div><div>(PS: the doc is in html format. if you stuck on it, I will send a plain text version)</div><div><br></div><div>Thanks,</div><div>Kyle</div><div><br></div><div><br></div><div><div id="content" style="font-family: Times; "><h1 class="title" style="text-align: center;">Design of Libsheepdog</h1><div id="table-of-contents"><h2>Table of Contents</h2><div id="text-table-of-contents"><ul><li>1. Original Intention</li><li>2. APIs</li></ul></div></div><div id="outline-container-sec-1" class="outline-2"><h2 id="sec-1"><span class="section-number-2">1</span> Original Intention</h2><div class="outline-text-2" id="text-1"><p>Libsheepdog has been discussed for a long time. And it's time to introduce it to sheepdog project.</p><p>Libsheepdog provides the ability of operating vdi and vdi snapshot. It will be used by other systems which are built on top of sheepdog or use sheepdog as a sub-module.</p></div></div><div id="outline-container-sec-2" class="outline-2"><h2 id="sec-2"><span class="section-number-2">2</span> APIs</h2><div class="outline-text-2" id="text-2"><div class="org-src-container"><pre class="src src-c" style="border: 1px solid rgb(204, 204, 204); box-shadow: rgb(238, 238, 238) 3px 3px 3px; padding: 1.2em 8pt 8pt; overflow: visible; margin: 1.2em; position: relative; ">typedef void *sd_t;
typedef struct sd_inode *sd_vdi_t;
struct string_iterator {
void *opaqe;
bool (*has_next)(void);
char *(*next)(void);
void (*destory)(void);
};
/* connection */
int sd_init(char *addr, const sd_t *sd);
int sd_close(sd_t *sd);
/* vdi */
int sd_vdi_create(sd_t sd, const char *name, size_t size, int copies,
bool prealloc, const sd_vdi_t *vdi);
int sd_vdi_clone(sd_t sd, const sd_vdi_t src_vdi, const char *dst_name,
int copies, const sd_vdi_t *dst_vdi);
int sd_vdi_open(sd_t sd, const char *name, const sd_vdi_t *vdi);
int sd_vdi_close(const sd_vdi_t *vdi);
int sd_vdi_read(sd_t sd, const sd_vdi_t vdi, void *data, size_t size,
size_t offset);
int sd_vdi_write(sd_t sd, const sd_vdi_t vdi, void *data, size_t size,
size_t offset, bool writeback);
int sd_vdi_resize(sd_t sd, const sd_vdi_t vdi, size_t size);
int sd_vdi_delete(sd_t sd, const char *name);
int sd_vdi_setattr(sd_t sd, const char *name, const char *key, void *value,
size_t value_len);
int sd_vdi_getattr(sd_t sd, const char *name, const char *key, void *value,
size_t value_len);
int sd_vdi_list(sd_t sd, string_iterator *si);
/* snapshot */
int sd_vdi_snap_create(sd_t sd, const sd_vdi_t vdi, const char *tag,
const sd_vdi_t snap_vdi);
int sd_vdi_snap_open(sd_t sd, const char *name, const char *tag, int idx,
const sd_vdi_t *snap_vdi);
int sd_vdi_snap_rollback(sd_t sd, const sd_vdi_t vdi);
int sd_vdi_snap_read(sd_t sd, const sd_vdi_t vdi, void *data, size_t size,
size_t offset);
</pre></div><p>Here are some semantics behind them:</p><ul class="org-ul"><li>sd_t and sd_vdi_t are created and destroyed explicitly by calling the APIs, but user don't need to care about the memory</li><li>current APIs are all blocking, and no additional thread in backgroud</li></ul><p>TODO:</p><ul class="org-ul"><li>asychronous APIs if needed</li><li>cluster operations if needed</li></ul></div></div></div><div id="postamble" class="status" style="font-family: Times; "><div style="font-size: 14px; margin: 0.2em; ">Author: Kai Zhang</div><div style="font-size: 14px; margin: 0.2em; ">Created: 2013-06-25 Tue 19:34</div><div style="font-size: 14px; margin: 0.2em; "><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.3.2 (<a href="http://orgmode.org">Org</a> mode 8.0.2)</div><div style="font-size: 14px; margin: 0.2em; "><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></div></div></div></body></html>