Skip to content

Commit 84d0301

Browse files
authored
Merge pull request ceph#60795 from taodd/fix-rbd-sparsify-on-ec-image-slow
osd: optimize extent comparison in PrimaryLogPG Reviewed-by: Radoslaw Zarzynski <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]>
2 parents 8b3e4bd + 60797f6 commit 84d0301

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/osd/PrimaryLogPG.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5808,10 +5808,19 @@ int PrimaryLogPG::do_extent_cmp(OpContext *ctx, OSDOp& osd_op)
58085808

58095809
int PrimaryLogPG::finish_extent_cmp(OSDOp& osd_op, const bufferlist &read_bl)
58105810
{
5811-
for (uint64_t idx = 0; idx < osd_op.indata.length(); ++idx) {
5812-
char read_byte = (idx < read_bl.length() ? read_bl[idx] : 0);
5813-
if (osd_op.indata[idx] != read_byte) {
5814-
return (-MAX_ERRNO - idx);
5811+
auto input_iter = osd_op.indata.begin();
5812+
auto read_iter = read_bl.begin();
5813+
uint64_t idx = 0;
5814+
5815+
while (input_iter != osd_op.indata.end()) {
5816+
char read_byte = (read_iter != read_bl.end() ? *read_iter : 0);
5817+
if (*input_iter != read_byte) {
5818+
return (-MAX_ERRNO - idx);
5819+
}
5820+
++idx;
5821+
++input_iter;
5822+
if (read_iter != read_bl.end()) {
5823+
++read_iter;
58155824
}
58165825
}
58175826

0 commit comments

Comments
 (0)