diff options
| author | vmallika <vmallika@redhat.com> | 2015-09-28 16:52:53 +0530 | 
|---|---|---|
| committer | Raghavendra G <rgowdapp@redhat.com> | 2015-09-28 22:35:19 -0700 | 
| commit | 9d31a55b7c4c4e1aeedfdc74eadbf36902f7bcd9 (patch) | |
| tree | 491644f0a1757b6e695e6ae1e25a989fbf654a99 /libglusterfs/src | |
| parent | d41bbb6dbaf64a8ef55e40e0550b83daac1eeb7a (diff) | |
posix: xattrop 'GF_XATTROP_ADD_ARRAY_WITH_DEFAULT' implementation
This is a backport of http://review.gluster.org/#/c/11702
Implementation of xattrop type:
GF_XATTROP_ADD_ARRAY_WITH_DEFAULT
GF_XATTROP_ADD_ARRAY64_WITH_DEFAULT
These operations are similar to 'GF_XATTROP_ADD_ARRAY',
except that it adds a default value if xattr is missing
or its value is zero on disk.
One use-case of this operation is in inode-quota.
When a new directory is created, its default dir_count
should be set to 1. So when a xattrop performed setting
inode-xattrs, it should account initial dir_count
1 if the xattrs are not present
Here is the usage of this operation
value required in xdata for each key
struct array {
    int32_t   newvalue_1;
    int32_t   newvalue_2;
    ...
    int32_t   newvalue_n;
    int32_t   default_1;
    int32_t   default_2;
    ...
    int32_t   default_n;
};
or
struct array {
    int32_t   value_1;
    int32_t   value_2;
    ...
    int32_t   value_n;
} data[2];
fill data[0] with new value to add
fill data[1] with default value
xattrop GF_XATTROP_ADD_ARRAY_WITH_DEFAULT
for i from 1 to n
{
    if (xattr (dest_i) is zero or not set in the disk)
        dest_i = newvalue_i + default_i
    else
        dest_i = dest_i + newvalue_i
}
value in xdata after xattrop is successful
struct array {
    int32_t   dest_1;
    int32_t   dest_2;
    ...
    int32_t   dest_n;
};
> Change-Id: Ic6a08473e99fd98299a839d4d8416081a7534efd
> BUG: 1243946
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/11702
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Change-Id: Ie0c8285d9d582afbc808b0fd878f6c02957ff928
BUG: 1266882
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/12241
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/glusterfs.h | 4 | 
1 files changed, 3 insertions, 1 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index b3851347da3..f23f19cbaa0 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -378,7 +378,9 @@ typedef enum {          GF_XATTROP_ADD_ARRAY64,          GF_XATTROP_OR_ARRAY,          GF_XATTROP_AND_ARRAY, -        GF_XATTROP_GET_AND_SET +        GF_XATTROP_GET_AND_SET, +        GF_XATTROP_ADD_ARRAY_WITH_DEFAULT, +        GF_XATTROP_ADD_ARRAY64_WITH_DEFAULT  } gf_xattrop_flags_t;  #define GF_SET_IF_NOT_PRESENT 0x1 /* default behaviour */  | 
