orangefs: document package install and xfstests procedure
[platform/kernel/linux-starfive.git] / Documentation / filesystems / orangefs.txt
1 ORANGEFS
2 ========
3
4 OrangeFS is an LGPL userspace scale-out parallel storage system. It is ideal
5 for large storage problems faced by HPC, BigData, Streaming Video,
6 Genomics, Bioinformatics.
7
8 Orangefs, originally called PVFS, was first developed in 1993 by
9 Walt Ligon and Eric Blumer as a parallel file system for Parallel
10 Virtual Machine (PVM) as part of a NASA grant to study the I/O patterns
11 of parallel programs.
12
13 Orangefs features include:
14
15   * Distributes file data among multiple file servers
16   * Supports simultaneous access by multiple clients
17   * Stores file data and metadata on servers using local file system
18     and access methods
19   * Userspace implementation is easy to install and maintain
20   * Direct MPI support
21   * Stateless
22
23
24 MAILING LIST
25 ============
26
27 http://beowulf-underground.org/mailman/listinfo/pvfs2-users
28
29
30 DOCUMENTATION
31 =============
32
33 http://www.orangefs.org/documentation/
34
35
36 USERSPACE FILESYSTEM SOURCE
37 ===========================
38
39 http://www.orangefs.org/download
40
41 Orangefs versions prior to 2.9.3 would not be compatible with the
42 upstream version of the kernel client.
43
44
45 RUNNING ORANGEFS ON A SINGLE SERVER
46 ===================================
47
48 OrangeFS is usually run in large installations with multiple servers and
49 clients, but a complete filesystem can be run on a single machine for
50 development and testing.
51
52 On Fedora, install orangefs and orangefs-server.
53
54 dnf -y install orangefs orangefs-server
55
56 There is an example server configuration file in
57 /etc/orangefs/orangefs.conf.  Change localhost to your hostname if
58 necessary.
59
60 To generate a filesystem to run xfstests against, see below.
61
62 There is an example client configuration file in /etc/pvfs2tab.  It is a
63 single line.  Uncomment it and change the hostname if necessary.  This
64 controls clients which use libpvfs2.  This does not control the
65 pvfs2-client-core.
66
67 Create the filesystem.
68
69 pvfs2-server -f /etc/orangefs/orangefs.conf
70
71 Start the server.
72
73 systemctl start orangefs-server
74
75 Test the server.
76
77 pvfs2-ping -m /pvfsmnt
78
79 Start the client.  The module must be compiled in or loaded before this
80 point.
81
82 systemctl start orangefs-client
83
84 Mount the filesystem.
85
86 mount -t pvfs2 tcp://localhost:3334/orangefs /pvfsmnt
87
88
89 BUILDING ORANGEFS ON A SINGLE SERVER
90 ====================================
91
92 Where OrangeFS cannot be installed from distribution packages, it may be
93 built from source.
94
95 You can omit --prefix if you don't care that things are sprinkled around
96 in /usr/local.  As of version 2.9.6, OrangeFS uses Berkeley DB by
97 default, we will probably be changing the default to LMDB soon.
98
99 ./configure --prefix=/opt/ofs --with-db-backend=lmdb
100
101 make
102
103 make install
104
105 Create an orangefs config file.
106
107 /opt/ofs/bin/pvfs2-genconfig /etc/pvfs2.conf
108
109 Create an /etc/pvfs2tab file.
110
111 echo tcp://localhost:3334/orangefs /pvfsmnt pvfs2 defaults,noauto 0 0 > \
112     /etc/pvfs2tab
113
114 Create the mount point you specified in the tab file if needed.
115
116 mkdir /pvfsmnt
117
118 Bootstrap the server.
119
120 /opt/ofs/sbin/pvfs2-server -f /etc/pvfs2.conf
121
122 Start the server.
123
124 /opt/osf/sbin/pvfs2-server /etc/pvfs2.conf
125
126 Now the server is running.  At this point you might like to
127 prove things are working with.
128
129 /opt/ofs/bin/pvfs2-ls /pvfsmnt
130
131 If stuff seems to be working, turn on the client core.
132
133 /opt/ofs/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
134
135 Mount your filesystem (load the kernel module first if necessary).
136
137 mount -t pvfs2 tcp://localhost:3334/orangefs /pvfsmnt
138
139
140 RUNNING XFSTESTS
141 ================
142
143 It is useful to use a scratch filesystem with xfstests.  This can be
144 done with only one server.
145
146 Make a second copy of the FileSystem section in the server configuration
147 file, which is /etc/orangefs/orangefs.conf.  Change the Name to scratch.
148 Change the ID to something other than the ID of the first FileSystem
149 section (2 is usually a good choice).
150
151 Then there are two FileSystem sections: orangefs and scratch.
152
153 This change should be made before creating the filesystem.
154
155 pvfs2-server -f /etc/orangefs/orangefs.conf
156
157 To run xfstests, create /etc/xfsqa.config.
158
159 TEST_DIR=/orangefs
160 TEST_DEV=tcp://localhost:3334/orangefs
161 SCRATCH_MNT=/scratch
162 SCRATCH_DEV=tcp://localhost:3334/scratch
163
164 Then xfstests can be run
165
166 ./check -pvfs2
167
168
169 OPTIONS
170 =======
171
172 The following mount options are accepted:
173
174   acl
175     Allow the use of Access Control Lists on files and directories.
176
177   intr
178     Some operations between the kernel client and the user space
179     filesystem can be interruptible, such as changes in debug levels
180     and the setting of tunable parameters.
181
182   local_lock
183     Enable posix locking from the perspective of "this" kernel. The
184     default file_operations lock action is to return ENOSYS. Posix
185     locking kicks in if the filesystem is mounted with -o local_lock.
186     Distributed locking is being worked on for the future.
187
188
189 DEBUGGING
190 =========
191
192 If you want the debug (GOSSIP) statements in a particular
193 source file (inode.c for example) go to syslog:
194
195   echo inode > /sys/kernel/debug/orangefs/kernel-debug
196
197 No debugging (the default):
198
199   echo none > /sys/kernel/debug/orangefs/kernel-debug
200
201 Debugging from several source files:
202
203   echo inode,dir > /sys/kernel/debug/orangefs/kernel-debug
204
205 All debugging:
206
207   echo all > /sys/kernel/debug/orangefs/kernel-debug
208
209 Get a list of all debugging keywords:
210
211   cat /sys/kernel/debug/orangefs/debug-help
212
213
214 PROTOCOL BETWEEN KERNEL MODULE AND USERSPACE
215 ============================================
216
217 Orangefs is a user space filesystem and an associated kernel module.
218 We'll just refer to the user space part of Orangefs as "userspace"
219 from here on out. Orangefs descends from PVFS, and userspace code
220 still uses PVFS for function and variable names. Userspace typedefs
221 many of the important structures. Function and variable names in
222 the kernel module have been transitioned to "orangefs", and The Linux
223 Coding Style avoids typedefs, so kernel module structures that
224 correspond to userspace structures are not typedefed.
225
226 The kernel module implements a pseudo device that userspace
227 can read from and write to. Userspace can also manipulate the
228 kernel module through the pseudo device with ioctl.
229
230 THE BUFMAP:
231
232 At startup userspace allocates two page-size-aligned (posix_memalign)
233 mlocked memory buffers, one is used for IO and one is used for readdir
234 operations. The IO buffer is 41943040 bytes and the readdir buffer is
235 4194304 bytes. Each buffer contains logical chunks, or partitions, and
236 a pointer to each buffer is added to its own PVFS_dev_map_desc structure
237 which also describes its total size, as well as the size and number of
238 the partitions.
239
240 A pointer to the IO buffer's PVFS_dev_map_desc structure is sent to a
241 mapping routine in the kernel module with an ioctl. The structure is
242 copied from user space to kernel space with copy_from_user and is used
243 to initialize the kernel module's "bufmap" (struct orangefs_bufmap), which
244 then contains:
245
246   * refcnt - a reference counter
247   * desc_size - PVFS2_BUFMAP_DEFAULT_DESC_SIZE (4194304) - the IO buffer's
248     partition size, which represents the filesystem's block size and
249     is used for s_blocksize in super blocks.
250   * desc_count - PVFS2_BUFMAP_DEFAULT_DESC_COUNT (10) - the number of
251     partitions in the IO buffer.
252   * desc_shift - log2(desc_size), used for s_blocksize_bits in super blocks.
253   * total_size - the total size of the IO buffer.
254   * page_count - the number of 4096 byte pages in the IO buffer.
255   * page_array - a pointer to page_count * (sizeof(struct page*)) bytes
256     of kcalloced memory. This memory is used as an array of pointers
257     to each of the pages in the IO buffer through a call to get_user_pages.
258   * desc_array - a pointer to desc_count * (sizeof(struct orangefs_bufmap_desc))
259     bytes of kcalloced memory. This memory is further intialized:
260
261       user_desc is the kernel's copy of the IO buffer's ORANGEFS_dev_map_desc
262       structure. user_desc->ptr points to the IO buffer.
263
264       pages_per_desc = bufmap->desc_size / PAGE_SIZE
265       offset = 0
266
267         bufmap->desc_array[0].page_array = &bufmap->page_array[offset]
268         bufmap->desc_array[0].array_count = pages_per_desc = 1024
269         bufmap->desc_array[0].uaddr = (user_desc->ptr) + (0 * 1024 * 4096)
270         offset += 1024
271                            .
272                            .
273                            .
274         bufmap->desc_array[9].page_array = &bufmap->page_array[offset]
275         bufmap->desc_array[9].array_count = pages_per_desc = 1024
276         bufmap->desc_array[9].uaddr = (user_desc->ptr) +
277                                                (9 * 1024 * 4096)
278         offset += 1024
279
280   * buffer_index_array - a desc_count sized array of ints, used to
281     indicate which of the IO buffer's partitions are available to use.
282   * buffer_index_lock - a spinlock to protect buffer_index_array during update.
283   * readdir_index_array - a five (ORANGEFS_READDIR_DEFAULT_DESC_COUNT) element
284     int array used to indicate which of the readdir buffer's partitions are
285     available to use.
286   * readdir_index_lock - a spinlock to protect readdir_index_array during
287     update.
288
289 OPERATIONS:
290
291 The kernel module builds an "op" (struct orangefs_kernel_op_s) when it
292 needs to communicate with userspace. Part of the op contains the "upcall"
293 which expresses the request to userspace. Part of the op eventually
294 contains the "downcall" which expresses the results of the request.
295
296 The slab allocator is used to keep a cache of op structures handy.
297
298 At init time the kernel module defines and initializes a request list
299 and an in_progress hash table to keep track of all the ops that are
300 in flight at any given time.
301
302 Ops are stateful:
303
304  * unknown  - op was just initialized
305  * waiting  - op is on request_list (upward bound)
306  * inprogr  - op is in progress (waiting for downcall)
307  * serviced - op has matching downcall; ok
308  * purged   - op has to start a timer since client-core
309               exited uncleanly before servicing op
310  * given up - submitter has given up waiting for it
311
312 When some arbitrary userspace program needs to perform a
313 filesystem operation on Orangefs (readdir, I/O, create, whatever)
314 an op structure is initialized and tagged with a distinguishing ID
315 number. The upcall part of the op is filled out, and the op is
316 passed to the "service_operation" function.
317
318 Service_operation changes the op's state to "waiting", puts
319 it on the request list, and signals the Orangefs file_operations.poll
320 function through a wait queue. Userspace is polling the pseudo-device
321 and thus becomes aware of the upcall request that needs to be read.
322
323 When the Orangefs file_operations.read function is triggered, the
324 request list is searched for an op that seems ready-to-process.
325 The op is removed from the request list. The tag from the op and
326 the filled-out upcall struct are copy_to_user'ed back to userspace.
327
328 If any of these (and some additional protocol) copy_to_users fail,
329 the op's state is set to "waiting" and the op is added back to
330 the request list. Otherwise, the op's state is changed to "in progress",
331 and the op is hashed on its tag and put onto the end of a list in the
332 in_progress hash table at the index the tag hashed to.
333
334 When userspace has assembled the response to the upcall, it
335 writes the response, which includes the distinguishing tag, back to
336 the pseudo device in a series of io_vecs. This triggers the Orangefs
337 file_operations.write_iter function to find the op with the associated
338 tag and remove it from the in_progress hash table. As long as the op's
339 state is not "canceled" or "given up", its state is set to "serviced".
340 The file_operations.write_iter function returns to the waiting vfs,
341 and back to service_operation through wait_for_matching_downcall.
342
343 Service operation returns to its caller with the op's downcall
344 part (the response to the upcall) filled out.
345
346 The "client-core" is the bridge between the kernel module and
347 userspace. The client-core is a daemon. The client-core has an
348 associated watchdog daemon. If the client-core is ever signaled
349 to die, the watchdog daemon restarts the client-core. Even though
350 the client-core is restarted "right away", there is a period of
351 time during such an event that the client-core is dead. A dead client-core
352 can't be triggered by the Orangefs file_operations.poll function.
353 Ops that pass through service_operation during a "dead spell" can timeout
354 on the wait queue and one attempt is made to recycle them. Obviously,
355 if the client-core stays dead too long, the arbitrary userspace processes
356 trying to use Orangefs will be negatively affected. Waiting ops
357 that can't be serviced will be removed from the request list and
358 have their states set to "given up". In-progress ops that can't
359 be serviced will be removed from the in_progress hash table and
360 have their states set to "given up".
361
362 Readdir and I/O ops are atypical with respect to their payloads.
363
364   - readdir ops use the smaller of the two pre-allocated pre-partitioned
365     memory buffers. The readdir buffer is only available to userspace.
366     The kernel module obtains an index to a free partition before launching
367     a readdir op. Userspace deposits the results into the indexed partition
368     and then writes them to back to the pvfs device.
369
370   - io (read and write) ops use the larger of the two pre-allocated
371     pre-partitioned memory buffers. The IO buffer is accessible from
372     both userspace and the kernel module. The kernel module obtains an
373     index to a free partition before launching an io op. The kernel module
374     deposits write data into the indexed partition, to be consumed
375     directly by userspace. Userspace deposits the results of read
376     requests into the indexed partition, to be consumed directly
377     by the kernel module.
378
379 Responses to kernel requests are all packaged in pvfs2_downcall_t
380 structs. Besides a few other members, pvfs2_downcall_t contains a
381 union of structs, each of which is associated with a particular
382 response type.
383
384 The several members outside of the union are:
385  - int32_t type - type of operation.
386  - int32_t status - return code for the operation.
387  - int64_t trailer_size - 0 unless readdir operation.
388  - char *trailer_buf - initialized to NULL, used during readdir operations.
389
390 The appropriate member inside the union is filled out for any
391 particular response.
392
393   PVFS2_VFS_OP_FILE_IO
394     fill a pvfs2_io_response_t
395
396   PVFS2_VFS_OP_LOOKUP
397     fill a PVFS_object_kref
398
399   PVFS2_VFS_OP_CREATE
400     fill a PVFS_object_kref
401
402   PVFS2_VFS_OP_SYMLINK
403     fill a PVFS_object_kref
404
405   PVFS2_VFS_OP_GETATTR
406     fill in a PVFS_sys_attr_s (tons of stuff the kernel doesn't need)
407     fill in a string with the link target when the object is a symlink.
408
409   PVFS2_VFS_OP_MKDIR
410     fill a PVFS_object_kref
411
412   PVFS2_VFS_OP_STATFS
413     fill a pvfs2_statfs_response_t with useless info <g>. It is hard for
414     us to know, in a timely fashion, these statistics about our
415     distributed network filesystem.
416
417   PVFS2_VFS_OP_FS_MOUNT
418     fill a pvfs2_fs_mount_response_t which is just like a PVFS_object_kref
419     except its members are in a different order and "__pad1" is replaced
420     with "id".
421
422   PVFS2_VFS_OP_GETXATTR
423     fill a pvfs2_getxattr_response_t
424
425   PVFS2_VFS_OP_LISTXATTR
426     fill a pvfs2_listxattr_response_t
427
428   PVFS2_VFS_OP_PARAM
429     fill a pvfs2_param_response_t
430
431   PVFS2_VFS_OP_PERF_COUNT
432     fill a pvfs2_perf_count_response_t
433
434   PVFS2_VFS_OP_FSKEY
435     file a pvfs2_fs_key_response_t
436
437   PVFS2_VFS_OP_READDIR
438     jamb everything needed to represent a pvfs2_readdir_response_t into
439     the readdir buffer descriptor specified in the upcall.
440
441 Userspace uses writev() on /dev/pvfs2-req to pass responses to the requests
442 made by the kernel side.
443
444 A buffer_list containing:
445   - a pointer to the prepared response to the request from the
446     kernel (struct pvfs2_downcall_t).
447   - and also, in the case of a readdir request, a pointer to a
448     buffer containing descriptors for the objects in the target
449     directory.
450 ... is sent to the function (PINT_dev_write_list) which performs
451 the writev.
452
453 PINT_dev_write_list has a local iovec array: struct iovec io_array[10];
454
455 The first four elements of io_array are initialized like this for all
456 responses:
457
458   io_array[0].iov_base = address of local variable "proto_ver" (int32_t)
459   io_array[0].iov_len = sizeof(int32_t)
460
461   io_array[1].iov_base = address of global variable "pdev_magic" (int32_t)
462   io_array[1].iov_len = sizeof(int32_t)
463
464   io_array[2].iov_base = address of parameter "tag" (PVFS_id_gen_t)
465   io_array[2].iov_len = sizeof(int64_t)
466
467   io_array[3].iov_base = address of out_downcall member (pvfs2_downcall_t)
468                          of global variable vfs_request (vfs_request_t)
469   io_array[3].iov_len = sizeof(pvfs2_downcall_t)
470
471 Readdir responses initialize the fifth element io_array like this:
472
473   io_array[4].iov_base = contents of member trailer_buf (char *)
474                          from out_downcall member of global variable
475                          vfs_request
476   io_array[4].iov_len = contents of member trailer_size (PVFS_size)
477                         from out_downcall member of global variable
478                         vfs_request
479
480 Orangefs exploits the dcache in order to avoid sending redundant
481 requests to userspace. We keep object inode attributes up-to-date with
482 orangefs_inode_getattr. Orangefs_inode_getattr uses two arguments to
483 help it decide whether or not to update an inode: "new" and "bypass".
484 Orangefs keeps private data in an object's inode that includes a short
485 timeout value, getattr_time, which allows any iteration of
486 orangefs_inode_getattr to know how long it has been since the inode was
487 updated. When the object is not new (new == 0) and the bypass flag is not
488 set (bypass == 0) orangefs_inode_getattr returns without updating the inode
489 if getattr_time has not timed out. Getattr_time is updated each time the
490 inode is updated.
491
492 Creation of a new object (file, dir, sym-link) includes the evaluation of
493 its pathname, resulting in a negative directory entry for the object.
494 A new inode is allocated and associated with the dentry, turning it from
495 a negative dentry into a "productive full member of society". Orangefs
496 obtains the new inode from Linux with new_inode() and associates
497 the inode with the dentry by sending the pair back to Linux with
498 d_instantiate().
499
500 The evaluation of a pathname for an object resolves to its corresponding
501 dentry. If there is no corresponding dentry, one is created for it in
502 the dcache. Whenever a dentry is modified or verified Orangefs stores a
503 short timeout value in the dentry's d_time, and the dentry will be trusted
504 for that amount of time. Orangefs is a network filesystem, and objects
505 can potentially change out-of-band with any particular Orangefs kernel module
506 instance, so trusting a dentry is risky. The alternative to trusting
507 dentries is to always obtain the needed information from userspace - at
508 least a trip to the client-core, maybe to the servers. Obtaining information
509 from a dentry is cheap, obtaining it from userspace is relatively expensive,
510 hence the motivation to use the dentry when possible.
511
512 The timeout values d_time and getattr_time are jiffy based, and the
513 code is designed to avoid the jiffy-wrap problem:
514
515 "In general, if the clock may have wrapped around more than once, there
516 is no way to tell how much time has elapsed. However, if the times t1
517 and t2 are known to be fairly close, we can reliably compute the
518 difference in a way that takes into account the possibility that the
519 clock may have wrapped between times."
520
521                       from course notes by instructor Andy Wang
522