From: Sage Weil Date: Fri, 5 Feb 2016 14:20:40 +0000 (-0500) Subject: os/bluestore: fix block device file creation X-Git-Tag: v10.0.4~38^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F7536%2Fhead;p=ceph.git os/bluestore: fix block device file creation Just make a separate flag to indicate whether we create a block file. This lets us drop the weird touch in vstart.sh, and default to creating a token 'block' file on --mkfs. Signed-off-by: Sage Weil --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 4ffc73992047..bd65846c3034 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -896,10 +896,13 @@ OPTION(bluestore_bluefs_reclaim_ratio, OPT_FLOAT, .20) // how much to reclaim at // bluestore_block_path = spdk:55cd2e404bd73932 OPTION(bluestore_block_path, OPT_STR, "") OPTION(bluestore_block_size, OPT_U64, 10 * 1024*1024*1024) // 10gb for testing +OPTION(bluestore_block_create, OPT_BOOL, true) OPTION(bluestore_block_db_path, OPT_STR, "") OPTION(bluestore_block_db_size, OPT_U64, 0) // rocksdb ssts (hot/warm) +OPTION(bluestore_block_db_create, OPT_BOOL, false) OPTION(bluestore_block_wal_path, OPT_STR, "") OPTION(bluestore_block_wal_size, OPT_U64, 96 * 1024*1024) // rocksdb wal +OPTION(bluestore_block_wal_create, OPT_BOOL, false) OPTION(bluestore_max_dir_size, OPT_U32, 1000000) OPTION(bluestore_min_alloc_size, OPT_U32, 64*1024) OPTION(bluestore_onode_map_size, OPT_U32, 1024) // onodes per collection diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index af3ca6c60429..3d86de5c24c0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1572,10 +1572,11 @@ int BlueStore::_open_collections(int *errors) int BlueStore::_setup_block_symlink_or_file( string name, string epath, - uint64_t size) + uint64_t size, + bool create) { dout(20) << __func__ << " name " << name << " path " << epath - << " size " << size << dendl; + << " size " << size << " create=" << (int)create << dendl; int r = 0; if (epath.length()) { if (!epath.compare(0, sizeof(SPDK_PREFIX-1), SPDK_PREFIX)) { @@ -1610,7 +1611,10 @@ int BlueStore::_setup_block_symlink_or_file( } } if (size) { - int fd = ::openat(path_fd, name.c_str(), O_RDWR, 0644); + unsigned flags = O_RDWR; + if (create) + flags |= O_CREAT; + int fd = ::openat(path_fd, name.c_str(), flags, 0644); if (fd >= 0) { // block file is present struct stat st; @@ -1703,15 +1707,18 @@ int BlueStore::mkfs() } r = _setup_block_symlink_or_file("block", g_conf->bluestore_block_path, - g_conf->bluestore_block_size); + g_conf->bluestore_block_size, + g_conf->bluestore_block_create); if (r < 0) goto out_close_fsid; r = _setup_block_symlink_or_file("block.wal", g_conf->bluestore_block_wal_path, - g_conf->bluestore_block_wal_size); + g_conf->bluestore_block_wal_size, + g_conf->bluestore_block_wal_create); if (r < 0) goto out_close_fsid; r = _setup_block_symlink_or_file("block.db", g_conf->bluestore_block_db_path, - g_conf->bluestore_block_db_size); + g_conf->bluestore_block_db_size, + g_conf->bluestore_block_db_create); if (r < 0) goto out_close_fsid; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index edb817c7c3c2..81031a7f3ead 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -563,7 +563,8 @@ private: int _open_collections(int *errors=0); void _close_collections(); - int _setup_block_symlink_or_file(string name, string path, uint64_t size); + int _setup_block_symlink_or_file(string name, string path, uint64_t size, + bool create); int _write_bdev_label(string path, bluestore_bdev_label_t label); static int _read_bdev_label(string path, bluestore_bdev_label_t *label); diff --git a/src/vstart.sh b/src/vstart.sh index a7aba2b5c887..cccab8808512 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -495,8 +495,11 @@ $DAEMONOPTS filestore wbthrottle btrfs ios hard limit = 20 filestore wbthrottle btrfs inodes hard limit = 30 bluestore fsck on mount = true + bluestore block create = true bluestore block db size = 67108864 + bluestore block db create = true bluestore block wal size = 134217728 + bluestore block wal create = true $COSDDEBUG $COSDMEMSTORE $extra_conf @@ -593,11 +596,6 @@ EOF for f in $CEPH_DEV_DIR/osd$osd/* ; do btrfs sub delete $f || true ; done || true mkdir -p $CEPH_DEV_DIR/osd$osd - # for bluestore - touch $CEPH_DEV_DIR/osd$osd/block - touch $CEPH_DEV_DIR/osd$osd/block.db - touch $CEPH_DEV_DIR/osd$osd/block.wal - uuid=`uuidgen` echo "add osd$osd $uuid" $SUDO $CEPH_ADM osd create $uuid