dlmfs.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. dlmfs
  2. ==================
  3. A minimal DLM userspace interface implemented via a virtual file
  4. system.
  5. dlmfs is built with OCFS2 as it requires most of its infrastructure.
  6. Project web page: http://ocfs2.wiki.kernel.org
  7. Tools web page: https://github.com/markfasheh/ocfs2-tools
  8. OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/
  9. All code copyright 2005 Oracle except when otherwise noted.
  10. CREDITS
  11. =======
  12. Some code taken from ramfs which is Copyright (C) 2000 Linus Torvalds
  13. and Transmeta Corp.
  14. Mark Fasheh <mark.fasheh@oracle.com>
  15. Caveats
  16. =======
  17. - Right now it only works with the OCFS2 DLM, though support for other
  18. DLM implementations should not be a major issue.
  19. Mount options
  20. =============
  21. None
  22. Usage
  23. =====
  24. If you're just interested in OCFS2, then please see ocfs2.txt. The
  25. rest of this document will be geared towards those who want to use
  26. dlmfs for easy to setup and easy to use clustered locking in
  27. userspace.
  28. Setup
  29. =====
  30. dlmfs requires that the OCFS2 cluster infrastructure be in
  31. place. Please download ocfs2-tools from the above url and configure a
  32. cluster.
  33. You'll want to start heartbeating on a volume which all the nodes in
  34. your lockspace can access. The easiest way to do this is via
  35. ocfs2_hb_ctl (distributed with ocfs2-tools). Right now it requires
  36. that an OCFS2 file system be in place so that it can automatically
  37. find its heartbeat area, though it will eventually support heartbeat
  38. against raw disks.
  39. Please see the ocfs2_hb_ctl and mkfs.ocfs2 manual pages distributed
  40. with ocfs2-tools.
  41. Once you're heartbeating, DLM lock 'domains' can be easily created /
  42. destroyed and locks within them accessed.
  43. Locking
  44. =======
  45. Users may access dlmfs via standard file system calls, or they can use
  46. 'libo2dlm' (distributed with ocfs2-tools) which abstracts the file
  47. system calls and presents a more traditional locking api.
  48. dlmfs handles lock caching automatically for the user, so a lock
  49. request for an already acquired lock will not generate another DLM
  50. call. Userspace programs are assumed to handle their own local
  51. locking.
  52. Two levels of locks are supported - Shared Read, and Exclusive.
  53. Also supported is a Trylock operation.
  54. For information on the libo2dlm interface, please see o2dlm.h,
  55. distributed with ocfs2-tools.
  56. Lock value blocks can be read and written to a resource via read(2)
  57. and write(2) against the fd obtained via your open(2) call. The
  58. maximum currently supported LVB length is 64 bytes (though that is an
  59. OCFS2 DLM limitation). Through this mechanism, users of dlmfs can share
  60. small amounts of data amongst their nodes.
  61. mkdir(2) signals dlmfs to join a domain (which will have the same name
  62. as the resulting directory)
  63. rmdir(2) signals dlmfs to leave the domain
  64. Locks for a given domain are represented by regular inodes inside the
  65. domain directory. Locking against them is done via the open(2) system
  66. call.
  67. The open(2) call will not return until your lock has been granted or
  68. an error has occurred, unless it has been instructed to do a trylock
  69. operation. If the lock succeeds, you'll get an fd.
  70. open(2) with O_CREAT to ensure the resource inode is created - dlmfs does
  71. not automatically create inodes for existing lock resources.
  72. Open Flag Lock Request Type
  73. --------- -----------------
  74. O_RDONLY Shared Read
  75. O_RDWR Exclusive
  76. Open Flag Resulting Locking Behavior
  77. --------- --------------------------
  78. O_NONBLOCK Trylock operation
  79. You must provide exactly one of O_RDONLY or O_RDWR.
  80. If O_NONBLOCK is also provided and the trylock operation was valid but
  81. could not lock the resource then open(2) will return ETXTBUSY.
  82. close(2) drops the lock associated with your fd.
  83. Modes passed to mkdir(2) or open(2) are adhered to locally. Chown is
  84. supported locally as well. This means you can use them to restrict
  85. access to the resources via dlmfs on your local node only.
  86. The resource LVB may be read from the fd in either Shared Read or
  87. Exclusive modes via the read(2) system call. It can be written via
  88. write(2) only when open in Exclusive mode.
  89. Once written, an LVB will be visible to other nodes who obtain Read
  90. Only or higher level locks on the resource.
  91. See Also
  92. ========
  93. http://opendlm.sourceforge.net/cvsmirror/opendlm/docs/dlmbook_final.pdf
  94. For more information on the VMS distributed locking API.