]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
os/bluestore/compression: Fix Estimator::split_and_compress 63749/head
authorAdam Kupczyk <akupczyk@ibm.com>
Tue, 20 May 2025 07:27:26 +0000 (07:27 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 5 Jun 2025 07:34:56 +0000 (07:34 +0000)
commit47ae8bc56f02598bd9e45ceb9e9695c0dc993c0d
tree233208732467cecb299f35b01157b286e71f5b2c
parent0e74c319ef2f47fb7f0159327d6e150c80bb512d
os/bluestore/compression: Fix Estimator::split_and_compress

Fixed calculation on effective blob size.
When fully non-compressible data is passed,
it could cause losing few bytes in the end.
Example:
 -107> 2025-05-17T20:40:50.468+0000 7f267a42f640 15 bluestore(/var/lib/ceph/osd/ceph-4) _do_write_v2_compressed 200000~78002 -> 200000~78002
 -106> 2025-05-17T20:40:50.468+0000 7f267a42f640 20 blobs to put: 200000~f000(4d61) 20f000~f000(b51) 21e000~f000(b51) 22d000~f000(b51) 23c000~f000(b51) 24b000~f000(b51) 25a000~f000(b51) 269000~f000(b51)
In result we split 0x78002 into 8 * 0xf000, losing 0x2 in the process.

Calculations for original:
>>> size=0x78002
>>> blobs=(size+0xffff) / 0x10000
>>> blob_size = size / blobs
>>> print hex(size), blobs, hex(blob_size)
0x78002 8 0xf000 <-this means roundup is 0xf000

Calculations for fixed:
>>> size=0x78002
>>> blobs=(size+0xffff) / 0x10000
>>> blob_size = (size+blobs-1) / blobs
>>> print hex(size), blobs, hex(blob_size)
0x78002 8 0xf001 <-this meand roundup is 0x10000

Fixes: https://tracker.ceph.com/issues/71531
Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
(cherry picked from commit 80b7d6840ca989d04a86e90ab946b464bd8d5982)
src/os/bluestore/Compression.cc