orangefs.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. ORANGEFS
  2. ========
  3. OrangeFS is an LGPL userspace scale-out parallel storage system. It is ideal
  4. for large storage problems faced by HPC, BigData, Streaming Video,
  5. Genomics, Bioinformatics.
  6. Orangefs, originally called PVFS, was first developed in 1993 by
  7. Walt Ligon and Eric Blumer as a parallel file system for Parallel
  8. Virtual Machine (PVM) as part of a NASA grant to study the I/O patterns
  9. of parallel programs.
  10. Orangefs features include:
  11. * Distributes file data among multiple file servers
  12. * Supports simultaneous access by multiple clients
  13. * Stores file data and metadata on servers using local file system
  14. and access methods
  15. * Userspace implementation is easy to install and maintain
  16. * Direct MPI support
  17. * Stateless
  18. MAILING LIST
  19. ============
  20. http://beowulf-underground.org/mailman/listinfo/pvfs2-users
  21. DOCUMENTATION
  22. =============
  23. http://www.orangefs.org/documentation/
  24. USERSPACE FILESYSTEM SOURCE
  25. ===========================
  26. http://www.orangefs.org/download
  27. Orangefs versions prior to 2.9.3 would not be compatible with the
  28. upstream version of the kernel client.
  29. BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER
  30. ====================================================
  31. When Orangefs is upstream, "--with-kernel" shouldn't be needed, but
  32. until then the path to where the kernel with the Orangefs kernel client
  33. patch was built is needed to ensure that pvfs2-client-core (the bridge
  34. between kernel space and user space) will build properly. You can omit
  35. --prefix if you don't care that things are sprinkled around in
  36. /usr/local.
  37. ./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel
  38. make
  39. make install
  40. Create an orangefs config file:
  41. /opt/ofs/bin/pvfs2-genconfig /etc/pvfs2.conf
  42. for "Enter hostnames", use the hostname, don't let it default to
  43. localhost.
  44. create a pvfs2tab file in /etc:
  45. cat /etc/pvfs2tab
  46. tcp://myhostname:3334/orangefs /mymountpoint pvfs2 defaults,noauto 0 0
  47. create the mount point you specified in the tab file if needed:
  48. mkdir /mymountpoint
  49. bootstrap the server:
  50. /opt/ofs/sbin/pvfs2-server /etc/pvfs2.conf -f
  51. start the server:
  52. /opt/osf/sbin/pvfs2-server /etc/pvfs2.conf
  53. Now the server is running. At this point you might like to
  54. prove things are working with:
  55. /opt/osf/bin/pvfs2-ls /mymountpoint
  56. You might not want to enforce selinux, it doesn't seem to matter by
  57. linux 3.11...
  58. If stuff seems to be working, turn on the client core:
  59. /opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
  60. Mount your filesystem.
  61. mount -t pvfs2 tcp://myhostname:3334/orangefs /mymountpoint
  62. OPTIONS
  63. =======
  64. The following mount options are accepted:
  65. acl
  66. Allow the use of Access Control Lists on files and directories.
  67. intr
  68. Some operations between the kernel client and the user space
  69. filesystem can be interruptible, such as changes in debug levels
  70. and the setting of tunable parameters.
  71. local_lock
  72. Enable posix locking from the perspective of "this" kernel. The
  73. default file_operations lock action is to return ENOSYS. Posix
  74. locking kicks in if the filesystem is mounted with -o local_lock.
  75. Distributed locking is being worked on for the future.
  76. DEBUGGING
  77. =========
  78. If you want the debug (GOSSIP) statements in a particular
  79. source file (inode.c for example) go to syslog:
  80. echo inode > /sys/kernel/debug/orangefs/kernel-debug
  81. No debugging (the default):
  82. echo none > /sys/kernel/debug/orangefs/kernel-debug
  83. Debugging from several source files:
  84. echo inode,dir > /sys/kernel/debug/orangefs/kernel-debug
  85. All debugging:
  86. echo all > /sys/kernel/debug/orangefs/kernel-debug
  87. Get a list of all debugging keywords:
  88. cat /sys/kernel/debug/orangefs/debug-help
  89. PROTOCOL BETWEEN KERNEL MODULE AND USERSPACE
  90. ============================================
  91. Orangefs is a user space filesystem and an associated kernel module.
  92. We'll just refer to the user space part of Orangefs as "userspace"
  93. from here on out. Orangefs descends from PVFS, and userspace code
  94. still uses PVFS for function and variable names. Userspace typedefs
  95. many of the important structures. Function and variable names in
  96. the kernel module have been transitioned to "orangefs", and The Linux
  97. Coding Style avoids typedefs, so kernel module structures that
  98. correspond to userspace structures are not typedefed.
  99. The kernel module implements a pseudo device that userspace
  100. can read from and write to. Userspace can also manipulate the
  101. kernel module through the pseudo device with ioctl.
  102. THE BUFMAP:
  103. At startup userspace allocates two page-size-aligned (posix_memalign)
  104. mlocked memory buffers, one is used for IO and one is used for readdir
  105. operations. The IO buffer is 41943040 bytes and the readdir buffer is
  106. 4194304 bytes. Each buffer contains logical chunks, or partitions, and
  107. a pointer to each buffer is added to its own PVFS_dev_map_desc structure
  108. which also describes its total size, as well as the size and number of
  109. the partitions.
  110. A pointer to the IO buffer's PVFS_dev_map_desc structure is sent to a
  111. mapping routine in the kernel module with an ioctl. The structure is
  112. copied from user space to kernel space with copy_from_user and is used
  113. to initialize the kernel module's "bufmap" (struct orangefs_bufmap), which
  114. then contains:
  115. * refcnt - a reference counter
  116. * desc_size - PVFS2_BUFMAP_DEFAULT_DESC_SIZE (4194304) - the IO buffer's
  117. partition size, which represents the filesystem's block size and
  118. is used for s_blocksize in super blocks.
  119. * desc_count - PVFS2_BUFMAP_DEFAULT_DESC_COUNT (10) - the number of
  120. partitions in the IO buffer.
  121. * desc_shift - log2(desc_size), used for s_blocksize_bits in super blocks.
  122. * total_size - the total size of the IO buffer.
  123. * page_count - the number of 4096 byte pages in the IO buffer.
  124. * page_array - a pointer to page_count * (sizeof(struct page*)) bytes
  125. of kcalloced memory. This memory is used as an array of pointers
  126. to each of the pages in the IO buffer through a call to get_user_pages.
  127. * desc_array - a pointer to desc_count * (sizeof(struct orangefs_bufmap_desc))
  128. bytes of kcalloced memory. This memory is further intialized:
  129. user_desc is the kernel's copy of the IO buffer's ORANGEFS_dev_map_desc
  130. structure. user_desc->ptr points to the IO buffer.
  131. pages_per_desc = bufmap->desc_size / PAGE_SIZE
  132. offset = 0
  133. bufmap->desc_array[0].page_array = &bufmap->page_array[offset]
  134. bufmap->desc_array[0].array_count = pages_per_desc = 1024
  135. bufmap->desc_array[0].uaddr = (user_desc->ptr) + (0 * 1024 * 4096)
  136. offset += 1024
  137. .
  138. .
  139. .
  140. bufmap->desc_array[9].page_array = &bufmap->page_array[offset]
  141. bufmap->desc_array[9].array_count = pages_per_desc = 1024
  142. bufmap->desc_array[9].uaddr = (user_desc->ptr) +
  143. (9 * 1024 * 4096)
  144. offset += 1024
  145. * buffer_index_array - a desc_count sized array of ints, used to
  146. indicate which of the IO buffer's partitions are available to use.
  147. * buffer_index_lock - a spinlock to protect buffer_index_array during update.
  148. * readdir_index_array - a five (ORANGEFS_READDIR_DEFAULT_DESC_COUNT) element
  149. int array used to indicate which of the readdir buffer's partitions are
  150. available to use.
  151. * readdir_index_lock - a spinlock to protect readdir_index_array during
  152. update.
  153. OPERATIONS:
  154. The kernel module builds an "op" (struct orangefs_kernel_op_s) when it
  155. needs to communicate with userspace. Part of the op contains the "upcall"
  156. which expresses the request to userspace. Part of the op eventually
  157. contains the "downcall" which expresses the results of the request.
  158. The slab allocator is used to keep a cache of op structures handy.
  159. At init time the kernel module defines and initializes a request list
  160. and an in_progress hash table to keep track of all the ops that are
  161. in flight at any given time.
  162. Ops are stateful:
  163. * unknown - op was just initialized
  164. * waiting - op is on request_list (upward bound)
  165. * inprogr - op is in progress (waiting for downcall)
  166. * serviced - op has matching downcall; ok
  167. * purged - op has to start a timer since client-core
  168. exited uncleanly before servicing op
  169. * given up - submitter has given up waiting for it
  170. When some arbitrary userspace program needs to perform a
  171. filesystem operation on Orangefs (readdir, I/O, create, whatever)
  172. an op structure is initialized and tagged with a distinguishing ID
  173. number. The upcall part of the op is filled out, and the op is
  174. passed to the "service_operation" function.
  175. Service_operation changes the op's state to "waiting", puts
  176. it on the request list, and signals the Orangefs file_operations.poll
  177. function through a wait queue. Userspace is polling the pseudo-device
  178. and thus becomes aware of the upcall request that needs to be read.
  179. When the Orangefs file_operations.read function is triggered, the
  180. request list is searched for an op that seems ready-to-process.
  181. The op is removed from the request list. The tag from the op and
  182. the filled-out upcall struct are copy_to_user'ed back to userspace.
  183. If any of these (and some additional protocol) copy_to_users fail,
  184. the op's state is set to "waiting" and the op is added back to
  185. the request list. Otherwise, the op's state is changed to "in progress",
  186. and the op is hashed on its tag and put onto the end of a list in the
  187. in_progress hash table at the index the tag hashed to.
  188. When userspace has assembled the response to the upcall, it
  189. writes the response, which includes the distinguishing tag, back to
  190. the pseudo device in a series of io_vecs. This triggers the Orangefs
  191. file_operations.write_iter function to find the op with the associated
  192. tag and remove it from the in_progress hash table. As long as the op's
  193. state is not "canceled" or "given up", its state is set to "serviced".
  194. The file_operations.write_iter function returns to the waiting vfs,
  195. and back to service_operation through wait_for_matching_downcall.
  196. Service operation returns to its caller with the op's downcall
  197. part (the response to the upcall) filled out.
  198. The "client-core" is the bridge between the kernel module and
  199. userspace. The client-core is a daemon. The client-core has an
  200. associated watchdog daemon. If the client-core is ever signaled
  201. to die, the watchdog daemon restarts the client-core. Even though
  202. the client-core is restarted "right away", there is a period of
  203. time during such an event that the client-core is dead. A dead client-core
  204. can't be triggered by the Orangefs file_operations.poll function.
  205. Ops that pass through service_operation during a "dead spell" can timeout
  206. on the wait queue and one attempt is made to recycle them. Obviously,
  207. if the client-core stays dead too long, the arbitrary userspace processes
  208. trying to use Orangefs will be negatively affected. Waiting ops
  209. that can't be serviced will be removed from the request list and
  210. have their states set to "given up". In-progress ops that can't
  211. be serviced will be removed from the in_progress hash table and
  212. have their states set to "given up".
  213. Readdir and I/O ops are atypical with respect to their payloads.
  214. - readdir ops use the smaller of the two pre-allocated pre-partitioned
  215. memory buffers. The readdir buffer is only available to userspace.
  216. The kernel module obtains an index to a free partition before launching
  217. a readdir op. Userspace deposits the results into the indexed partition
  218. and then writes them to back to the pvfs device.
  219. - io (read and write) ops use the larger of the two pre-allocated
  220. pre-partitioned memory buffers. The IO buffer is accessible from
  221. both userspace and the kernel module. The kernel module obtains an
  222. index to a free partition before launching an io op. The kernel module
  223. deposits write data into the indexed partition, to be consumed
  224. directly by userspace. Userspace deposits the results of read
  225. requests into the indexed partition, to be consumed directly
  226. by the kernel module.
  227. Responses to kernel requests are all packaged in pvfs2_downcall_t
  228. structs. Besides a few other members, pvfs2_downcall_t contains a
  229. union of structs, each of which is associated with a particular
  230. response type.
  231. The several members outside of the union are:
  232. - int32_t type - type of operation.
  233. - int32_t status - return code for the operation.
  234. - int64_t trailer_size - 0 unless readdir operation.
  235. - char *trailer_buf - initialized to NULL, used during readdir operations.
  236. The appropriate member inside the union is filled out for any
  237. particular response.
  238. PVFS2_VFS_OP_FILE_IO
  239. fill a pvfs2_io_response_t
  240. PVFS2_VFS_OP_LOOKUP
  241. fill a PVFS_object_kref
  242. PVFS2_VFS_OP_CREATE
  243. fill a PVFS_object_kref
  244. PVFS2_VFS_OP_SYMLINK
  245. fill a PVFS_object_kref
  246. PVFS2_VFS_OP_GETATTR
  247. fill in a PVFS_sys_attr_s (tons of stuff the kernel doesn't need)
  248. fill in a string with the link target when the object is a symlink.
  249. PVFS2_VFS_OP_MKDIR
  250. fill a PVFS_object_kref
  251. PVFS2_VFS_OP_STATFS
  252. fill a pvfs2_statfs_response_t with useless info <g>. It is hard for
  253. us to know, in a timely fashion, these statistics about our
  254. distributed network filesystem.
  255. PVFS2_VFS_OP_FS_MOUNT
  256. fill a pvfs2_fs_mount_response_t which is just like a PVFS_object_kref
  257. except its members are in a different order and "__pad1" is replaced
  258. with "id".
  259. PVFS2_VFS_OP_GETXATTR
  260. fill a pvfs2_getxattr_response_t
  261. PVFS2_VFS_OP_LISTXATTR
  262. fill a pvfs2_listxattr_response_t
  263. PVFS2_VFS_OP_PARAM
  264. fill a pvfs2_param_response_t
  265. PVFS2_VFS_OP_PERF_COUNT
  266. fill a pvfs2_perf_count_response_t
  267. PVFS2_VFS_OP_FSKEY
  268. file a pvfs2_fs_key_response_t
  269. PVFS2_VFS_OP_READDIR
  270. jamb everything needed to represent a pvfs2_readdir_response_t into
  271. the readdir buffer descriptor specified in the upcall.
  272. Userspace uses writev() on /dev/pvfs2-req to pass responses to the requests
  273. made by the kernel side.
  274. A buffer_list containing:
  275. - a pointer to the prepared response to the request from the
  276. kernel (struct pvfs2_downcall_t).
  277. - and also, in the case of a readdir request, a pointer to a
  278. buffer containing descriptors for the objects in the target
  279. directory.
  280. ... is sent to the function (PINT_dev_write_list) which performs
  281. the writev.
  282. PINT_dev_write_list has a local iovec array: struct iovec io_array[10];
  283. The first four elements of io_array are initialized like this for all
  284. responses:
  285. io_array[0].iov_base = address of local variable "proto_ver" (int32_t)
  286. io_array[0].iov_len = sizeof(int32_t)
  287. io_array[1].iov_base = address of global variable "pdev_magic" (int32_t)
  288. io_array[1].iov_len = sizeof(int32_t)
  289. io_array[2].iov_base = address of parameter "tag" (PVFS_id_gen_t)
  290. io_array[2].iov_len = sizeof(int64_t)
  291. io_array[3].iov_base = address of out_downcall member (pvfs2_downcall_t)
  292. of global variable vfs_request (vfs_request_t)
  293. io_array[3].iov_len = sizeof(pvfs2_downcall_t)
  294. Readdir responses initialize the fifth element io_array like this:
  295. io_array[4].iov_base = contents of member trailer_buf (char *)
  296. from out_downcall member of global variable
  297. vfs_request
  298. io_array[4].iov_len = contents of member trailer_size (PVFS_size)
  299. from out_downcall member of global variable
  300. vfs_request
  301. Orangefs exploits the dcache in order to avoid sending redundant
  302. requests to userspace. We keep object inode attributes up-to-date with
  303. orangefs_inode_getattr. Orangefs_inode_getattr uses two arguments to
  304. help it decide whether or not to update an inode: "new" and "bypass".
  305. Orangefs keeps private data in an object's inode that includes a short
  306. timeout value, getattr_time, which allows any iteration of
  307. orangefs_inode_getattr to know how long it has been since the inode was
  308. updated. When the object is not new (new == 0) and the bypass flag is not
  309. set (bypass == 0) orangefs_inode_getattr returns without updating the inode
  310. if getattr_time has not timed out. Getattr_time is updated each time the
  311. inode is updated.
  312. Creation of a new object (file, dir, sym-link) includes the evaluation of
  313. its pathname, resulting in a negative directory entry for the object.
  314. A new inode is allocated and associated with the dentry, turning it from
  315. a negative dentry into a "productive full member of society". Orangefs
  316. obtains the new inode from Linux with new_inode() and associates
  317. the inode with the dentry by sending the pair back to Linux with
  318. d_instantiate().
  319. The evaluation of a pathname for an object resolves to its corresponding
  320. dentry. If there is no corresponding dentry, one is created for it in
  321. the dcache. Whenever a dentry is modified or verified Orangefs stores a
  322. short timeout value in the dentry's d_time, and the dentry will be trusted
  323. for that amount of time. Orangefs is a network filesystem, and objects
  324. can potentially change out-of-band with any particular Orangefs kernel module
  325. instance, so trusting a dentry is risky. The alternative to trusting
  326. dentries is to always obtain the needed information from userspace - at
  327. least a trip to the client-core, maybe to the servers. Obtaining information
  328. from a dentry is cheap, obtaining it from userspace is relatively expensive,
  329. hence the motivation to use the dentry when possible.
  330. The timeout values d_time and getattr_time are jiffy based, and the
  331. code is designed to avoid the jiffy-wrap problem:
  332. "In general, if the clock may have wrapped around more than once, there
  333. is no way to tell how much time has elapsed. However, if the times t1
  334. and t2 are known to be fairly close, we can reliably compute the
  335. difference in a way that takes into account the possibility that the
  336. clock may have wrapped between times."
  337. from course notes by instructor Andy Wang