Hi Andreas,
Debugging OST_PUNCH found that server does not reply back with updated blocks count to client. Presently OST_PUNCH RPC is processed under lustretre/ofd/ofd_dev.c:ofd_punch_hdl(). Here server does not update repbody with updated block count.
Addressing this allows the client to fetch these values in RPC reply. Under osc_io.c:osc_io_setattr_end() I could update object attributes with updated values received from server calling cl_object_attr_update(). Ive added tests to verify truncate reflects block count correctly for sparse files as well.
We can format and push a patch for review if this looks like a good solution.
The output of truncate run on Sparse file:
===============================
- yes 'a' | dd of=/mnt/lustre/sparstest bs=4096 count=2 seek=5
2+0 records in
2+0 records out
8192 bytes (8.2 kB) copied, 0.001071 s, 7.6 MB/s
- stat /mnt/lustre/sparstest
File: '/mnt/lustre/sparstest'
Size: 28672 Blocks: 16 IO Block: 4194304 regular file
Device: 2c54f966h/743766374d Inode: 144115205272502281 Links: 1
Access: (0644/rw-rr-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-02-08 18:24:18.000000000 +0530
Modify: 2018-02-08 18:24:18.000000000 +0530
Change: 2018-02-08 18:24:18.000000000 +0530
Birth: -
- truncate -s24500 /mnt/lustre/sparstest
- stat /mnt/lustre/sparstest
File: '/mnt/lustre/sparstest'
Size: 24500 Blocks: 8 IO Block: 4194304 regular file
Device: 2c54f966h/743766374d Inode: 144115205272502281 Links: 1
Access: (0644/rw-rr-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-02-08 18:24:18.000000000 +0530
Modify: 2018-02-08 18:24:42.000000000 +0530
Change: 2018-02-08 18:24:42.000000000 +0530
Birth: -
Landed for 2.12