1
0

fs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. .TH FS 3
  2. .SH NAME
  3. fs \- file system devices
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind -b #k /dev
  7. .sp 0.3v
  8. .B /dev/fs
  9. .B /dev/fs/ctl
  10. .B /dev/fs/...
  11. .B /dev/\fInew\fP
  12. .fi
  13. .SH DESCRIPTION
  14. The
  15. .I fs
  16. driver builds complex disk files out of simpler disk files.
  17. Inspired by the Plan 9 file server kernel's configuration strings,
  18. it provides device mirroring, partitioning, interleaving, and catenation
  19. for disk-based services like
  20. .IR fossil (4)
  21. or
  22. .IR venti (8).
  23. .PP
  24. The device is intended to be bound at
  25. .B /dev
  26. and initially contains a directory named
  27. .BR fs ,
  28. which in turn contains a
  29. .B ctl
  30. file and one file per configured device.
  31. .PP
  32. Most control messages introduce a new device, here named
  33. .IR new .
  34. The
  35. .I file
  36. arguments are interpreted in the name space of the writing process.
  37. .PP
  38. The device name
  39. .I new
  40. may be a single filename component (containing no slashes);
  41. in this case, the device is created under
  42. .BR #k/fs .
  43. If
  44. .I new
  45. instead has the format
  46. .IB dir / file,
  47. the device is made available at
  48. .BI #k/ dir / file.
  49. The directory
  50. .I dir
  51. goes away when the last device on it is removed with the
  52. .B del
  53. control message,
  54. but
  55. .B #k/fs
  56. will never be removed.
  57. .TF "del \fIold
  58. .PD
  59. .TP
  60. .BI cat " new files" \fR...
  61. The device
  62. .I new
  63. corresponds to the catenation of
  64. .IR files .
  65. .TP
  66. .BI inter " new files" \fR...
  67. The device
  68. .I new
  69. corresponds to the block interleaving of
  70. .IR files ;
  71. an 8192-byte block size is assumed.
  72. .TP
  73. .BI mirror " new files" \fR...
  74. The device
  75. .I new
  76. corresponds to a RAID-1-like mirroring of
  77. .IR files .
  78. Writes to
  79. .BI new
  80. are handled by sequentially writing the same data to the
  81. .I files
  82. from right to left (the reverse of
  83. the order in the control message).
  84. A failed write causes an eventual error return
  85. but does not prevent the rest of the writes
  86. to the other devices of the mirror set.
  87. Reads from
  88. .BI new
  89. are handled by sequentially reading from the
  90. .I files
  91. from left to right until one succeeds.
  92. The length of the mirror device is the minimum of the lengths of the
  93. .IR files .
  94. .TP
  95. .BI part " new file offset length"
  96. .PD 0
  97. .TP
  98. .BI part " new offset end
  99. .PD
  100. In the first form,
  101. the device
  102. .I new
  103. corresponds to the
  104. .I length
  105. units starting at
  106. .I offset
  107. in
  108. .IR file .
  109. If
  110. .IR offset + length
  111. reaches past the end of
  112. .IR file ,
  113. .I length
  114. is silently reduced to fit.
  115. Units are bytes.
  116. In the second form,
  117. a previous
  118. .B disk
  119. request must have defined the source
  120. .I file
  121. for further requests and the end of the device
  122. is determined by the
  123. .I end
  124. offset in the source file, and not by the device
  125. length. Units are as defined in the previous
  126. .B disk
  127. request. This form is accepted for compatibility with
  128. .IR fdisk
  129. (in
  130. .IR prep (8))
  131. and
  132. .IR sd (3)
  133. devices.
  134. .TP
  135. .BI del " old
  136. Removes the device named
  137. .IR old .
  138. The device will still be seen while in use.
  139. Further I/O attempts will fail with an error indication stating that
  140. the device is gone.
  141. When
  142. .I old
  143. is
  144. .IB dir /*\fR,
  145. all devices under
  146. .I dir
  147. are removed.
  148. .TP
  149. .BI disk " dir [ n file ]
  150. makes
  151. .I dir
  152. implicit in new device names (i.e., it makes
  153. .I new
  154. mean
  155. .IB dir / new
  156. by default).
  157. Optional argument
  158. .I n
  159. specifies the default unit (sector) size in bytes and the default source
  160. .I file
  161. for further partition devices.
  162. Default values are restored when the control file is closed.
  163. .TP
  164. .B clear
  165. Discard all
  166. .I fs
  167. device definitions.
  168. .PD
  169. .LP
  170. If the variable
  171. .B fsconfig
  172. is set in
  173. .IR plan9.ini (8),
  174. .I fs
  175. will read its configuration from the file
  176. .B $fsconfig
  177. on the first attach.
  178. This is useful when the machine boots from a local file server that uses
  179. .IR fs .
  180. .SH EXAMPLES
  181. Use a previously partitioned disk,
  182. .BR /dev/sdC0 ,
  183. making
  184. partition files available under
  185. .BR /dev/sdC0parts :
  186. .IP
  187. .EX
  188. {
  189. echo disk sdC0parts 512 /dev/sdC0/data
  190. disk/fdisk -p /dev/sdC0/data
  191. # now create plan 9 partitions
  192. echo disk sdC0parts 512 /dev/sdC0parts/plan9
  193. disk/prep -p /dev/sdC0parts/plan9
  194. } > /dev/fs/ctl
  195. .EE
  196. .LP
  197. Mirror the two disks
  198. .B /dev/sdC0/data
  199. and
  200. .B /dev/sdD0/data
  201. as
  202. .BR /dev/fs/m0 ;
  203. similarly, mirror
  204. .B /dev/sdC1/data
  205. and
  206. .B /dev/sdD1/data
  207. as
  208. .BR /dev/fs/m1 :
  209. .IP
  210. .EX
  211. echo mirror m0 /dev/sdC0/data /dev/sdD0/data >/dev/fs/ctl
  212. echo mirror m1 /dev/sdC1/data /dev/sdD1/data >/dev/fs/ctl
  213. .EE
  214. .LP
  215. Interleave the two mirrored disks to create
  216. .BR /dev/fs/data :
  217. .IP
  218. .EX
  219. echo inter data /dev/fs/m0 /dev/fs/m1 >/dev/fs/ctl
  220. .EE
  221. .LP
  222. Run
  223. .IR kfs (4)
  224. on the interleaved device:
  225. .IP
  226. .EX
  227. disk/kfs -f /dev/fs/data
  228. .EE
  229. .LP
  230. Save the configuration:
  231. .IP
  232. .EX
  233. cp /dev/fs/ctl /dev/fd0disk
  234. .EE
  235. .LP
  236. To load the configuration automatically at boot time,
  237. add this to
  238. .IR plan9.ini :
  239. .IP
  240. .EX
  241. fsconfig=/dev/fd0disk
  242. .EE
  243. .SH "SEE ALSO"
  244. .I read
  245. in
  246. .IR cat (1),
  247. .IR dd (1),
  248. .IR sd (3),
  249. .IR fossil (4),
  250. .IR fs (8),
  251. .IR plan9.ini (8),
  252. .IR prep (8),
  253. .IR venti (8)
  254. .SH SOURCE
  255. .B /sys/src/9/port/devfs.c
  256. .SH BUGS
  257. Mirrors are RAID-like but not RAID.
  258. There is no fancy recovery mechanism and
  259. no automatic initial copying from a master drive to its mirror drives.
  260. .PP
  261. Each
  262. .I write
  263. system call on
  264. .B ctl
  265. may transmit at most one command.