osd: Return the stored bitmap for secondary reads sent without attr_len #227

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:sec-read-bitmap-attr-len-0 into master
Contributor

Description

Since 51ecbadb ("Only update bitmaps when writing data in primary subops") a secondary OSD passes no bitmap to the blockstore when attr_len is 0 (exec_secondary_real, src/osd/osd_secondary.cpp:203). That is right for writes. But the SEC_READ reply still carries attr_len = clean_entry_bitmap_size and cur_op->bitmap (osd_secondary.cpp:29, sent by msgr_send.cpp), and that buffer is now never filled.

Current primaries always send reads with attr_len = clean_entry_bitmap_size (submit_primary_subop), so they are not affected. Primaries without 51ecbadb (3.0.13 and older) send every read with attr_len = 0 and take the unfilled buffer as the part's bitmap. So while old and new OSDs serve the same PGs during a rolling upgrade:

  • chained reads of layered images build their plan from one set of bitmaps and assemble the result from another, and hit assert(stripes[role].read_buf) in send_chained_read_results;
  • EC read-modify-write on the old primary computes new data and parity bitmaps from the zero bitmap of the part on the new OSD.

The fix keeps "no attr_len, no bitmap" for SEC_WRITE / SEC_WRITE_STABLE only. SEC_READ always passes its (always allocated) bitmap buffer to the blockstore, as before 51ecbadb. Read-with-bitmap is the path local primary reads already take. The reply format does not change.

Found: seen in a run. On a cluster in the middle of a rolling upgrade, primaries running the old version repeatedly crashed on the stripes[role].read_buf assert in send_chained_read_results while new OSDs were in their PGs. The cause was traced in the code and reproduced by the unit test below, not on a mixed-version cluster.

Tested: osd_test. The new test_sec_read_without_attr_len_returns_bitmap sends SEC_READ to a secondary with attr_len = 0 and with attr_len = 4 and checks that the reply carries the stored bitmap. It fails without the fix (Assertion '!memcmp(reply->bitmap, &stored_bmp, sizeof(stored_bmp))' failed) and passes with it, as does the rest of osd_test.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description Since 51ecbadb ("Only update bitmaps when writing data in primary subops") a secondary OSD passes no bitmap to the blockstore when `attr_len` is 0 (`exec_secondary_real`, `src/osd/osd_secondary.cpp:203`). That is right for writes. But the SEC_READ reply still carries `attr_len = clean_entry_bitmap_size` and `cur_op->bitmap` (`osd_secondary.cpp:29`, sent by `msgr_send.cpp`), and that buffer is now never filled. Current primaries always send reads with `attr_len = clean_entry_bitmap_size` (`submit_primary_subop`), so they are not affected. Primaries without 51ecbadb (3.0.13 and older) send every read with `attr_len = 0` and take the unfilled buffer as the part's bitmap. So while old and new OSDs serve the same PGs during a rolling upgrade: - chained reads of layered images build their plan from one set of bitmaps and assemble the result from another, and hit `assert(stripes[role].read_buf)` in `send_chained_read_results`; - EC read-modify-write on the old primary computes new data and parity bitmaps from the zero bitmap of the part on the new OSD. The fix keeps "no `attr_len`, no bitmap" for SEC_WRITE / SEC_WRITE_STABLE only. SEC_READ always passes its (always allocated) bitmap buffer to the blockstore, as before 51ecbadb. Read-with-bitmap is the path local primary reads already take. The reply format does not change. Found: seen in a run. On a cluster in the middle of a rolling upgrade, primaries running the old version repeatedly crashed on the `stripes[role].read_buf` assert in `send_chained_read_results` while new OSDs were in their PGs. The cause was traced in the code and reproduced by the unit test below, not on a mixed-version cluster. Tested: osd_test. The new `test_sec_read_without_attr_len_returns_bitmap` sends SEC_READ to a secondary with `attr_len = 0` and with `attr_len = 4` and checks that the reply carries the stored bitmap. It fails without the fix (`Assertion '!memcmp(reply->bitmap, &stored_bmp, sizeof(stored_bmp))' failed`) and passes with it, as does the rest of osd_test. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-12-04 18:10:28 +03:00
Since 51ecbadb a secondary OSD passes no bitmap to the blockstore when
attr_len is 0. That is right for writes, but the SEC_READ reply always
carries clean_entry_bitmap_size bytes of bitmap, so a read with
attr_len = 0 now returns an unfilled buffer instead of the object's
bitmap. Primaries before 51ecbadb (3.0.13 and older) send every read
with attr_len = 0. During a rolling upgrade they take that buffer as the
part's bitmap: chained reads of layered images then assert in
send_chained_read_results, and EC read-modify-write builds new bitmaps
from it.

Keep the attr_len check for writes only, so reads always fill the bitmap.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u sec-read-bitmap-attr-len-0:koolkhel-sec-read-bitmap-attr-len-0
git checkout koolkhel-sec-read-bitmap-attr-len-0
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#227
No description provided.