[LU-14128] truncate does not set file size correctly in corner case Created: 09/Nov/20  Updated: 17/Nov/21  Resolved: 12/Jan/21

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.14.0, Lustre 2.12.8

Type: Bug Priority: Minor
Reporter: Zhenyu Xu Assignee: Zhenyu Xu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

created a file with layout with "lfs setstripe -E 4m -E 1g -c 4 -E -1 /mnt/lustre/test"

and truncate then seek and read of it

54917 1600771094.532399 ftruncate(11, 1070596096) = 0 <0.002077>
54917 1600771094.534496 lseek(11, 1070596092, SEEK_SET) = 1070596092 <0.000020>
54917 1600771094.534535 read(11, "", 4) = 0 <0.000477>

while the same operations upon a plain file is like follows

176699 1600824857.107003 lseek(11, 0, SEEK_CUR) = 1069547272 <0.000016>
176699 1600824857.107034 ftruncate(11, 1070596096) = 0 <0.002115>
176699 1600824857.109166 lseek(11, 1070596092, SEEK_SET) = 1070596092 <0.000016>
176699 1600824857.109197 read(11, "\0\0\0\0", 4) = 4 <0.001038>

The location 1070596096 (1021M) is exactly at the end of the 1st stripe of the 2nd component, and truncate will not set the OST object size of the 1st stripe (because it's not intersected with [1070596096, EOF)) and set the 2nd, 3rd and 4th stripe object size, from the 4th stripe object we can get file size of 1069547520 (1020M). This is incorrect, so the seek and read think we are reading after the EOF of the file, so return 0 instead of 4 bytes.



 Comments   
Comment by Gerrit Updater [ 09/Nov/20 ]

Bobi Jam (bobijam@hotmail.com) uploaded a new patch: https://review.whamcloud.com/40581
Subject: LU-14128 lov: correctly set OST obj size
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 138e852e30e6a68f78543ca8f5fbaad17bb6e9db

Comment by Gerrit Updater [ 12/Jan/21 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/40581/
Subject: LU-14128 lov: correctly set OST obj size
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 98015004516cad1173e2bac2a4695bdc56e4d9a4

Comment by Peter Jones [ 12/Jan/21 ]

Landed for 2.14

Comment by Gerrit Updater [ 03/Nov/21 ]

"Patrick Farrell <pfarrell@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/45448
Subject: LU-14128 lov: correctly set OST obj size
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: fc68ce9fdfed82ff483b997b0887cdfe06e1ad34

Comment by Gerrit Updater [ 17/Nov/21 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/45448/
Subject: LU-14128 lov: correctly set OST obj size
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: cfb24815e825738cea16270bbd6e7841b0e7d09b

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