xfs_super.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216
  1. /*
  2. * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_bit.h"
  20. #include "xfs_log.h"
  21. #include "xfs_clnt.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_sb.h"
  25. #include "xfs_ag.h"
  26. #include "xfs_dir2.h"
  27. #include "xfs_alloc.h"
  28. #include "xfs_dmapi.h"
  29. #include "xfs_quota.h"
  30. #include "xfs_mount.h"
  31. #include "xfs_bmap_btree.h"
  32. #include "xfs_alloc_btree.h"
  33. #include "xfs_ialloc_btree.h"
  34. #include "xfs_dir2_sf.h"
  35. #include "xfs_attr_sf.h"
  36. #include "xfs_dinode.h"
  37. #include "xfs_inode.h"
  38. #include "xfs_btree.h"
  39. #include "xfs_ialloc.h"
  40. #include "xfs_bmap.h"
  41. #include "xfs_rtalloc.h"
  42. #include "xfs_error.h"
  43. #include "xfs_itable.h"
  44. #include "xfs_fsops.h"
  45. #include "xfs_rw.h"
  46. #include "xfs_acl.h"
  47. #include "xfs_attr.h"
  48. #include "xfs_buf_item.h"
  49. #include "xfs_utils.h"
  50. #include "xfs_vnodeops.h"
  51. #include "xfs_vfsops.h"
  52. #include "xfs_version.h"
  53. #include "xfs_log_priv.h"
  54. #include "xfs_trans_priv.h"
  55. #include "xfs_filestream.h"
  56. #include "xfs_da_btree.h"
  57. #include "xfs_dir2_trace.h"
  58. #include "xfs_extfree_item.h"
  59. #include "xfs_mru_cache.h"
  60. #include "xfs_inode_item.h"
  61. #include <linux/namei.h>
  62. #include <linux/init.h>
  63. #include <linux/mount.h>
  64. #include <linux/mempool.h>
  65. #include <linux/writeback.h>
  66. #include <linux/kthread.h>
  67. #include <linux/freezer.h>
  68. static struct quotactl_ops xfs_quotactl_operations;
  69. static struct super_operations xfs_super_operations;
  70. static kmem_zone_t *xfs_vnode_zone;
  71. static kmem_zone_t *xfs_ioend_zone;
  72. mempool_t *xfs_ioend_pool;
  73. STATIC struct xfs_mount_args *
  74. xfs_args_allocate(
  75. struct super_block *sb,
  76. int silent)
  77. {
  78. struct xfs_mount_args *args;
  79. args = kzalloc(sizeof(struct xfs_mount_args), GFP_KERNEL);
  80. if (!args)
  81. return NULL;
  82. args->logbufs = args->logbufsize = -1;
  83. strncpy(args->fsname, sb->s_id, MAXNAMELEN);
  84. /* Copy the already-parsed mount(2) flags we're interested in */
  85. if (sb->s_flags & MS_DIRSYNC)
  86. args->flags |= XFSMNT_DIRSYNC;
  87. if (sb->s_flags & MS_SYNCHRONOUS)
  88. args->flags |= XFSMNT_WSYNC;
  89. if (silent)
  90. args->flags |= XFSMNT_QUIET;
  91. args->flags |= XFSMNT_32BITINODES;
  92. return args;
  93. }
  94. #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
  95. #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
  96. #define MNTOPT_LOGDEV "logdev" /* log device */
  97. #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
  98. #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
  99. #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
  100. #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
  101. #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
  102. #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
  103. #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
  104. #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
  105. #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
  106. #define MNTOPT_MTPT "mtpt" /* filesystem mount point */
  107. #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
  108. #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
  109. #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
  110. #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
  111. #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
  112. #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
  113. #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
  114. * unwritten extent conversion */
  115. #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
  116. #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
  117. #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
  118. #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
  119. #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
  120. #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
  121. #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
  122. * in stat(). */
  123. #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
  124. #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
  125. #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
  126. #define MNTOPT_QUOTA "quota" /* disk quotas (user) */
  127. #define MNTOPT_NOQUOTA "noquota" /* no quotas */
  128. #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
  129. #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
  130. #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
  131. #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
  132. #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
  133. #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
  134. #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
  135. #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
  136. #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
  137. #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
  138. #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
  139. #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
  140. #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
  141. STATIC unsigned long
  142. suffix_strtoul(char *s, char **endp, unsigned int base)
  143. {
  144. int last, shift_left_factor = 0;
  145. char *value = s;
  146. last = strlen(value) - 1;
  147. if (value[last] == 'K' || value[last] == 'k') {
  148. shift_left_factor = 10;
  149. value[last] = '\0';
  150. }
  151. if (value[last] == 'M' || value[last] == 'm') {
  152. shift_left_factor = 20;
  153. value[last] = '\0';
  154. }
  155. if (value[last] == 'G' || value[last] == 'g') {
  156. shift_left_factor = 30;
  157. value[last] = '\0';
  158. }
  159. return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
  160. }
  161. STATIC int
  162. xfs_parseargs(
  163. struct xfs_mount *mp,
  164. char *options,
  165. struct xfs_mount_args *args,
  166. int update)
  167. {
  168. char *this_char, *value, *eov;
  169. int dsunit, dswidth, vol_dsunit, vol_dswidth;
  170. int iosize;
  171. int dmapi_implies_ikeep = 1;
  172. args->flags |= XFSMNT_BARRIER;
  173. args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
  174. if (!options)
  175. goto done;
  176. iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0;
  177. while ((this_char = strsep(&options, ",")) != NULL) {
  178. if (!*this_char)
  179. continue;
  180. if ((value = strchr(this_char, '=')) != NULL)
  181. *value++ = 0;
  182. if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
  183. if (!value || !*value) {
  184. cmn_err(CE_WARN,
  185. "XFS: %s option requires an argument",
  186. this_char);
  187. return EINVAL;
  188. }
  189. args->logbufs = simple_strtoul(value, &eov, 10);
  190. } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
  191. if (!value || !*value) {
  192. cmn_err(CE_WARN,
  193. "XFS: %s option requires an argument",
  194. this_char);
  195. return EINVAL;
  196. }
  197. args->logbufsize = suffix_strtoul(value, &eov, 10);
  198. } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
  199. if (!value || !*value) {
  200. cmn_err(CE_WARN,
  201. "XFS: %s option requires an argument",
  202. this_char);
  203. return EINVAL;
  204. }
  205. strncpy(args->logname, value, MAXNAMELEN);
  206. } else if (!strcmp(this_char, MNTOPT_MTPT)) {
  207. if (!value || !*value) {
  208. cmn_err(CE_WARN,
  209. "XFS: %s option requires an argument",
  210. this_char);
  211. return EINVAL;
  212. }
  213. strncpy(args->mtpt, value, MAXNAMELEN);
  214. } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
  215. if (!value || !*value) {
  216. cmn_err(CE_WARN,
  217. "XFS: %s option requires an argument",
  218. this_char);
  219. return EINVAL;
  220. }
  221. strncpy(args->rtname, value, MAXNAMELEN);
  222. } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
  223. if (!value || !*value) {
  224. cmn_err(CE_WARN,
  225. "XFS: %s option requires an argument",
  226. this_char);
  227. return EINVAL;
  228. }
  229. iosize = simple_strtoul(value, &eov, 10);
  230. args->flags |= XFSMNT_IOSIZE;
  231. args->iosizelog = (uint8_t) iosize;
  232. } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
  233. if (!value || !*value) {
  234. cmn_err(CE_WARN,
  235. "XFS: %s option requires an argument",
  236. this_char);
  237. return EINVAL;
  238. }
  239. iosize = suffix_strtoul(value, &eov, 10);
  240. args->flags |= XFSMNT_IOSIZE;
  241. args->iosizelog = ffs(iosize) - 1;
  242. } else if (!strcmp(this_char, MNTOPT_GRPID) ||
  243. !strcmp(this_char, MNTOPT_BSDGROUPS)) {
  244. mp->m_flags |= XFS_MOUNT_GRPID;
  245. } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
  246. !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
  247. mp->m_flags &= ~XFS_MOUNT_GRPID;
  248. } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
  249. args->flags |= XFSMNT_WSYNC;
  250. } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
  251. args->flags |= XFSMNT_OSYNCISOSYNC;
  252. } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
  253. args->flags |= XFSMNT_NORECOVERY;
  254. } else if (!strcmp(this_char, MNTOPT_INO64)) {
  255. args->flags |= XFSMNT_INO64;
  256. #if !XFS_BIG_INUMS
  257. cmn_err(CE_WARN,
  258. "XFS: %s option not allowed on this system",
  259. this_char);
  260. return EINVAL;
  261. #endif
  262. } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
  263. args->flags |= XFSMNT_NOALIGN;
  264. } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
  265. args->flags |= XFSMNT_SWALLOC;
  266. } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
  267. if (!value || !*value) {
  268. cmn_err(CE_WARN,
  269. "XFS: %s option requires an argument",
  270. this_char);
  271. return EINVAL;
  272. }
  273. dsunit = simple_strtoul(value, &eov, 10);
  274. } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
  275. if (!value || !*value) {
  276. cmn_err(CE_WARN,
  277. "XFS: %s option requires an argument",
  278. this_char);
  279. return EINVAL;
  280. }
  281. dswidth = simple_strtoul(value, &eov, 10);
  282. } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
  283. args->flags &= ~XFSMNT_32BITINODES;
  284. #if !XFS_BIG_INUMS
  285. cmn_err(CE_WARN,
  286. "XFS: %s option not allowed on this system",
  287. this_char);
  288. return EINVAL;
  289. #endif
  290. } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
  291. args->flags |= XFSMNT_NOUUID;
  292. } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
  293. args->flags |= XFSMNT_BARRIER;
  294. } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
  295. args->flags &= ~XFSMNT_BARRIER;
  296. } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
  297. args->flags |= XFSMNT_IKEEP;
  298. } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
  299. dmapi_implies_ikeep = 0;
  300. args->flags &= ~XFSMNT_IKEEP;
  301. } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
  302. args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
  303. } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
  304. args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
  305. } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
  306. args->flags |= XFSMNT_ATTR2;
  307. } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
  308. args->flags &= ~XFSMNT_ATTR2;
  309. args->flags |= XFSMNT_NOATTR2;
  310. } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
  311. args->flags2 |= XFSMNT2_FILESTREAMS;
  312. } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
  313. args->flags &= ~(XFSMNT_UQUOTAENF|XFSMNT_UQUOTA);
  314. args->flags &= ~(XFSMNT_GQUOTAENF|XFSMNT_GQUOTA);
  315. } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
  316. !strcmp(this_char, MNTOPT_UQUOTA) ||
  317. !strcmp(this_char, MNTOPT_USRQUOTA)) {
  318. args->flags |= XFSMNT_UQUOTA | XFSMNT_UQUOTAENF;
  319. } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
  320. !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
  321. args->flags |= XFSMNT_UQUOTA;
  322. args->flags &= ~XFSMNT_UQUOTAENF;
  323. } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
  324. !strcmp(this_char, MNTOPT_PRJQUOTA)) {
  325. args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF;
  326. } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
  327. args->flags |= XFSMNT_PQUOTA;
  328. args->flags &= ~XFSMNT_PQUOTAENF;
  329. } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
  330. !strcmp(this_char, MNTOPT_GRPQUOTA)) {
  331. args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF;
  332. } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
  333. args->flags |= XFSMNT_GQUOTA;
  334. args->flags &= ~XFSMNT_GQUOTAENF;
  335. } else if (!strcmp(this_char, MNTOPT_DMAPI)) {
  336. args->flags |= XFSMNT_DMAPI;
  337. } else if (!strcmp(this_char, MNTOPT_XDSM)) {
  338. args->flags |= XFSMNT_DMAPI;
  339. } else if (!strcmp(this_char, MNTOPT_DMI)) {
  340. args->flags |= XFSMNT_DMAPI;
  341. } else if (!strcmp(this_char, "ihashsize")) {
  342. cmn_err(CE_WARN,
  343. "XFS: ihashsize no longer used, option is deprecated.");
  344. } else if (!strcmp(this_char, "osyncisdsync")) {
  345. /* no-op, this is now the default */
  346. cmn_err(CE_WARN,
  347. "XFS: osyncisdsync is now the default, option is deprecated.");
  348. } else if (!strcmp(this_char, "irixsgid")) {
  349. cmn_err(CE_WARN,
  350. "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
  351. } else {
  352. cmn_err(CE_WARN,
  353. "XFS: unknown mount option [%s].", this_char);
  354. return EINVAL;
  355. }
  356. }
  357. if (args->flags & XFSMNT_NORECOVERY) {
  358. if ((mp->m_flags & XFS_MOUNT_RDONLY) == 0) {
  359. cmn_err(CE_WARN,
  360. "XFS: no-recovery mounts must be read-only.");
  361. return EINVAL;
  362. }
  363. }
  364. if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) {
  365. cmn_err(CE_WARN,
  366. "XFS: sunit and swidth options incompatible with the noalign option");
  367. return EINVAL;
  368. }
  369. if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) {
  370. cmn_err(CE_WARN,
  371. "XFS: cannot mount with both project and group quota");
  372. return EINVAL;
  373. }
  374. if ((args->flags & XFSMNT_DMAPI) && *args->mtpt == '\0') {
  375. printk("XFS: %s option needs the mount point option as well\n",
  376. MNTOPT_DMAPI);
  377. return EINVAL;
  378. }
  379. if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
  380. cmn_err(CE_WARN,
  381. "XFS: sunit and swidth must be specified together");
  382. return EINVAL;
  383. }
  384. if (dsunit && (dswidth % dsunit != 0)) {
  385. cmn_err(CE_WARN,
  386. "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
  387. dswidth, dsunit);
  388. return EINVAL;
  389. }
  390. /*
  391. * Applications using DMI filesystems often expect the
  392. * inode generation number to be monotonically increasing.
  393. * If we delete inode chunks we break this assumption, so
  394. * keep unused inode chunks on disk for DMI filesystems
  395. * until we come up with a better solution.
  396. * Note that if "ikeep" or "noikeep" mount options are
  397. * supplied, then they are honored.
  398. */
  399. if ((args->flags & XFSMNT_DMAPI) && dmapi_implies_ikeep)
  400. args->flags |= XFSMNT_IKEEP;
  401. if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
  402. if (dsunit) {
  403. args->sunit = dsunit;
  404. args->flags |= XFSMNT_RETERR;
  405. } else {
  406. args->sunit = vol_dsunit;
  407. }
  408. dswidth ? (args->swidth = dswidth) :
  409. (args->swidth = vol_dswidth);
  410. } else {
  411. args->sunit = args->swidth = 0;
  412. }
  413. done:
  414. if (args->flags & XFSMNT_32BITINODES)
  415. mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
  416. if (args->flags2)
  417. args->flags |= XFSMNT_FLAGS2;
  418. return 0;
  419. }
  420. struct proc_xfs_info {
  421. int flag;
  422. char *str;
  423. };
  424. STATIC int
  425. xfs_showargs(
  426. struct xfs_mount *mp,
  427. struct seq_file *m)
  428. {
  429. static struct proc_xfs_info xfs_info_set[] = {
  430. /* the few simple ones we can get from the mount struct */
  431. { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
  432. { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
  433. { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
  434. { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
  435. { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
  436. { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
  437. { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
  438. { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
  439. { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
  440. { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
  441. { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI },
  442. { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
  443. { 0, NULL }
  444. };
  445. static struct proc_xfs_info xfs_info_unset[] = {
  446. /* the few simple ones we can get from the mount struct */
  447. { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
  448. { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
  449. { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
  450. { 0, NULL }
  451. };
  452. struct proc_xfs_info *xfs_infop;
  453. for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
  454. if (mp->m_flags & xfs_infop->flag)
  455. seq_puts(m, xfs_infop->str);
  456. }
  457. for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
  458. if (!(mp->m_flags & xfs_infop->flag))
  459. seq_puts(m, xfs_infop->str);
  460. }
  461. if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
  462. seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
  463. (int)(1 << mp->m_writeio_log) >> 10);
  464. if (mp->m_logbufs > 0)
  465. seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
  466. if (mp->m_logbsize > 0)
  467. seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
  468. if (mp->m_logname)
  469. seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
  470. if (mp->m_rtname)
  471. seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
  472. if (mp->m_dalign > 0)
  473. seq_printf(m, "," MNTOPT_SUNIT "=%d",
  474. (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
  475. if (mp->m_swidth > 0)
  476. seq_printf(m, "," MNTOPT_SWIDTH "=%d",
  477. (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
  478. if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
  479. seq_puts(m, "," MNTOPT_USRQUOTA);
  480. else if (mp->m_qflags & XFS_UQUOTA_ACCT)
  481. seq_puts(m, "," MNTOPT_UQUOTANOENF);
  482. if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
  483. seq_puts(m, "," MNTOPT_PRJQUOTA);
  484. else if (mp->m_qflags & XFS_PQUOTA_ACCT)
  485. seq_puts(m, "," MNTOPT_PQUOTANOENF);
  486. if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
  487. seq_puts(m, "," MNTOPT_GRPQUOTA);
  488. else if (mp->m_qflags & XFS_GQUOTA_ACCT)
  489. seq_puts(m, "," MNTOPT_GQUOTANOENF);
  490. if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
  491. seq_puts(m, "," MNTOPT_NOQUOTA);
  492. return 0;
  493. }
  494. __uint64_t
  495. xfs_max_file_offset(
  496. unsigned int blockshift)
  497. {
  498. unsigned int pagefactor = 1;
  499. unsigned int bitshift = BITS_PER_LONG - 1;
  500. /* Figure out maximum filesize, on Linux this can depend on
  501. * the filesystem blocksize (on 32 bit platforms).
  502. * __block_prepare_write does this in an [unsigned] long...
  503. * page->index << (PAGE_CACHE_SHIFT - bbits)
  504. * So, for page sized blocks (4K on 32 bit platforms),
  505. * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
  506. * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
  507. * but for smaller blocksizes it is less (bbits = log2 bsize).
  508. * Note1: get_block_t takes a long (implicit cast from above)
  509. * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
  510. * can optionally convert the [unsigned] long from above into
  511. * an [unsigned] long long.
  512. */
  513. #if BITS_PER_LONG == 32
  514. # if defined(CONFIG_LBD)
  515. ASSERT(sizeof(sector_t) == 8);
  516. pagefactor = PAGE_CACHE_SIZE;
  517. bitshift = BITS_PER_LONG;
  518. # else
  519. pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
  520. # endif
  521. #endif
  522. return (((__uint64_t)pagefactor) << bitshift) - 1;
  523. }
  524. STATIC_INLINE void
  525. xfs_set_inodeops(
  526. struct inode *inode)
  527. {
  528. switch (inode->i_mode & S_IFMT) {
  529. case S_IFREG:
  530. inode->i_op = &xfs_inode_operations;
  531. inode->i_fop = &xfs_file_operations;
  532. inode->i_mapping->a_ops = &xfs_address_space_operations;
  533. break;
  534. case S_IFDIR:
  535. if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
  536. inode->i_op = &xfs_dir_ci_inode_operations;
  537. else
  538. inode->i_op = &xfs_dir_inode_operations;
  539. inode->i_fop = &xfs_dir_file_operations;
  540. break;
  541. case S_IFLNK:
  542. inode->i_op = &xfs_symlink_inode_operations;
  543. if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
  544. inode->i_mapping->a_ops = &xfs_address_space_operations;
  545. break;
  546. default:
  547. inode->i_op = &xfs_inode_operations;
  548. init_special_inode(inode, inode->i_mode, inode->i_rdev);
  549. break;
  550. }
  551. }
  552. STATIC_INLINE void
  553. xfs_revalidate_inode(
  554. xfs_mount_t *mp,
  555. bhv_vnode_t *vp,
  556. xfs_inode_t *ip)
  557. {
  558. struct inode *inode = vn_to_inode(vp);
  559. inode->i_mode = ip->i_d.di_mode;
  560. inode->i_nlink = ip->i_d.di_nlink;
  561. inode->i_uid = ip->i_d.di_uid;
  562. inode->i_gid = ip->i_d.di_gid;
  563. switch (inode->i_mode & S_IFMT) {
  564. case S_IFBLK:
  565. case S_IFCHR:
  566. inode->i_rdev =
  567. MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
  568. sysv_minor(ip->i_df.if_u2.if_rdev));
  569. break;
  570. default:
  571. inode->i_rdev = 0;
  572. break;
  573. }
  574. inode->i_generation = ip->i_d.di_gen;
  575. i_size_write(inode, ip->i_d.di_size);
  576. inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
  577. inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
  578. inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
  579. inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
  580. inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
  581. inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
  582. if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
  583. inode->i_flags |= S_IMMUTABLE;
  584. else
  585. inode->i_flags &= ~S_IMMUTABLE;
  586. if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
  587. inode->i_flags |= S_APPEND;
  588. else
  589. inode->i_flags &= ~S_APPEND;
  590. if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
  591. inode->i_flags |= S_SYNC;
  592. else
  593. inode->i_flags &= ~S_SYNC;
  594. if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
  595. inode->i_flags |= S_NOATIME;
  596. else
  597. inode->i_flags &= ~S_NOATIME;
  598. xfs_iflags_clear(ip, XFS_IMODIFIED);
  599. }
  600. void
  601. xfs_initialize_vnode(
  602. struct xfs_mount *mp,
  603. bhv_vnode_t *vp,
  604. struct xfs_inode *ip)
  605. {
  606. struct inode *inode = vn_to_inode(vp);
  607. if (!ip->i_vnode) {
  608. ip->i_vnode = vp;
  609. inode->i_private = ip;
  610. }
  611. /*
  612. * We need to set the ops vectors, and unlock the inode, but if
  613. * we have been called during the new inode create process, it is
  614. * too early to fill in the Linux inode. We will get called a
  615. * second time once the inode is properly set up, and then we can
  616. * finish our work.
  617. */
  618. if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
  619. xfs_revalidate_inode(mp, vp, ip);
  620. xfs_set_inodeops(inode);
  621. xfs_iflags_clear(ip, XFS_INEW);
  622. barrier();
  623. unlock_new_inode(inode);
  624. }
  625. }
  626. int
  627. xfs_blkdev_get(
  628. xfs_mount_t *mp,
  629. const char *name,
  630. struct block_device **bdevp)
  631. {
  632. int error = 0;
  633. *bdevp = open_bdev_excl(name, 0, mp);
  634. if (IS_ERR(*bdevp)) {
  635. error = PTR_ERR(*bdevp);
  636. printk("XFS: Invalid device [%s], error=%d\n", name, error);
  637. }
  638. return -error;
  639. }
  640. void
  641. xfs_blkdev_put(
  642. struct block_device *bdev)
  643. {
  644. if (bdev)
  645. close_bdev_excl(bdev);
  646. }
  647. /*
  648. * Try to write out the superblock using barriers.
  649. */
  650. STATIC int
  651. xfs_barrier_test(
  652. xfs_mount_t *mp)
  653. {
  654. xfs_buf_t *sbp = xfs_getsb(mp, 0);
  655. int error;
  656. XFS_BUF_UNDONE(sbp);
  657. XFS_BUF_UNREAD(sbp);
  658. XFS_BUF_UNDELAYWRITE(sbp);
  659. XFS_BUF_WRITE(sbp);
  660. XFS_BUF_UNASYNC(sbp);
  661. XFS_BUF_ORDERED(sbp);
  662. xfsbdstrat(mp, sbp);
  663. error = xfs_iowait(sbp);
  664. /*
  665. * Clear all the flags we set and possible error state in the
  666. * buffer. We only did the write to try out whether barriers
  667. * worked and shouldn't leave any traces in the superblock
  668. * buffer.
  669. */
  670. XFS_BUF_DONE(sbp);
  671. XFS_BUF_ERROR(sbp, 0);
  672. XFS_BUF_UNORDERED(sbp);
  673. xfs_buf_relse(sbp);
  674. return error;
  675. }
  676. void
  677. xfs_mountfs_check_barriers(xfs_mount_t *mp)
  678. {
  679. int error;
  680. if (mp->m_logdev_targp != mp->m_ddev_targp) {
  681. xfs_fs_cmn_err(CE_NOTE, mp,
  682. "Disabling barriers, not supported with external log device");
  683. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  684. return;
  685. }
  686. if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
  687. xfs_fs_cmn_err(CE_NOTE, mp,
  688. "Disabling barriers, underlying device is readonly");
  689. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  690. return;
  691. }
  692. error = xfs_barrier_test(mp);
  693. if (error) {
  694. xfs_fs_cmn_err(CE_NOTE, mp,
  695. "Disabling barriers, trial barrier write failed");
  696. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  697. return;
  698. }
  699. }
  700. void
  701. xfs_blkdev_issue_flush(
  702. xfs_buftarg_t *buftarg)
  703. {
  704. blkdev_issue_flush(buftarg->bt_bdev, NULL);
  705. }
  706. STATIC void
  707. xfs_close_devices(
  708. struct xfs_mount *mp)
  709. {
  710. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  711. xfs_free_buftarg(mp->m_logdev_targp);
  712. xfs_blkdev_put(mp->m_logdev_targp->bt_bdev);
  713. }
  714. if (mp->m_rtdev_targp) {
  715. xfs_free_buftarg(mp->m_rtdev_targp);
  716. xfs_blkdev_put(mp->m_rtdev_targp->bt_bdev);
  717. }
  718. xfs_free_buftarg(mp->m_ddev_targp);
  719. }
  720. /*
  721. * The file system configurations are:
  722. * (1) device (partition) with data and internal log
  723. * (2) logical volume with data and log subvolumes.
  724. * (3) logical volume with data, log, and realtime subvolumes.
  725. *
  726. * We only have to handle opening the log and realtime volumes here if
  727. * they are present. The data subvolume has already been opened by
  728. * get_sb_bdev() and is stored in sb->s_bdev.
  729. */
  730. STATIC int
  731. xfs_open_devices(
  732. struct xfs_mount *mp,
  733. struct xfs_mount_args *args)
  734. {
  735. struct block_device *ddev = mp->m_super->s_bdev;
  736. struct block_device *logdev = NULL, *rtdev = NULL;
  737. int error;
  738. /*
  739. * Open real time and log devices - order is important.
  740. */
  741. if (args->logname[0]) {
  742. error = xfs_blkdev_get(mp, args->logname, &logdev);
  743. if (error)
  744. goto out;
  745. }
  746. if (args->rtname[0]) {
  747. error = xfs_blkdev_get(mp, args->rtname, &rtdev);
  748. if (error)
  749. goto out_close_logdev;
  750. if (rtdev == ddev || rtdev == logdev) {
  751. cmn_err(CE_WARN,
  752. "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
  753. error = EINVAL;
  754. goto out_close_rtdev;
  755. }
  756. }
  757. /*
  758. * Setup xfs_mount buffer target pointers
  759. */
  760. error = ENOMEM;
  761. mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0);
  762. if (!mp->m_ddev_targp)
  763. goto out_close_rtdev;
  764. if (rtdev) {
  765. mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1);
  766. if (!mp->m_rtdev_targp)
  767. goto out_free_ddev_targ;
  768. }
  769. if (logdev && logdev != ddev) {
  770. mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1);
  771. if (!mp->m_logdev_targp)
  772. goto out_free_rtdev_targ;
  773. } else {
  774. mp->m_logdev_targp = mp->m_ddev_targp;
  775. }
  776. return 0;
  777. out_free_rtdev_targ:
  778. if (mp->m_rtdev_targp)
  779. xfs_free_buftarg(mp->m_rtdev_targp);
  780. out_free_ddev_targ:
  781. xfs_free_buftarg(mp->m_ddev_targp);
  782. out_close_rtdev:
  783. if (rtdev)
  784. xfs_blkdev_put(rtdev);
  785. out_close_logdev:
  786. if (logdev && logdev != ddev)
  787. xfs_blkdev_put(logdev);
  788. out:
  789. return error;
  790. }
  791. /*
  792. * Setup xfs_mount buffer target pointers based on superblock
  793. */
  794. STATIC int
  795. xfs_setup_devices(
  796. struct xfs_mount *mp)
  797. {
  798. int error;
  799. error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
  800. mp->m_sb.sb_sectsize);
  801. if (error)
  802. return error;
  803. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  804. unsigned int log_sector_size = BBSIZE;
  805. if (xfs_sb_version_hassector(&mp->m_sb))
  806. log_sector_size = mp->m_sb.sb_logsectsize;
  807. error = xfs_setsize_buftarg(mp->m_logdev_targp,
  808. mp->m_sb.sb_blocksize,
  809. log_sector_size);
  810. if (error)
  811. return error;
  812. }
  813. if (mp->m_rtdev_targp) {
  814. error = xfs_setsize_buftarg(mp->m_rtdev_targp,
  815. mp->m_sb.sb_blocksize,
  816. mp->m_sb.sb_sectsize);
  817. if (error)
  818. return error;
  819. }
  820. return 0;
  821. }
  822. /*
  823. * XFS AIL push thread support
  824. */
  825. void
  826. xfsaild_wakeup(
  827. xfs_mount_t *mp,
  828. xfs_lsn_t threshold_lsn)
  829. {
  830. mp->m_ail.xa_target = threshold_lsn;
  831. wake_up_process(mp->m_ail.xa_task);
  832. }
  833. int
  834. xfsaild(
  835. void *data)
  836. {
  837. xfs_mount_t *mp = (xfs_mount_t *)data;
  838. xfs_lsn_t last_pushed_lsn = 0;
  839. long tout = 0;
  840. while (!kthread_should_stop()) {
  841. if (tout)
  842. schedule_timeout_interruptible(msecs_to_jiffies(tout));
  843. tout = 1000;
  844. /* swsusp */
  845. try_to_freeze();
  846. ASSERT(mp->m_log);
  847. if (XFS_FORCED_SHUTDOWN(mp))
  848. continue;
  849. tout = xfsaild_push(mp, &last_pushed_lsn);
  850. }
  851. return 0;
  852. } /* xfsaild */
  853. int
  854. xfsaild_start(
  855. xfs_mount_t *mp)
  856. {
  857. mp->m_ail.xa_target = 0;
  858. mp->m_ail.xa_task = kthread_run(xfsaild, mp, "xfsaild");
  859. if (IS_ERR(mp->m_ail.xa_task))
  860. return -PTR_ERR(mp->m_ail.xa_task);
  861. return 0;
  862. }
  863. void
  864. xfsaild_stop(
  865. xfs_mount_t *mp)
  866. {
  867. kthread_stop(mp->m_ail.xa_task);
  868. }
  869. STATIC struct inode *
  870. xfs_fs_alloc_inode(
  871. struct super_block *sb)
  872. {
  873. bhv_vnode_t *vp;
  874. vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP);
  875. if (unlikely(!vp))
  876. return NULL;
  877. return vn_to_inode(vp);
  878. }
  879. STATIC void
  880. xfs_fs_destroy_inode(
  881. struct inode *inode)
  882. {
  883. kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode));
  884. }
  885. STATIC void
  886. xfs_fs_inode_init_once(
  887. void *vnode)
  888. {
  889. inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
  890. }
  891. /*
  892. * Attempt to flush the inode, this will actually fail
  893. * if the inode is pinned, but we dirty the inode again
  894. * at the point when it is unpinned after a log write,
  895. * since this is when the inode itself becomes flushable.
  896. */
  897. STATIC int
  898. xfs_fs_write_inode(
  899. struct inode *inode,
  900. int sync)
  901. {
  902. int error = 0;
  903. int flags = 0;
  904. xfs_itrace_entry(XFS_I(inode));
  905. if (sync) {
  906. filemap_fdatawait(inode->i_mapping);
  907. flags |= FLUSH_SYNC;
  908. }
  909. error = xfs_inode_flush(XFS_I(inode), flags);
  910. /*
  911. * if we failed to write out the inode then mark
  912. * it dirty again so we'll try again later.
  913. */
  914. if (error)
  915. mark_inode_dirty_sync(inode);
  916. return -error;
  917. }
  918. STATIC void
  919. xfs_fs_clear_inode(
  920. struct inode *inode)
  921. {
  922. xfs_inode_t *ip = XFS_I(inode);
  923. /*
  924. * ip can be null when xfs_iget_core calls xfs_idestroy if we
  925. * find an inode with di_mode == 0 but without IGET_CREATE set.
  926. */
  927. if (ip) {
  928. xfs_itrace_entry(ip);
  929. XFS_STATS_INC(vn_rele);
  930. XFS_STATS_INC(vn_remove);
  931. XFS_STATS_INC(vn_reclaim);
  932. XFS_STATS_DEC(vn_active);
  933. xfs_inactive(ip);
  934. xfs_iflags_clear(ip, XFS_IMODIFIED);
  935. if (xfs_reclaim(ip))
  936. panic("%s: cannot reclaim 0x%p\n", __func__, inode);
  937. }
  938. ASSERT(XFS_I(inode) == NULL);
  939. }
  940. /*
  941. * Enqueue a work item to be picked up by the vfs xfssyncd thread.
  942. * Doing this has two advantages:
  943. * - It saves on stack space, which is tight in certain situations
  944. * - It can be used (with care) as a mechanism to avoid deadlocks.
  945. * Flushing while allocating in a full filesystem requires both.
  946. */
  947. STATIC void
  948. xfs_syncd_queue_work(
  949. struct xfs_mount *mp,
  950. void *data,
  951. void (*syncer)(struct xfs_mount *, void *))
  952. {
  953. struct bhv_vfs_sync_work *work;
  954. work = kmem_alloc(sizeof(struct bhv_vfs_sync_work), KM_SLEEP);
  955. INIT_LIST_HEAD(&work->w_list);
  956. work->w_syncer = syncer;
  957. work->w_data = data;
  958. work->w_mount = mp;
  959. spin_lock(&mp->m_sync_lock);
  960. list_add_tail(&work->w_list, &mp->m_sync_list);
  961. spin_unlock(&mp->m_sync_lock);
  962. wake_up_process(mp->m_sync_task);
  963. }
  964. /*
  965. * Flush delayed allocate data, attempting to free up reserved space
  966. * from existing allocations. At this point a new allocation attempt
  967. * has failed with ENOSPC and we are in the process of scratching our
  968. * heads, looking about for more room...
  969. */
  970. STATIC void
  971. xfs_flush_inode_work(
  972. struct xfs_mount *mp,
  973. void *arg)
  974. {
  975. struct inode *inode = arg;
  976. filemap_flush(inode->i_mapping);
  977. iput(inode);
  978. }
  979. void
  980. xfs_flush_inode(
  981. xfs_inode_t *ip)
  982. {
  983. struct inode *inode = ip->i_vnode;
  984. igrab(inode);
  985. xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work);
  986. delay(msecs_to_jiffies(500));
  987. }
  988. /*
  989. * This is the "bigger hammer" version of xfs_flush_inode_work...
  990. * (IOW, "If at first you don't succeed, use a Bigger Hammer").
  991. */
  992. STATIC void
  993. xfs_flush_device_work(
  994. struct xfs_mount *mp,
  995. void *arg)
  996. {
  997. struct inode *inode = arg;
  998. sync_blockdev(mp->m_super->s_bdev);
  999. iput(inode);
  1000. }
  1001. void
  1002. xfs_flush_device(
  1003. xfs_inode_t *ip)
  1004. {
  1005. struct inode *inode = vn_to_inode(XFS_ITOV(ip));
  1006. igrab(inode);
  1007. xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_device_work);
  1008. delay(msecs_to_jiffies(500));
  1009. xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
  1010. }
  1011. STATIC void
  1012. xfs_sync_worker(
  1013. struct xfs_mount *mp,
  1014. void *unused)
  1015. {
  1016. int error;
  1017. if (!(mp->m_flags & XFS_MOUNT_RDONLY))
  1018. error = xfs_sync(mp, SYNC_FSDATA | SYNC_BDFLUSH | SYNC_ATTR);
  1019. mp->m_sync_seq++;
  1020. wake_up(&mp->m_wait_single_sync_task);
  1021. }
  1022. STATIC int
  1023. xfssyncd(
  1024. void *arg)
  1025. {
  1026. struct xfs_mount *mp = arg;
  1027. long timeleft;
  1028. bhv_vfs_sync_work_t *work, *n;
  1029. LIST_HEAD (tmp);
  1030. set_freezable();
  1031. timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
  1032. for (;;) {
  1033. timeleft = schedule_timeout_interruptible(timeleft);
  1034. /* swsusp */
  1035. try_to_freeze();
  1036. if (kthread_should_stop() && list_empty(&mp->m_sync_list))
  1037. break;
  1038. spin_lock(&mp->m_sync_lock);
  1039. /*
  1040. * We can get woken by laptop mode, to do a sync -
  1041. * that's the (only!) case where the list would be
  1042. * empty with time remaining.
  1043. */
  1044. if (!timeleft || list_empty(&mp->m_sync_list)) {
  1045. if (!timeleft)
  1046. timeleft = xfs_syncd_centisecs *
  1047. msecs_to_jiffies(10);
  1048. INIT_LIST_HEAD(&mp->m_sync_work.w_list);
  1049. list_add_tail(&mp->m_sync_work.w_list,
  1050. &mp->m_sync_list);
  1051. }
  1052. list_for_each_entry_safe(work, n, &mp->m_sync_list, w_list)
  1053. list_move(&work->w_list, &tmp);
  1054. spin_unlock(&mp->m_sync_lock);
  1055. list_for_each_entry_safe(work, n, &tmp, w_list) {
  1056. (*work->w_syncer)(mp, work->w_data);
  1057. list_del(&work->w_list);
  1058. if (work == &mp->m_sync_work)
  1059. continue;
  1060. kmem_free(work);
  1061. }
  1062. }
  1063. return 0;
  1064. }
  1065. STATIC void
  1066. xfs_fs_put_super(
  1067. struct super_block *sb)
  1068. {
  1069. struct xfs_mount *mp = XFS_M(sb);
  1070. struct xfs_inode *rip = mp->m_rootip;
  1071. int unmount_event_flags = 0;
  1072. int error;
  1073. kthread_stop(mp->m_sync_task);
  1074. xfs_sync(mp, SYNC_ATTR | SYNC_DELWRI);
  1075. #ifdef HAVE_DMAPI
  1076. if (mp->m_flags & XFS_MOUNT_DMAPI) {
  1077. unmount_event_flags =
  1078. (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ?
  1079. 0 : DM_FLAGS_UNWANTED;
  1080. /*
  1081. * Ignore error from dmapi here, first unmount is not allowed
  1082. * to fail anyway, and second we wouldn't want to fail a
  1083. * unmount because of dmapi.
  1084. */
  1085. XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL,
  1086. NULL, NULL, 0, 0, unmount_event_flags);
  1087. }
  1088. #endif
  1089. /*
  1090. * Blow away any referenced inode in the filestreams cache.
  1091. * This can and will cause log traffic as inodes go inactive
  1092. * here.
  1093. */
  1094. xfs_filestream_unmount(mp);
  1095. XFS_bflush(mp->m_ddev_targp);
  1096. error = xfs_unmount_flush(mp, 0);
  1097. WARN_ON(error);
  1098. IRELE(rip);
  1099. /*
  1100. * If we're forcing a shutdown, typically because of a media error,
  1101. * we want to make sure we invalidate dirty pages that belong to
  1102. * referenced vnodes as well.
  1103. */
  1104. if (XFS_FORCED_SHUTDOWN(mp)) {
  1105. error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE);
  1106. ASSERT(error != EFSCORRUPTED);
  1107. }
  1108. if (mp->m_flags & XFS_MOUNT_DMAPI) {
  1109. XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0,
  1110. unmount_event_flags);
  1111. }
  1112. xfs_unmountfs(mp);
  1113. xfs_icsb_destroy_counters(mp);
  1114. xfs_close_devices(mp);
  1115. xfs_qmops_put(mp);
  1116. xfs_dmops_put(mp);
  1117. kfree(mp);
  1118. }
  1119. STATIC void
  1120. xfs_fs_write_super(
  1121. struct super_block *sb)
  1122. {
  1123. if (!(sb->s_flags & MS_RDONLY))
  1124. xfs_sync(XFS_M(sb), SYNC_FSDATA);
  1125. sb->s_dirt = 0;
  1126. }
  1127. STATIC int
  1128. xfs_fs_sync_super(
  1129. struct super_block *sb,
  1130. int wait)
  1131. {
  1132. struct xfs_mount *mp = XFS_M(sb);
  1133. int error;
  1134. int flags;
  1135. /*
  1136. * Treat a sync operation like a freeze. This is to work
  1137. * around a race in sync_inodes() which works in two phases
  1138. * - an asynchronous flush, which can write out an inode
  1139. * without waiting for file size updates to complete, and a
  1140. * synchronous flush, which wont do anything because the
  1141. * async flush removed the inode's dirty flag. Also
  1142. * sync_inodes() will not see any files that just have
  1143. * outstanding transactions to be flushed because we don't
  1144. * dirty the Linux inode until after the transaction I/O
  1145. * completes.
  1146. */
  1147. if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE)) {
  1148. /*
  1149. * First stage of freeze - no more writers will make progress
  1150. * now we are here, so we flush delwri and delalloc buffers
  1151. * here, then wait for all I/O to complete. Data is frozen at
  1152. * that point. Metadata is not frozen, transactions can still
  1153. * occur here so don't bother flushing the buftarg (i.e
  1154. * SYNC_QUIESCE) because it'll just get dirty again.
  1155. */
  1156. flags = SYNC_DATA_QUIESCE;
  1157. } else
  1158. flags = SYNC_FSDATA;
  1159. error = xfs_sync(mp, flags);
  1160. sb->s_dirt = 0;
  1161. if (unlikely(laptop_mode)) {
  1162. int prev_sync_seq = mp->m_sync_seq;
  1163. /*
  1164. * The disk must be active because we're syncing.
  1165. * We schedule xfssyncd now (now that the disk is
  1166. * active) instead of later (when it might not be).
  1167. */
  1168. wake_up_process(mp->m_sync_task);
  1169. /*
  1170. * We have to wait for the sync iteration to complete.
  1171. * If we don't, the disk activity caused by the sync
  1172. * will come after the sync is completed, and that
  1173. * triggers another sync from laptop mode.
  1174. */
  1175. wait_event(mp->m_wait_single_sync_task,
  1176. mp->m_sync_seq != prev_sync_seq);
  1177. }
  1178. return -error;
  1179. }
  1180. STATIC int
  1181. xfs_fs_statfs(
  1182. struct dentry *dentry,
  1183. struct kstatfs *statp)
  1184. {
  1185. struct xfs_mount *mp = XFS_M(dentry->d_sb);
  1186. xfs_sb_t *sbp = &mp->m_sb;
  1187. __uint64_t fakeinos, id;
  1188. xfs_extlen_t lsize;
  1189. statp->f_type = XFS_SB_MAGIC;
  1190. statp->f_namelen = MAXNAMELEN - 1;
  1191. id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
  1192. statp->f_fsid.val[0] = (u32)id;
  1193. statp->f_fsid.val[1] = (u32)(id >> 32);
  1194. xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
  1195. spin_lock(&mp->m_sb_lock);
  1196. statp->f_bsize = sbp->sb_blocksize;
  1197. lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
  1198. statp->f_blocks = sbp->sb_dblocks - lsize;
  1199. statp->f_bfree = statp->f_bavail =
  1200. sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
  1201. fakeinos = statp->f_bfree << sbp->sb_inopblog;
  1202. #if XFS_BIG_INUMS
  1203. fakeinos += mp->m_inoadd;
  1204. #endif
  1205. statp->f_files =
  1206. MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
  1207. if (mp->m_maxicount)
  1208. #if XFS_BIG_INUMS
  1209. if (!mp->m_inoadd)
  1210. #endif
  1211. statp->f_files = min_t(typeof(statp->f_files),
  1212. statp->f_files,
  1213. mp->m_maxicount);
  1214. statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
  1215. spin_unlock(&mp->m_sb_lock);
  1216. XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp);
  1217. return 0;
  1218. }
  1219. STATIC int
  1220. xfs_fs_remount(
  1221. struct super_block *sb,
  1222. int *flags,
  1223. char *options)
  1224. {
  1225. struct xfs_mount *mp = XFS_M(sb);
  1226. struct xfs_mount_args *args;
  1227. int error;
  1228. args = xfs_args_allocate(sb, 0);
  1229. if (!args)
  1230. return -ENOMEM;
  1231. error = xfs_parseargs(mp, options, args, 1);
  1232. if (error)
  1233. goto out_free_args;
  1234. if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */
  1235. if (mp->m_flags & XFS_MOUNT_RDONLY)
  1236. mp->m_flags &= ~XFS_MOUNT_RDONLY;
  1237. if (args->flags & XFSMNT_BARRIER) {
  1238. mp->m_flags |= XFS_MOUNT_BARRIER;
  1239. xfs_mountfs_check_barriers(mp);
  1240. } else {
  1241. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  1242. }
  1243. } else if (!(mp->m_flags & XFS_MOUNT_RDONLY)) { /* rw -> ro */
  1244. xfs_filestream_flush(mp);
  1245. xfs_sync(mp, SYNC_DATA_QUIESCE);
  1246. xfs_attr_quiesce(mp);
  1247. mp->m_flags |= XFS_MOUNT_RDONLY;
  1248. }
  1249. out_free_args:
  1250. kfree(args);
  1251. return -error;
  1252. }
  1253. /*
  1254. * Second stage of a freeze. The data is already frozen so we only
  1255. * need to take care of themetadata. Once that's done write a dummy
  1256. * record to dirty the log in case of a crash while frozen.
  1257. */
  1258. STATIC void
  1259. xfs_fs_lockfs(
  1260. struct super_block *sb)
  1261. {
  1262. struct xfs_mount *mp = XFS_M(sb);
  1263. xfs_attr_quiesce(mp);
  1264. xfs_fs_log_dummy(mp);
  1265. }
  1266. STATIC int
  1267. xfs_fs_show_options(
  1268. struct seq_file *m,
  1269. struct vfsmount *mnt)
  1270. {
  1271. return -xfs_showargs(XFS_M(mnt->mnt_sb), m);
  1272. }
  1273. STATIC int
  1274. xfs_fs_quotasync(
  1275. struct super_block *sb,
  1276. int type)
  1277. {
  1278. return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XQUOTASYNC, 0, NULL);
  1279. }
  1280. STATIC int
  1281. xfs_fs_getxstate(
  1282. struct super_block *sb,
  1283. struct fs_quota_stat *fqs)
  1284. {
  1285. return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XGETQSTAT, 0, (caddr_t)fqs);
  1286. }
  1287. STATIC int
  1288. xfs_fs_setxstate(
  1289. struct super_block *sb,
  1290. unsigned int flags,
  1291. int op)
  1292. {
  1293. return -XFS_QM_QUOTACTL(XFS_M(sb), op, 0, (caddr_t)&flags);
  1294. }
  1295. STATIC int
  1296. xfs_fs_getxquota(
  1297. struct super_block *sb,
  1298. int type,
  1299. qid_t id,
  1300. struct fs_disk_quota *fdq)
  1301. {
  1302. return -XFS_QM_QUOTACTL(XFS_M(sb),
  1303. (type == USRQUOTA) ? Q_XGETQUOTA :
  1304. ((type == GRPQUOTA) ? Q_XGETGQUOTA :
  1305. Q_XGETPQUOTA), id, (caddr_t)fdq);
  1306. }
  1307. STATIC int
  1308. xfs_fs_setxquota(
  1309. struct super_block *sb,
  1310. int type,
  1311. qid_t id,
  1312. struct fs_disk_quota *fdq)
  1313. {
  1314. return -XFS_QM_QUOTACTL(XFS_M(sb),
  1315. (type == USRQUOTA) ? Q_XSETQLIM :
  1316. ((type == GRPQUOTA) ? Q_XSETGQLIM :
  1317. Q_XSETPQLIM), id, (caddr_t)fdq);
  1318. }
  1319. /*
  1320. * This function fills in xfs_mount_t fields based on mount args.
  1321. * Note: the superblock has _not_ yet been read in.
  1322. */
  1323. STATIC int
  1324. xfs_start_flags(
  1325. struct xfs_mount_args *ap,
  1326. struct xfs_mount *mp)
  1327. {
  1328. /* Values are in BBs */
  1329. if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
  1330. /*
  1331. * At this point the superblock has not been read
  1332. * in, therefore we do not know the block size.
  1333. * Before the mount call ends we will convert
  1334. * these to FSBs.
  1335. */
  1336. mp->m_dalign = ap->sunit;
  1337. mp->m_swidth = ap->swidth;
  1338. }
  1339. if (ap->logbufs != -1 &&
  1340. ap->logbufs != 0 &&
  1341. (ap->logbufs < XLOG_MIN_ICLOGS ||
  1342. ap->logbufs > XLOG_MAX_ICLOGS)) {
  1343. cmn_err(CE_WARN,
  1344. "XFS: invalid logbufs value: %d [not %d-%d]",
  1345. ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
  1346. return XFS_ERROR(EINVAL);
  1347. }
  1348. mp->m_logbufs = ap->logbufs;
  1349. if (ap->logbufsize != -1 &&
  1350. ap->logbufsize != 0 &&
  1351. (ap->logbufsize < XLOG_MIN_RECORD_BSIZE ||
  1352. ap->logbufsize > XLOG_MAX_RECORD_BSIZE ||
  1353. !is_power_of_2(ap->logbufsize))) {
  1354. cmn_err(CE_WARN,
  1355. "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
  1356. ap->logbufsize);
  1357. return XFS_ERROR(EINVAL);
  1358. }
  1359. mp->m_logbsize = ap->logbufsize;
  1360. mp->m_fsname_len = strlen(ap->fsname) + 1;
  1361. mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
  1362. strcpy(mp->m_fsname, ap->fsname);
  1363. if (ap->rtname[0]) {
  1364. mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP);
  1365. strcpy(mp->m_rtname, ap->rtname);
  1366. }
  1367. if (ap->logname[0]) {
  1368. mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP);
  1369. strcpy(mp->m_logname, ap->logname);
  1370. }
  1371. if (ap->flags & XFSMNT_WSYNC)
  1372. mp->m_flags |= XFS_MOUNT_WSYNC;
  1373. #if XFS_BIG_INUMS
  1374. if (ap->flags & XFSMNT_INO64) {
  1375. mp->m_flags |= XFS_MOUNT_INO64;
  1376. mp->m_inoadd = XFS_INO64_OFFSET;
  1377. }
  1378. #endif
  1379. if (ap->flags & XFSMNT_RETERR)
  1380. mp->m_flags |= XFS_MOUNT_RETERR;
  1381. if (ap->flags & XFSMNT_NOALIGN)
  1382. mp->m_flags |= XFS_MOUNT_NOALIGN;
  1383. if (ap->flags & XFSMNT_SWALLOC)
  1384. mp->m_flags |= XFS_MOUNT_SWALLOC;
  1385. if (ap->flags & XFSMNT_OSYNCISOSYNC)
  1386. mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
  1387. if (ap->flags & XFSMNT_32BITINODES)
  1388. mp->m_flags |= XFS_MOUNT_32BITINODES;
  1389. if (ap->flags & XFSMNT_IOSIZE) {
  1390. if (ap->iosizelog > XFS_MAX_IO_LOG ||
  1391. ap->iosizelog < XFS_MIN_IO_LOG) {
  1392. cmn_err(CE_WARN,
  1393. "XFS: invalid log iosize: %d [not %d-%d]",
  1394. ap->iosizelog, XFS_MIN_IO_LOG,
  1395. XFS_MAX_IO_LOG);
  1396. return XFS_ERROR(EINVAL);
  1397. }
  1398. mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
  1399. mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
  1400. }
  1401. if (ap->flags & XFSMNT_IKEEP)
  1402. mp->m_flags |= XFS_MOUNT_IKEEP;
  1403. if (ap->flags & XFSMNT_DIRSYNC)
  1404. mp->m_flags |= XFS_MOUNT_DIRSYNC;
  1405. if (ap->flags & XFSMNT_ATTR2)
  1406. mp->m_flags |= XFS_MOUNT_ATTR2;
  1407. if (ap->flags & XFSMNT_NOATTR2)
  1408. mp->m_flags |= XFS_MOUNT_NOATTR2;
  1409. if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
  1410. mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
  1411. /*
  1412. * no recovery flag requires a read-only mount
  1413. */
  1414. if (ap->flags & XFSMNT_NORECOVERY) {
  1415. if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
  1416. cmn_err(CE_WARN,
  1417. "XFS: tried to mount a FS read-write without recovery!");
  1418. return XFS_ERROR(EINVAL);
  1419. }
  1420. mp->m_flags |= XFS_MOUNT_NORECOVERY;
  1421. }
  1422. if (ap->flags & XFSMNT_NOUUID)
  1423. mp->m_flags |= XFS_MOUNT_NOUUID;
  1424. if (ap->flags & XFSMNT_BARRIER)
  1425. mp->m_flags |= XFS_MOUNT_BARRIER;
  1426. else
  1427. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  1428. if (ap->flags2 & XFSMNT2_FILESTREAMS)
  1429. mp->m_flags |= XFS_MOUNT_FILESTREAMS;
  1430. if (ap->flags & XFSMNT_DMAPI)
  1431. mp->m_flags |= XFS_MOUNT_DMAPI;
  1432. return 0;
  1433. }
  1434. /*
  1435. * This function fills in xfs_mount_t fields based on mount args.
  1436. * Note: the superblock _has_ now been read in.
  1437. */
  1438. STATIC int
  1439. xfs_finish_flags(
  1440. struct xfs_mount_args *ap,
  1441. struct xfs_mount *mp)
  1442. {
  1443. int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
  1444. /* Fail a mount where the logbuf is smaller then the log stripe */
  1445. if (xfs_sb_version_haslogv2(&mp->m_sb)) {
  1446. if ((ap->logbufsize <= 0) &&
  1447. (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
  1448. mp->m_logbsize = mp->m_sb.sb_logsunit;
  1449. } else if (ap->logbufsize > 0 &&
  1450. ap->logbufsize < mp->m_sb.sb_logsunit) {
  1451. cmn_err(CE_WARN,
  1452. "XFS: logbuf size must be greater than or equal to log stripe size");
  1453. return XFS_ERROR(EINVAL);
  1454. }
  1455. } else {
  1456. /* Fail a mount if the logbuf is larger than 32K */
  1457. if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) {
  1458. cmn_err(CE_WARN,
  1459. "XFS: logbuf size for version 1 logs must be 16K or 32K");
  1460. return XFS_ERROR(EINVAL);
  1461. }
  1462. }
  1463. /*
  1464. * mkfs'ed attr2 will turn on attr2 mount unless explicitly
  1465. * told by noattr2 to turn it off
  1466. */
  1467. if (xfs_sb_version_hasattr2(&mp->m_sb) &&
  1468. !(ap->flags & XFSMNT_NOATTR2))
  1469. mp->m_flags |= XFS_MOUNT_ATTR2;
  1470. /*
  1471. * prohibit r/w mounts of read-only filesystems
  1472. */
  1473. if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
  1474. cmn_err(CE_WARN,
  1475. "XFS: cannot mount a read-only filesystem as read-write");
  1476. return XFS_ERROR(EROFS);
  1477. }
  1478. /*
  1479. * check for shared mount.
  1480. */
  1481. if (ap->flags & XFSMNT_SHARED) {
  1482. if (!xfs_sb_version_hasshared(&mp->m_sb))
  1483. return XFS_ERROR(EINVAL);
  1484. /*
  1485. * For IRIX 6.5, shared mounts must have the shared
  1486. * version bit set, have the persistent readonly
  1487. * field set, must be version 0 and can only be mounted
  1488. * read-only.
  1489. */
  1490. if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
  1491. (mp->m_sb.sb_shared_vn != 0))
  1492. return XFS_ERROR(EINVAL);
  1493. mp->m_flags |= XFS_MOUNT_SHARED;
  1494. /*
  1495. * Shared XFS V0 can't deal with DMI. Return EINVAL.
  1496. */
  1497. if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI))
  1498. return XFS_ERROR(EINVAL);
  1499. }
  1500. if (ap->flags & XFSMNT_UQUOTA) {
  1501. mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
  1502. if (ap->flags & XFSMNT_UQUOTAENF)
  1503. mp->m_qflags |= XFS_UQUOTA_ENFD;
  1504. }
  1505. if (ap->flags & XFSMNT_GQUOTA) {
  1506. mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
  1507. if (ap->flags & XFSMNT_GQUOTAENF)
  1508. mp->m_qflags |= XFS_OQUOTA_ENFD;
  1509. } else if (ap->flags & XFSMNT_PQUOTA) {
  1510. mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
  1511. if (ap->flags & XFSMNT_PQUOTAENF)
  1512. mp->m_qflags |= XFS_OQUOTA_ENFD;
  1513. }
  1514. return 0;
  1515. }
  1516. STATIC int
  1517. xfs_fs_fill_super(
  1518. struct super_block *sb,
  1519. void *data,
  1520. int silent)
  1521. {
  1522. struct inode *root;
  1523. struct xfs_mount *mp = NULL;
  1524. struct xfs_mount_args *args;
  1525. int flags = 0, error = ENOMEM;
  1526. args = xfs_args_allocate(sb, silent);
  1527. if (!args)
  1528. return -ENOMEM;
  1529. mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
  1530. if (!mp)
  1531. goto out_free_args;
  1532. spin_lock_init(&mp->m_sb_lock);
  1533. mutex_init(&mp->m_ilock);
  1534. mutex_init(&mp->m_growlock);
  1535. atomic_set(&mp->m_active_trans, 0);
  1536. INIT_LIST_HEAD(&mp->m_sync_list);
  1537. spin_lock_init(&mp->m_sync_lock);
  1538. init_waitqueue_head(&mp->m_wait_single_sync_task);
  1539. mp->m_super = sb;
  1540. sb->s_fs_info = mp;
  1541. if (sb->s_flags & MS_RDONLY)
  1542. mp->m_flags |= XFS_MOUNT_RDONLY;
  1543. error = xfs_parseargs(mp, (char *)data, args, 0);
  1544. if (error)
  1545. goto out_free_mp;
  1546. sb_min_blocksize(sb, BBSIZE);
  1547. sb->s_xattr = xfs_xattr_handlers;
  1548. sb->s_export_op = &xfs_export_operations;
  1549. sb->s_qcop = &xfs_quotactl_operations;
  1550. sb->s_op = &xfs_super_operations;
  1551. error = xfs_dmops_get(mp, args);
  1552. if (error)
  1553. goto out_free_mp;
  1554. error = xfs_qmops_get(mp, args);
  1555. if (error)
  1556. goto out_put_dmops;
  1557. if (args->flags & XFSMNT_QUIET)
  1558. flags |= XFS_MFSI_QUIET;
  1559. error = xfs_open_devices(mp, args);
  1560. if (error)
  1561. goto out_put_qmops;
  1562. if (xfs_icsb_init_counters(mp))
  1563. mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB;
  1564. /*
  1565. * Setup flags based on mount(2) options and then the superblock
  1566. */
  1567. error = xfs_start_flags(args, mp);
  1568. if (error)
  1569. goto out_destroy_counters;
  1570. error = xfs_readsb(mp, flags);
  1571. if (error)
  1572. goto out_destroy_counters;
  1573. error = xfs_finish_flags(args, mp);
  1574. if (error)
  1575. goto out_free_sb;
  1576. error = xfs_setup_devices(mp);
  1577. if (error)
  1578. goto out_free_sb;
  1579. if (mp->m_flags & XFS_MOUNT_BARRIER)
  1580. xfs_mountfs_check_barriers(mp);
  1581. error = xfs_filestream_mount(mp);
  1582. if (error)
  1583. goto out_free_sb;
  1584. error = xfs_mountfs(mp, flags);
  1585. if (error)
  1586. goto out_filestream_unmount;
  1587. XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
  1588. sb->s_dirt = 1;
  1589. sb->s_magic = XFS_SB_MAGIC;
  1590. sb->s_blocksize = mp->m_sb.sb_blocksize;
  1591. sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
  1592. sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
  1593. sb->s_time_gran = 1;
  1594. set_posix_acl_flag(sb);
  1595. root = igrab(mp->m_rootip->i_vnode);
  1596. if (!root) {
  1597. error = ENOENT;
  1598. goto fail_unmount;
  1599. }
  1600. if (is_bad_inode(root)) {
  1601. error = EINVAL;
  1602. goto fail_vnrele;
  1603. }
  1604. sb->s_root = d_alloc_root(root);
  1605. if (!sb->s_root) {
  1606. error = ENOMEM;
  1607. goto fail_vnrele;
  1608. }
  1609. mp->m_sync_work.w_syncer = xfs_sync_worker;
  1610. mp->m_sync_work.w_mount = mp;
  1611. mp->m_sync_task = kthread_run(xfssyncd, mp, "xfssyncd");
  1612. if (IS_ERR(mp->m_sync_task)) {
  1613. error = -PTR_ERR(mp->m_sync_task);
  1614. goto fail_vnrele;
  1615. }
  1616. xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
  1617. kfree(args);
  1618. return 0;
  1619. out_filestream_unmount:
  1620. xfs_filestream_unmount(mp);
  1621. out_free_sb:
  1622. xfs_freesb(mp);
  1623. out_destroy_counters:
  1624. xfs_icsb_destroy_counters(mp);
  1625. xfs_close_devices(mp);
  1626. out_put_qmops:
  1627. xfs_qmops_put(mp);
  1628. out_put_dmops:
  1629. xfs_dmops_put(mp);
  1630. out_free_mp:
  1631. kfree(mp);
  1632. out_free_args:
  1633. kfree(args);
  1634. return -error;
  1635. fail_vnrele:
  1636. if (sb->s_root) {
  1637. dput(sb->s_root);
  1638. sb->s_root = NULL;
  1639. } else {
  1640. iput(root);
  1641. }
  1642. fail_unmount:
  1643. /*
  1644. * Blow away any referenced inode in the filestreams cache.
  1645. * This can and will cause log traffic as inodes go inactive
  1646. * here.
  1647. */
  1648. xfs_filestream_unmount(mp);
  1649. XFS_bflush(mp->m_ddev_targp);
  1650. error = xfs_unmount_flush(mp, 0);
  1651. WARN_ON(error);
  1652. IRELE(mp->m_rootip);
  1653. xfs_unmountfs(mp);
  1654. goto out_destroy_counters;
  1655. }
  1656. STATIC int
  1657. xfs_fs_get_sb(
  1658. struct file_system_type *fs_type,
  1659. int flags,
  1660. const char *dev_name,
  1661. void *data,
  1662. struct vfsmount *mnt)
  1663. {
  1664. return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
  1665. mnt);
  1666. }
  1667. static struct super_operations xfs_super_operations = {
  1668. .alloc_inode = xfs_fs_alloc_inode,
  1669. .destroy_inode = xfs_fs_destroy_inode,
  1670. .write_inode = xfs_fs_write_inode,
  1671. .clear_inode = xfs_fs_clear_inode,
  1672. .put_super = xfs_fs_put_super,
  1673. .write_super = xfs_fs_write_super,
  1674. .sync_fs = xfs_fs_sync_super,
  1675. .write_super_lockfs = xfs_fs_lockfs,
  1676. .statfs = xfs_fs_statfs,
  1677. .remount_fs = xfs_fs_remount,
  1678. .show_options = xfs_fs_show_options,
  1679. };
  1680. static struct quotactl_ops xfs_quotactl_operations = {
  1681. .quota_sync = xfs_fs_quotasync,
  1682. .get_xstate = xfs_fs_getxstate,
  1683. .set_xstate = xfs_fs_setxstate,
  1684. .get_xquota = xfs_fs_getxquota,
  1685. .set_xquota = xfs_fs_setxquota,
  1686. };
  1687. static struct file_system_type xfs_fs_type = {
  1688. .owner = THIS_MODULE,
  1689. .name = "xfs",
  1690. .get_sb = xfs_fs_get_sb,
  1691. .kill_sb = kill_block_super,
  1692. .fs_flags = FS_REQUIRES_DEV,
  1693. };
  1694. STATIC int __init
  1695. xfs_alloc_trace_bufs(void)
  1696. {
  1697. #ifdef XFS_ALLOC_TRACE
  1698. xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
  1699. if (!xfs_alloc_trace_buf)
  1700. goto out;
  1701. #endif
  1702. #ifdef XFS_BMAP_TRACE
  1703. xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
  1704. if (!xfs_bmap_trace_buf)
  1705. goto out_free_alloc_trace;
  1706. #endif
  1707. #ifdef XFS_BMBT_TRACE
  1708. xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
  1709. if (!xfs_bmbt_trace_buf)
  1710. goto out_free_bmap_trace;
  1711. #endif
  1712. #ifdef XFS_ATTR_TRACE
  1713. xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
  1714. if (!xfs_attr_trace_buf)
  1715. goto out_free_bmbt_trace;
  1716. #endif
  1717. #ifdef XFS_DIR2_TRACE
  1718. xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
  1719. if (!xfs_dir2_trace_buf)
  1720. goto out_free_attr_trace;
  1721. #endif
  1722. return 0;
  1723. #ifdef XFS_DIR2_TRACE
  1724. out_free_attr_trace:
  1725. #endif
  1726. #ifdef XFS_ATTR_TRACE
  1727. ktrace_free(xfs_attr_trace_buf);
  1728. out_free_bmbt_trace:
  1729. #endif
  1730. #ifdef XFS_BMBT_TRACE
  1731. ktrace_free(xfs_bmbt_trace_buf);
  1732. out_free_bmap_trace:
  1733. #endif
  1734. #ifdef XFS_BMAP_TRACE
  1735. ktrace_free(xfs_bmap_trace_buf);
  1736. out_free_alloc_trace:
  1737. #endif
  1738. #ifdef XFS_ALLOC_TRACE
  1739. ktrace_free(xfs_alloc_trace_buf);
  1740. out:
  1741. #endif
  1742. return -ENOMEM;
  1743. }
  1744. STATIC void
  1745. xfs_free_trace_bufs(void)
  1746. {
  1747. #ifdef XFS_DIR2_TRACE
  1748. ktrace_free(xfs_dir2_trace_buf);
  1749. #endif
  1750. #ifdef XFS_ATTR_TRACE
  1751. ktrace_free(xfs_attr_trace_buf);
  1752. #endif
  1753. #ifdef XFS_BMBT_TRACE
  1754. ktrace_free(xfs_bmbt_trace_buf);
  1755. #endif
  1756. #ifdef XFS_BMAP_TRACE
  1757. ktrace_free(xfs_bmap_trace_buf);
  1758. #endif
  1759. #ifdef XFS_ALLOC_TRACE
  1760. ktrace_free(xfs_alloc_trace_buf);
  1761. #endif
  1762. }
  1763. STATIC int __init
  1764. xfs_init_zones(void)
  1765. {
  1766. xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode",
  1767. KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
  1768. KM_ZONE_SPREAD,
  1769. xfs_fs_inode_init_once);
  1770. if (!xfs_vnode_zone)
  1771. goto out;
  1772. xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
  1773. if (!xfs_ioend_zone)
  1774. goto out_destroy_vnode_zone;
  1775. xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
  1776. xfs_ioend_zone);
  1777. if (!xfs_ioend_pool)
  1778. goto out_destroy_ioend_zone;
  1779. xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
  1780. "xfs_log_ticket");
  1781. if (!xfs_log_ticket_zone)
  1782. goto out_destroy_ioend_pool;
  1783. xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
  1784. "xfs_bmap_free_item");
  1785. if (!xfs_bmap_free_item_zone)
  1786. goto out_destroy_log_ticket_zone;
  1787. xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
  1788. "xfs_btree_cur");
  1789. if (!xfs_btree_cur_zone)
  1790. goto out_destroy_bmap_free_item_zone;
  1791. xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
  1792. "xfs_da_state");
  1793. if (!xfs_da_state_zone)
  1794. goto out_destroy_btree_cur_zone;
  1795. xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
  1796. if (!xfs_dabuf_zone)
  1797. goto out_destroy_da_state_zone;
  1798. xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
  1799. if (!xfs_ifork_zone)
  1800. goto out_destroy_dabuf_zone;
  1801. xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
  1802. if (!xfs_trans_zone)
  1803. goto out_destroy_ifork_zone;
  1804. /*
  1805. * The size of the zone allocated buf log item is the maximum
  1806. * size possible under XFS. This wastes a little bit of memory,
  1807. * but it is much faster.
  1808. */
  1809. xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) +
  1810. (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
  1811. NBWORD) * sizeof(int))), "xfs_buf_item");
  1812. if (!xfs_buf_item_zone)
  1813. goto out_destroy_trans_zone;
  1814. xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
  1815. ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
  1816. sizeof(xfs_extent_t))), "xfs_efd_item");
  1817. if (!xfs_efd_zone)
  1818. goto out_destroy_buf_item_zone;
  1819. xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
  1820. ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
  1821. sizeof(xfs_extent_t))), "xfs_efi_item");
  1822. if (!xfs_efi_zone)
  1823. goto out_destroy_efd_zone;
  1824. xfs_inode_zone =
  1825. kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
  1826. KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
  1827. KM_ZONE_SPREAD, NULL);
  1828. if (!xfs_inode_zone)
  1829. goto out_destroy_efi_zone;
  1830. xfs_ili_zone =
  1831. kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
  1832. KM_ZONE_SPREAD, NULL);
  1833. if (!xfs_ili_zone)
  1834. goto out_destroy_inode_zone;
  1835. #ifdef CONFIG_XFS_POSIX_ACL
  1836. xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl");
  1837. if (!xfs_acl_zone)
  1838. goto out_destroy_ili_zone;
  1839. #endif
  1840. return 0;
  1841. #ifdef CONFIG_XFS_POSIX_ACL
  1842. out_destroy_ili_zone:
  1843. #endif
  1844. kmem_zone_destroy(xfs_ili_zone);
  1845. out_destroy_inode_zone:
  1846. kmem_zone_destroy(xfs_inode_zone);
  1847. out_destroy_efi_zone:
  1848. kmem_zone_destroy(xfs_efi_zone);
  1849. out_destroy_efd_zone:
  1850. kmem_zone_destroy(xfs_efd_zone);
  1851. out_destroy_buf_item_zone:
  1852. kmem_zone_destroy(xfs_buf_item_zone);
  1853. out_destroy_trans_zone:
  1854. kmem_zone_destroy(xfs_trans_zone);
  1855. out_destroy_ifork_zone:
  1856. kmem_zone_destroy(xfs_ifork_zone);
  1857. out_destroy_dabuf_zone:
  1858. kmem_zone_destroy(xfs_dabuf_zone);
  1859. out_destroy_da_state_zone:
  1860. kmem_zone_destroy(xfs_da_state_zone);
  1861. out_destroy_btree_cur_zone:
  1862. kmem_zone_destroy(xfs_btree_cur_zone);
  1863. out_destroy_bmap_free_item_zone:
  1864. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1865. out_destroy_log_ticket_zone:
  1866. kmem_zone_destroy(xfs_log_ticket_zone);
  1867. out_destroy_ioend_pool:
  1868. mempool_destroy(xfs_ioend_pool);
  1869. out_destroy_ioend_zone:
  1870. kmem_zone_destroy(xfs_ioend_zone);
  1871. out_destroy_vnode_zone:
  1872. kmem_zone_destroy(xfs_vnode_zone);
  1873. out:
  1874. return -ENOMEM;
  1875. }
  1876. STATIC void
  1877. xfs_destroy_zones(void)
  1878. {
  1879. #ifdef CONFIG_XFS_POSIX_ACL
  1880. kmem_zone_destroy(xfs_acl_zone);
  1881. #endif
  1882. kmem_zone_destroy(xfs_ili_zone);
  1883. kmem_zone_destroy(xfs_inode_zone);
  1884. kmem_zone_destroy(xfs_efi_zone);
  1885. kmem_zone_destroy(xfs_efd_zone);
  1886. kmem_zone_destroy(xfs_buf_item_zone);
  1887. kmem_zone_destroy(xfs_trans_zone);
  1888. kmem_zone_destroy(xfs_ifork_zone);
  1889. kmem_zone_destroy(xfs_dabuf_zone);
  1890. kmem_zone_destroy(xfs_da_state_zone);
  1891. kmem_zone_destroy(xfs_btree_cur_zone);
  1892. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1893. kmem_zone_destroy(xfs_log_ticket_zone);
  1894. mempool_destroy(xfs_ioend_pool);
  1895. kmem_zone_destroy(xfs_ioend_zone);
  1896. kmem_zone_destroy(xfs_vnode_zone);
  1897. }
  1898. STATIC int __init
  1899. init_xfs_fs(void)
  1900. {
  1901. int error;
  1902. static char message[] __initdata = KERN_INFO \
  1903. XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
  1904. printk(message);
  1905. ktrace_init(64);
  1906. vn_init();
  1907. xfs_dir_startup();
  1908. error = xfs_init_zones();
  1909. if (error)
  1910. goto out;
  1911. error = xfs_alloc_trace_bufs();
  1912. if (error)
  1913. goto out_destroy_zones;
  1914. error = xfs_mru_cache_init();
  1915. if (error)
  1916. goto out_free_trace_buffers;
  1917. error = xfs_filestream_init();
  1918. if (error)
  1919. goto out_mru_cache_uninit;
  1920. error = xfs_buf_init();
  1921. if (error)
  1922. goto out_filestream_uninit;
  1923. error = xfs_init_procfs();
  1924. if (error)
  1925. goto out_buf_terminate;
  1926. error = xfs_sysctl_register();
  1927. if (error)
  1928. goto out_cleanup_procfs;
  1929. vfs_initquota();
  1930. error = register_filesystem(&xfs_fs_type);
  1931. if (error)
  1932. goto out_sysctl_unregister;
  1933. return 0;
  1934. out_sysctl_unregister:
  1935. xfs_sysctl_unregister();
  1936. out_cleanup_procfs:
  1937. xfs_cleanup_procfs();
  1938. out_buf_terminate:
  1939. xfs_buf_terminate();
  1940. out_filestream_uninit:
  1941. xfs_filestream_uninit();
  1942. out_mru_cache_uninit:
  1943. xfs_mru_cache_uninit();
  1944. out_free_trace_buffers:
  1945. xfs_free_trace_bufs();
  1946. out_destroy_zones:
  1947. xfs_destroy_zones();
  1948. out:
  1949. return error;
  1950. }
  1951. STATIC void __exit
  1952. exit_xfs_fs(void)
  1953. {
  1954. vfs_exitquota();
  1955. unregister_filesystem(&xfs_fs_type);
  1956. xfs_sysctl_unregister();
  1957. xfs_cleanup_procfs();
  1958. xfs_buf_terminate();
  1959. xfs_filestream_uninit();
  1960. xfs_mru_cache_uninit();
  1961. xfs_free_trace_bufs();
  1962. xfs_destroy_zones();
  1963. ktrace_uninit();
  1964. }
  1965. module_init(init_xfs_fs);
  1966. module_exit(exit_xfs_fs);
  1967. MODULE_AUTHOR("Silicon Graphics, Inc.");
  1968. MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
  1969. MODULE_LICENSE("GPL");