}
run_test 1005 "test for write updating with partial chunks"
+test_1006() {
+ local tf=$DIR/$tfile
+ local tf2=$DIR2/$tfile
+ local hdf=$LUSTRE/tests/AMSR_E_L3_DailyOcean_V05_20111003.hdf
+ local tmp_hdf=$TMP/$tfile.hdf
+ local source=$tmp_hdf
+ # Larger than arm page size
+ local chunksize=128
+ local cs_bytes=$((chunksize * 1024))
+
+ # Larger than arm page size
+ local chunksize=128
+
+ if [[ -f $hdf.bz2 ]] && type -p bzcat >/dev/null; then
+ bzcat $hdf.bz2 > $tmp_hdf
+ elif [[ -f $hdf.bz2 ]] && type -p bunzip2 >/dev/null; then
+ cp $hdf.bz2 $tmp_hdf.bz2 || error "cp $tmp_hdf.bz2"
+ bunzip2 $tmp_hdf.bz2 || error "bunzip2 $tmp_hdf.bz2"
+ else
+ echo "bunzip2 is not installed, skip it"
+ return 0
+ fi
+
+ mount_client $MOUNT2
+ stack_trap "umount_client $MOUNT2" EXIT
+
+ # Fail test if source size changes so we catch this
+ # Source should be a few MiB in size
+ $CHECKSTAT -s 14625450 $source || error "checkstat wrong size"
+
+ stack_trap "rm -f $tf; disable_compression"
+ enable_compression
+
+ $LFS setstripe -E -1 -Z lz4:0 --compress-chunk=$chunksize $tf.source ||
+ error "set a compress component in $tf.source failed"
+
+ # Copy the source file to Lustre so we also read from Lustre
+ dd if=$source of=$tf.source bs=1M || error "dd to create $tf.source failed"
+ flush_and_compare $source $tf.source "(0) failed compare of source"
+
+ for bs in $((PAGE_SIZE - 1024)) $PAGE_SIZE $((PAGE_SIZE * 3/2)) \
+ $(((cs_bytes - 1024))) $cs_bytes $((cs_bytes * 3/2)); do
+
+ # Simple compressed layout
+ $LFS setstripe -E -1 -Z lz4:0 --compress-chunk=$chunksize $tf ||
+ error "set a compress component in $tf failed"
+
+ echo "bs: $bs"
+ dd if=$tf.source bs=$bs of=$tf conv=notrunc &
+ pid1=$!
+ # Second mount with similar but not the same block size
+ dd if=$tf.source bs=$((bs * 2)) of=$tf2 conv=notrunc &
+ pid2=$!
+ wait $pid1
+ rc1=$?
+ wait $pid2
+ rc2=$?
+ if (( rc1 != 0 )); then
+ error "copy 1 w/bsize $bs failed: $rc1"
+ fi
+ if (( rc2 != 0 )); then
+ error "copy 2 w/bsize $bs failed: $rc2"
+ fi
+
+ flush_and_compare $source $tf "(1) failed compare with size $bs"
+ flush_and_compare $tf $tf2 "(2) failed compare with size $bs"
+ rm -f $tf $tf2
+ done
+}
+run_test 1006 "racing writes with compressed layout"
+
complete_test $SECONDS
check_and_cleanup_lustre
declare -a logs=($ONLY)