@@ -21,52 +21,61 @@ SET_SUBSYS(seastore_device);
2121RBMDevice::mkfs_ret RBMDevice::do_primary_mkfs (device_config_t config,
2222 int shard_num, size_t journal_size) {
2323 LOG_PREFIX (RBMDevice::do_primary_mkfs);
24- return stat_device (
25- ).handle_error (
26- mkfs_ertr::pass_further{},
27- crimson::ct_error::assert_all{
28- " Invalid error stat_device in RBMDevice::do_primary_mkfs" }
29- ).safe_then (
30- [this , FNAME, config=std::move (config), shard_num, journal_size](auto st) {
31- super.block_size = st.block_size ;
32- super.size = st.size ;
33- super.config = std::move (config);
34- super.journal_size = journal_size;
35- ceph_assert_always (super.journal_size > 0 );
36- ceph_assert_always (super.size >= super.journal_size );
37- ceph_assert_always (shard_num > 0 );
38-
39- std::vector<rbm_shard_info_t > shard_infos (shard_num);
40- for (int i = 0 ; i < shard_num; i++) {
41- uint64_t aligned_size =
42- (super.size / shard_num) -
43- ((super.size / shard_num) % super.block_size );
44- shard_infos[i].size = aligned_size;
45- shard_infos[i].start_offset = i * aligned_size;
46- assert (shard_infos[i].size > super.journal_size );
47- }
48- super.shard_infos = shard_infos;
49- super.shard_num = shard_num;
50- shard_info = shard_infos[seastar::this_shard_id ()];
51- DEBUG (" super {} " , super);
52-
53- // write super block
54- return open (get_device_path (),
55- seastar::open_flags::rw | seastar::open_flags::dsync
24+ check_create_device_ret maybe_create = check_create_device_ertr::now ();
25+ using crimson::common::get_conf;
26+ if (get_conf<bool >(" seastore_block_create" ) && !get_device_path ().empty ()) {
27+ auto size = get_conf<Option::size_t >(" seastore_device_size" );
28+ maybe_create = check_create_device (get_device_path (), size);
29+ }
30+ return maybe_create.safe_then ([this , FNAME, config=std::move (config),
31+ shard_num, journal_size] {
32+ return stat_device (
5633 ).handle_error (
5734 mkfs_ertr::pass_further{},
5835 crimson::ct_error::assert_all{
59- " Invalid error open in RBMDevice::do_primary_mkfs" }
60- ).safe_then ([this ] {
61- return initialize_nvme_features (
36+ " Invalid error stat_device in RBMDevice::do_primary_mkfs" }
37+ ).safe_then (
38+ [this , FNAME, config=std::move (config), shard_num, journal_size](auto st) {
39+ super.block_size = st.block_size ;
40+ super.size = st.size ;
41+ super.config = std::move (config);
42+ super.journal_size = journal_size;
43+ ceph_assert_always (super.journal_size > 0 );
44+ ceph_assert_always (super.size >= super.journal_size );
45+ ceph_assert_always (shard_num > 0 );
46+
47+ std::vector<rbm_shard_info_t > shard_infos (shard_num);
48+ for (int i = 0 ; i < shard_num; i++) {
49+ uint64_t aligned_size =
50+ (super.size / shard_num) -
51+ ((super.size / shard_num) % super.block_size );
52+ shard_infos[i].size = aligned_size;
53+ shard_infos[i].start_offset = i * aligned_size;
54+ assert (shard_infos[i].size > super.journal_size );
55+ }
56+ super.shard_infos = shard_infos;
57+ super.shard_num = shard_num;
58+ shard_info = shard_infos[seastar::this_shard_id ()];
59+ DEBUG (" super {} " , super);
60+
61+ // write super block
62+ return open (get_device_path (),
63+ seastar::open_flags::rw | seastar::open_flags::dsync
64+ ).handle_error (
65+ mkfs_ertr::pass_further{},
66+ crimson::ct_error::assert_all{
67+ " Invalid error open in RBMDevice::do_primary_mkfs" }
6268 ).safe_then ([this ] {
63- return write_rbm_superblock (
69+ return initialize_nvme_features (
6470 ).safe_then ([this ] {
65- return close ();
66- }).handle_error (
67- mkfs_ertr::pass_further{},
68- crimson::ct_error::assert_all{
69- " Invalid error write_rbm_superblock in RBMDevice::do_primary_mkfs"
71+ return write_rbm_superblock (
72+ ).safe_then ([this ] {
73+ return close ();
74+ }).handle_error (
75+ mkfs_ertr::pass_further{},
76+ crimson::ct_error::assert_all{
77+ " Invalid error write_rbm_superblock in RBMDevice::do_primary_mkfs"
78+ });
7079 });
7180 });
7281 });
0 commit comments