1.. SPDX-License-Identifier: GPL-2.0 2 3======================================= 4v9fs: Plan 9 Resource Sharing for Linux 5======================================= 6 7About 8===== 9 10v9fs is a Unix implementation of the Plan 9 9p remote filesystem protocol. 11 12This software was originally developed by Ron Minnich <rminnich@sandia.gov> 13and Maya Gokhale. Additional development by Greg Watson 14<gwatson@lanl.gov> and most recently Eric Van Hensbergen 15<ericvh@gmail.com>, Latchesar Ionkov <lucho@ionkov.net> and Russ Cox 16<rsc@swtch.com>. 17 18The best detailed explanation of the Linux implementation and applications of 19the 9p client is available in the form of a USENIX paper: 20 21 https://www.usenix.org/events/usenix05/tech/freenix/hensbergen.html 22 23Other applications are described in the following papers: 24 25 * XCPU & Clustering 26 * KVMFS: control file system for KVM 27 * CellFS: A New Programming Model for the Cell BE 28 * PROSE I/O: Using 9p to enable Application Partitions 29 http://web.archive.org/web/20110101152020/http://plan9.escet.urjc.es/iwp9/cready/PROSE_iwp9_2006.pdf 30 * VirtFS: A Virtualization Aware File System pass-through 31 https://kernel.org/doc/ols/2010/ols2010-pages-109-120.pdf 32 33Usage 34===== 35 36For remote file server:: 37 38 mount -t 9p 10.10.1.2 /mnt/9 39 40For Plan 9 From User Space applications (https://9fans.github.io/plan9port/):: 41 42 mount -t 9p `namespace`/acme /mnt/9 -o trans=unix,uname=$USER 43 44For server running on QEMU host with virtio transport:: 45 46 mount -t 9p -o trans=virtio <mount_tag> /mnt/9 47 48where mount_tag is the tag generated by the server to each of the exported 49mount points. Each 9P export is seen by the client as a virtio device with an 50associated "mount_tag" property. Available mount tags can be 51seen by reading /sys/bus/virtio/drivers/9pnet_virtio/virtio<n>/mount_tag files. 52 53For server accessible over vsock (VM sockets):: 54 55 mount -t 9p -o trans=vsock[,port=<port>] <CID> /mnt/9 56 57where CID is the vsock Context ID of the remote endpoint (2 for host from 58a guest VM, 3+ for guest VMs from the host). The port to connect to can be 59specified with the port option (default: 564). 60 61USBG Usage 62========== 63 64To mount a 9p FS on a USB Host accessible via the gadget at runtime:: 65 66 mount -t 9p -o trans=usbg,aname=/path/to/fs <device> /mnt/9 67 68To mount a 9p FS on a USB Host accessible via the gadget as root filesystem:: 69 70 root=<device> rootfstype=9p rootflags=trans=usbg,cache=loose,uname=root,access=0,dfltuid=0,dfltgid=0,aname=/path/to/rootfs 71 72where <device> is the tag associated by the usb gadget transport. 73It is defined by the configfs instance name. 74 75USBG Example 76============ 77 78The USB host exports a filesystem, while the gadget on the USB device 79side makes it mountable. 80 81Diod (9pfs server) and the forwarder are on the development host, where 82the root filesystem is actually stored. The gadget is initialized during 83boot (or later) on the embedded board. Then the forwarder will find it 84on the USB bus and start forwarding requests. 85 86In this case the 9p requests come from the device and are handled by the 87host. The reason is that USB device ports are normally not available on 88PCs, so a connection in the other direction would not work. 89 90When using the usbg transport, for now there is no native usb host 91service capable to handle the requests from the gadget driver. For 92this we have to use the extra python tool p9_fwd.py from tools/usb. 93 94Just start the 9pfs capable network server like diod/nfs-ganesha e.g.:: 95 96 $ diod -f -n -d 0 -S -l 0.0.0.0:9999 -e $PWD 97 98Optionally scan your bus if there are more then one usbg gadgets to find their path:: 99 100 $ python $kernel_dir/tools/usb/p9_fwd.py list 101 102 Bus | Addr | Manufacturer | Product | ID | Path 103 --- | ---- | ---------------- | ---------------- | --------- | ---- 104 2 | 67 | unknown | unknown | 1d6b:0109 | 2-1.1.2 105 2 | 68 | unknown | unknown | 1d6b:0109 | 2-1.1.3 106 107Then start the python transport:: 108 109 $ python $kernel_dir/tools/usb/p9_fwd.py --path 2-1.1.2 connect -p 9999 110 111After that the gadget driver can be used as described above. 112 113One use-case is to use it as an alternative to NFS root booting during 114the development of embedded Linux devices. 115 116Options 117======= 118 119 ============= =============================================================== 120 trans=name select an alternative transport. Valid options are 121 currently: 122 123 ======== ============================================ 124 unix specifying a named pipe mount point 125 tcp specifying a normal TCP/IP connection 126 fd used passed file descriptors for connection 127 (see rfdno and wfdno) 128 vsock connect over VM sockets (vsock) using 129 CID as the mount source 130 virtio connect to the next virtio channel available 131 (from QEMU with trans_virtio module) 132 rdma connect to a specified RDMA channel 133 usbg connect to a specified usb gadget channel 134 ======== ============================================ 135 136 uname=name user name to attempt mount as on the remote server. The 137 server may override or ignore this value. Certain user 138 names may require authentication. 139 140 aname=name aname specifies the file tree to access when the server is 141 offering several exported file systems. 142 143 cache=mode specifies a caching policy. By default, no caches are used. 144 The mode can be specified as a bitmask or by using one of the 145 preexisting common 'shortcuts'. 146 The bitmask is described below: (unspecified bits are reserved) 147 148 ========== ==================================================== 149 0b00000000 all caches disabled, mmap disabled 150 0b00000001 file caches enabled 151 0b00000010 meta-data caches enabled 152 0b00000100 writeback behavior (as opposed to writethrough) 153 0b00001000 loose caches (no explicit consistency with server) 154 0b10000000 fscache enabled for persistent caching 155 ========== ==================================================== 156 157 The current shortcuts and their associated bitmask are: 158 159 ========= ==================================================== 160 none 0b00000000 (no caching) 161 readahead 0b00000001 (only read-ahead file caching) 162 mmap 0b00000101 (read-ahead + writeback file cache) 163 loose 0b00001111 (non-coherent file and meta-data caches) 164 fscache 0b10001111 (persistent loose cache) 165 ========= ==================================================== 166 167 NOTE: only these shortcuts are tested modes of operation at the 168 moment, so using other combinations of bit-patterns is not 169 known to work. Work on better cache support is in progress. 170 171 IMPORTANT: loose caches (and by extension at the moment fscache) 172 do not necessarily validate cached values on the server. In other 173 words changes on the server are not guaranteed to be reflected 174 on the client system. Only use this mode of operation if you 175 have an exclusive mount and the server will not modify the 176 filesystem underneath you. 177 178 debug=n specifies debug level. The debug level is a bitmask. 179 180 ===== ================================ 181 0x01 display verbose error messages 182 0x02 developer debug (DEBUG_CURRENT) 183 0x04 display 9p trace 184 0x08 display VFS trace 185 0x10 display Marshalling debug 186 0x20 display RPC debug 187 0x40 display transport debug 188 0x80 display allocation debug 189 0x100 display protocol message debug 190 0x200 display Fid debug 191 0x400 display packet debug 192 0x800 display fscache tracing debug 193 ===== ================================ 194 195 rfdno=n the file descriptor for reading with trans=fd 196 197 wfdno=n the file descriptor for writing with trans=fd 198 199 msize=n the number of bytes to use for 9p packet payload 200 201 port=n port to connect to on the remote server 202 203 noextend force legacy mode (no 9p2000.u or 9p2000.L semantics) 204 205 version=name Select 9P protocol version. Valid options are: 206 207 ======== ============================== 208 9p2000 Legacy mode (same as noextend) 209 9p2000.u Use 9P2000.u protocol 210 9p2000.L Use 9P2000.L protocol 211 ======== ============================== 212 213 dfltuid attempt to mount as a particular uid 214 215 dfltgid attempt to mount with a particular gid 216 217 afid security channel - used by Plan 9 authentication protocols 218 219 nodevmap do not map special files - represent them as normal files. 220 This can be used to share devices/named pipes/sockets between 221 hosts. This functionality will be expanded in later versions. 222 223 directio bypass page cache on all read/write operations 224 225 ignoreqv ignore qid.version==0 as a marker to ignore cache 226 227 noxattr do not offer xattr functions on this mount. 228 229 access there are four access modes. 230 user 231 if a user tries to access a file on v9fs 232 filesystem for the first time, v9fs sends an 233 attach command (Tattach) for that user. 234 This is the default mode. 235 <uid> 236 allows only user with uid=<uid> to access 237 the files on the mounted filesystem 238 any 239 v9fs does single attach and performs all 240 operations as one user 241 client 242 ACL based access check on the 9p client 243 side for access validation 244 245 cachetag cache tag to use the specified persistent cache. 246 cache tags for existing cache sessions can be listed at 247 /sys/fs/9p/caches. (applies only to cache=fscache) 248 249 negtimeout the duration (in milliseconds) that negative dentries (paths 250 that do not actually exist) are retained in the cache. If 251 set to a negative value, those entries are kept indefinitely 252 until evicted by the buffer cache management system 253 ============= =============================================================== 254 255Behavior 256======== 257 258This section aims at describing 9p 'quirks' that can be different 259from a local filesystem behaviors. 260 261 - Setting O_NONBLOCK on a file will make client reads return as early 262 as the server returns some data instead of trying to fill the read 263 buffer with the requested amount of bytes or end of file is reached. 264 265Resources 266========= 267 268Protocol specifications are maintained on github: 269http://ericvh.github.com/9p-rfc/ 270 2719p client and server implementations are listed on 272http://9p.cat-v.org/implementations 273 274A 9p2000.L server is being developed by LLNL and can be found 275at http://code.google.com/p/diod/ 276 277There are user and developer mailing lists available through the v9fs project 278on sourceforge (http://sourceforge.net/projects/v9fs). 279 280News and other information is maintained on a Wiki. 281(http://sf.net/apps/mediawiki/v9fs/index.php). 282 283Bug reports are best issued via the mailing list. 284 285For more information on the Plan 9 Operating System check out 286http://plan9.bell-labs.com/plan9 287 288For information on Plan 9 from User Space (Plan 9 applications and libraries 289ported to Linux/BSD/OSX/etc) check out https://9fans.github.io/plan9port/ 290