diff options
| author | Mohammed Rafi KC <rkavunga@redhat.com> | 2015-04-23 22:57:39 +0530 | 
|---|---|---|
| committer | Niels de Vos <ndevos@redhat.com> | 2015-05-07 02:24:59 -0700 | 
| commit | 2a4f346fe57fb21330857b7eb75153dc8abc4def (patch) | |
| tree | 35aa4afe5d50ae3102b1df48a374e1363e84cb93 | |
| parent | 4aad69a8f88acf384c812316aaa985cde2229cd7 (diff) | |
api/libgfapi: Add support for statfs handle
        Backport of http://review.gluster.org/10356
snapd feature require statfs fops and thereby
handle of statfs
Change-Id: I037ee846aee3971826a73c592e15f1be27796c64
BUG: 1218741
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: http://review.gluster.org/10356
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-on: http://review.gluster.org/10598
| -rw-r--r-- | api/src/gfapi.aliases | 1 | ||||
| -rw-r--r-- | api/src/gfapi.map | 1 | ||||
| -rw-r--r-- | api/src/glfs-handleops.c | 51 | ||||
| -rw-r--r-- | api/src/glfs-handles.h | 4 | 
4 files changed, 57 insertions, 0 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases index 8c60373fd4b..6d48ecdf2c9 100644 --- a/api/src/gfapi.aliases +++ b/api/src/gfapi.aliases @@ -129,6 +129,7 @@ _pub_glfs_ipc _glfs_ipc$GFAPI_3.7.0  _pub_glfs_h_poll_upcall _glfs_h_poll_upcall$GFAPI_3.7.0  _pub_glfs_h_acl_set _glfs_h_acl_set$GFAPI_3.7.0  _pub_glfs_h_acl_get _glfs_h_acl_get$GFAPI_3.7.0 +_pub_glfs_h_statfs _glfs_h_statfs$GFAPI_3.7.0  _priv_glfs_free_from_ctx _glfs_free_from_ctx$GFAPI_PRIVATE_3.7.0  _priv_glfs_new_from_ctx _glfs_new_from_ctx$GFAPI_PRIVATE_3.7.0 diff --git a/api/src/gfapi.map b/api/src/gfapi.map index ebb2f85e68b..24209d666dc 100644 --- a/api/src/gfapi.map +++ b/api/src/gfapi.map @@ -151,6 +151,7 @@ GFAPI_3.7.0 {  		glfs_h_poll_upcall;  		glfs_h_acl_set;  		glfs_h_acl_get; +		glfs_h_statfs;  } GFAPI_3.6.0;  GFAPI_PRIVATE_3.7.0 { diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index 886eb3fc42c..12ca94cb2dc 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -120,6 +120,57 @@ out:  GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_lookupat, 3.4.2); +int +pub_glfs_h_statfs (struct glfs *fs, struct glfs_object *object, +                   struct statvfs *statvfs) +{ +        int              ret = -1; +        xlator_t        *subvol = NULL; +        inode_t         *inode = NULL; +        loc_t            loc = {0, }; + +        /* validate in args */ +        if ((fs == NULL) || (object == NULL || statvfs == NULL)) { +                errno = EINVAL; +                return -1; +        } + +        __glfs_entry_fs (fs); + +        /* get the active volume */ +        subvol = glfs_active_subvol (fs); +        if (!subvol) { +                ret = -1; +                errno = EIO; +                goto out; +        } + +        /* get/refresh the in arg objects inode in correlation to the xlator */ +        inode = glfs_resolve_inode (fs, subvol, object); +        if (!inode) { +                errno = ESTALE; +                goto out; +        } + +        /* populate loc */ +        GLFS_LOC_FILL_INODE (inode, loc, out); + +        /* fop/op */ +        ret = syncop_statfs (subvol, &loc, statvfs, NULL, NULL); +        DECODE_SYNCOP_ERR (ret); + +        loc_wipe (&loc); + +out: +        if (inode) +                inode_unref (inode); + +        glfs_subvol_done (fs, subvol); + +        return ret; +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_statfs, 3.7.0);  int  pub_glfs_h_stat (struct glfs *fs, struct glfs_object *object, struct stat *stat) diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h index 02204a76385..9f81cb9dcbf 100644 --- a/api/src/glfs-handles.h +++ b/api/src/glfs-handles.h @@ -174,6 +174,10 @@ int glfs_h_stat(struct glfs *fs, struct glfs_object *object,                  struct stat *stat) __THROW          GFAPI_PUBLIC(glfs_h_stat, 3.4.0); +int glfs_h_statfs(struct glfs *fs, struct glfs_object *object, +                struct statvfs *stat) __THROW +        GFAPI_PUBLIC(glfs_h_statfs, 3.7.0); +  int glfs_h_getattrs (struct glfs *fs, struct glfs_object *object,  		     struct stat *stat) __THROW          GFAPI_PUBLIC(glfs_h_getattrs, 3.4.0);  | 
