[LU-14176] lfs mirror resync may truncate file to wrong size Created: 02/Dec/20  Updated: 24/Feb/21  Resolved: 04/Jan/21

Status: Closed
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Related
is related to LU-13397 lfs migrate/mirror extend/resync does... Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

To reproduce:

export OSTCOUNT=4
export OSTSIZE=800000
$LUSTRE/tests/llmount.sh

lctl pool_new lustre.ddn_ssd
lctl pool_new lustre.ddn_hdd
lctl pool_add lustre.ddn_ssd lustre-OST0000
lctl pool_add lustre.ddn_ssd lustre-OST0001
lctl pool_add lustre.ddn_hdd lustre-OST0002
lctl pool_add lustre.ddn_hdd lustre-OST0003

lfs setstripe -c 1 -p ddn_ssd /mnt/lustre

rm -f /tmp/f0 /mnt/lustre/f0
dd if=/dev/urandom of=/tmp/f0 bs=4096 count=1 seek=$(( (134217728 - 3 * 4096) / 4096 ))
dd if=/dev/urandom of=/tmp/f0 bs=4096 count=1 seek=$(( (134217728 + 3 * 4096) / 4096 )) conv=notrunc
/usr/bin/truncate --size=2G /tmp/f0

cp /tmp/f0 /mnt/lustre/f0
stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0

hole=0
data=0
while true; do
  data=$(lseek_test --data $hole /mnt/lustre/f0) || break
  hole=$(lseek_test --hole $data /mnt/lustre/f0) || break
  echo $data $hole
done

lfs mirror extend -N -p ddn_ssd /mnt/lustre/f0
stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0

cp /tmp/f0 /mnt/lustre/f0
stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0

lfs mirror resync /mnt/lustre/f0
stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0

Output:

 lfs setstripe -c 1 -p ddn_ssd /mnt/lustre
# rm -f /tmp/f0 /mnt/lustre/f0
# dd if=/dev/urandom of=/tmp/f0 bs=4096 count=1 seek=$(( (134217728 - 3 * 4096) / 4096 ))
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.000328655 s, 12.5 MB/s
# dd if=/dev/urandom of=/tmp/f0 bs=4096 count=1 seek=$(( (134217728 + 3 * 4096) / 4096 )) conv=notrunc
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.0011132 s, 3.7 MB/s
# /usr/bin/truncate --size=2G /tmp/f0
# 
# cp /tmp/f0 /mnt/lustre/f0
# stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0
2147483648 112 512
2147483648 1 512
# 
# hole=0
# data=0
# while true; do
>   data=$(lseek_test --data $hole /mnt/lustre/f0) || break
>   hole=$(lseek_test --hole $data /mnt/lustre/f0) || break
>   echo $data $hole
> done
134205440 134209536
134230016 134283264
lseek to 134283264 failed with 6
# 
# lfs mirror extend -N -p ddn_ssd /mnt/lustre/f0
# stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0
2147483648 112 512
2147483648 112 512
# 
# cp /tmp/f0 /mnt/lustre/f0
# stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0
2147483648 112 512
2147483648 1 512
# 
# lfs mirror resync /mnt/lustre/f0
# stat --format='%s %b %B' /tmp/f0 /mnt/lustre/f0
2147483648 112 512
134283264 224 512

Generated at Sat Feb 10 03:07:29 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.