NFSクライアントがクラッシュしてNFSサーバにロックが残った場合、Solaris は clear_locks コマンドで解放できるようだが、Linux はないのかな。
ロックやアンロックは /fs/lockd/clntproc.c でやっているぽい。
Managing NFS and NIS: Help for Unix System Administrators (English Edition)
- 作者: Mike Eisler,Ricardo Labiaga,Hal Stern
- 出版社/メーカー: O'Reilly Media
- 発売日: 2009/02/09
- メディア: Kindle版
- この商品を含むブログを見る
The most likely cause of the lock not getting released is that the holding NFS client has crashed. You can take the list of hosts from the /var/statmon/sm directory and check if any are dead, or not responding due to a network partition. Once you determine which are dead, you can use Solaris's clear_locks command to clear lock state. Let's suppose you determine that gonzo is dead. Then you would do:
spike# clear_locks gonzoTroubleshooting locking problems (Managing NFS and NIS, 2nd Edition)
メモ
$ perl -MFcntl -e '$locked=pack("ssL",Fcntl::F_WRLCK,q/SEEK_SET/,0);open(FH,">> ./test2.txt") and fcntl(FH, F_SETLK, $locked) and sleep(300)' & [3] 7297 $ lsof +f g -- /home/oracle/nfs/remote COMMAND PID USER FD TYPE FILE-FLAG DEVICE SIZE/OFF NODE NAME bash 5309 root cwd DIR 0,34 82 268435611 /home/oracle/nfs/remote (ggt.oracle.com:/home/oracle/nfs/local) perl 5410 root cwd DIR 0,34 82 268435611 /home/oracle/nfs/remote (ggt.oracle.com:/home/oracle/nfs/local) perl 5410 root 3wW REG W,AP,LG,0x80000 0,34 0 268440149 /home/oracle/nfs/remote/test1.txt (ggt.oracle.com:/home/oracle/nfs/local) perl 7221 root cwd DIR 0,34 82 268435611 /home/oracle/nfs/remote (ggt.oracle.com:/home/oracle/nfs/local) perl 7221 root 3wW REG W,AP,LG,0x80000 0,34 0 268440148 /home/oracle/nfs/remote/test2.txt (ggt.oracle.com:/home/oracle/nfs/local) lsof 7306 root cwd DIR 0,34 82 268435611 /home/oracle/nfs/remote (ggt.oracle.com:/home/oracle/nfs/local) lsof 7307 root cwd DIR 0,34 82 268435611 /home/oracle/nfs/remote (ggt.oracle.com:/home/oracle/nfs/local) d fcntl(FH, F_SETLK, $locked) and sleep(300)' $ perl -MFcntl -e '$locked=pack("ssL", Fcntl::F_UNLCK, 'SEEK_SET', 0);open(FH,">> ./test2.txt") and fcntl(FH, F_SETLK, $locked)'
- 作者: Michael Kerrisk,千住治郎
- 出版社/メーカー: オライリージャパン
- 発売日: 2012/12/01
- メディア: 大型本
- クリック: 14回
- この商品を含むブログ (7件) を見る
$ cat /proc/locks 1: POSIX ADVISORY WRITE 23915 fc:02:271151215 0 EOF 2: POSIX ADVISORY WRITE 23915 fc:02:271151214 0 EOF 3: POSIX ADVISORY READ 23901 fc:02:3425 0 EOF 4: POSIX ADVISORY READ 23889 fc:02:3425 0 EOF 5: POSIX ADVISORY READ 23891 fc:02:3425 0 EOF