-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
vvp_prep_size() writes KMS into i_size unconditionally:
i_size_write(inode, kms);
KMS is a lower bound only. osc_lock_lvb_update() clamps it to the end of
the granted DLM extent, and sub-objects with no valid KMS contribute nothing
to the merged value. On a PFL file whose size lives in a component the client
holds no lock on, that publishes the end of the component being read as the
file size.
A concurrent stat() reads i_size back out of the inode and reports it.
A 4K read at offset 0 of a 200MB file whose first component ends at 128K
leaves i_size at 131072, while the cat_size of the very same
cl_attr says 209715200.
Where it comes from
The unconditional write was introduced by:
ec07ddc4120b9850982c8f39bcc43e57d2d76549
LUS-13048 llite: set read size correctly
Before it, i_size was only ever extended:
if (i_size_read(inode) < kms)
i_size_write(inode, kms);
LUS-13048 made the write unconditional so that a size which had decreased
after a lock renewal would be followed - sanityn test_16i, a read after a
truncate done by another client. That part has to be kept; what must go is
lowering i_size to a value that is not a size at all.
Fix
Extend i_size up to KMS, and use cat_size as the upper bound rather
than KMS:
cat_size is max(lvb_size, loi_kms) per stripe, merged as a max over
the instantiated components, so it is always >= KMS;
the OSC layer lowers it only on an authoritative update, such as another
client's truncate.
Keeping that clamp is what stops the generic read loop - which runs to
i_size with no further control from llite - from returning zeroes between
a new EOF and a stale i_size after a remote truncate, i.e. sanityn
test_16i still passes.
i_size is sampled once for both comparisons, since ll_update_inode()
writes it without ll_inode_size_lock() and a second read may differ; the
debug lines print the value actually written.