From 0bfb02e3b56abf411882f245655921a91df885ef Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 30 Dec 2015 14:56:12 +0530 Subject: features/bitrot: add check for corrupted object in f{stat} Backport of http://review.gluster.org/13120 Check for corrupted objects is done bt bitrot stub component for data operations and such fops are denied processing by returning EIO. These checks were not done for operations such as get/set extended attribute, stat and the likes - IOW, stub only blocked pure data operations. However, its necessary to have these checks for certain other fops, most importantly stat (and fstat). This is due to the fact that clients could possibly get stale stat information (such as size, {a,c,m}time) resulting in incorrect operation of the application that rely on these fields. Note that, the data that replication would take care of fetching good (and correct) data, but the staleness of stat information could lead to data inconsistencies (e.g., rebalance, tier). Change-Id: I5a22780373b182a13f8d2c4ca6b7d9aa0ffbfca3 BUG: 1297213 Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.org/13276 Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- tests/bugs/bitrot/bug-1288490.t | 48 +++++++++++++++++++++++++++++++++++++++++ tests/volume.rc | 8 +++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/bugs/bitrot/bug-1288490.t (limited to 'tests') diff --git a/tests/bugs/bitrot/bug-1288490.t b/tests/bugs/bitrot/bug-1288490.t new file mode 100644 index 00000000000..1d5e913cd59 --- /dev/null +++ b/tests/bugs/bitrot/bug-1288490.t @@ -0,0 +1,48 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/brick{0,1} +TEST $CLI volume start $V0 + +TEST $CLI volume bitrot $V0 enable +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0 +TEST dd if=/dev/urandom of=$M0/FILE bs=1024 count=1 + +# corrupt data -- append 2 bytes +echo -n "~~" >> $B0/brick0/FILE +# manually set bad-file xattr +TEST setfattr -n trusted.bit-rot.bad-file -v 0x3100 $B0/brick0/FILE + +TEST $CLI volume stop $V0 +TEST $CLI volume start $V0 +EXPECT 'Started' volinfo_field $V0 'Status'; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" brick_up_status $V0 $H0 $B0/brick0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" brick_up_status $V0 $H0 $B0/brick1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +# trigger lookup +TEST stat $M0/FILE + +# extend the file +TEST dd if=/dev/urandom of=$M0/FILE bs=1024 count=1 oflag=append conv=notrunc + +# check backend file size +EXPECT "1026" stat -c "%s" $B0/brick0/FILE +EXPECT "2048" stat -c "%s" $B0/brick1/FILE + +# check file size on mount +EXPECT "2048" stat -c "%s" $M0/FILE + +TEST umount $M0 +cleanup diff --git a/tests/volume.rc b/tests/volume.rc index 15037059deb..8724c08d249 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -19,6 +19,14 @@ function online_brick_count () pgrep glusterfsd | wc -l } +function brick_up_status { + local vol=$1 + local host=$2 + local brick=$3 + brick_pid=$(get_brick_pid $vol $host $brick) + gluster volume status | grep $brick_pid | awk '{print $4}' +} + function volume_option() { local vol=$1 -- cgit