xfs_super.c 57 KB

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