diff options
| -rwxr-xr-x | tests/bugs/bug-1064147.t | 71 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 26 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-selfheal.c | 15 | ||||
| -rw-r--r-- | xlators/storage/posix/src/posix-common.c | 16 | 
4 files changed, 110 insertions, 18 deletions
diff --git a/tests/bugs/bug-1064147.t b/tests/bugs/bug-1064147.t new file mode 100755 index 00000000000..617a1aa90e3 --- /dev/null +++ b/tests/bugs/bug-1064147.t @@ -0,0 +1,71 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +# Initialize +#------------------------------------------------------------ +cleanup; + +# Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +# Create a volume +TEST $CLI volume create $V0 $H0:/${V0}{1,2}; + +# Verify volume creation + EXPECT "$V0" volinfo_field $V0 'Volume Name'; + EXPECT 'Created' volinfo_field $V0 'Status'; + +# Start volume and verify successful start + TEST $CLI volume start $V0; + EXPECT 'Started' volinfo_field $V0 'Status'; + TEST glusterfs -s $H0 --volfile-id=$V0 $M0 +#------------------------------------------------------------ + +# Test case 1 - Subvolume down + Healing +#------------------------------------------------------------ +# Kill 2nd brick process +TEST kill -9  `ps aux | grep glusterfsd | grep ${V0}2 | grep -v grep | awk '{print $2}'`; + +# Change root permissions +TEST chmod 444 $M0 + +# Store permission for comparision +TEST permission_new=`stat -c "%A" $M0` + +# Bring up the killed brick process +TEST $CLI volume start $V0 force + +# Perform lookup +sleep 5 +TEST ls $M0 + +# Check brick permissions +TEST brick_perm=`stat -c "%A" /${V0}2` +TEST [ ${brick_perm} = ${permission_new} ] +#------------------------------------------------------------ + +# Test case 2 - Add-brick + Healing +#------------------------------------------------------------ +# Change root permissions +TEST chmod 777 $M0 + +# Store permission for comparision +TEST permission_new_2=`stat -c "%A" $M0` + +# Add a 3rd brick +TEST $CLI volume add-brick $V0 $H0:/${V0}3 + +# Perform lookup +sleep 5 +TEST ls $M0 + +# Check permissions on the new brick +TEST brick_perm2=`stat -c "%A" /${V0}3` + +TEST [ ${brick_perm2} = ${permission_new_2} ] + +cleanup; diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 2231af647de..22ef8200911 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1435,15 +1435,31 @@ dht_lookup_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,              dht_aggregate_xattr(local->xattr, xattr);          } +        if (__is_root_gfid(stbuf->ia_gfid)) { +            ret = dht_dir_has_layout(xattr, conf->xattr_name); +            if (ret >= 0) { +                if (is_greater_time(local->prebuf.ia_ctime, +                                    local->prebuf.ia_ctime_nsec, +                                    stbuf->ia_ctime, stbuf->ia_ctime_nsec)) { +                    /* Choose source */ +                    local->prebuf.ia_gid = stbuf->ia_gid; +                    local->prebuf.ia_uid = stbuf->ia_uid; + +                    local->prebuf.ia_ctime = stbuf->ia_ctime; +                    local->prebuf.ia_ctime_nsec = stbuf->ia_ctime_nsec; +                    local->prebuf.ia_prot = stbuf->ia_prot; +                } +            } +        } +          if (local->stbuf.ia_type != IA_INVAL) {              /* This is not the first subvol to respond               * Compare values to see if attrs need to be healed               */ -            if (!__is_root_gfid(stbuf->ia_gfid) && -                ((local->stbuf.ia_gid != stbuf->ia_gid) || -                 (local->stbuf.ia_uid != stbuf->ia_uid) || -                 (is_permission_different(&local->stbuf.ia_prot, -                                          &stbuf->ia_prot)))) { +            if ((local->stbuf.ia_gid != stbuf->ia_gid) || +                (local->stbuf.ia_uid != stbuf->ia_uid) || +                (is_permission_different(&local->stbuf.ia_prot, +                                         &stbuf->ia_prot))) {                  local->need_attrheal = 1;              }          } diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index eb0a853e81f..8657a22fd82 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -1941,9 +1941,18 @@ dht_selfheal_directory(call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,      local->selfheal.dir_cbk = dir_cbk;      local->selfheal.layout = dht_layout_ref(this, layout); -    if (local->need_attrheal && !IA_ISINVAL(local->mds_stbuf.ia_type)) { -        /*Use the one in the mds_stbuf*/ -        local->stbuf = local->mds_stbuf; +    if (local->need_attrheal) { +        if (__is_root_gfid(local->stbuf.ia_gfid)) { +            local->stbuf.ia_gid = local->prebuf.ia_gid; +            local->stbuf.ia_uid = local->prebuf.ia_uid; + +            local->stbuf.ia_ctime = local->prebuf.ia_ctime; +            local->stbuf.ia_ctime_nsec = local->prebuf.ia_ctime_nsec; +            local->stbuf.ia_prot = local->prebuf.ia_prot; + +        } else if (!IA_ISINVAL(local->mds_stbuf.ia_type)) { +            local->stbuf = local->mds_stbuf; +        }      }      if (!__is_root_gfid(local->stbuf.ia_gfid)) { diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c index 1fc0eae2056..da9c653218f 100644 --- a/xlators/storage/posix/src/posix-common.c +++ b/xlators/storage/posix/src/posix-common.c @@ -611,6 +611,7 @@ posix_init(xlator_t *this)          0,      };      int hdirfd = -1; +    char value;      dir_data = dict_get(this->options, "directory"); @@ -672,16 +673,11 @@ posix_init(xlator_t *this)      }      /* Check for Extended attribute support, if not present, log it */ -    op_ret = sys_lsetxattr(dir_data->data, "trusted.glusterfs.test", "working", -                           8, 0); -    if (op_ret != -1) { -        ret = sys_lremovexattr(dir_data->data, "trusted.glusterfs.test"); -        if (ret) { -            gf_msg(this->name, GF_LOG_DEBUG, errno, P_MSG_INVALID_OPTION, -                   "failed to remove xattr: " -                   "trusted.glusterfs.test"); -        } -    } else { +    size = sys_lgetxattr(dir_data->data, "user.x", &value, sizeof(value)); + +    if ((size == -1) && (errno == EOPNOTSUPP)) { +        gf_msg(this->name, GF_LOG_DEBUG, 0, P_MSG_XDATA_GETXATTR, +               "getxattr returned %zd", size);          tmp_data = dict_get(this->options, "mandate-attribute");          if (tmp_data) {              if (gf_string2boolean(tmp_data->data, &tmp_bool) == -1) {  | 
