From ecfa2edd7816abbf8fbbe43c308ddf895849e8e6 Mon Sep 17 00:00:00 2001 From: vmallika Date: Tue, 22 Sep 2015 12:17:50 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/11702 Tested-by: NetBSD Build System Reviewed-by: Raghavendra G --- libglusterfs/src/glusterfs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libglusterfs/src/glusterfs.h') diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 18ffbb1f2b1..fae7d490af8 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -373,7 +373,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 */ -- cgit