diff options
| author | Pranith Kumar K <pranithk@gluster.com> | 2012-09-05 20:16:52 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2012-09-06 13:28:14 -0700 | 
| commit | ff4b227910903b0958bdd5437d6d93ddb54919ce (patch) | |
| tree | e0388fcc3f82116108425bae2e1853a5f59851b5 /xlators/storage/posix/src/posix.c | |
| parent | fb6c8f8b4efb113d302fd53910bbe5c321eafd7a (diff) | |
storage/posix: Add or_array/and_array op for xattrop
Problem:
For set/reset of outcast (ALL changelog bits set per transaction
type i.e. data/mdata/entry) from afr the capability of OR/AND in
xattrop is needed in posix.  Otherwise marking outcast will only
be possible in self-heals where appropriate locks are held so
that no other transaction is in progress, so exact number can be
computed with which when XATTROP_ADD happens all bits will be set
for that changelog.
Fix:
Implemented new xattrop-op OR_ARRAY, AND_ARRAY. Made checks in
__add_array to work well with __or_array.
Tests:
From Afr code made an OR_ARRAY with ALL bits set and it reflected
on the changelog xattrs. changelog incrementing did not have any
effects on the all-set changelog.
From Afr code made an AND_ARRAY with 0 and it reflected in the
changelog xattrs.
Change-Id: Ie89c78a43d05789e3a8fa03d2422b52083ae80b9
BUG: 847671
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.org/3909
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
| -rw-r--r-- | xlators/storage/posix/src/posix.c | 36 | 
1 files changed, 35 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 64cfca0c0..9e23c4b72 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3081,9 +3081,31 @@ posix_print_xattr (dict_t *this,  static void  __add_array (int32_t *dest, int32_t *src, int count)  { +        int     i = 0; +        int32_t destval = 0; +        for (i = 0; i < count; i++) { +                destval = ntoh32 (dest[i]); +                if (destval == 0xffffffff) +                        continue; +                dest[i] = hton32 (destval + ntoh32 (src[i])); +        } +} + +static void +__or_array (int32_t *dest, int32_t *src, int count) +{ +        int i = 0; +        for (i = 0; i < count; i++) { +                dest[i] = hton32 (ntoh32 (dest[i]) | ntoh32 (src[i])); +        } +} + +static void +__and_array (int32_t *dest, int32_t *src, int count) +{          int i = 0;          for (i = 0; i < count; i++) { -                dest[i] = hton32 (ntoh32 (dest[i]) + ntoh32 (src[i])); +                dest[i] = hton32 (ntoh32 (dest[i]) & ntoh32 (src[i]));          }  } @@ -3205,6 +3227,18 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,                                                    v->len / 8);                                  break; +                        case GF_XATTROP_OR_ARRAY: +                                __or_array ((int32_t *) array, +                                            (int32_t *) trav->value->data, +                                            trav->value->len / 4); +                                break; + +                        case GF_XATTROP_AND_ARRAY: +                                __and_array ((int32_t *) array, +                                             (int32_t *) trav->value->data, +                                             trav->value->len / 4); +                                break; +                          default:                                  gf_log (this->name, GF_LOG_ERROR,                                          "Unknown xattrop type (%d) on %s. Please send "  | 
