Skip to content

os/bluestore: Implemented create-bdev-label#62148

Merged
Jayaprakash-ibm merged 1 commit intoceph:mainfrom
Jayaprakash-ibm:wip-create-bdev-label
Jun 11, 2025
Merged

os/bluestore: Implemented create-bdev-label#62148
Jayaprakash-ibm merged 1 commit intoceph:mainfrom
Jayaprakash-ibm:wip-create-bdev-label

Conversation

@Jayaprakash-ibm
Copy link
Contributor

@Jayaprakash-ibm Jayaprakash-ibm commented Mar 5, 2025

os/bluestore: Implemented create_bdev_label

Introduces a helper function create_bdev_label() and a new command create-bdev-label
to write essential OSD metadata (e.g., fsid, whoami) directly into the device label
at offset 0, for use on devices where support_bdev_label == false.

Usage: ./bin/ceph-bluestore-tool --path dev/osd0 --dev dev/osd0/block create-bdev-label

If a label already exists, the function throws an error to avoid overwriting.

This lays the groundwork for eventually removing duplicated metadata from
the OSD directory for devices that don’t support native bdev labels

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

@Jayaprakash-ibm Jayaprakash-ibm requested a review from aclamk March 5, 2025 22:00
@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch 2 times, most recently from 9f628c1 to d8cc39b Compare March 7, 2025 11:50
bool is_multi = false;
int64_t epoch = -1;

int r = BlueStore::read_bdev_label(cct.get(), devs.front(), &label,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to create new bdev label; we cannot fail if there isn't one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the Change

"bluefs", "ceph_fsid", "ceph_version_when_created", "created_at",
"elastic_shared_blobs", "fsid", "keyring", "kv_backend", "magic",
"mkfs_done", "osd_key", "ready", "require_osd_release", "type", "whoami"
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List of metas is a good idea.
It is almost certain that we will add more metas in the future.
I think we should have some warning when there is a file (potentially meta) in the dir that we are not putting to bdev label.
However, ignoring those extra files is OK overall.
If they are needed in meta one can always use CBT to set additional meta.

}
if (action == "create-bdev-label") {
if (path.empty()) {
cerr << "must specify bluestore path *or* raw device(s)" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot go without "path", we need to read files from there.

@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch 2 times, most recently from 76262e3 to e64c3cb Compare April 8, 2025 12:13
@Jayaprakash-ibm Jayaprakash-ibm marked this pull request as ready for review April 8, 2025 12:47
@Jayaprakash-ibm Jayaprakash-ibm requested a review from a team as a code owner April 8, 2025 12:47
@Jayaprakash-ibm Jayaprakash-ibm removed the request for review from a team April 8, 2025 12:47
for (const auto& file : metadata_files) {
std::ifstream infile(path + "/" + file);
if (infile) {
std::string value((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one-liner.

}

bool wrote_at_least_one = false;
for (uint64_t position : valid_positions) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we didn't read any labels "-ENOENT" than valid_positions is empty.
I agree we do not want to go into multi, but we should at least write bdev_label at offset 0.

} else {
cerr << "Warning: unable to read metadata file: " << file << std::endl;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are fields in bluestore_bdev_label_t that should be set too, for example bluestore_bdev_label_t::description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the Change

@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch 2 times, most recently from fb8ceb5 to 18fed8c Compare April 9, 2025 16:45
@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch 2 times, most recently from 79df7a2 to 21247ec Compare April 24, 2025 10:12
@aclamk aclamk added the aclamk-testing-phoebe bluestore testing label May 8, 2025
@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch from 21247ec to c46245d Compare May 27, 2025 20:00
@Jayaprakash-ibm
Copy link
Contributor Author

@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch 2 times, most recently from 02b15a3 to 0c0ea1b Compare May 28, 2025 13:37
@aclamk aclamk added the aclamk-testing-nauvoo bluestore testing label May 28, 2025
@aclamk
Copy link
Contributor

aclamk commented Jun 3, 2025

Also verified by https://tracker.ceph.com/issues/71503.

@aclamk aclamk self-requested a review June 3, 2025 09:37
@aclamk
Copy link
Contributor

aclamk commented Jun 3, 2025

jenkins test make check arm64

@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch from 0c0ea1b to d879d56 Compare June 3, 2025 09:53
@Jayaprakash-ibm Jayaprakash-ibm requested a review from a team as a code owner June 3, 2025 09:53

:command:`create-bdev-labels` --path *osd path* --dev *device*

Writes a bdev label to BlueStore devices that originally did not support labeling.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What manner of device did originally not support labeling?

Copy link
Contributor

@aclamk aclamk Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anthonyeleven None. In bluestore meaning label is first 4K of device.
But due to some misguided thinking or something we pretended that NVME and PMEM devices might not support label.

@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch from d879d56 to ea601c4 Compare June 6, 2025 09:52
@aclamk aclamk removed aclamk-testing-phoebe bluestore testing aclamk-testing-nauvoo bluestore testing labels Jun 6, 2025
@aclamk
Copy link
Contributor

aclamk commented Jun 6, 2025

jenkins test windows

@aclamk
Copy link
Contributor

aclamk commented Jun 6, 2025

jenkins test make check arm64

Introduces a helper function create_bdev_label() and a new command create-bdev-label
to write essential OSD metadata (e.g., fsid, whoami) directly into the device label
at offset 0, for use on devices where support_bdev_label == false.

Usage: ./bin/ceph-bluestore-tool --path dev/osd0 --dev dev/osd0/block create-bdev-label

If a label already exists, the function throws an error to avoid overwriting.

This lays the groundwork for eventually removing duplicated metadata from
the OSD directory for devices that don’t support native bdev labels

Signed-off-by: Jaya Prakash <jayaprakash@ibm.com>
@Jayaprakash-ibm Jayaprakash-ibm force-pushed the wip-create-bdev-label branch from ea601c4 to f2faf3e Compare June 11, 2025 09:44
@Jayaprakash-ibm Jayaprakash-ibm merged commit 14000ba into ceph:main Jun 11, 2025
12 checks passed
@Jayaprakash-ibm Jayaprakash-ibm deleted the wip-create-bdev-label branch June 11, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants