libgfapi interface of GlusterFS

One of the known methods to access glusterfs is via fuse module. However, it has some overhead or performance issues because of the number of context switches which need to be performed to complete one i/o transaction as shown below.

lex

To over come this limitation, a new method called ‘libgfapi’ is introduced. libgfapi support is available from GlusterFS-3.4 release.

libgfapi is a userspace library for accessing data in glusterfs. libgfapi library perform IO on gluster volumes directly without FUSE mount. It is a filesystem like api and runs/sits in application process context. libgfapi eliminates the fuse and the kernel vfs layer from the glusterfs volume access. The speed and latency have improved with libgfapi access.

lex

Using libgfapi, various user-space filesystems (like NFS-Ganesha or Samba) or the virtualizer (like QEMU) can interact with GlusterFS which serves as back-end filesystem. Currently below projects integrate with glusterfs using libgfapi interfaces:

* qemu storage layer
* Samba VFS plugin
* NFS-Ganesha

All the APIs in libgfapi make use of struct glfs object. This object
contains information about volume name, glusterfs context associated,
subvols in the graph etc which makes it unique for each volume.

For any application to make use of libgfapi, it should typically start
with the below APIs in the following order –

* To create a new glfs object use glfs_new() and it returns glfs_t object:

* On this newly created glfs_t, you need to be either set a volfile path
(glfs_set_volfile) or a volfile server (glfs_set_volfile_server).
In case of failures, the corresponding cleanup routine is
“glfs_unset_volfile_server”

* Specify logging parameters using glfs_set_logging():

* Initialize the glfs_t object using glfs_init()

* Incase of failures or to close the connection and destroy glfs_t
object, use glfs_fini().

All the fileops are typically divided into below categories

* a) Handle based Operations

These APIs create/make use of a glfs_object (referred as handles) unique
to each file within a volume.
The structure glfs_object contains inode pointer and gfid.

For example: Since NFS protocol uses file handles to access files, these APIs are
mainly used by NFS-Ganesha server.

Eg:

* b) File path/descriptor based Operations –

These APIs make use of file path/descriptor to determine the file on
which it needs to operate on.

For example: Samba uses these APIs for file operations.

Examples of the APIs using file path –

Once the file is opened, the file-descriptor generated is used for
further operations.

Eg:

libgfapi bindings :

libgfapi bindings are available for below languages:

– Go
– Java
– python
– Ruby

For more details on these bindings,please refer :

#www.gluster.org/community/documentation/index.php/Language_Bindings

Leave a Reply

Your email address will not be published. Required fields are marked *