Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CephFS防误删:回收站开发 #38

Open
liuyingjie1di opened this issue Nov 1, 2024 · 0 comments
Open

CephFS防误删:回收站开发 #38

liuyingjie1di opened this issue Nov 1, 2024 · 0 comments

Comments

@liuyingjie1di
Copy link

改动:客户端收到的unlink请求,在mds端转化成 rename 请求,转移到一个我们指定的目录。
问题:修改之后的rm执行完成之后,没有让缓存失效,ls显示的是dcache缓存中的内容,没有出现新移入的文件。只有当重新挂载或者执行原始rm和mv操作时,让缓存失效,重新调用readdir,此时回收站才会出现最新移入的文件。

原因
mds端收到的unlink请求,将其转化成 rename 请求,转移到一个我们指定的目录。
在内核端,handl_reply处理请求,在其中的ceph_fill_trace函数中
如下代码,满足下面两个条件时,会进入rename的if语句中, 调用ceph_dir_clear_ordered(dir)函数清除order,让目录的缓存失效

if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) {
	struct inode *olddir = req->r_old_dentry_dir;
	BUG_ON(!olddir);
	pr_err("-------------- olddir: %p \n",olddir);
	dout(" src %p '%pd' dst %p '%pd'\n",
	     req->r_old_dentry,
	     req->r_old_dentry,
	     dn, dn);
	dout("fill_trace doing d_move %p -> %p\n",
	     req->r_old_dentry, dn);

	/* d_move screws up sibling dentries' offsets */
	ceph_dir_clear_ordered(dir);
	ceph_dir_clear_ordered(olddir);
              ....
          }

调试过程中发现并没有进入该if语句
此时将req->r_op打印出来显示的是rm的请求,req->r_old_dentry 也为空,不满足if条件。
并不是mds端没转换成功,而是因为r_old_dentry和r_op是内核客户端保存的参数,create_request_message时进行的初始化,此时还未到达mds端进行转换

需求:在不修改Linux内核的前提下,有什么办法可以在mds端rm转为mv的时候,同时让缓存失效,下一次ls的时候调用readdir吗?

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

No branches or pull requests

1 participant