Linux

mount(2): Stale file handle 에러

eden.do 2022. 8. 12. 11:39

nfs service를 이용할 때 Stale file handle이라는 에러가 종종 나곤 한다.

mount -t nfs [ip]:/nfs /home/eden/nfs-test -v 하면 mount하는 자세한 과정을 볼 수 있는데 이 때 stale file handle 에러를 확인할 수 있다. 

찾아보니 서버에는 이전 file handle이 남아 있는데 참조한 file의 inode가 바뀌는 경우(예를 들면 파일 참조되어 있는 상태에서 서버 재시작) 더이상 그 파일을 참조할 수 없어 발생하는 문제로 보인다. 이 상황이 지속되면 kernel lock이 걸려버림..

마운트된 파일의 기본 inode, 디스크 장치 또는 NFS 서버의 inode 생성이 변경되면 NFS 부실 파일 핸들이 발생

문제 상황

  • mount를 하려고 할 때 nfs v3은 잘 동작하지만 nfs v4로 mount를 하려 했을 때 timed out이 발생
  • error message를 확인해봤을 때 mount.nfs: mount(2): Stale file handle 메시지 확인
  • 확인을 해보니 nfs v4로 둘 이상의 디렉토리에 마운트를 하는 경우 stale file handle 발생

문제 해결 과정

  • 버전 상의 문제일지 혹은 여러 버전들을 같이 사용하면 문제가 발생하는건지 테스트 진행
    • 문제 없음
  • 관련하여 확인을 해보니 nfs client에 mount되어 있는 상태에서 nfs server가 reboot 되면 세션 가비지들이 클라이언트에 남아 발생하는것으로 파악
    • 이 때 바로 unmount 시켜서 해결할 수 있지만 오래 되면 세션 파일들이 커널 lock이 걸리게됨 -> 그러면 해당 버전으로는 다시 mount 불가

문제 해결 방법

  1. 강제로 unmount
    • unmount -f 명령어를 이용하여 mount된 파일들을 unmount 시킴 -> 이미 시간이 지나서 소용이 없는 것으로 보임
  2. 재부팅
    • 커널에 남은 Lock 파일들은 지우기가 힘들어서 재부팅을 하는게 가장 빠른 방법… -> nfs 정상 동작

관련 커맨드

mount 확인(nfs version 확인 가능 / nfs-client에서 실행) : mount | grep nfs 

mount 확인(nfs version 3에 한해서만 나옴 / nfs-server에서 실행 ) : showmount -a 

mount w/log : mount -t nfs [ip]:/nfs /home/eden/nfs-test -v 

unmount : umount /home/eden/nfs-test

 

https://unix.stackexchange.com/questions/433051/mount-nfs-stale-file-handle-error-cannot-umount

 

mount.nfs: Stale file handle error - cannot umount

Every time I try to mount a NFS share I get this: >> mount -t nfs gitlab-replica-storage.blah.com:/export/registry-gitlab-prod-data-vol /mnt/test mount.nfs: Stale file handle The problem is...

unix.stackexchange.com

https://stackoverflow.com/questions/34919597/how-to-get-the-list-of-clients-connected-to-an-nfs-server-within-a-local-network

 

How to get the list of clients connected to an NFS server within a local network?

I have an NFS server with folder permissions as follows. There are 50 clients which need to connect to this server within the same network. I would like to know what's the command to lookup which a...

stackoverflow.com

https://www.suse.com/support/kb/doc/?id=000019722 

 

NFS file system is hung. New mount attempts hang also. | Support | SUSE

 

www.suse.com

https://docs.oracle.com/cd/E18752_01/html/816-4555/rfsrefer-45.html

 

How the NFS Service Works - System Administration Guide: Network Services

How the NFS Service Works The following sections describe some of the complex functions of the NFS software. Note that some of the feature descriptions in this section are exclusive to NFS version 4. Version Negotiation in NFS The NFS initiation process in

docs.oracle.com

https://bugzilla.redhat.com/show_bug.cgi?id=1477231 

 

1477231 – ls hang on NFS share

Wireshark captures no flags Details

bugzilla.redhat.com

https://bugzilla.redhat.com/show_bug.cgi?id=1477231 

 

1477231 – ls hang on NFS share

Wireshark captures no flags Details

bugzilla.redhat.com

inode 값 확인

https://blog.warpmemory.com/150

 

Linux inode 값 확인 및 inode로 파일 찾기

inode 확인 ls -il 옵션을 추가하여, inode 값 확인 # ls -il test.txt 27563 -rw-r--r-- 1 root root 0 Jul 21 14:29 test.txt stat 명령어로 inode 값 확인 # stat test.txt File: `test.txt' Size: 0 Blocks: 0..

blog.warpmemory.com

tcpdump -vvv -nn -A -G 3600 -w /var/log/tcpdump/nodeip_dump_eden-csp-dmz-worker3.eden.io_%Y%m%d-%H%M%S.pcap -Z root host xxx.xxx.xxx and port 2049 &