性能测试用例和结果更新

This commit is contained in:
1iaan
2026-03-30 21:17:25 +08:00
parent 224d813499
commit ea64511f95
17 changed files with 706 additions and 65 deletions

View File

@@ -239,25 +239,36 @@ fallocate(int fd, int mode, off_t offset, off_t len)
return -1;
}
/* FALLOC_FL_KEEP_SIZE预分配但不改变文件逻辑大小直接返回 0 */
if (mode & FALLOC_FL_KEEP_SIZE) {
ZVFS_HOOK_LEAVE();
return 0;
}
uint64_t new_end = (uint64_t)offset + (uint64_t)len;
uint64_t alloc_end = new_end;
/*
* 普通 fallocatemode == 0
* 确保 [offset, offset+len) 范围内的空间被"分配"
* zvfs 的语义:把 logical_size 扩展到 max(logical_size, offset+len)。
* 不提前 blob_resize因为 SPDK cluster 按写入时分配更高效。
* ZVFS 读路径会按 blob 当前 cluster 大小做越界检查,因此这里不能只
* 更新 logical_size/st_size必须同步把 blob capacity 扩到目标范围
*
* 对 KEEP_SIZE
* 预分配空间,但不改变文件逻辑大小。
* 对普通 fallocate
* 预分配空间,并把逻辑大小扩展到 offset + len。
*/
uint64_t new_end = (uint64_t)offset + (uint64_t)len;
pthread_mutex_lock(&of->inode->mu);
if (new_end > of->inode->logical_size)
inode_update_size(of->inode, fd, new_end);
if (alloc_end < of->inode->logical_size)
alloc_end = of->inode->logical_size;
pthread_mutex_unlock(&of->inode->mu);
if (blob_resize(of->handle_id, alloc_end) < 0) {
errno = EIO;
ZVFS_HOOK_LEAVE();
return -1;
}
if ((mode & FALLOC_FL_KEEP_SIZE) == 0) {
pthread_mutex_lock(&of->inode->mu);
if (new_end > of->inode->logical_size)
inode_update_size(of->inode, fd, new_end);
pthread_mutex_unlock(&of->inode->mu);
}
ZVFS_HOOK_LEAVE();
return 0;
}
@@ -293,6 +304,17 @@ posix_fallocate(int fd, off_t offset, off_t len)
if (offset < 0 || len <= 0) { ZVFS_HOOK_LEAVE(); return EINVAL; }
uint64_t new_end = (uint64_t)offset + (uint64_t)len;
uint64_t alloc_end = new_end;
pthread_mutex_lock(&of->inode->mu);
if (alloc_end < of->inode->logical_size)
alloc_end = of->inode->logical_size;
pthread_mutex_unlock(&of->inode->mu);
if (blob_resize(of->handle_id, alloc_end) < 0) {
ZVFS_HOOK_LEAVE();
return errno ? errno : EIO;
}
pthread_mutex_lock(&of->inode->mu);
if (new_end > of->inode->logical_size)