summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-handleops.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2013-12-11 16:26:25 -0500
committerJeff Darcy <jdarcy@redhat.com>2013-12-11 16:26:25 -0500
commitef171ff2bfd114e46442441fbdeb692a416cc951 (patch)
tree27ac663045954c8efb145fbbae3df87d7bbfe5b3 /api/src/glfs-handleops.c
parent4bbbda2017be3cfae57c122d70d11c9470364f63 (diff)
Roll-up patch for NSR so far.
Previous history: https://forge.gluster.org/~jdarcy/glusterfs-core/glusterfs-nsr Change-Id: I2b56328788753c6a74d9589815f2dd705ac9ce6a Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r--api/src/glfs-handleops.c193
1 files changed, 127 insertions, 66 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 0f996d3a2..6a60557ff 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -270,7 +270,7 @@ out:
}
struct glfs_fd *
-glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
+glfs_h_open_with_xdata (struct glfs *fs, struct glfs_object *object, int flags, dict_t * dict)
{
int ret = -1;
struct glfs_fd *glfd = NULL;
@@ -279,7 +279,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
loc_t loc = {0, };
/* validate in args */
- if ((fs == NULL) || (object == NULL)) {
+ if ((fs == NULL) || (object == NULL) || (dict == NULL)) {
errno = EINVAL;
return NULL;
}
@@ -330,7 +330,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
GLFS_LOC_FILL_INODE (inode, loc, out);
/* fop/op */
- ret = syncop_open (subvol, &loc, flags, glfd->fd);
+ ret = syncop_open_with_xdata (subvol, &loc, flags, glfd->fd, dict);
out:
loc_wipe (&loc);
@@ -352,9 +352,16 @@ out:
return glfd;
}
+struct glfs_fd *
+glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
+{
+ return(glfs_h_open_with_xdata(fs, object, flags, NULL));
+}
+
struct glfs_object *
-glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
- int flags, mode_t mode, struct stat *stat)
+glfs_h_creat_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path,
+ int flags, mode_t mode, struct stat *stat,
+ uuid_t gfid, dict_t * xattr_req)
{
int ret = -1;
struct glfs_fd *glfd = NULL;
@@ -362,12 +369,10 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
inode_t *inode = NULL;
loc_t loc = {0, };
struct iatt iatt = {0, };
- uuid_t gfid;
- dict_t *xattr_req = NULL;
struct glfs_object *object = NULL;
/* validate in args */
- if ((fs == NULL) || (parent == NULL) || (path == NULL)) {
+ if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) {
errno = EINVAL;
return NULL;
}
@@ -389,14 +394,6 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
goto out;
}
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
-
- uuid_generate (gfid);
ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16);
if (ret) {
ret = -1;
@@ -464,20 +461,34 @@ out:
}
struct glfs_object *
-glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path,
- mode_t mode, struct stat *stat)
+glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
+ int flags, mode_t mode, struct stat *stat)
+{
+ uuid_t gfid;
+ dict_t *xattr_req = NULL;
+
+ xattr_req = dict_new ();
+ if (!xattr_req) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ uuid_generate (gfid);
+ return(glfs_h_creat_with_xdata(fs, parent, path, flags, mode, stat, gfid, xattr_req));
+}
+
+struct glfs_object *
+glfs_h_mkdir_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path,
+ mode_t mode, struct stat *stat, uuid_t gfid, dict_t *xattr_req)
{
int ret = -1;
xlator_t *subvol = NULL;
inode_t *inode = NULL;
loc_t loc = {0, };
struct iatt iatt = {0, };
- uuid_t gfid;
- dict_t *xattr_req = NULL;
struct glfs_object *object = NULL;
/* validate in args */
- if ((fs == NULL) || (parent == NULL) || (path == NULL)) {
+ if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) {
errno = EINVAL;
return NULL;
}
@@ -499,14 +510,6 @@ glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path,
goto out;
}
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
-
- uuid_generate (gfid);
ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16);
if (ret) {
ret = -1;
@@ -552,20 +555,36 @@ out:
}
struct glfs_object *
-glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path,
- mode_t mode, dev_t dev, struct stat *stat)
+glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path,
+ mode_t mode, struct stat *stat)
+{
+ uuid_t gfid;
+ dict_t *xattr_req = NULL;
+
+ xattr_req = dict_new ();
+ if (!xattr_req) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ uuid_generate (gfid);
+ return(glfs_h_mkdir_with_xdata(fs, parent, path, mode, stat, gfid, xattr_req));
+}
+
+struct glfs_object *
+glfs_h_mknod_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path,
+ mode_t mode, dev_t dev, struct stat *stat,
+ uuid_t gfid, dict_t * xattr_req)
{
int ret = -1;
xlator_t *subvol = NULL;
inode_t *inode = NULL;
loc_t loc = {0, };
struct iatt iatt = {0, };
- uuid_t gfid;
- dict_t *xattr_req = NULL;
struct glfs_object *object = NULL;
/* validate in args */
- if ((fs == NULL) || (parent == NULL) || (path == NULL)) {
+ if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) {
errno = EINVAL;
return NULL;
}
@@ -587,14 +606,6 @@ glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path,
goto out;
}
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
-
- uuid_generate (gfid);
ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16);
if (ret) {
ret = -1;
@@ -638,8 +649,26 @@ out:
return object;
}
+struct glfs_object *
+glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path,
+ mode_t mode, dev_t dev, struct stat *stat)
+{
+ uuid_t gfid;
+ dict_t *xattr_req = NULL;
+
+ xattr_req = dict_new ();
+ if (!xattr_req) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ uuid_generate (gfid);
+
+ return(glfs_h_mknod_with_xdata(fs, parent, path, mode, dev, stat, gfid, xattr_req));
+}
+
int
-glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path)
+glfs_h_unlink_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path, dict_t *dict)
{
int ret = -1;
xlator_t *subvol = NULL;
@@ -675,12 +704,12 @@ glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path)
}
if (!IA_ISDIR(loc.inode->ia_type)) {
- ret = syncop_unlink (subvol, &loc);
+ ret = syncop_unlink_with_xdata (subvol, &loc, dict);
if (ret != 0) {
goto out;
}
} else {
- ret = syncop_rmdir (subvol, &loc, 0);
+ ret = syncop_rmdir_with_xdata (subvol, &loc, 0, dict);
if (ret != 0) {
goto out;
}
@@ -700,8 +729,14 @@ out:
return ret;
}
+int
+glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path)
+{
+ return(glfs_h_unlink_with_xdata(fs, parent, path, NULL));
+}
+
struct glfs_fd *
-glfs_h_opendir (struct glfs *fs, struct glfs_object *object)
+glfs_h_opendir_with_xdata (struct glfs *fs, struct glfs_object *object, dict_t *dict)
{
int ret = -1;
struct glfs_fd *glfd = NULL;
@@ -754,7 +789,7 @@ glfs_h_opendir (struct glfs *fs, struct glfs_object *object)
GLFS_LOC_FILL_INODE (inode, loc, out);
/* fop/op */
- ret = syncop_opendir (subvol, &loc, glfd->fd);
+ ret = syncop_opendir_with_xdata (subvol, &loc, glfd->fd, dict);
out:
loc_wipe (&loc);
@@ -775,6 +810,12 @@ out:
return glfd;
}
+struct glfs_fd *
+glfs_h_opendir (struct glfs *fs, struct glfs_object *object)
+{
+ return(glfs_h_opendir_with_xdata(fs, object, NULL));
+}
+
ssize_t
glfs_h_extract_handle (struct glfs_object *object, unsigned char *handle,
int len)
@@ -951,21 +992,19 @@ out:
}
struct glfs_object *
-glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name,
- const char *data, struct stat *stat)
+glfs_h_symlink_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *name,
+ const char *data, struct stat *stat, uuid_t gfid, dict_t * xattr_req)
{
int ret = -1;
xlator_t *subvol = NULL;
inode_t *inode = NULL;
loc_t loc = {0, };
struct iatt iatt = {0, };
- uuid_t gfid;
- dict_t *xattr_req = NULL;
struct glfs_object *object = NULL;
/* validate in args */
if ((fs == NULL) || (parent == NULL) || (name == NULL) ||
- (data == NULL)) {
+ (data == NULL) || (xattr_req == NULL)) {
errno = EINVAL;
return NULL;
}
@@ -987,14 +1026,6 @@ glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name,
goto out;
}
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
-
- uuid_generate (gfid);
ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16);
if (ret) {
ret = -1;
@@ -1044,6 +1075,23 @@ out:
return object;
}
+struct glfs_object *
+glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name,
+ const char *data, struct stat *stat)
+{
+ uuid_t gfid;
+ dict_t *xattr_req = NULL;
+
+ xattr_req = dict_new ();
+ if (!xattr_req) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ uuid_generate (gfid);
+ return(glfs_h_symlink_with_xdata(fs, parent, name, data, stat, gfid, xattr_req));
+}
+
int
glfs_h_readlink (struct glfs *fs, struct glfs_object *object, char *buf,
size_t bufsiz)
@@ -1101,8 +1149,8 @@ out:
}
int
-glfs_h_link (struct glfs *fs, struct glfs_object *linksrc,
- struct glfs_object *parent, const char *name)
+glfs_h_link_with_xdata (struct glfs *fs, struct glfs_object *linksrc,
+ struct glfs_object *parent, const char *name, dict_t *dict)
{
int ret = -1;
xlator_t *subvol = NULL;
@@ -1165,7 +1213,7 @@ glfs_h_link (struct glfs *fs, struct glfs_object *linksrc,
newloc.inode = inode_ref (inode);
/* fop/op */
- ret = syncop_link (subvol, &oldloc, &newloc);
+ ret = syncop_link_with_xdata (subvol, &oldloc, &newloc, dict);
if (ret == 0)
/* TODO: No iatt to pass as there has been no lookup */
@@ -1186,8 +1234,14 @@ out:
}
int
-glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname,
- struct glfs_object *newdir, const char *newname)
+glfs_h_link (struct glfs *fs, struct glfs_object *linksrc,
+ struct glfs_object *parent, const char *name)
+{
+ return(glfs_h_link_with_xdata(fs, linksrc, parent, name, NULL));
+}
+int
+glfs_h_rename_with_xdata (struct glfs *fs, struct glfs_object *olddir, const char *oldname,
+ struct glfs_object *newdir, const char *newname, dict_t *dict)
{
int ret = -1;
xlator_t *subvol = NULL;
@@ -1255,7 +1309,7 @@ glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname,
/* TODO: check if new or old is a prefix of the other, and fail EINVAL */
- ret = syncop_rename (subvol, &oldloc, &newloc);
+ ret = syncop_rename_with_xdata (subvol, &oldloc, &newloc, dict);
if (ret == 0)
inode_rename (oldloc.parent->table, oldloc.parent, oldloc.name,
@@ -1276,3 +1330,10 @@ out:
return ret;
}
+
+int
+glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname,
+ struct glfs_object *newdir, const char *newname)
+{
+ return(glfs_h_rename_with_xdata(fs, olddir, oldname, newdir, newname, NULL));
+}