nfs 的 subtree_check 属性

subtree_check 是说在用一个 file handle 时,要检查它的挂载点变化,且到挂载点之间的目录均有访问权限。举例说明:

  • 服务端导出两个目录 /export_a /export_b
  • 客户端在挂载了 /export_a 目录,当前在 /export_a/a 目录下
  • 服务端执行 mv /export_a/a /export_b/,将export_a下的 a 目录转至 export_b 导出点下
  • 客户端在 a 目录下创建文件 b

这时 subtree_check 与 no_subtree_check 就会起作用:

  • 服务端如果在/etc/export 下在 /export_a 目录配置了 subtree_check,则在检查从a目录向上的挂载点时发现挂载点变化,创建文件失败
  • 服务端如果在/etc/export 下在 /export_a 目录配置了 no_subtree_check,则不检查a目录的导出点变化,可以成功创建文件
bash 复制代码
# /root/mnt/x/ 的权限是只读
[root@localhost nfs]# ll
总用量 4
dr--r--r--. 4 root root 4096  6月  5 10:03 x

--------------------------------------------------------
[root@localhost ww]# cat /etc/exports
/root/mnt *(rw,sync,subtree_check,no_root_squash)  # check
/root/mnt/x *(rw,sync,subtree_check,no_root_squash)

[test@localhost nfs]$ cd ww
# [root@localhost tracing]# mv /root/mnt/ww /root/mnt/x/  # 移至其它只读挂载点
[test@localhost ww]$ mkdir aa
mkdir: 无法创建目录 "aa": Stale file handle    # 失败

--------------------------------------------------------
[root@localhost ww]# cat /etc/exports
/root/mnt *(rw,sync,no_subtree_check,no_root_squash)  # no check
/root/mnt/x *(rw,sync,subtree_check,no_root_squash)

[test@localhost nfs]$ cd ww
# [root@localhost tracing]# mv /root/mnt/ww /root/mnt/x/  # 移至其它只读挂载点
[test@localhost ww]$ mkdir aa   
[test@localhost ww]$             # 成功

除此之外,如果a目录移动出挂载点,也是一样的。

相关推荐
qeen8729 分钟前
【Linux】Linux环境下的进程终止与进程等待问题
linux·运维·服务器
LRL_2 小时前
【实战指南】Node.js 跨平台依赖下载:如何在 Windows/Linux 环境下互跨下载目标系统的 npm/pnpm 包
linux·windows·node.js
高山有多高2 小时前
【Linux笔记】网络命令
linux
一条破秋裤3 小时前
Linux 线程同步:读写锁
java·linux·jvm
工作10年+,存储芯片行业3 小时前
Linux NVMe 中断排查与性能优化:IRQ 优化(原理+排查)
linux·运维·性能优化·ssd·nvme·pcie·中断
宵时待雨4 小时前
linux笔记归纳25:多路转接epoll
linux·服务器·网络·c++
geats人山人海4 小时前
linux 1.目录结构
linux·运维·服务器
wuminyu4 小时前
JEP491中synchronized关键字引发的平台线程钉住解决方法简介
java·linux·c语言·jvm·c++
应用市场4 小时前
嵌入式Linux从裸板到产品(一):全景地图与交叉编译环境,从四个上板翻车现场说
linux·运维·服务器
皓月盈江5 小时前
Linux系统PC与Linux系统服务器通过scp上传与下载文件
linux·运维·服务器·scp·文件上传·文件下载