<div dir="ltr">Mohan,<div>It would be better to approach this problem by defining the FOPs and behavior at the xlator levels, and let gfapi calls be simple wrappers around the FOPs. We can introduce new FOPs splice() and reflink(), and discuss more on the best MERGE semantics.</div>
<div><br></div><div>Avati</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 9, 2013 at 11:48 PM, M. Mohan Kumar <span dir="ltr">&lt;<a href="mailto:mohan@in.ibm.com" target="_blank">mohan@in.ibm.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello,<br>
<br>
BD xlator provides certain features such as server offloaded copy,<br>
snapshot etc. But there is no standard way of invoking these operations<br>
due to the limitation in fops and system call interfaces. One has to<br>
issue setxattr interface to achieve these offload operations. Using<br>
setxattr interface in GlusterFS for all non standard operations becomes<br>
ugly and complicated. We are looking for adding new FOPs to cover<br>
these operations.<br>
<br>
glfs interfaces for BD xlator:<br>
-------------------------------<br>
We are looking for adding interfaces to libgfapi to facilitate consuming<br>
BD xlator features seamlessly. As of now one has to create a posix file<br>
and then issue setxattr/fsetxattr call to create a LV and map that LV to<br>
the posix file. For offload operations they have to get the gfid of the<br>
destination file and pass that gfid in {f}setxattr interface.<br>
<br>
Typical users of BD xlator will be qemu-img utility. To create a BD<br>
backed file on a GlusterFS volume, qemu-img has to issue glfs_create and<br>
glfs_fsetxattr, but it doesn&#39;t look elegant. Idea is to provide a single<br>
glfs call to create a posix file, BD and map that BD to the posix file.<br>
<br>
/*<br>
  SYNOPSIS<br>
<br>
  glfs_bd_creat: Create a posix file, BD and maps the posix file to BD<br>
  in a BD GlusterFS volume.<br>
<br>
  DESCRIPTION<br>
<br>
  This function creates a posix file &amp; BD and maps them. This interface<br>
  takes care of the transaction consistency case where posix file creation<br>
  succeeded but BD creation failed for whatever reason, created posix<br>
  file is deleted to make sure that file is not dangling.<br>
<br>
  PARAMETERS<br>
<br>
  @fs: The &#39;virtual mount&#39; object to be initialized.<br>
<br>
  @path: Path of the posix file within the virtual mount.<br>
<br>
  @mode: Permission of the file to be created.<br>
<br>
  @flags: Create flags. See open(2). O_EXCL is supported.<br>
<br>
  RETURN VALUES<br>
<br>
  NULL   : Failure. @errno will be set with the type of failure.<br>
  @errno: EOPNOTSUPP if underlying volume is not BD capable.<br>
<br>
  Others : Pointer to the opened glfs_fd_t.<br>
 */<br>
struct glfs_fd * glfs_bd_create(struct glfs *fs, const char *path, int flags,<br>
                     mode_t mode);<br>
<br>
Also planning to provide glfs interfaces for other offload features of<br>
BD such as snapshot, clone and merge. This API can be used to abstract<br>
the steps involved in getting the gfid of the destination file and<br>
passing it to the setfattr interface (optionally mode parameter can be<br>
used to specify if the destination file has to be created, as of now bd<br>
xlator code expects the destination file to exist for offload<br>
operations).<br>
<br>
/*<br>
  SYNOPSIS<br>
<br>
  glfs_copy: Offloads copy operation between two files.<br>
<br>
  DESCRIPTION<br>
<br>
  This function optionally creates destination posix file and initiates<br>
  server offloaded copy between them. Optionally based on<br>
  the mode it could create destination file and issue glfs_{f}setxattr<br>
  interface to do actual offload operation.<br>
<br>
  PARAMETERS<br>
<br>
  @fs: The &#39;virtual mount&#39; object to be initialized.<br>
<br>
  @source: Path of the source file within the virtual mount.<br>
<br>
  @dest: Path of the destination file within the virtual mount.<br>
<br>
  @flag: Specifies if destination file need to be created or not.<br>
<br>
  @mode: Permission of the destination file to be created.<br>
<br>
  RETURN VALUES<br>
<br>
  -1 : Failure. @errno will be set with the type of failure.<br>
  0  : Success<br>
<br>
 */<br>
<br>
int glfs_copy(struct glfs *fs, const char *source, const char *dest,<br>
                        int mode);<br>
<br>
Similarly<br>
int glfs_snapshot(struct glfs *fs, const char *source, const char *dest,<br>
    int mode);<br>
int glfs_merge(struct glfs *fs, const char *snapshot);<br>
<br>
<br>
Upstream effort for server offloaded and copy on write:<br>
-------------------------------------------------------<br>
Clone - offloaded copy:<br>
FS Community already started discussing about the interfaces for<br>
supporting server offloaded copy. Initially it started with adding a new<br>
syscall &#39;copy_range&#39; [<a href="https://patchwork.kernel.org/patch/2568761/" target="_blank">https://patchwork.kernel.org/patch/2568761/</a>] and<br>
later the plan is to use existing splice system call itself to extend<br>
copy between two regular files<br>
[<a href="http://article.gmane.org/gmane.linux.kernel/1560133" target="_blank">http://article.gmane.org/gmane.linux.kernel/1560133</a>].  So is it safe to<br>
assume that splice is the way for copy offload and add these FOPs to<br>
GlusterFS(XFS, FUSE also) and support it in BD xlator?<br>
<br>
Snapshot - reflink:<br>
Also there is an upstream effort to provide interfaces for creating Copy<br>
on Write files (ie snapshots in LVM terminlogy) using reflink syscall<br>
interface, but its not merged in upstream [<a href="http://lwn.net/Articles/331808/" target="_blank">http://lwn.net/Articles/331808/</a>]<br>
This snapshot feature is supported by BRTFS and OCFS2 through ioctl<br>
interface. Can we assume its the way for snapshot interface and add FOPs<br>
similar to splice in GlusterFS stack?<br>
<br>
Merge:<br>
There is no discussion happening about defining an interface for<br>
snapshot merge. IIUC deleting a source file in BTRFS results in snapshot<br>
merge. But in LVM, merging a snapshot results in snapshot LV getting<br>
deleted. So can BD xlator also mimic this by merging the snapshot when<br>
there is a request to remove the snapshot file? But if an user doesn&#39;t<br>
want to merge but wants to remove the snapshot no way he can specify that.<br>
<br>
Concerns:<br>
<br>
But when upstream supports copy offload via splice &amp; snapshot via<br>
reflink syscalls these glfs interfaces become redundant and might needed<br>
to be removed.<br>
<br>
<br>
_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a><br>
<a href="https://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">https://lists.nongnu.org/mailman/listinfo/gluster-devel</a><br>
</blockquote></div><br></div>