glusterfs/libglusterfs
vmallika ecfa2edd78 posix: xattrop 'GF_XATTROP_ADD_ARRAY_WITH_DEFAULT' implementation
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>
2015-09-28 04:12:16 -07:00
..
2015-03-18 10:36:42 -07:00