*/
if (cl_io_is_trunc(io)) {
io->ci_write_intent.e_start = 0;
- io->ci_write_intent.e_end = io->u.ci_setattr.sa_attr.lvb_size;
+ /* for writes, e_end is endpos, the location of the file
+ * pointer after the write is completed, so it is not accessed.
+ * For truncate, 'end' is the size, and *is* acccessed.
+ * In other words, writes are [start, end), but truncate is
+ * [start, size], where both are included. So add 1 to the
+ * size when creating the write intent to account for this.
+ */
+ io->ci_write_intent.e_end =
+ io->u.ci_setattr.sa_attr.lvb_size + 1;
} else {
io->ci_write_intent.e_start = lio->lis_pos;
io->ci_write_intent.e_end = lio->lis_endpos;
[[ -n $f4 ]] && error "1: 4th component instantiated"
# the first 2 components instantiated
- $TRUNCATE $comp_file $((1024*1024*1+1))
+ # Truncate to exact start of new component - LU-12586
+ $TRUNCATE $comp_file $((1024*1024*1))
f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
[[ -z $f2 ]] && error "2: 2nd component uninstantiated"
[[ -n $f4 ]] && error "2: 4th component instantiated"
# the first 3 components instantiated
- $TRUNCATE $comp_file $((1024*1024*3))
+ $TRUNCATE $comp_file $((1024*1024*3 - 1))
$TRUNCATE $comp_file $((1024*1024*1+1))
f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")