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