1.. SPDX-License-Identifier: GPL-2.0 2 3======== 4ORANGEFS 5======== 6 7OrangeFS is an LGPL userspace scale-out parallel storage system. It is ideal 8for large storage problems faced by HPC, BigData, Streaming Video, 9Genomics, Bioinformatics. 10 11Orangefs, originally called PVFS, was first developed in 1993 by 12Walt Ligon and Eric Blumer as a parallel file system for Parallel 13Virtual Machine (PVM) as part of a NASA grant to study the I/O patterns 14of parallel programs. 15 16Orangefs 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 27Mailing List Archives 28===================== 29 30http://lists.orangefs.org/pipermail/devel_lists.orangefs.org/ 31 32 33Mailing List Submissions 34======================== 35 36devel@lists.orangefs.org 37 38 39Documentation 40============= 41 42http://www.orangefs.org/documentation/ 43 44 45Userspace Filesystem Source 46=========================== 47 48http://www.orangefs.org/download 49 50Orangefs versions prior to 2.9.3 would not be compatible with the 51upstream version of the kernel client. 52 53 54Running ORANGEFS On a Single Server 55=================================== 56 57OrangeFS is usually run in large installations with multiple servers and 58clients, but a complete filesystem can be run on a single machine for 59development and testing. 60 61On Fedora, install orangefs and orangefs-server:: 62 63 dnf -y install orangefs orangefs-server 64 65There is an example server configuration file in 66/etc/orangefs/orangefs.conf. Change localhost to your hostname if 67necessary. 68 69To generate a filesystem to run xfstests against, see below. 70 71There is an example client configuration file in /etc/pvfs2tab. It is a 72single line. Uncomment it and change the hostname if necessary. This 73controls clients which use libpvfs2. This does not control the 74pvfs2-client-core. 75 76Create the filesystem:: 77 78 pvfs2-server -f /etc/orangefs/orangefs.conf 79 80Start the server:: 81 82 systemctl start orangefs-server 83 84Test the server:: 85 86 pvfs2-ping -m /pvfsmnt 87 88Start the client. The module must be compiled in or loaded before this 89point:: 90 91 systemctl start orangefs-client 92 93Mount the filesystem:: 94 95 mount -t pvfs2 tcp://localhost:3334/orangefs /pvfsmnt 96 97 98Building ORANGEFS on a Single Server 99==================================== 100 101Where OrangeFS cannot be installed from distribution packages, it may be 102built from source. 103 104You can omit --prefix if you don't care that things are sprinkled around 105in /usr/local. As of version 2.9.6, OrangeFS uses Berkeley DB by 106default, 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 116Create an orangefs config file:: 117 118 /opt/ofs/bin/pvfs2-genconfig /etc/pvfs2.conf 119 120Create an /etc/pvfs2tab file:: 121 122 echo tcp://localhost:3334/orangefs /pvfsmnt pvfs2 defaults,noauto 0 0 > \ 123 /etc/pvfs2tab 124 125Create the mount point you specified in the tab file if needed:: 126 127 mkdir /pvfsmnt 128 129Bootstrap the server:: 130 131 /opt/ofs/sbin/pvfs2-server -f /etc/pvfs2.conf 132 133Start the server:: 134 135 /opt/osf/sbin/pvfs2-server /etc/pvfs2.conf 136 137Now the server should be running. Pvfs2-ls is a simple 138test to verify that the server is running:: 139 140 /opt/ofs/bin/pvfs2-ls /pvfsmnt 141 142If stuff seems to be working, load the kernel module and 143turn on the client core:: 144 145 /opt/ofs/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core 146 147Mount your filesystem:: 148 149 mount -t pvfs2 tcp://localhost:3334/orangefs /pvfsmnt 150 151 152Running xfstests 153================ 154 155It is useful to use a scratch filesystem with xfstests. This can be 156done with only one server. 157 158Make a second copy of the FileSystem section in the server configuration 159file, which is /etc/orangefs/orangefs.conf. Change the Name to scratch. 160Change the ID to something other than the ID of the first FileSystem 161section (2 is usually a good choice). 162 163Then there are two FileSystem sections: orangefs and scratch. 164 165This change should be made before creating the filesystem. 166 167:: 168 169 pvfs2-server -f /etc/orangefs/orangefs.conf 170 171To 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 178Then xfstests can be run:: 179 180 ./check -pvfs2 181 182 183Options 184======= 185 186The 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 203Debugging 204========= 205 206If you want the debug (GOSSIP) statements in a particular 207source file (inode.c for example) go to syslog:: 208 209 echo inode > /sys/kernel/debug/orangefs/kernel-debug 210 211No debugging (the default):: 212 213 echo none > /sys/kernel/debug/orangefs/kernel-debug 214 215Debugging from several source files:: 216 217 echo inode,dir > /sys/kernel/debug/orangefs/kernel-debug 218 219All debugging:: 220 221 echo all > /sys/kernel/debug/orangefs/kernel-debug 222 223Get a list of all debugging keywords:: 224 225 cat /sys/kernel/debug/orangefs/debug-help 226 227 228Protocol between Kernel Module and Userspace 229============================================ 230 231Orangefs is a user space filesystem and an associated kernel module. 232We'll just refer to the user space part of Orangefs as "userspace" 233from here on out. Orangefs descends from PVFS, and userspace code 234still uses PVFS for function and variable names. Userspace typedefs 235many of the important structures. Function and variable names in 236the kernel module have been transitioned to "orangefs", and The Linux 237Coding Style avoids typedefs, so kernel module structures that 238correspond to userspace structures are not typedefed. 239 240The kernel module implements a pseudo device that userspace 241can read from and write to. Userspace can also manipulate the 242kernel module through the pseudo device with ioctl. 243 244The Bufmap 245---------- 246 247At startup userspace allocates two page-size-aligned (posix_memalign) 248mlocked memory buffers, one is used for IO and one is used for readdir 249operations. The IO buffer is 41943040 bytes and the readdir buffer is 2504194304 bytes. Each buffer contains logical chunks, or partitions, and 251a pointer to each buffer is added to its own PVFS_dev_map_desc structure 252which also describes its total size, as well as the size and number of 253the partitions. 254 255A pointer to the IO buffer's PVFS_dev_map_desc structure is sent to a 256mapping routine in the kernel module with an ioctl. The structure is 257copied from user space to kernel space with copy_from_user and is used 258to initialize the kernel module's "bufmap" (struct orangefs_bufmap), which 259then 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 307Operations 308---------- 309 310The kernel module builds an "op" (struct orangefs_kernel_op_s) when it 311needs to communicate with userspace. Part of the op contains the "upcall" 312which expresses the request to userspace. Part of the op eventually 313contains the "downcall" which expresses the results of the request. 314 315The slab allocator is used to keep a cache of op structures handy. 316 317At init time the kernel module defines and initializes a request list 318and an in_progress hash table to keep track of all the ops that are 319in flight at any given time. 320 321Ops 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 337When some arbitrary userspace program needs to perform a 338filesystem operation on Orangefs (readdir, I/O, create, whatever) 339an op structure is initialized and tagged with a distinguishing ID 340number. The upcall part of the op is filled out, and the op is 341passed to the "service_operation" function. 342 343Service_operation changes the op's state to "waiting", puts 344it on the request list, and signals the Orangefs file_operations.poll 345function through a wait queue. Userspace is polling the pseudo-device 346and thus becomes aware of the upcall request that needs to be read. 347 348When the Orangefs file_operations.read function is triggered, the 349request list is searched for an op that seems ready-to-process. 350The op is removed from the request list. The tag from the op and 351the filled-out upcall struct are copy_to_user'ed back to userspace. 352 353If any of these (and some additional protocol) copy_to_users fail, 354the op's state is set to "waiting" and the op is added back to 355the request list. Otherwise, the op's state is changed to "in progress", 356and the op is hashed on its tag and put onto the end of a list in the 357in_progress hash table at the index the tag hashed to. 358 359When userspace has assembled the response to the upcall, it 360writes the response, which includes the distinguishing tag, back to 361the pseudo device in a series of io_vecs. This triggers the Orangefs 362file_operations.write_iter function to find the op with the associated 363tag and remove it from the in_progress hash table. As long as the op's 364state is not "canceled" or "given up", its state is set to "serviced". 365The file_operations.write_iter function returns to the waiting vfs, 366and back to service_operation through wait_for_matching_downcall. 367 368Service operation returns to its caller with the op's downcall 369part (the response to the upcall) filled out. 370 371The "client-core" is the bridge between the kernel module and 372userspace. The client-core is a daemon. The client-core has an 373associated watchdog daemon. If the client-core is ever signaled 374to die, the watchdog daemon restarts the client-core. Even though 375the client-core is restarted "right away", there is a period of 376time during such an event that the client-core is dead. A dead client-core 377can't be triggered by the Orangefs file_operations.poll function. 378Ops that pass through service_operation during a "dead spell" can timeout 379on the wait queue and one attempt is made to recycle them. Obviously, 380if the client-core stays dead too long, the arbitrary userspace processes 381trying to use Orangefs will be negatively affected. Waiting ops 382that can't be serviced will be removed from the request list and 383have their states set to "given up". In-progress ops that can't 384be serviced will be removed from the in_progress hash table and 385have their states set to "given up". 386 387Readdir 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 404Responses to kernel requests are all packaged in pvfs2_downcall_t 405structs. Besides a few other members, pvfs2_downcall_t contains a 406union of structs, each of which is associated with a particular 407response type. 408 409The 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 420The appropriate member inside the union is filled out for any 421particular 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 471Userspace uses writev() on /dev/pvfs2-req to pass responses to the requests 472made by the kernel side. 473 474A 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 483the writev. 484 485PINT_dev_write_list has a local iovec array: struct iovec io_array[10]; 486 487The first four elements of io_array are initialized like this for all 488responses:: 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 503Readdir 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 512Orangefs exploits the dcache in order to avoid sending redundant 513requests to userspace. We keep object inode attributes up-to-date with 514orangefs_inode_getattr. Orangefs_inode_getattr uses two arguments to 515help it decide whether or not to update an inode: "new" and "bypass". 516Orangefs keeps private data in an object's inode that includes a short 517timeout value, getattr_time, which allows any iteration of 518orangefs_inode_getattr to know how long it has been since the inode was 519updated. When the object is not new (new == 0) and the bypass flag is not 520set (bypass == 0) orangefs_inode_getattr returns without updating the inode 521if getattr_time has not timed out. Getattr_time is updated each time the 522inode is updated. 523 524Creation of a new object (file, dir, sym-link) includes the evaluation of 525its pathname, resulting in a negative directory entry for the object. 526A new inode is allocated and associated with the dentry, turning it from 527a negative dentry into a "productive full member of society". Orangefs 528obtains the new inode from Linux with new_inode() and associates 529the inode with the dentry by sending the pair back to Linux with 530d_instantiate(). 531 532The evaluation of a pathname for an object resolves to its corresponding 533dentry. If there is no corresponding dentry, one is created for it in 534the dcache. Whenever a dentry is modified or verified Orangefs stores a 535short timeout value in the dentry's d_time, and the dentry will be trusted 536for that amount of time. Orangefs is a network filesystem, and objects 537can potentially change out-of-band with any particular Orangefs kernel module 538instance, so trusting a dentry is risky. The alternative to trusting 539dentries is to always obtain the needed information from userspace - at 540least a trip to the client-core, maybe to the servers. Obtaining information 541from a dentry is cheap, obtaining it from userspace is relatively expensive, 542hence the motivation to use the dentry when possible. 543 544The timeout values d_time and getattr_time are jiffy based, and the 545code 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 553from course notes by instructor Andy Wang 554 555