ZNS与LevelDB相关记录

仅做简单记录,自用,没太大价值

最大数据传输大小

1
2
3
4
5
root@osd-node0 /s/c/n/n/nvme1n1# nvme id-ctrl /dev/nvme0n1 | grep mdts
mdts : 5
root@osd-node0 /s/c/n/n/nvme1n1# nvme zns id-ctrl /dev/nvme0n1
NVMe ZNS Identify Controller:
zasl : 0
LevelDB的写入文件操作

①日志文件的写入

创建与销毁

1
2
3
4
5
6
7
8
9
10
11
12
// 创建新日志文件
uint64_t new_log_number = versions_->NewFileNumber();
WritableFile* lfile = nullptr;
s = env_->NewWritableFile(LogFileName(dbname_, new_log_number), &lfile);
delete log_;
// 关闭并销毁旧日志文件
s = logfile_->Close();
delete logfile_;

logfile_ = lfile;
logfile_number_ = new_log_number;
log_ = new log::Writer(lfile);

写入

1
2
3
4
status = log_->AddRecord(WriteBatchInternal::Contents(write_batch));
s = EmitPhysicalRecord(type, ptr, fragment_length);
Status s = dest_->Append(Slice(buf, kHeaderSize));
s = dest_->Append(Slice(ptr, length));

②后台合并线程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
CompactMemTable
WriteLevel0Table
BuildTable
TableBuilder::Add
TableBuilder::Flush
TableBuilder::WriteBlock

void TableBuilder::WriteRawBlock(const Slice& block_contents,
CompressionType type, BlockHandle* handle) {
Rep* r = rep_;
handle->set_offset(r->offset);
handle->set_size(block_contents.size());
r->status = r->file->Append(block_contents);
if (r->status.ok()) {
char trailer[kBlockTrailerSize];
trailer[0] = type;
uint32_t crc = crc32c::Value(block_contents.data(), block_contents.size());
crc = crc32c::Extend(crc, trailer, 1); // Extend crc to cover block type
EncodeFixed32(trailer + 1, crc32c::Mask(crc));
r->status = r->file->Append(Slice(trailer, kBlockTrailerSize));
if (r->status.ok()) {
r->offset += block_contents.size() + kBlockTrailerSize;
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Status TableBuilder::Finish() {
Rep* r = rep_;
Flush();
assert(!r->closed);
r->closed = true;

BlockHandle filter_block_handle, metaindex_block_handle, index_block_handle;

// Write filter block
if (ok() && r->filter_block != nullptr) {
WriteRawBlock(r->filter_block->Finish(), kNoCompression,
&filter_block_handle);
}

// Write metaindex block
if (ok()) {
BlockBuilder meta_index_block(&r->options);
if (r->filter_block != nullptr) {
// Add mapping from "filter.Name" to location of filter data
std::string key = "filter.";
key.append(r->options.filter_policy->Name());
std::string handle_encoding;
filter_block_handle.EncodeTo(&handle_encoding);
meta_index_block.Add(key, handle_encoding);
}

// TODO(postrelease): Add stats and other meta blocks
WriteBlock(&meta_index_block, &metaindex_block_handle);
}

// Write index block
if (ok()) {
if (r->pending_index_entry) {
r->options.comparator->FindShortSuccessor(&r->last_key);
std::string handle_encoding;
r->pending_handle.EncodeTo(&handle_encoding);
r->index_block.Add(r->last_key, Slice(handle_encoding));
r->pending_index_entry = false;
}
WriteBlock(&r->index_block, &index_block_handle);
}

// Write footer
if (ok()) {
Footer footer;
footer.set_metaindex_handle(metaindex_block_handle);
footer.set_index_handle(index_block_handle);
std::string footer_encoding;
footer.EncodeTo(&footer_encoding);
r->status = r->file->Append(footer_encoding);
if (r->status.ok()) {
r->offset += footer_encoding.size();
}
}
return r->status;
}
nvme盘被ceph占用

解决重装系统后有磁盘被ceph占用问题

device-mapper: remove ioctl on luks-xxxx failed: Device or resource busy

zonefs

zonefs-tools

zonefs File System

1
2
error: Couldn't find blkid/blkid.h
apt install libblkid-dev
f2fs

千万注意f2fs的调度设置mq-deadline,有可能出现问题

File Systems

西数ZN540如何修改sector size

mount: /root/rocksdb/f2fs: mount(2) system call failed: Structure needs cleaning.

f2fs版本有点老,换成阿里云源后依然没找到更新的安装包

1
2
3
4
5
6
7
8
9
10
11
mkfs.f2fs -V
mkfs.f2fs 1.14.0 (2020-08-24)

apt-cache policy f2fs-tools
f2fs-tools:
Installed: 1.14.0-2build1
Candidate: 1.14.0-2build1
Version table:
*** 1.14.0-2build1 500
500 https://mirrors.aliyun.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status

在以下网站找到安装包:f2fs-tools package in Ubuntu

认真阅读网站内容并对比自身操作系统版本下载合适的文件

而后对着github仓库的安装步骤:jaegeuk/f2fs-tools

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
F2FS format utilility
---------------------

To use f2fs filesystem, you should format the storage partition
with this utilility. Otherwise, you cannot mount f2fs.

Before compilation
------------------

You should install the following packages.
- libuuid-devel or uuid-dev
- pkg-config
- autoconf
- libtool
- libselinux1-dev

Initial compilation
-------------------

Before compilation initially, autoconf/automake tools should be run.

# ./autogen.sh

How to compile
--------------

# ./configure
# make
# make install

How to cross-compile (e.g., for ARM)
------------------------------------

1. Add the below line into mkfs/Makefile.am:
mkfs_f2fs_LDFLAGS = -all-static

2. Add the below line into fsck/Makefile.am:
fsck_f2fs_LDFLAGS = -all-static

3. then, do:
# LDFLAGS=--static ./configure \
--host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi
# make

How to run by default
---------------------

$ mkfs.f2fs -l [LABEL] $DEV

For more mkfs options, see man page.

注意卸载之前安装的f2fs-tools,并且Before compilation中的软件全部存在

1
2
mkfs.f2fs -V
mkfs.f2fs 1.16.0 (2023-04-11)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 命令历史
apt install libuuid-devel
apt install uuid-dev
apt install pkg-config

apt install autoconf
apt install libtool
apt install libselinux1-dev
./autogen.sh
./configure
make
make install
mkfs.f2fs -f -m -c /dev/nvme1n2 /dev/nvme2n1
mount -t f2fs /dev/nvme2n1
mkdir f2fs
mount -t f2fs /dev/nvme2n1 f2fs/
df -
mkfs.f2fs -V
;s
cd ..
dd if=/dev/zero of=outputfile bs=1M count=1000
ls -la
cp outputfile f2fs/
cd f2fs
fdisk -l
dd if=/dev/zero of=outputfile bs=1M count=10000
ls -lah
df -a
cat /etc/fstab
dd if=/dev/zero of=outputfile-1 bs=1M count=100000
fish
nvme list
df -T
nvme zns report-zones /dev/nvme1n2 | head -10

ConfZNS支持传统Zone不仅需要修改femu代码,同时需要修改内核驱动代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//in linux-5.10.2/driver/nvme/host/zns.c:146 

static int nvme_zone_parse_entry(struct nvme_ns *ns,
struct nvme_zone_descriptor *entry,
unsigned int idx, report_zones_cb cb,
void *data)
{
struct blk_zone zone = { };

if ((((entry->zt & 0xf) != NVME_ZONE_TYPE_SEQWRITE_REQ)&&((entry->zt & 0xf) != NVME_ZONE_TYPE_CONVENTIONAL))){
return -EINVAL;
}

//zone.type = BLK_ZONE_TYPE_SEQWRITE_REQ;
if((entry->zt & 0xf) == NVME_ZONE_TYPE_CONVENTIONAL){
zone.type = BLK_ZONE_TYPE_CONVENTIONAL;
dev_err(ns->ctrl->device, "[inho] conv to zidx %x\n",idx);
}
else {
zone.type = BLK_ZONE_TYPE_SEQWRITE_REQ;
}
zone.cond = entry->zs >> 4;
zone.len = ns->zsze;
zone.capacity = nvme_lba_to_sect(ns, le64_to_cpu(entry->zcap));
zone.start = nvme_lba_to_sect(ns, le64_to_cpu(entry->zslba));
zone.wp = nvme_lba_to_sect(ns, le64_to_cpu(entry->wp));

return cb(&zone, idx, data);
}

//in linux-5.10.2/include/linux/nvme.h:570

enum {
NVME_ZONE_TYPE_CONVENTIONAL =0x1,
NVME_ZONE_TYPE_SEQWRITE_REQ =0x2,
};
1
2
3
4
5
6
7
8
9
10
11
12
13
[   73.427370] F2FS-fs (sdc): Mount Device [ 0]:             /dev/sdc,       64,        0 -     ffff
[ 73.427605] F2FS-fs (sdc): Mount Device [ 1]: /dev/nvme0n1, 8192, 10000 - 40ffff (zone: Host-managed)
[ 73.427610] F2FS-fs (sdc): IO Block Size: 4 KB
[ 73.436833] F2FS-fs (sdc): Found nat_bits in checkpoint
[ 73.510180] F2FS-fs (sdc): Mounted with checkpoint version = 6982e7e5



[ 652.514970] F2FS-fs (sdb): Mount Device [ 0]: /dev/sdb, 32512, 0 - ffffff
[ 652.515138] F2FS-fs (sdb): Mount Device [ 1]: /dev/nvme0n1, 8192, 1000000 - 13fffff (zone: Host-managed)
[ 652.515146] F2FS-fs (sdb): IO Block Size: 4 KB
[ 652.539311] F2FS-fs (sdb): Found nat_bits in checkpoint
[ 652.742884] F2FS-fs (sdb): Mounted with checkpoint version = 596d4527

1 挂载f2fs文件系统后一直随机写入第257个zone,破坏了顺序写的限制

2 f2fs环境需求(内核版本,f2fs版本,调度器)

3 14版本 Error: Failed to get number of blocks per zone,16版本无法正常运行

4 自己制作镜像而不是用femu提供的

vmware中创建qemu的嵌套虚拟化问题

由于需要图形界面,在vmware的Ubuntu虚拟机中制作qemu镜像

[Ubuntu 22.04.2] Running kernel seems to be up-to-date. Restarting services Daemons using outdated

测试未修改的femu与confzns能否成功运行f2fs

解决 Github SSH 连接超时

解决 Github SSH 连接超时

githubstatus

About GitHub’s IP addresses

Using SSH over the HTTPS port

GitHub520

修改Windows host文件权限

如何修改Win10文件夹访问权限

spdk相关设置步骤

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
link_directories(
/usr/local/lib
/root/SPDK/dpdk/build/lib
/usr/local/lib
)
include_directories(/usr/local/include)
if(BUILD_SHARED_LIBS)
# Only export LEVELDB_EXPORT symbols from the shared library.
add_compile_options(-fvisibility=hidden)
endif(BUILD_SHARED_LIBS)

# Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
include(GNUInstallDirs)

add_library(leveldb "")

target_link_libraries(leveldb
-Wl,--no-as-needed
spdk_env_dpdk rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring rte_telemetry rte_kvargs rte_rcu rte_power rte_ethdev rte_vhost rte_net rte_dmadev rte_cryptodev rte_hash spdk_event_iscsi spdk_event_nbd spdk_nbd spdk_event_nvmf spdk_nvmf spdk_event_scheduler spdk_event spdk_env_dpdk_rpc spdk_event_scsi spdk_event_bdev spdk_event_accel spdk_event_iobuf spdk_event_sock spdk_event_vmd spdk_init spdk_vhost spdk_iscsi spdk_conf spdk_scsi spdk_blobfs_bdev spdk_blob_bdev spdk_bdev spdk_notify spdk_bdev_malloc spdk_bdev_null spdk_bdev_nvme spdk_accel spdk_accel_error spdk_accel_ioat spdk_ioat spdk_bdev_passthru spdk_bdev_lvol spdk_bdev_raid spdk_bdev_error spdk_bdev_gpt spdk_bdev_split spdk_bdev_delay spdk_bdev_zone_block spdk_lvol spdk_nvme spdk_sock spdk_sock_posix spdk_bdev_aio spdk_bdev_ftl spdk_ftl spdk_bdev_virtio spdk_virtio spdk_vfio_user spdk_blobfs spdk_blob spdk_dma spdk_vmd spdk_thread spdk_trace spdk_rpc spdk_jsonrpc spdk_json spdk_util spdk_log
-Wl,--as-needed
)
250G主机问题

vscode无法连接主机

VSCode server unexpected “Missing GLIBC >= 2.28”

Provide legacy server when remote requirements fail

解决方法:

1 更新vscode至1.86.2,很多功能不能用了 ×

如何手动升级Visual Studio Code?

2 下载1.85并禁用更新

can-i-run-vs-code-server-on-older-linux-distributions

Failed building wheel for pillow

解决安装Failed building wheel for pillow

debug经历

1 各个FileState的锁只能保证各自的原子性,不能保证全局静态变量(cur_max_lba )的原子性

2 reset zone之前设成了10而不是904,导致zone is full

3 table cache pin了一部分文件,导致内存占用

1
2
3
4
5
6
7
8
9
10
11
12
13
 table_cache_(new TableCache(dbname_, options_, TableCacheSize(options_))),

static int TableCacheSize(const Options& sanitized_options) {
// Reserve ten files or so for other uses and give the rest to TableCache.
return sanitized_options.max_open_files - kNumNonTableCacheFiles;
}

static void DeleteEntry(const Slice& key, void* value) {
TableAndFile* tf = reinterpret_cast<TableAndFile*>(value);
delete tf->table;
delete tf->file;
delete tf;
}

Could not find operator[].

gdb高级用法和常见问题处理

gdb升级

从12.1升级13.1

Ubuntu18.04升级gdb10.2

gdb调试stl

解决 ‘makeinfo‘ is missing on your system.

gmp is missing while configuring building gdb from source

升级后仍然未能解决问题,删除gdb可执行文件后由apt重新安装gdb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(gdb) p kZoneToFile[0x0]
Could not find operator[].
(gdb) p kZoneToFile[0]
Could not find operator[].
(gdb) p GetZoneFiles(0)
$2 = std::set with 0 elements
(gdb) p GetZoneFiles(4194304)
$3 = std::set with 53 elements = {[0] = "./testdb/000760.ldb", [1] = "./testdb/000761.ldb", [2] = "./testdb/000762.ldb", [3] = "./testdb/000764.ldb", [4] = "./testdb/000765.ldb",
[5] = "./testdb/000766.ldb", [6] = "./testdb/000767.ldb", [7] = "./testdb/000769.ldb", [8] = "./testdb/000770.ldb", [9] = "./testdb/000771.ldb", [10] = "./testdb/000772.ldb",
[11] = "./testdb/000774.ldb", [12] = "./testdb/000775.ldb", [13] = "./testdb/000776.ldb", [14] = "./testdb/000833.ldb", [15] = "./testdb/000834.ldb", [16] = "./testdb/000835.ldb",
[17] = "./testdb/000837.ldb", [18] = "./testdb/000838.ldb", [19] = "./testdb/000839.ldb", [20] = "./testdb/000841.ldb", [21] = "./testdb/000842.ldb", [22] = "./testdb/000843.ldb",
[23] = "./testdb/000845.ldb", [24] = "./testdb/000846.ldb", [25] = "./testdb/000849.ldb", [26] = "./testdb/000850.ldb", [27] = "./testdb/000851.ldb", [28] = "./testdb/000852.ldb",
[29] = "./testdb/000853.ldb", [30] = "./testdb/000854.ldb", [31] = "./testdb/000855.ldb", [32] = "./testdb/000856.ldb", [33] = "./testdb/000858.ldb", [34] = "./testdb/000859.ldb",
[35] = "./testdb/000860.ldb", [36] = "./testdb/000861.ldb", [37] = "./testdb/000863.ldb", [38] = "./testdb/000864.ldb", [39] = "./testdb/000865.ldb", [40] = "./testdb/000866.ldb",
[41] = "./testdb/000867.ldb", [42] = "./testdb/000868.ldb", [43] = "./testdb/000869.ldb", [44] = "./testdb/000870.ldb", [45] = "./testdb/000871.ldb", [46] = "./testdb/000873.ldb",
[47] = "./testdb/000887.ldb", [48] = "./testdb/000888.ldb", [49] = "./testdb/000890.ldb", [50] = "./testdb/000891.ldb", [51] = "./testdb/000892.ldb", [52] = "./testdb/000893.ldb"}
AER request execute failed
1
2
3
4
5
6
7
8
9
10
11
12
13
2024-03-11 15:27:02.036029] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036044] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036055] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036065] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036077] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036086] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036098] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036111] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036120] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036137] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036150] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036160] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
[2024-03-11 15:27:02.036176] bdev_nvme.c:5074:aer_cb: *WARNING*: AER request execute failed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Signature for callback function invoked when an asynchronous event request
* command is completed.
*
* \param aer_cb_arg Context specified by spdk_nvme_register_aer_callback().
* \param cpl Completion queue entry that contains the completion status
* of the asynchronous event request that was completed.
*/
typedef void (*spdk_nvme_aer_cb)(void *aer_cb_arg,
const struct spdk_nvme_cpl *cpl);

/**
* Register callback function invoked when an AER command is completed for the
* given NVMe controller.
*
* \param ctrlr Opaque handle to NVMe controller.
* \param aer_cb_fn Callback function invoked when an asynchronous event request
* command is completed.
* \param aer_cb_arg Argument passed to callback function.
*/
void spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
spdk_nvme_aer_cb aer_cb_fn,
void *aer_cb_arg);


spdk_nvme_ctrlr_register_aer_callback(ctrlr, aer_cb, nvme_ctrlr);

static void
aer_cb(void *arg, const struct spdk_nvme_cpl *cpl)
{
struct nvme_ctrlr *nvme_ctrlr = arg;
union spdk_nvme_async_event_completion event;

if (spdk_nvme_cpl_is_error(cpl)) {
SPDK_WARNLOG("AER request execute failed\n");
return;
}

event.raw = cpl->cdw0;
if ((event.bits.async_event_type == SPDK_NVME_ASYNC_EVENT_TYPE_NOTICE) &&
(event.bits.async_event_info == SPDK_NVME_ASYNC_EVENT_NS_ATTR_CHANGED)) {
nvme_ctrlr_populate_namespaces(nvme_ctrlr, NULL);
} else if ((event.bits.async_event_type == SPDK_NVME_ASYNC_EVENT_TYPE_NOTICE) &&
(event.bits.async_event_info == SPDK_NVME_ASYNC_EVENT_ANA_CHANGE)) {
nvme_ctrlr_read_ana_log_page(nvme_ctrlr);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
修改状态机跳转
// nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_CONFIGURE_AER,
// ctrlr->opts.admin_timeout_ms);
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_KEEP_ALIVE_TIMEOUT,
ctrlr->opts.admin_timeout_ms);

case NVME_CTRLR_STATE_CONFIGURE_AER:
rc = nvme_ctrlr_configure_aer(ctrlr);
break;

case NVME_CTRLR_STATE_SET_KEEP_ALIVE_TIMEOUT:
rc = nvme_ctrlr_set_keep_alive_timeout(ctrlr);
break;


static void
nvme_ctrlr_configure_aer_done(void *arg, const struct spdk_nvme_cpl *cpl)
{
struct nvme_async_event_request *aer;
int rc;
uint32_t i;
struct spdk_nvme_ctrlr *ctrlr = (struct spdk_nvme_ctrlr *)arg;

if (spdk_nvme_cpl_is_error(cpl)) {
NVME_CTRLR_NOTICELOG(ctrlr, "nvme_ctrlr_configure_aer failed!\n");
ctrlr->num_aers = 0;
} else {
/* aerl is a zero-based value, so we need to add 1 here. */
ctrlr->num_aers = spdk_min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl + 1));
}

for (i = 0; i < ctrlr->num_aers; i++) {
aer = &ctrlr->aer[i];
rc = nvme_ctrlr_construct_and_submit_aer(ctrlr, aer);
if (rc) {
NVME_CTRLR_ERRLOG(ctrlr, "nvme_ctrlr_construct_and_submit_aer failed!\n");
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_ERROR, NVME_TIMEOUT_INFINITE);
return;
}
}
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_KEEP_ALIVE_TIMEOUT, ctrlr->opts.admin_timeout_ms);
}

work_version无法中止

全网最细!LSM-tree delete 性能优化(RocksDB,Lethe)

《Lethe: A Tunable Delete-Aware LSM Engine》笔记

https://disc-projects.bu.edu/lethe/

https://github.com/BU-DiSC/lethe-codebase.git

问题所在:key为string而不是int

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  while (!workload_file.eof()) {
char instruction;
long key, start_key, end_key;
string value;
workload_file >> instruction;
_env->current_op = instruction; // !YBS-sep18-XX!

// key为long类型
#define STRING_KEY_ENABLED true
if(!STRING_KEY_ENABLED && (lambda > 0 && lambda < 1)){
key_size = sizeof(uint32_t);
}else if(lambda > 0 && lambda < 1){
key_size = lambda * entry_size;
}
刚开始STRING_KEY_ENABLED为true,导致key一直为string
改成false后生成数值的key
I 3956937496 xdnjnSXekJoQPcPlI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
UpdateFilesByCompactionPri

ComputeCompactionScore
void VersionStorageInfo::ComputeCompensatedSizes() {
static const int kDeletionWeightOnCompaction = 2;
uint64_t average_value_size = GetAverageValueSize();

// compute the compensated size
for (int level = 0; level < num_levels_; level++) {
for (auto* file_meta : files_[level]) {
// Here we only compute compensated_file_size for those file_meta
// which compensated_file_size is uninitialized (== 0). This is true only
// for files that have been created right now and no other thread has
// access to them. That's why we can safely mutate compensated_file_size.
if (file_meta->compensated_file_size == 0) {
file_meta->compensated_file_size = file_meta->fd.GetFileSize();
// Here we only boost the size of deletion entries of a file only
// when the number of deletion entries is greater than the number of
// non-deletion entries in the file. The motivation here is that in
// a stable workload, the number of deletion entries should be roughly
// equal to the number of non-deletion entries. If we compensate the
// size of deletion entries in a stable workload, the deletion
// compensation logic might introduce unwanted effet which changes the
// shape of LSM tree.
if (file_meta->num_deletions * 2 >= file_meta->num_entries) {
file_meta->compensated_file_size += (file_meta->num_deletions * 2 - file_meta->num_entries) * average_value_size * kDeletionWeightOnCompaction;
}
}
}
}
}



auto c = (std::chrono::duration<double, std::milli>(current_timestamp - files[i]->fd.file_timestamp)).count();
double level_delete_persistence_latency = _env->GetLevelDeletePersistenceLatency(level, _env);
if (c > level_delete_persistence_latency * 1000 && level_delete_persistence_latency != -1 && files[i]->num_deletions > 0) {
if (_env->verbosity >= 2) std::cout << c << " > " << level_delete_persistence_latency << std::endl;
files[i]->fd.expired_ttl = true;
}

bool GetExpiredTTL() const {
return expired_ttl; // & kFileNumberMask;
}
1
option(WITH_ALL_TESTS "Build all test, rather than a small subset" OFF)
1
2
#define NDEBUG
关闭断言
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
void ZenFS::GCWorker() {
while (run_gc_worker_) {
usleep(1000 * 1000 * 10);

uint64_t non_free = zbd_->GetUsedSpace() + zbd_->GetReclaimableSpace();
uint64_t free = zbd_->GetFreeSpace();
uint64_t free_percent = (100 * free) / (free + non_free);
ZenFSSnapshot snapshot;
ZenFSSnapshotOptions options;

if (free_percent > GC_START_LEVEL) continue;

options.zone_ = 1;
options.zone_file_ = 1;
options.log_garbage_ = 1;

GetZenFSSnapshot(snapshot, options);

uint64_t threshold = (100 - GC_SLOPE * (GC_START_LEVEL - free_percent));
std::set<uint64_t> migrate_zones_start;
for (const auto& zone : snapshot.zones_) {
if (zone.capacity == 0) {
uint64_t garbage_percent_approx =
100 - 100 * zone.used_capacity / zone.max_capacity;
if (garbage_percent_approx > threshold &&
garbage_percent_approx < 100) {
migrate_zones_start.emplace(zone.start);
}
}
}

std::vector<ZoneExtentSnapshot*> migrate_exts;
for (auto& ext : snapshot.extents_) {
if (migrate_zones_start.find(ext.zone_start) !=
migrate_zones_start.end()) {
migrate_exts.push_back(&ext);
}
}

if (migrate_exts.size() > 0) {
IOStatus s;
Info(logger_, "Garbage collecting %d extents \n",
(int)migrate_exts.size());
s = MigrateExtents(migrate_exts);
if (!s.ok()) {
Error(logger_, "Garbage collection failed");
}
}
}
}
lethe修改
1
2
# ‘block_rep’ may be used uninitialized [-Werror=maybe-uninitialized]
CXXFLAGS += -Wno-error=maybe-uninitialized
1
2
3
file_age_file.open("/Users/subhadeep/Git/shared/infrastructure/rocksdb-fade/examples/__working_branch/file_age_stats.txt", std::ios_base::app);
改成
file_age_file.open("./file_age_stats.txt", std::ios_base::app);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  virtual IOStatus Append(const Slice& data, const IOOptions& options,
IODebugContext* dbg) override;
virtual IOStatus Append(const Slice& data, const IOOptions& opts,
const DataVerificationInfo& /* verification_info */,
IODebugContext* dbg) override {
return Append(data, opts, dbg);
}
virtual IOStatus PositionedAppend(const Slice& data, uint64_t offset,
const IOOptions& options,
IODebugContext* dbg) override;
virtual IOStatus PositionedAppend(
const Slice& data, uint64_t offset, const IOOptions& opts,
const DataVerificationInfo& /* verification_info */,
IODebugContext* dbg) override {
return PositionedAppend(data, offset, opts, dbg);
}


删掉DataVerificationInfo版本的api
1
2
3
4
5

# 'git describe --abbrev=7 --dirty' will output a version in that looks like "v0.1.0-12-g3456789-dirty".
VERSION=$(git describe --abbrev=7 --dirty)
改成
VERSION="v1.0-lt"

用正确版本的makefile替换当前版本的makefile以编译zenfs

由于当前Rocksdb并没有CreateFromString,故直接自己加接口与实现,得到ZenFS FileSystem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Status Env::CreateFromUri(const ConfigOptions& config_options,
const std::string& env_uri, const std::string& fs_uri,
Env** result, std::shared_ptr<Env>* guard) {
*result = config_options.env;
if (env_uri.empty() && fs_uri.empty()) {
// Neither specified. Use the default
guard->reset();
return Status::OK();
} else if (!env_uri.empty() && !fs_uri.empty()) {
// Both specified. Cannot choose. Return Invalid
return Status::InvalidArgument("cannot specify both fs_uri and env_uri");
} else if (fs_uri.empty()) { // Only have an ENV URI. Create an Env from it
return CreateFromString(config_options, env_uri, result, guard);
} else {
std::shared_ptr<FileSystem> fs;
Status s = FileSystem::CreateFromString(config_options, fs_uri, &fs);
if (s.ok()) {
guard->reset(new CompositeEnvWrapper(*result, fs));
*result = guard->get();
}
return s;
}
}

Status FileSystem::CreateFromString(const ConfigOptions& config_options,
const std::string& value,
std::shared_ptr<FileSystem>* result) {
auto default_fs = FileSystem::Default();
if (default_fs->IsInstanceOf(value)) {
*result = default_fs;
return Status::OK();
} else {
static std::once_flag once;
std::call_once(once, [&]() {
RegisterBuiltinFileSystems(*(ObjectLibrary::Default().get()), "");
});
return LoadSharedObject<FileSystem>(config_options, value, result);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// /lethe-codebase/include/rocksdb/file_system.h
Env* CreateZenFSEnv(std::string DevID);

// /lethe-codebase/plugin/zenfs/fs/fs_zenfs.cc
Env* CreateZenFSEnv(std::string DevID) {
FileSystem* fs = nullptr;
Status s;
s = NewZenFS(&fs, ZbdBackendType::kBlockDev, DevID);
if (!s.ok()) {
std::cout << s.ToString() << std::endl;
}
std::shared_ptr<FileSystem> f(fs);
Env* env = new CompositeEnvWrapper(Env::Default(), f);
return env;
}
// working_version.cc
std::string ZNS_DevID = "nvme0n1";
op->env = CreateZenFSEnv(ZNS_DevID);

单独增加ZenFS日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
static std::string GetLogFilename(std::string bdev) {
std::ostringstream ss;
time_t t = time(0);
struct tm* log_start = std::localtime(&t);
char buf[40];

std::strftime(buf, sizeof(buf), "%Y-%m-%d_%H:%M:%S.log", log_start);
ss << "./" << std::string("zenfs_") << bdev << "_" << buf;

return ss.str();
}

s = Env::Default()->NewLogger(GetLogFilename(backend_name), &logger);
std::cout << "log name: " << GetLogFilename(backend_name) << std::endl;
if (!s.ok()) {
fprintf(stderr, "ZenFS: Could not create logger");
} else {
logger->SetInfoLogLevel(DEBUG_LEVEL);
// #ifdef WITH_TERARKDB
// logger->SetInfoLogLevel(INFO_LEVEL);
// #endif
}

file age文件由追加写改成清空写

1
file_age_file.open("./file_age_stats.txt", std::ios_base::out | std::ios_base::trunc);
zenfs

安装libzbd:https://github.com/westerndigitalcorporation/libzbd

安装gflags:apt-get install libgflags-dev

1
2
3
/usr/bin/ld: /tmp/cc9CnjMI.o: in function `main':
/root/rocksdb/plugin/zenfs/util/zenfs.cc:775: undefined reference to `google::SetUsageMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /root/rocksdb/plugin/zenfs/util/zenfs.cc:787: undefined reference to `google::SetVersionString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
1
2
3
# /root/rocksdb/plugin/zenfs/util/Makefile
$(TARGET): $(TARGET).cc
$(CXX) $(CXXFLAGS) -g -o $(TARGET) $< $(LIBS) $(LDFLAGS) -lgflags # 加上gflags第三方库

invalid new-expression of abstract class type ‘rocksdb::ZonedWritableFile’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
for header_dir in `find "include/rocksdb" -type d`; do \
install -d //usr/local/$header_dir; \
done
for header in `find "include/rocksdb" -type f -name *.h`; do \
install -C -m 644 $header //usr/local/$header; \
done
plugin/zenfs/fs/fs_zenfs.cc: In member function ‘rocksdb::IOStatus rocksdb::ZenFS::OpenWritableFile(const string&, const rocksdb::FileOptions&, std::unique_ptr<rocksdb::FSWritableFile>*, rocksdb::IODebugContext*, bool)’:
plugin/zenfs/fs/fs_zenfs.cc:779:70: error: invalid new-expression of abstract class type ‘rocksdb::ZonedWritableFile’
779 | zoneFile, &metadata_writer_));
| ^
In file included from plugin/zenfs/fs/fs_zenfs.h:12,
from plugin/zenfs/fs/fs_zenfs.cc:9:
plugin/zenfs/fs/io_zenfs.h:186:7: note: because the following virtual functions are pure within ‘rocksdb::ZonedWritableFile’:
186 | class ZonedWritableFile : public FSWritableFile {
| ^~~~~~~~~~~~~~~~~
In file included from plugin/zenfs/fs/io_zenfs.h:24,
from plugin/zenfs/fs/fs_zenfs.h:12,
from plugin/zenfs/fs/fs_zenfs.cc:9:
./include/rocksdb/file_system.h:1168:20: note: ‘virtual uint64_t rocksdb::FSWritableFile::GetFileSize(const rocksdb::IOOptions&, rocksdb::IODebugContext*)’
1168 | virtual uint64_t GetFileSize(const IOOptions& /*options*/,
| ^~~~~~~~~~~
plugin/zenfs/fs/fs_zenfs.cc:810:68: error: invalid new-expression of abstract class type ‘rocksdb::ZonedWritableFile’
810 | zoneFile, &metadata_writer_));
| ^
for header in plugin/zenfs/fs/fs_zenfs.h plugin/zenfs/fs/zbd_zenfs.h plugin/zenfs/fs/io_zenfs.h plugin/zenfs/fs/version.h plugin/zenfs/fs/metrics.h plugin/zenfs/fs/snapshot.h; do \
install -d //usr/local/include/rocksdb/`dirname $header`; \
install -C -m 644 $header //usr/local/include/rocksdb/$header; \
done
install -C -m 644 rocksdb.pc /usr/local/lib/pkgconfig/rocksdb.pc
make: *** [Makefile:2535: plugin/zenfs/fs/fs_zenfs.o] Error 1
make: *** Waiting for unfinished jobs....
1
2
3
4
5
6
7
8
// 实现GetFileSize方法即可  
virtual uint64_t GetFileSize(const IOOptions& /*options*/,
IODebugContext* /*dbg*/);

uint64_t ZonedWritableFile::GetFileSize(const IOOptions& /*options*/,
IODebugContext* /*dbg*/) {
return zoneFile_->GetFileSize();
}
比较函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
auto cmp = [&current_timestamp, &level_delete_persistence_latency](const Fsize& f1, const Fsize& f2) -> bool {
auto c1 = (std::chrono::duration<double, std::milli>(current_timestamp - f1.file->fd.file_timestamp)).count();
auto c2 = (std::chrono::duration<double, std::milli>(current_timestamp - f2.file->fd.file_timestamp)).count();
if (c1 > level_delete_persistence_latency * 1000 && c2 > level_delete_persistence_latency * 1000 && level_delete_persistence_latency != -1) {
if (c1 == c2) {
return f1.file->num_deletions > f2.file->num_deletions;
} else {
return c1 > c2;
}
} else if (c1 > level_delete_persistence_latency * 1000 && c2 <= level_delete_persistence_latency * 1000 && level_delete_persistence_latency != -1) {
return c1 > c2;
} else if (c1 <= level_delete_persistence_latency * 1000 && c2 > level_delete_persistence_latency * 1000 && level_delete_persistence_latency != -1) {
return c2 > c1;
} else {
return f1.file->num_deletions < f2.file->num_deletions;
}
};
std::sort(temp.begin(), temp.end(), cmp);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$1 = std::vector of length 104, capacity 104 = {{index = 64, file = 0x7fffec1ab120}, {index = 64, file = 0x7fffec1ab120}, {index = 76, file = 0x7fffec56f600}, {index = 75, file = 0x7fffec11b0d0}, {index = 74, 
file = 0x7fffec11af30}, {index = 73, file = 0x7fffec11ad90}, {index = 72, file = 0x7fffec5701e0}, {index = 71, file = 0x7fffec570040}, {index = 70, file = 0x7fffec56fea0}, {index = 69,
file = 0x7fffec0d5a30}, {index = 68, file = 0x7fffec0d5890}, {index = 67, file = 0x7fffec0d56f0}, {index = 66, file = 0x7fffec1ab460}, {index = 65, file = 0x7fffec1ab2c0}, {index = 77,
file = 0x7fffe800d000}, {index = 63, file = 0x7fffec5d7c40}, {index = 62, file = 0x7fffec5d7aa0}, {index = 61, file = 0x7fffec5d7900}, {index = 60, file = 0x7fffec106290}, {index = 59,
file = 0x7fffec1060f0}, {index = 58, file = 0x7fffe0033430}, {index = 57, file = 0x7fffec5f4f80}, {index = 56, file = 0x7fffe80f29d0}, {index = 55, file = 0x7ffff03d9100}, {index = 54,
file = 0x7fffe821e820}, {index = 53, file = 0x7fffec0c7ee0}, {index = 52, file = 0x7fffec0b3fe0}, {index = 90, file = 0x7fffe82fa9c0}, {index = 102, file = 0x7fffec065780}, {index = 101,
file = 0x7ffff051b320}, {index = 100, file = 0x7fffe817c5f0}, {index = 99, file = 0x7fffe817c450}, {index = 98, file = 0x7fffe817c2b0}, {index = 97, file = 0x7fffe817c110}, {index = 96,
file = 0x7fffe817bf70}, {index = 95, file = 0x7fffe82fb1e0}, {index = 94, file = 0x7fffe82fb040}, {index = 93, file = 0x7fffe82faea0}, {index = 92, file = 0x7fffe82fad00}, {index = 91,
file = 0x7fffe82fab60}, {index = 1, file = 0x7ffff032e8b0}, {index = 89, file = 0x7fffe84333b0}, {index = 88, file = 0x7fffe8433210}, {index = 87, file = 0x7fffe8433070}, {index = 86, file = 0x7fffe8432ed0},
{index = 85, file = 0x7fffe8432d30}, {index = 84, file = 0x7fffe8057bd0}, {index = 83, file = 0x7ffff03b1200}, {index = 82, file = 0x7fffe8139460}, {index = 81, file = 0x7fffe80366c0}, {index = 80,
file = 0x7fffe8126ad0}, {index = 79, file = 0x7fffe8347480}, {index = 78, file = 0x7fffe814ec90}, {index = 13, file = 0x7ffff0234720}, {index = 25, file = 0x7ffff044b150}, {index = 24,
file = 0x7ffff0579b90}, {index = 23, file = 0x7ffff05799f0}, {index = 22, file = 0x7ffff0372c40}, {index = 21, file = 0x7ffff0372ac0}, {index = 20, file = 0x7ffff023e660}, {index = 19,
file = 0x7ffff023e4c0}, {index = 18, file = 0x7ffff0245410}, {index = 17, file = 0x7ffff0245270}, {index = 16, file = 0x7ffff03e5420}, {index = 15, file = 0x7ffff03e5280}, {index = 14,
file = 0x7ffff03ed700}, {index = 50, file = 0x7fffe81506f0}, {index = 12, file = 0x7ffff0234580}, {index = 11, file = 0x7ffff05d87a0}, {index = 10, file = 0x7ffff05d8600}, {index = 9, file = 0x7ffff02c15a0},
{index = 8, file = 0x7ffff02c1400}, {index = 7, file = 0x7ffff0550e70}, {index = 6, file = 0x7ffff037eac0}, {index = 5, file = 0x7ffff038c690}, {index = 4, file = 0x7ffff05dd1d0}, {index = 3,
file = 0x7ffff05314f0}, {index = 2, file = 0x7ffff02ee620}, {index = 0, file = 0x7ffff03e2740}, {index = 27, file = 0x7fffe81b5550}, {index = 51, file = 0x7fffe8150890}, {index = 49, file = 0x7fffe82b0750}, {
index = 48, file = 0x7fffe82b05b0}, {index = 47, file = 0x7fffe82b0410}, {index = 46, file = 0x7fffe817f620}, {index = 45, file = 0x7fffe817f480}, {index = 44, file = 0x7fffe817f2e0}, {index = 43,
file = 0x7fffe8305410}, {index = 42, file = 0x7fffe8305270}, {index = 41, file = 0x7fffe83050d0}, {index = 40, file = 0x7fffe8179f00}, {index = 39, file = 0x7fffe8179d60}, {index = 38,
file = 0x7fffe8179bc0}, {index = 37, file = 0x7fffe81be560}, {index = 36, file = 0x7fffe81be3c0}, {index = 35, file = 0x7fffe81be220}, {index = 34, file = 0x7fffe848ed60}, {index = 33,
file = 0x7fffe848ebc0}, {index = 32, file = 0x7fffe848ea20}, {index = 31, file = 0x7fffe8390940}, {index = 30, file = 0x7fffe83907a0}, {index = 29, file = 0x7fffe8390600}, {index = 28,
file = 0x7fffe82780f0}, {index = 26, file = 0x7fffe82d95d0}}

在C++中,当你使用标准库的排序功能(如 std::sort)或任何需要比较的数据结构(如 std::setstd::map)时,提供给这些功能的比较函数需要满足特定的性质。这些性质确保比较函数能够正确地指导排序或数据结构的行为。以下是比较函数需要满足的主要性质:

  1. 反射性

比较函数对于任何元素 a,必须返回 false 当作 a < a 的判断:

1
2
3
cpp
Copy code
comp(a, a) == false
  1. 反对称性

对于任何元素 ab,如果 a < btrue,那么 b < a 必须是 false

1
2
3
cpp
Copy code
if (comp(a, b) == true) then comp(b, a) must be false
  1. 传递性

对于任何元素 abc,如果 a < btrue 并且 b < ctrue,那么 a < c 也必须是 true

1
2
3
cpp
Copy code
if (comp(a, b) == true && comp(b, c) == true) then comp(a, c) must be true
  1. 强传递性

除了上述的基本传递性之外,比较函数还应满足强传递性,这涉及到等价的情况。即如果 a 等于 b(在排序意义上,即 !comp(a, b) && !comp(b, a)),并且 b < c,则 a < c

1
2
3
cpp
Copy code
if (!comp(a, b) && !comp(b, a) && comp(b, c)) then comp(a, c) must be true
  1. 总体性

对于任何两个元素 ab,比较函数应该能返回一个确定的比较结果,即 a < bb < a 或两者都不成立(认为它们等价),从而保证元素可以完全排序。

实现建议

  • 当定义一个比较函数时,确保它是 非成员函数 或者 静态成员函数,这样它就不会依赖于对象的状态。
  • 对于复杂类型的比较,考虑可能的边界情况和特殊值,如空值、极限大小等。
  • 在实现比较函数时,要特别小心处理浮点数的比较,避免因精度问题导致的错误排序。

通过确保这些性质,你的比较函数可以安全地用于标准库中的排序和其他数据结构,保证它们的正确性和效率。

在C++中,比较函数通常用于定义元素之间的排序关系。当使用比较函数(如 cmp)对元素 f1f2 进行比较时,函数返回的 truefalse 值具有特定的意义:

  1. 返回 true
    • 这意味着在比较函数定义的排序规则下,第一个参数 f1 应该排在第二个参数 f2 之前。换句话说,根据定义的准则,f1 小于(或优先于)f2。这个返回值告诉排序算法或任何使用该比较函数的数据结构,f1 在排序顺序中应该出现在 f2 的前面。
  2. 返回 false
    • 这意味着根据比较函数的排序规则,f1 不应该排在 f2 之前。这并不一定意味着 f1 大于 f2,因为 false 的返回值还可能意味着 f1f2 是等价的(在排序意义上相等)。所以,返回 false 可以被解释为 f1 大于或等于 f2,或者说 f1 不小于 f2
scatter/gather I/O

linux文件IO与内存映射:分散/聚集IO技术(scatter-gather)

Linux: When to use scatter/gather IO (readv, writev) vs a large buffer with fread

画图工具:

draw.io

PPT

visio

word插入图片后变模糊

插入Word的图片如何保持清晰度

image-20231109160906171

leveldb上运行YCSB工作负载

github仓库地址:https://github.com/ls4154/YCSB-cpp

很好的解决思路

使用memcpy()时报错

可以试一下将memcpy()替换掉,自己写一个for循环进行拷贝,找到错误

vmware扩展分区

首先将未分配的空间放进大目录下(/dev/sda2),而后再在/dev/sda5里resize

内核查询函数:elixir.bootlin.com

gpt

润色以下文本,使其更具学术性,语义更加通顺。你需要具有分区固态盘与日志合并树,计算机存储的相关知识。 整体的文字数不需要太大的改变,文字数为原先文字数的100%-110%最好,注意不用出现“我们”一词,以及一些比较口语化的词汇

润色以下文本,使其更具学术性,语义更加通顺。你需要具有分区固态盘与日志合并树,计算机存储的相关知识。 整体的文字数不需要太大的改变,文字数为原先文字数的100%-110%最好,注意不用出现“我们”一词,以及一些比较口语化的词汇

润色并扩充以下文本,使其更具学术性,语义更加通顺。你需要具有日志合并树,计算机存储的相关知识。

润色以下文本,使其更具学术性,语义更加通顺。你需要具有分区固态盘与日志合并树,计算机存储的相关知识。 整体的文字数不需要太大的改变,文字数为原先文字数的100%-110%最好,注意不用出现“我们”一词,以及一些比较口语化的词汇,同时注意纠正语句中的错别字并在发现错别字后第一时间报告

我现在正在编写论文的相关工作部分,现在需要介绍这篇论文,请用两三句话介绍它的主要工作,注意语言风格与论文的相关工作风格保持一致,突出主要工作而不是空泛的概念,用中文回答

不要过分依赖人工智能,对人工智能发脾气是没有任何意义的

endnote

Endnote GB/T 7714-2015(numeric)格式文献插入与修改

2015版本的style

EndNote导入文献出现带有大括号{}乱码的解决办法

参考文献不在最后一页,如何使用EndNote将参考文献统一放在参考文献那一章?

其实不用那么麻烦,选择文末endnote生成的文献列表,直接拖拽到目标位置(注意这里必须拖拽,不要ctrl+x剪切,这样不会消除文献列表的域代码),你会发现此后更新的文献全部都在新位置而非文末

git submodule sync

git rm –cached plugin/zenfs

杂项

set(HAVE_SNAPPY OFF)

fio测试zns脚本:ZNS : 解决传统SSD问题的高性能存储栈设计(fs–>io–>device)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[global]
filename=/dev/nvme0n1
zonemode=zbd
max_open_zones=1
direct=1
ioengine=libaio
numjobs=1
iodepth=1
group_reporting
size=1G
time_based
runtime=60s
zonesize = 131072

[seqwrite]
rw=write # or write
bs=4K

confzns:

1
2
可随机读的区域
#define MK_ZONE_CONVENTIONAL 5

RocksDB原理学习笔记

1
level0的文件大小是由write_buffer_size决定的,level1的文件大小是由target_file_size_base决定的,level2及以上,size = target_file_size_base * (target_file_size_multiplier ^ (L - 1))

西数ZN540如何修改sector size

512字节时各命令输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
nvme id-ns -H /dev/nvme1n1
NVME Identify Namespace 1:
nsze : 0x400000
ncap : 0x400000
nuse : 0
nsfeat : 0x2
[4:4] : 0 NPWG, NPWA, NPDG, NPDA, and NOWS are Not Supported
[3:3] : 0 NGUID and EUI64 fields if non-zero, Reused
[2:2] : 0 Deallocated or Unwritten Logical Block error Not Supported
[1:1] : 0x1 Namespace uses NAWUN, NAWUPF, and NACWU
[0:0] : 0 Thin Provisioning Not Supported

nlbaf : 4
flbas : 0
[4:4] : 0 Metadata Transferred in Separate Contiguous Buffer
[3:0] : 0 Current LBA Format Selected

mc : 0x3
[1:1] : 0x1 Metadata Pointer Supported
[0:0] : 0x1 Metadata as Part of Extended Data LBA Supported

dpc : 0
[4:4] : 0 Protection Information Transferred as Last 8 Bytes of Metadata Not Supported
[3:3] : 0 Protection Information Transferred as First 8 Bytes of Metadata Not Supported
[2:2] : 0 Protection Information Type 3 Not Supported
[1:1] : 0 Protection Information Type 2 Not Supported
[0:0] : 0 Protection Information Type 1 Not Supported

dps : 0
[3:3] : 0 Protection Information is Transferred as Last 8 Bytes of Metadata
[2:0] : 0 Protection Information Disabled

nmic : 0
[0:0] : 0 Namespace Multipath Not Capable

rescap : 0xff
[7:7] : 0x1 Ignore Existing Key - Used as defined in revision 1.3 or later
[6:6] : 0x1 Exclusive Access - All Registrants Supported
[5:5] : 0x1 Write Exclusive - All Registrants Supported
[4:4] : 0x1 Exclusive Access - Registrants Only Supported
[3:3] : 0x1 Write Exclusive - Registrants Only Supported
[2:2] : 0x1 Exclusive Access Supported
[1:1] : 0x1 Write Exclusive Supported
[0:0] : 0x1 Persist Through Power Loss Supported

fpi : 0x80
[7:7] : 0x1 Format Progress Indicator Supported
[6:0] : 0 Format Progress Indicator (Remaining 0%)

dlfeat : 9
[4:4] : 0 Guard Field of Deallocated Logical Blocks is set to 0xFFFF
[3:3] : 0x1 Deallocate Bit in the Write Zeroes Command is Supported
[2:0] : 0x1 Bytes Read From a Deallocated Logical Block and its Metadata are 0x00

nawun : 511
nawupf : 511
nacwu : 0
nabsn : 0
nabo : 0
nabspf : 0
noiob : 0
nvmcap : 2147483648
mssrl : 0
mcl : 0
msrc : 0
anagrpid: 0
nsattr : 0
nvmsetid: 0
endgid : 0
nguid : 0d000000000000000014ee8303a65080
eui64 : 0014ee8303a65080
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0 Best (in use)
LBA Format 1 : Metadata Size: 8 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 2 : Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 3 : Metadata Size: 8 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 4 : Metadata Size: 64 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
nvme id-ns -H /dev/nvme1n2
NVME Identify Namespace 2:
nsze : 0xe2000000
ncap : 0x76d94000
nuse : 0x86a000
nsfeat : 0x2
[4:4] : 0 NPWG, NPWA, NPDG, NPDA, and NOWS are Not Supported
[3:3] : 0 NGUID and EUI64 fields if non-zero, Reused
[2:2] : 0 Deallocated or Unwritten Logical Block error Not Supported
[1:1] : 0x1 Namespace uses NAWUN, NAWUPF, and NACWU
[0:0] : 0 Thin Provisioning Not Supported

nlbaf : 4
flbas : 0
[4:4] : 0 Metadata Transferred in Separate Contiguous Buffer
[3:0] : 0 Current LBA Format Selected

mc : 0x3
[1:1] : 0x1 Metadata Pointer Supported
[0:0] : 0x1 Metadata as Part of Extended Data LBA Supported

dpc : 0
[4:4] : 0 Protection Information Transferred as Last 8 Bytes of Metadata Not Supported
[3:3] : 0 Protection Information Transferred as First 8 Bytes of Metadata Not Supported
[2:2] : 0 Protection Information Type 3 Not Supported
[1:1] : 0 Protection Information Type 2 Not Supported
[0:0] : 0 Protection Information Type 1 Not Supported

dps : 0
[3:3] : 0 Protection Information is Transferred as Last 8 Bytes of Metadata
[2:0] : 0 Protection Information Disabled

nmic : 0
[0:0] : 0 Namespace Multipath Not Capable

rescap : 0xff
[7:7] : 0x1 Ignore Existing Key - Used as defined in revision 1.3 or later
[6:6] : 0x1 Exclusive Access - All Registrants Supported
[5:5] : 0x1 Write Exclusive - All Registrants Supported
[4:4] : 0x1 Exclusive Access - Registrants Only Supported
[3:3] : 0x1 Write Exclusive - Registrants Only Supported
[2:2] : 0x1 Exclusive Access Supported
[1:1] : 0x1 Write Exclusive Supported
[0:0] : 0x1 Persist Through Power Loss Supported

fpi : 0x80
[7:7] : 0x1 Format Progress Indicator Supported
[6:0] : 0 Format Progress Indicator (Remaining 0%)

dlfeat : 8
[4:4] : 0 Guard Field of Deallocated Logical Blocks is set to 0xFFFF
[3:3] : 0x1 Deallocate Bit in the Write Zeroes Command is Supported
[2:0] : 0 Bytes Read From a Deallocated Logical Block and its Metadata are Not Reported

nawun : 511
nawupf : 511
nacwu : 0
nabsn : 0
nabo : 0
nabspf : 0
noiob : 0
nvmcap : 1941325217792
mssrl : 0
mcl : 0
msrc : 0
anagrpid: 0
nsattr : 0
nvmsetid: 0
endgid : 0
nguid : 0e000000000000000014ee8303a65081
eui64 : 0014ee8303a65081
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0 Best (in use)
LBA Format 1 : Metadata Size: 8 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 2 : Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 3 : Metadata Size: 8 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 4 : Metadata Size: 64 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
1
2
3
4
5
6
7
8
9
10
nr_zones: 904
SLBA: 0 WP: 0x1b000f Cap: 0x21a800 State: 0x20 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x400000 WP: 0x5af05c Cap: 0x21a800 State: 0x20 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x800000 WP: 0x9afd61 Cap: 0x21a800 State: 0x20 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0xc00000 WP: 0xd1b6a0 Cap: 0x21a800 State: 0x20 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x1000000 WP: 0x1000000 Cap: 0x21a800 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x1400000 WP: 0x1400000 Cap: 0x21a800 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x1800000 WP: 0x1800000 Cap: 0x21a800 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x1c00000 WP: 0x1c00000 Cap: 0x21a800 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x2000000 WP: 0x2000000 Cap: 0x21a800 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0

块大小为4096

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
nvme id-ns -H /dev/nvme1n1
NVME Identify Namespace 1:
nsze : 0x80000
ncap : 0x80000
nuse : 0
nsfeat : 0x2
[4:4] : 0 NPWG, NPWA, NPDG, NPDA, and NOWS are Not Supported
[3:3] : 0 NGUID and EUI64 fields if non-zero, Reused
[2:2] : 0 Deallocated or Unwritten Logical Block error Not Supported
[1:1] : 0x1 Namespace uses NAWUN, NAWUPF, and NACWU
[0:0] : 0 Thin Provisioning Not Supported

nlbaf : 4
flbas : 0x2
[4:4] : 0 Metadata Transferred in Separate Contiguous Buffer
[3:0] : 0x2 Current LBA Format Selected

mc : 0x3
[1:1] : 0x1 Metadata Pointer Supported
[0:0] : 0x1 Metadata as Part of Extended Data LBA Supported

dpc : 0
[4:4] : 0 Protection Information Transferred as Last 8 Bytes of Metadata Not Supported
[3:3] : 0 Protection Information Transferred as First 8 Bytes of Metadata Not Supported
[2:2] : 0 Protection Information Type 3 Not Supported
[1:1] : 0 Protection Information Type 2 Not Supported
[0:0] : 0 Protection Information Type 1 Not Supported

dps : 0
[3:3] : 0 Protection Information is Transferred as Last 8 Bytes of Metadata
[2:0] : 0 Protection Information Disabled

nmic : 0
[0:0] : 0 Namespace Multipath Not Capable

rescap : 0xff
[7:7] : 0x1 Ignore Existing Key - Used as defined in revision 1.3 or later
[6:6] : 0x1 Exclusive Access - All Registrants Supported
[5:5] : 0x1 Write Exclusive - All Registrants Supported
[4:4] : 0x1 Exclusive Access - Registrants Only Supported
[3:3] : 0x1 Write Exclusive - Registrants Only Supported
[2:2] : 0x1 Exclusive Access Supported
[1:1] : 0x1 Write Exclusive Supported
[0:0] : 0x1 Persist Through Power Loss Supported

fpi : 0x80
[7:7] : 0x1 Format Progress Indicator Supported
[6:0] : 0 Format Progress Indicator (Remaining 0%)

dlfeat : 9
[4:4] : 0 Guard Field of Deallocated Logical Blocks is set to 0xFFFF
[3:3] : 0x1 Deallocate Bit in the Write Zeroes Command is Supported
[2:0] : 0x1 Bytes Read From a Deallocated Logical Block and its Metadata are 0x00

nawun : 63
nawupf : 63
nacwu : 0
nabsn : 0
nabo : 0
nabspf : 0
noiob : 0
nvmcap : 2147483648
mssrl : 0
mcl : 0
msrc : 0
anagrpid: 0
nsattr : 0
nvmsetid: 0
endgid : 0
nguid : 0f000000000000000014ee8303a65080
eui64 : 0014ee8303a65080
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 1 : Metadata Size: 8 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 2 : Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best (in use)
LBA Format 3 : Metadata Size: 8 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 4 : Metadata Size: 64 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
NVME Identify Namespace 2:
nsze : 0x1c400000
ncap : 0xedb2800
nuse : 0
nsfeat : 0x2
[4:4] : 0 NPWG, NPWA, NPDG, NPDA, and NOWS are Not Supported
[3:3] : 0 NGUID and EUI64 fields if non-zero, Reused
[2:2] : 0 Deallocated or Unwritten Logical Block error Not Supported
[1:1] : 0x1 Namespace uses NAWUN, NAWUPF, and NACWU
[0:0] : 0 Thin Provisioning Not Supported

nlbaf : 4
flbas : 0x2
[4:4] : 0 Metadata Transferred in Separate Contiguous Buffer
[3:0] : 0x2 Current LBA Format Selected

mc : 0x3
[1:1] : 0x1 Metadata Pointer Supported
[0:0] : 0x1 Metadata as Part of Extended Data LBA Supported

dpc : 0
[4:4] : 0 Protection Information Transferred as Last 8 Bytes of Metadata Not Supported
[3:3] : 0 Protection Information Transferred as First 8 Bytes of Metadata Not Supported
[2:2] : 0 Protection Information Type 3 Not Supported
[1:1] : 0 Protection Information Type 2 Not Supported
[0:0] : 0 Protection Information Type 1 Not Supported

dps : 0
[3:3] : 0 Protection Information is Transferred as Last 8 Bytes of Metadata
[2:0] : 0 Protection Information Disabled

nmic : 0
[0:0] : 0 Namespace Multipath Not Capable

rescap : 0xff
[7:7] : 0x1 Ignore Existing Key - Used as defined in revision 1.3 or later
[6:6] : 0x1 Exclusive Access - All Registrants Supported
[5:5] : 0x1 Write Exclusive - All Registrants Supported
[4:4] : 0x1 Exclusive Access - Registrants Only Supported
[3:3] : 0x1 Write Exclusive - Registrants Only Supported
[2:2] : 0x1 Exclusive Access Supported
[1:1] : 0x1 Write Exclusive Supported
[0:0] : 0x1 Persist Through Power Loss Supported

fpi : 0x80
[7:7] : 0x1 Format Progress Indicator Supported
[6:0] : 0 Format Progress Indicator (Remaining 0%)

dlfeat : 8
[4:4] : 0 Guard Field of Deallocated Logical Blocks is set to 0xFFFF
[3:3] : 0x1 Deallocate Bit in the Write Zeroes Command is Supported
[2:0] : 0 Bytes Read From a Deallocated Logical Block and its Metadata are Not Reported

nawun : 63
nawupf : 63
nacwu : 0
nabsn : 0
nabo : 0
nabspf : 0
noiob : 0
nvmcap : 1941325217792
mssrl : 0
mcl : 0
msrc : 0
anagrpid: 0
nsattr : 0
nvmsetid: 0
endgid : 0
nguid : 10000000000000000014ee8303a65081
eui64 : 0014ee8303a65081
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 1 : Metadata Size: 8 bytes - Data Size: 512 bytes - Relative Performance: 0 Best
LBA Format 2 : Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best (in use)
LBA Format 3 : Metadata Size: 8 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best
LBA Format 4 : Metadata Size: 64 bytes - Data Size: 4096 bytes - Relative Performance: 0 Bes
1
2
3
4
5
6
7
8
9
10
11
nvme zns report-zones /dev/nvme1n2 | head -10
nr_zones: 904
SLBA: 0 WP: 0 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x80000 WP: 0x80000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x100000 WP: 0x100000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x180000 WP: 0x180000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x200000 WP: 0x200000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x280000 WP: 0x280000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x300000 WP: 0x300000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x380000 WP: 0x380000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0
SLBA: 0x400000 WP: 0x400000 Cap: 0x43500 State: 0x10 Type: 0x2 Attrs: 0 AttrsInfo: 0