Skip to content

fix(slayerfs): align redis rename/unlink semantics and fuse rename behavior#596

Open
KBrynhild wants to merge 1 commit intork8s-dev:mainfrom
KBrynhild:trouble-fix
Open

fix(slayerfs): align redis rename/unlink semantics and fuse rename behavior#596
KBrynhild wants to merge 1 commit intork8s-dev:mainfrom
KBrynhild:trouble-fix

Conversation

@KBrynhild
Copy link
Copy Markdown

本 PR 针对 Redis 元数据后端与 FUSE/VFS 语义不一致的问题进行修复,重点覆盖以下风险:

  1. 覆盖式 rename 缺少端到端原子性,存在并发竞态下误删目标的可能。
  2. unlink 在节点缺失或损坏时存在吞错行为,削弱错误可观测性。
  3. FUSE 层同路径 rename 返回 EINVAL,与 POSIX no-op 语义不一致。
  4. FUSE 模块结构中占位 adapter 容易误导真实入口,带来维护风险。

### 主要改动

  1. Redis rename 改为原子替换语义
  • 在 Redis Lua rename 脚本中实现目标替换与源移动的单次原子流程。

  • 覆盖式重命名时在脚本内完成目标类型校验、目录非空判断、目标删除与源项迁移,避免 VFS 先删后改名导致的竞态窗口。

  • 针对硬链接场景同步维护 link_parents 与 nlink 变化。

  1. 收紧 UNLINK_LUA 语义
  • 目录项不存在时返回 not_found。

  • 节点不存在时返回 node_not_found。

  • 节点损坏时返回 corrupt_node。

  • Rust 层按上述错误进行显式映射,不再将异常状态统一吞为成功删除。

  1. 修复 FUSE 同路径 rename 语义
  • FUSE rename 在 parent/new_parent 与 name/new_name 相同场景下改为直接成功返回(no-op),与 POSIX 语义对齐。
  1. 清理 FUSE 结构误导点(5.4)
  • 移除未使用且仅占位的 adapter 模块,避免误导真实实现入口。

  • 同步更新模块说明,聚焦实际的 FUSE 实现位置。

### 测试与回归保障

新增/更新了 Redis 相关回归测试,覆盖以下关键场景:

  1. 目标已存在时 rename 应执行原子替换,而非返回 AlreadyExists。
  2. 覆盖式 rename 与并发 create 竞争时不应出现“先删后失败”的可见窗口。
  3. 并发双重 unlink 应表现为一次成功、一次 NotFound。
  4. FUSE 挂载烟测增加同路径 rename no-op 断言,防止接口语义回退。

…havior

Signed-off-by: KBrynhild <K_Bohemian@outlook.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ed3faebb3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1003 to +1005
// POSIX allows same-path rename as a no-op.
if adapter::is_same_rename(parent, name.as_ref(), new_parent, new_name.as_ref()) {
return Ok(());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check source existence before same-path rename fast path

Returning Ok(()) for parent/new_parent + name/new_name equality before the source lookup skips the child_of/stat_ino validation below, so a same-path rename can succeed even when the source entry has already disappeared (e.g., under concurrent unlink/rename races). POSIX no-op semantics only apply when the source exists; otherwise callers should see ENOENT, and silently succeeding here can mask real failures.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant