fault_injection.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Fault Injection
  2. ===============
  3. Fault injection is a method for forcing errors that may not normally occur, or
  4. may be difficult to reproduce. Forcing these errors in a controlled environment
  5. can help the developer find and fix bugs before their code is shipped in a
  6. production system. Injecting an error on the Linux NFS server will allow us to
  7. observe how the client reacts and if it manages to recover its state correctly.
  8. NFSD_FAULT_INJECTION must be selected when configuring the kernel to use this
  9. feature.
  10. Using Fault Injection
  11. =====================
  12. On the client, mount the fault injection server through NFS v4.0+ and do some
  13. work over NFS (open files, take locks, ...).
  14. On the server, mount the debugfs filesystem to <debug_dir> and ls
  15. <debug_dir>/nfsd. This will show a list of files that will be used for
  16. injecting faults on the NFS server. As root, write a number n to the file
  17. corresponding to the action you want the server to take. The server will then
  18. process the first n items it finds. So if you want to forget 5 locks, echo '5'
  19. to <debug_dir>/nfsd/forget_locks. A value of 0 will tell the server to forget
  20. all corresponding items. A log message will be created containing the number
  21. of items forgotten (check dmesg).
  22. Go back to work on the client and check if the client recovered from the error
  23. correctly.
  24. Available Faults
  25. ================
  26. forget_clients:
  27. The NFS server keeps a list of clients that have placed a mount call. If
  28. this list is cleared, the server will have no knowledge of who the client
  29. is, forcing the client to reauthenticate with the server.
  30. forget_openowners:
  31. The NFS server keeps a list of what files are currently opened and who
  32. they were opened by. Clearing this list will force the client to reopen
  33. its files.
  34. forget_locks:
  35. The NFS server keeps a list of what files are currently locked in the VFS.
  36. Clearing this list will force the client to reclaim its locks (files are
  37. unlocked through the VFS as they are cleared from this list).
  38. forget_delegations:
  39. A delegation is used to assure the client that a file, or part of a file,
  40. has not changed since the delegation was awarded. Clearing this list will
  41. force the client to reaquire its delegation before accessing the file
  42. again.
  43. recall_delegations:
  44. Delegations can be recalled by the server when another client attempts to
  45. access a file. This test will notify the client that its delegation has
  46. been revoked, forcing the client to reaquire the delegation before using
  47. the file again.
  48. tools/nfs/inject_faults.sh script
  49. =================================
  50. This script has been created to ease the fault injection process. This script
  51. will detect the mounted debugfs directory and write to the files located there
  52. based on the arguments passed by the user. For example, running
  53. `inject_faults.sh forget_locks 1` as root will instruct the server to forget
  54. one lock. Running `inject_faults forget_locks` will instruct the server to
  55. forgetall locks.