xfs_super.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  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_log.h"
  20. #include "xfs_inum.h"
  21. #include "xfs_trans.h"
  22. #include "xfs_sb.h"
  23. #include "xfs_ag.h"
  24. #include "xfs_dir2.h"
  25. #include "xfs_alloc.h"
  26. #include "xfs_quota.h"
  27. #include "xfs_mount.h"
  28. #include "xfs_bmap_btree.h"
  29. #include "xfs_alloc_btree.h"
  30. #include "xfs_ialloc_btree.h"
  31. #include "xfs_dinode.h"
  32. #include "xfs_inode.h"
  33. #include "xfs_btree.h"
  34. #include "xfs_ialloc.h"
  35. #include "xfs_bmap.h"
  36. #include "xfs_rtalloc.h"
  37. #include "xfs_error.h"
  38. #include "xfs_itable.h"
  39. #include "xfs_fsops.h"
  40. #include "xfs_attr.h"
  41. #include "xfs_buf_item.h"
  42. #include "xfs_utils.h"
  43. #include "xfs_vnodeops.h"
  44. #include "xfs_log_priv.h"
  45. #include "xfs_trans_priv.h"
  46. #include "xfs_filestream.h"
  47. #include "xfs_da_btree.h"
  48. #include "xfs_extfree_item.h"
  49. #include "xfs_mru_cache.h"
  50. #include "xfs_inode_item.h"
  51. #include "xfs_sync.h"
  52. #include "xfs_trace.h"
  53. #include <linux/namei.h>
  54. #include <linux/init.h>
  55. #include <linux/slab.h>
  56. #include <linux/mount.h>
  57. #include <linux/mempool.h>
  58. #include <linux/writeback.h>
  59. #include <linux/kthread.h>
  60. #include <linux/freezer.h>
  61. #include <linux/parser.h>
  62. static const struct super_operations xfs_super_operations;
  63. static kmem_zone_t *xfs_ioend_zone;
  64. mempool_t *xfs_ioend_pool;
  65. #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
  66. #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
  67. #define MNTOPT_LOGDEV "logdev" /* log device */
  68. #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
  69. #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
  70. #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
  71. #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
  72. #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
  73. #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
  74. #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
  75. #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
  76. #define MNTOPT_MTPT "mtpt" /* filesystem mount point */
  77. #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
  78. #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
  79. #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
  80. #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
  81. #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
  82. #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
  83. #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
  84. * unwritten extent conversion */
  85. #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
  86. #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
  87. #define MNTOPT_32BITINODE "inode32" /* inode allocation limited to
  88. * XFS_MAXINUMBER_32 */
  89. #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
  90. #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
  91. #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
  92. #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
  93. * in stat(). */
  94. #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
  95. #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
  96. #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
  97. #define MNTOPT_QUOTA "quota" /* disk quotas (user) */
  98. #define MNTOPT_NOQUOTA "noquota" /* no quotas */
  99. #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
  100. #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
  101. #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
  102. #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
  103. #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
  104. #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
  105. #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
  106. #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
  107. #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
  108. #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
  109. #define MNTOPT_DELAYLOG "delaylog" /* Delayed logging enabled */
  110. #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
  111. #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
  112. #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
  113. /*
  114. * Table driven mount option parser.
  115. *
  116. * Currently only used for remount, but it will be used for mount
  117. * in the future, too.
  118. */
  119. enum {
  120. Opt_barrier, Opt_nobarrier, Opt_inode64, Opt_err
  121. };
  122. static const match_table_t tokens = {
  123. {Opt_barrier, "barrier"},
  124. {Opt_nobarrier, "nobarrier"},
  125. {Opt_inode64, "inode64"},
  126. {Opt_err, NULL}
  127. };
  128. STATIC unsigned long
  129. suffix_strtoul(char *s, char **endp, unsigned int base)
  130. {
  131. int last, shift_left_factor = 0;
  132. char *value = s;
  133. last = strlen(value) - 1;
  134. if (value[last] == 'K' || value[last] == 'k') {
  135. shift_left_factor = 10;
  136. value[last] = '\0';
  137. }
  138. if (value[last] == 'M' || value[last] == 'm') {
  139. shift_left_factor = 20;
  140. value[last] = '\0';
  141. }
  142. if (value[last] == 'G' || value[last] == 'g') {
  143. shift_left_factor = 30;
  144. value[last] = '\0';
  145. }
  146. return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
  147. }
  148. /*
  149. * This function fills in xfs_mount_t fields based on mount args.
  150. * Note: the superblock has _not_ yet been read in.
  151. *
  152. * Note that this function leaks the various device name allocations on
  153. * failure. The caller takes care of them.
  154. */
  155. STATIC int
  156. xfs_parseargs(
  157. struct xfs_mount *mp,
  158. char *options)
  159. {
  160. struct super_block *sb = mp->m_super;
  161. char *this_char, *value, *eov;
  162. int dsunit = 0;
  163. int dswidth = 0;
  164. int iosize = 0;
  165. __uint8_t iosizelog = 0;
  166. /*
  167. * set up the mount name first so all the errors will refer to the
  168. * correct device.
  169. */
  170. mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
  171. if (!mp->m_fsname)
  172. return ENOMEM;
  173. mp->m_fsname_len = strlen(mp->m_fsname) + 1;
  174. /*
  175. * Copy binary VFS mount flags we are interested in.
  176. */
  177. if (sb->s_flags & MS_RDONLY)
  178. mp->m_flags |= XFS_MOUNT_RDONLY;
  179. if (sb->s_flags & MS_DIRSYNC)
  180. mp->m_flags |= XFS_MOUNT_DIRSYNC;
  181. if (sb->s_flags & MS_SYNCHRONOUS)
  182. mp->m_flags |= XFS_MOUNT_WSYNC;
  183. /*
  184. * Set some default flags that could be cleared by the mount option
  185. * parsing.
  186. */
  187. mp->m_flags |= XFS_MOUNT_BARRIER;
  188. mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
  189. #if !XFS_BIG_INUMS
  190. mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
  191. #endif
  192. /*
  193. * These can be overridden by the mount option parsing.
  194. */
  195. mp->m_logbufs = -1;
  196. mp->m_logbsize = -1;
  197. if (!options)
  198. goto done;
  199. while ((this_char = strsep(&options, ",")) != NULL) {
  200. if (!*this_char)
  201. continue;
  202. if ((value = strchr(this_char, '=')) != NULL)
  203. *value++ = 0;
  204. if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
  205. if (!value || !*value) {
  206. xfs_warn(mp, "%s option requires an argument",
  207. this_char);
  208. return EINVAL;
  209. }
  210. mp->m_logbufs = simple_strtoul(value, &eov, 10);
  211. } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
  212. if (!value || !*value) {
  213. xfs_warn(mp, "%s option requires an argument",
  214. this_char);
  215. return EINVAL;
  216. }
  217. mp->m_logbsize = suffix_strtoul(value, &eov, 10);
  218. } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
  219. if (!value || !*value) {
  220. xfs_warn(mp, "%s option requires an argument",
  221. this_char);
  222. return EINVAL;
  223. }
  224. mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
  225. if (!mp->m_logname)
  226. return ENOMEM;
  227. } else if (!strcmp(this_char, MNTOPT_MTPT)) {
  228. xfs_warn(mp, "%s option not allowed on this system",
  229. this_char);
  230. return EINVAL;
  231. } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
  232. if (!value || !*value) {
  233. xfs_warn(mp, "%s option requires an argument",
  234. this_char);
  235. return EINVAL;
  236. }
  237. mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
  238. if (!mp->m_rtname)
  239. return ENOMEM;
  240. } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
  241. if (!value || !*value) {
  242. xfs_warn(mp, "%s option requires an argument",
  243. this_char);
  244. return EINVAL;
  245. }
  246. iosize = simple_strtoul(value, &eov, 10);
  247. iosizelog = ffs(iosize) - 1;
  248. } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
  249. if (!value || !*value) {
  250. xfs_warn(mp, "%s option requires an argument",
  251. this_char);
  252. return EINVAL;
  253. }
  254. iosize = suffix_strtoul(value, &eov, 10);
  255. iosizelog = ffs(iosize) - 1;
  256. } else if (!strcmp(this_char, MNTOPT_GRPID) ||
  257. !strcmp(this_char, MNTOPT_BSDGROUPS)) {
  258. mp->m_flags |= XFS_MOUNT_GRPID;
  259. } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
  260. !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
  261. mp->m_flags &= ~XFS_MOUNT_GRPID;
  262. } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
  263. mp->m_flags |= XFS_MOUNT_WSYNC;
  264. } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
  265. mp->m_flags |= XFS_MOUNT_NORECOVERY;
  266. } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
  267. mp->m_flags |= XFS_MOUNT_NOALIGN;
  268. } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
  269. mp->m_flags |= XFS_MOUNT_SWALLOC;
  270. } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
  271. if (!value || !*value) {
  272. xfs_warn(mp, "%s option requires an argument",
  273. this_char);
  274. return EINVAL;
  275. }
  276. dsunit = simple_strtoul(value, &eov, 10);
  277. } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
  278. if (!value || !*value) {
  279. xfs_warn(mp, "%s option requires an argument",
  280. this_char);
  281. return EINVAL;
  282. }
  283. dswidth = simple_strtoul(value, &eov, 10);
  284. } else if (!strcmp(this_char, MNTOPT_32BITINODE)) {
  285. mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
  286. } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
  287. mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
  288. #if !XFS_BIG_INUMS
  289. xfs_warn(mp, "%s option not allowed on this system",
  290. this_char);
  291. return EINVAL;
  292. #endif
  293. } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
  294. mp->m_flags |= XFS_MOUNT_NOUUID;
  295. } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
  296. mp->m_flags |= XFS_MOUNT_BARRIER;
  297. } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
  298. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  299. } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
  300. mp->m_flags |= XFS_MOUNT_IKEEP;
  301. } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
  302. mp->m_flags &= ~XFS_MOUNT_IKEEP;
  303. } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
  304. mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
  305. } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
  306. mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
  307. } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
  308. mp->m_flags |= XFS_MOUNT_ATTR2;
  309. } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
  310. mp->m_flags &= ~XFS_MOUNT_ATTR2;
  311. mp->m_flags |= XFS_MOUNT_NOATTR2;
  312. } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
  313. mp->m_flags |= XFS_MOUNT_FILESTREAMS;
  314. } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
  315. mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
  316. mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
  317. mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
  318. } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
  319. !strcmp(this_char, MNTOPT_UQUOTA) ||
  320. !strcmp(this_char, MNTOPT_USRQUOTA)) {
  321. mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
  322. XFS_UQUOTA_ENFD);
  323. } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
  324. !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
  325. mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
  326. mp->m_qflags &= ~XFS_UQUOTA_ENFD;
  327. } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
  328. !strcmp(this_char, MNTOPT_PRJQUOTA)) {
  329. mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
  330. XFS_OQUOTA_ENFD);
  331. } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
  332. mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
  333. mp->m_qflags &= ~XFS_OQUOTA_ENFD;
  334. } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
  335. !strcmp(this_char, MNTOPT_GRPQUOTA)) {
  336. mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
  337. XFS_OQUOTA_ENFD);
  338. } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
  339. mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
  340. mp->m_qflags &= ~XFS_OQUOTA_ENFD;
  341. } else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
  342. xfs_warn(mp,
  343. "delaylog is the default now, option is deprecated.");
  344. } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
  345. xfs_warn(mp,
  346. "nodelaylog support has been removed, option is deprecated.");
  347. } else if (!strcmp(this_char, MNTOPT_DISCARD)) {
  348. mp->m_flags |= XFS_MOUNT_DISCARD;
  349. } else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
  350. mp->m_flags &= ~XFS_MOUNT_DISCARD;
  351. } else if (!strcmp(this_char, "ihashsize")) {
  352. xfs_warn(mp,
  353. "ihashsize no longer used, option is deprecated.");
  354. } else if (!strcmp(this_char, "osyncisdsync")) {
  355. xfs_warn(mp,
  356. "osyncisdsync has no effect, option is deprecated.");
  357. } else if (!strcmp(this_char, "osyncisosync")) {
  358. xfs_warn(mp,
  359. "osyncisosync has no effect, option is deprecated.");
  360. } else if (!strcmp(this_char, "irixsgid")) {
  361. xfs_warn(mp,
  362. "irixsgid is now a sysctl(2) variable, option is deprecated.");
  363. } else {
  364. xfs_warn(mp, "unknown mount option [%s].", this_char);
  365. return EINVAL;
  366. }
  367. }
  368. /*
  369. * no recovery flag requires a read-only mount
  370. */
  371. if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
  372. !(mp->m_flags & XFS_MOUNT_RDONLY)) {
  373. xfs_warn(mp, "no-recovery mounts must be read-only.");
  374. return EINVAL;
  375. }
  376. if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
  377. xfs_warn(mp,
  378. "sunit and swidth options incompatible with the noalign option");
  379. return EINVAL;
  380. }
  381. #ifndef CONFIG_XFS_QUOTA
  382. if (XFS_IS_QUOTA_RUNNING(mp)) {
  383. xfs_warn(mp, "quota support not available in this kernel.");
  384. return EINVAL;
  385. }
  386. #endif
  387. if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
  388. (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) {
  389. xfs_warn(mp, "cannot mount with both project and group quota");
  390. return EINVAL;
  391. }
  392. if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
  393. xfs_warn(mp, "sunit and swidth must be specified together");
  394. return EINVAL;
  395. }
  396. if (dsunit && (dswidth % dsunit != 0)) {
  397. xfs_warn(mp,
  398. "stripe width (%d) must be a multiple of the stripe unit (%d)",
  399. dswidth, dsunit);
  400. return EINVAL;
  401. }
  402. done:
  403. if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) {
  404. /*
  405. * At this point the superblock has not been read
  406. * in, therefore we do not know the block size.
  407. * Before the mount call ends we will convert
  408. * these to FSBs.
  409. */
  410. if (dsunit) {
  411. mp->m_dalign = dsunit;
  412. mp->m_flags |= XFS_MOUNT_RETERR;
  413. }
  414. if (dswidth)
  415. mp->m_swidth = dswidth;
  416. }
  417. if (mp->m_logbufs != -1 &&
  418. mp->m_logbufs != 0 &&
  419. (mp->m_logbufs < XLOG_MIN_ICLOGS ||
  420. mp->m_logbufs > XLOG_MAX_ICLOGS)) {
  421. xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
  422. mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
  423. return XFS_ERROR(EINVAL);
  424. }
  425. if (mp->m_logbsize != -1 &&
  426. mp->m_logbsize != 0 &&
  427. (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
  428. mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
  429. !is_power_of_2(mp->m_logbsize))) {
  430. xfs_warn(mp,
  431. "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
  432. mp->m_logbsize);
  433. return XFS_ERROR(EINVAL);
  434. }
  435. if (iosizelog) {
  436. if (iosizelog > XFS_MAX_IO_LOG ||
  437. iosizelog < XFS_MIN_IO_LOG) {
  438. xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
  439. iosizelog, XFS_MIN_IO_LOG,
  440. XFS_MAX_IO_LOG);
  441. return XFS_ERROR(EINVAL);
  442. }
  443. mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
  444. mp->m_readio_log = iosizelog;
  445. mp->m_writeio_log = iosizelog;
  446. }
  447. return 0;
  448. }
  449. struct proc_xfs_info {
  450. int flag;
  451. char *str;
  452. };
  453. STATIC int
  454. xfs_showargs(
  455. struct xfs_mount *mp,
  456. struct seq_file *m)
  457. {
  458. static struct proc_xfs_info xfs_info_set[] = {
  459. /* the few simple ones we can get from the mount struct */
  460. { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
  461. { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
  462. { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
  463. { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
  464. { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
  465. { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
  466. { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
  467. { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
  468. { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
  469. { XFS_MOUNT_DISCARD, "," MNTOPT_DISCARD },
  470. { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_32BITINODE },
  471. { 0, NULL }
  472. };
  473. static struct proc_xfs_info xfs_info_unset[] = {
  474. /* the few simple ones we can get from the mount struct */
  475. { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
  476. { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
  477. { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
  478. { 0, NULL }
  479. };
  480. struct proc_xfs_info *xfs_infop;
  481. for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
  482. if (mp->m_flags & xfs_infop->flag)
  483. seq_puts(m, xfs_infop->str);
  484. }
  485. for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
  486. if (!(mp->m_flags & xfs_infop->flag))
  487. seq_puts(m, xfs_infop->str);
  488. }
  489. if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
  490. seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
  491. (int)(1 << mp->m_writeio_log) >> 10);
  492. if (mp->m_logbufs > 0)
  493. seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
  494. if (mp->m_logbsize > 0)
  495. seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
  496. if (mp->m_logname)
  497. seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
  498. if (mp->m_rtname)
  499. seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
  500. if (mp->m_dalign > 0)
  501. seq_printf(m, "," MNTOPT_SUNIT "=%d",
  502. (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
  503. if (mp->m_swidth > 0)
  504. seq_printf(m, "," MNTOPT_SWIDTH "=%d",
  505. (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
  506. if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
  507. seq_puts(m, "," MNTOPT_USRQUOTA);
  508. else if (mp->m_qflags & XFS_UQUOTA_ACCT)
  509. seq_puts(m, "," MNTOPT_UQUOTANOENF);
  510. /* Either project or group quotas can be active, not both */
  511. if (mp->m_qflags & XFS_PQUOTA_ACCT) {
  512. if (mp->m_qflags & XFS_OQUOTA_ENFD)
  513. seq_puts(m, "," MNTOPT_PRJQUOTA);
  514. else
  515. seq_puts(m, "," MNTOPT_PQUOTANOENF);
  516. } else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
  517. if (mp->m_qflags & XFS_OQUOTA_ENFD)
  518. seq_puts(m, "," MNTOPT_GRPQUOTA);
  519. else
  520. seq_puts(m, "," MNTOPT_GQUOTANOENF);
  521. }
  522. if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
  523. seq_puts(m, "," MNTOPT_NOQUOTA);
  524. return 0;
  525. }
  526. __uint64_t
  527. xfs_max_file_offset(
  528. unsigned int blockshift)
  529. {
  530. unsigned int pagefactor = 1;
  531. unsigned int bitshift = BITS_PER_LONG - 1;
  532. /* Figure out maximum filesize, on Linux this can depend on
  533. * the filesystem blocksize (on 32 bit platforms).
  534. * __block_write_begin does this in an [unsigned] long...
  535. * page->index << (PAGE_CACHE_SHIFT - bbits)
  536. * So, for page sized blocks (4K on 32 bit platforms),
  537. * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
  538. * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
  539. * but for smaller blocksizes it is less (bbits = log2 bsize).
  540. * Note1: get_block_t takes a long (implicit cast from above)
  541. * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
  542. * can optionally convert the [unsigned] long from above into
  543. * an [unsigned] long long.
  544. */
  545. #if BITS_PER_LONG == 32
  546. # if defined(CONFIG_LBDAF)
  547. ASSERT(sizeof(sector_t) == 8);
  548. pagefactor = PAGE_CACHE_SIZE;
  549. bitshift = BITS_PER_LONG;
  550. # else
  551. pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
  552. # endif
  553. #endif
  554. return (((__uint64_t)pagefactor) << bitshift) - 1;
  555. }
  556. xfs_agnumber_t
  557. xfs_set_inode32(struct xfs_mount *mp)
  558. {
  559. xfs_agnumber_t index = 0;
  560. xfs_sb_t *sbp = &mp->m_sb;
  561. xfs_agnumber_t max_metadata;
  562. xfs_agino_t agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks -1, 0);
  563. xfs_ino_t ino = XFS_AGINO_TO_INO(mp, sbp->sb_agcount -1, agino);
  564. xfs_perag_t *pag;
  565. /* Calculate how much should be reserved for inodes to meet
  566. * the max inode percentage.
  567. */
  568. if (mp->m_maxicount) {
  569. __uint64_t icount;
  570. icount = sbp->sb_dblocks * sbp->sb_imax_pct;
  571. do_div(icount, 100);
  572. icount += sbp->sb_agblocks - 1;
  573. do_div(icount, sbp->sb_agblocks);
  574. max_metadata = icount;
  575. } else {
  576. max_metadata = sbp->sb_agcount;
  577. }
  578. for (index = 0; index < sbp->sb_agcount; index++) {
  579. ino = XFS_AGINO_TO_INO(mp, index, agino);
  580. if (ino > XFS_MAXINUMBER_32) {
  581. index++;
  582. break;
  583. }
  584. pag = xfs_perag_get(mp, index);
  585. pag->pagi_inodeok = 1;
  586. if (index < max_metadata)
  587. pag->pagf_metadata = 1;
  588. xfs_perag_put(pag);
  589. }
  590. return index;
  591. }
  592. xfs_agnumber_t
  593. xfs_set_inode64(struct xfs_mount *mp)
  594. {
  595. xfs_agnumber_t index = 0;
  596. for (index = 0; index < mp->m_sb.sb_agcount; index++) {
  597. struct xfs_perag *pag;
  598. pag = xfs_perag_get(mp, index);
  599. pag->pagi_inodeok = 1;
  600. pag->pagf_metadata = 0;
  601. xfs_perag_put(pag);
  602. }
  603. /* There is no need for lock protection on m_flags,
  604. * the rw_semaphore of the VFS superblock is locked
  605. * during mount/umount/remount operations, so this is
  606. * enough to avoid concurency on the m_flags field
  607. */
  608. mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
  609. XFS_MOUNT_SMALL_INUMS);
  610. return index;
  611. }
  612. STATIC int
  613. xfs_blkdev_get(
  614. xfs_mount_t *mp,
  615. const char *name,
  616. struct block_device **bdevp)
  617. {
  618. int error = 0;
  619. *bdevp = blkdev_get_by_path(name, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
  620. mp);
  621. if (IS_ERR(*bdevp)) {
  622. error = PTR_ERR(*bdevp);
  623. xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error);
  624. }
  625. return -error;
  626. }
  627. STATIC void
  628. xfs_blkdev_put(
  629. struct block_device *bdev)
  630. {
  631. if (bdev)
  632. blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
  633. }
  634. void
  635. xfs_blkdev_issue_flush(
  636. xfs_buftarg_t *buftarg)
  637. {
  638. blkdev_issue_flush(buftarg->bt_bdev, GFP_NOFS, NULL);
  639. }
  640. STATIC void
  641. xfs_close_devices(
  642. struct xfs_mount *mp)
  643. {
  644. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  645. struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
  646. xfs_free_buftarg(mp, mp->m_logdev_targp);
  647. xfs_blkdev_put(logdev);
  648. }
  649. if (mp->m_rtdev_targp) {
  650. struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
  651. xfs_free_buftarg(mp, mp->m_rtdev_targp);
  652. xfs_blkdev_put(rtdev);
  653. }
  654. xfs_free_buftarg(mp, mp->m_ddev_targp);
  655. }
  656. /*
  657. * The file system configurations are:
  658. * (1) device (partition) with data and internal log
  659. * (2) logical volume with data and log subvolumes.
  660. * (3) logical volume with data, log, and realtime subvolumes.
  661. *
  662. * We only have to handle opening the log and realtime volumes here if
  663. * they are present. The data subvolume has already been opened by
  664. * get_sb_bdev() and is stored in sb->s_bdev.
  665. */
  666. STATIC int
  667. xfs_open_devices(
  668. struct xfs_mount *mp)
  669. {
  670. struct block_device *ddev = mp->m_super->s_bdev;
  671. struct block_device *logdev = NULL, *rtdev = NULL;
  672. int error;
  673. /*
  674. * Open real time and log devices - order is important.
  675. */
  676. if (mp->m_logname) {
  677. error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
  678. if (error)
  679. goto out;
  680. }
  681. if (mp->m_rtname) {
  682. error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
  683. if (error)
  684. goto out_close_logdev;
  685. if (rtdev == ddev || rtdev == logdev) {
  686. xfs_warn(mp,
  687. "Cannot mount filesystem with identical rtdev and ddev/logdev.");
  688. error = EINVAL;
  689. goto out_close_rtdev;
  690. }
  691. }
  692. /*
  693. * Setup xfs_mount buffer target pointers
  694. */
  695. error = ENOMEM;
  696. mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev, 0, mp->m_fsname);
  697. if (!mp->m_ddev_targp)
  698. goto out_close_rtdev;
  699. if (rtdev) {
  700. mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev, 1,
  701. mp->m_fsname);
  702. if (!mp->m_rtdev_targp)
  703. goto out_free_ddev_targ;
  704. }
  705. if (logdev && logdev != ddev) {
  706. mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev, 1,
  707. mp->m_fsname);
  708. if (!mp->m_logdev_targp)
  709. goto out_free_rtdev_targ;
  710. } else {
  711. mp->m_logdev_targp = mp->m_ddev_targp;
  712. }
  713. return 0;
  714. out_free_rtdev_targ:
  715. if (mp->m_rtdev_targp)
  716. xfs_free_buftarg(mp, mp->m_rtdev_targp);
  717. out_free_ddev_targ:
  718. xfs_free_buftarg(mp, mp->m_ddev_targp);
  719. out_close_rtdev:
  720. if (rtdev)
  721. xfs_blkdev_put(rtdev);
  722. out_close_logdev:
  723. if (logdev && logdev != ddev)
  724. xfs_blkdev_put(logdev);
  725. out:
  726. return error;
  727. }
  728. /*
  729. * Setup xfs_mount buffer target pointers based on superblock
  730. */
  731. STATIC int
  732. xfs_setup_devices(
  733. struct xfs_mount *mp)
  734. {
  735. int error;
  736. error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
  737. mp->m_sb.sb_sectsize);
  738. if (error)
  739. return error;
  740. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  741. unsigned int log_sector_size = BBSIZE;
  742. if (xfs_sb_version_hassector(&mp->m_sb))
  743. log_sector_size = mp->m_sb.sb_logsectsize;
  744. error = xfs_setsize_buftarg(mp->m_logdev_targp,
  745. mp->m_sb.sb_blocksize,
  746. log_sector_size);
  747. if (error)
  748. return error;
  749. }
  750. if (mp->m_rtdev_targp) {
  751. error = xfs_setsize_buftarg(mp->m_rtdev_targp,
  752. mp->m_sb.sb_blocksize,
  753. mp->m_sb.sb_sectsize);
  754. if (error)
  755. return error;
  756. }
  757. return 0;
  758. }
  759. STATIC int
  760. xfs_init_mount_workqueues(
  761. struct xfs_mount *mp)
  762. {
  763. mp->m_data_workqueue = alloc_workqueue("xfs-data/%s",
  764. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  765. if (!mp->m_data_workqueue)
  766. goto out;
  767. mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
  768. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  769. if (!mp->m_unwritten_workqueue)
  770. goto out_destroy_data_iodone_queue;
  771. mp->m_cil_workqueue = alloc_workqueue("xfs-cil/%s",
  772. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  773. if (!mp->m_cil_workqueue)
  774. goto out_destroy_unwritten;
  775. return 0;
  776. out_destroy_unwritten:
  777. destroy_workqueue(mp->m_unwritten_workqueue);
  778. out_destroy_data_iodone_queue:
  779. destroy_workqueue(mp->m_data_workqueue);
  780. out:
  781. return -ENOMEM;
  782. }
  783. STATIC void
  784. xfs_destroy_mount_workqueues(
  785. struct xfs_mount *mp)
  786. {
  787. destroy_workqueue(mp->m_cil_workqueue);
  788. destroy_workqueue(mp->m_data_workqueue);
  789. destroy_workqueue(mp->m_unwritten_workqueue);
  790. }
  791. /* Catch misguided souls that try to use this interface on XFS */
  792. STATIC struct inode *
  793. xfs_fs_alloc_inode(
  794. struct super_block *sb)
  795. {
  796. BUG();
  797. return NULL;
  798. }
  799. /*
  800. * Now that the generic code is guaranteed not to be accessing
  801. * the linux inode, we can reclaim the inode.
  802. */
  803. STATIC void
  804. xfs_fs_destroy_inode(
  805. struct inode *inode)
  806. {
  807. struct xfs_inode *ip = XFS_I(inode);
  808. trace_xfs_destroy_inode(ip);
  809. XFS_STATS_INC(vn_reclaim);
  810. /* bad inode, get out here ASAP */
  811. if (is_bad_inode(inode))
  812. goto out_reclaim;
  813. ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);
  814. /*
  815. * We should never get here with one of the reclaim flags already set.
  816. */
  817. ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
  818. ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM));
  819. /*
  820. * We always use background reclaim here because even if the
  821. * inode is clean, it still may be under IO and hence we have
  822. * to take the flush lock. The background reclaim path handles
  823. * this more efficiently than we can here, so simply let background
  824. * reclaim tear down all inodes.
  825. */
  826. out_reclaim:
  827. xfs_inode_set_reclaim_tag(ip);
  828. }
  829. /*
  830. * Slab object creation initialisation for the XFS inode.
  831. * This covers only the idempotent fields in the XFS inode;
  832. * all other fields need to be initialised on allocation
  833. * from the slab. This avoids the need to repeatedly initialise
  834. * fields in the xfs inode that left in the initialise state
  835. * when freeing the inode.
  836. */
  837. STATIC void
  838. xfs_fs_inode_init_once(
  839. void *inode)
  840. {
  841. struct xfs_inode *ip = inode;
  842. memset(ip, 0, sizeof(struct xfs_inode));
  843. /* vfs inode */
  844. inode_init_once(VFS_I(ip));
  845. /* xfs inode */
  846. atomic_set(&ip->i_pincount, 0);
  847. spin_lock_init(&ip->i_flags_lock);
  848. mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
  849. "xfsino", ip->i_ino);
  850. }
  851. STATIC void
  852. xfs_fs_evict_inode(
  853. struct inode *inode)
  854. {
  855. xfs_inode_t *ip = XFS_I(inode);
  856. ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
  857. trace_xfs_evict_inode(ip);
  858. truncate_inode_pages(&inode->i_data, 0);
  859. clear_inode(inode);
  860. XFS_STATS_INC(vn_rele);
  861. XFS_STATS_INC(vn_remove);
  862. XFS_STATS_DEC(vn_active);
  863. xfs_inactive(ip);
  864. }
  865. /*
  866. * We do an unlocked check for XFS_IDONTCACHE here because we are already
  867. * serialised against cache hits here via the inode->i_lock and igrab() in
  868. * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
  869. * racing with us, and it avoids needing to grab a spinlock here for every inode
  870. * we drop the final reference on.
  871. */
  872. STATIC int
  873. xfs_fs_drop_inode(
  874. struct inode *inode)
  875. {
  876. struct xfs_inode *ip = XFS_I(inode);
  877. return generic_drop_inode(inode) || (ip->i_flags & XFS_IDONTCACHE);
  878. }
  879. STATIC void
  880. xfs_free_fsname(
  881. struct xfs_mount *mp)
  882. {
  883. kfree(mp->m_fsname);
  884. kfree(mp->m_rtname);
  885. kfree(mp->m_logname);
  886. }
  887. STATIC void
  888. xfs_fs_put_super(
  889. struct super_block *sb)
  890. {
  891. struct xfs_mount *mp = XFS_M(sb);
  892. xfs_filestream_unmount(mp);
  893. cancel_delayed_work_sync(&mp->m_sync_work);
  894. xfs_unmountfs(mp);
  895. xfs_syncd_stop(mp);
  896. xfs_freesb(mp);
  897. xfs_icsb_destroy_counters(mp);
  898. xfs_destroy_mount_workqueues(mp);
  899. xfs_close_devices(mp);
  900. xfs_free_fsname(mp);
  901. kfree(mp);
  902. }
  903. STATIC int
  904. xfs_fs_sync_fs(
  905. struct super_block *sb,
  906. int wait)
  907. {
  908. struct xfs_mount *mp = XFS_M(sb);
  909. int error;
  910. /*
  911. * Doing anything during the async pass would be counterproductive.
  912. */
  913. if (!wait)
  914. return 0;
  915. error = xfs_quiesce_data(mp);
  916. if (error)
  917. return -error;
  918. if (laptop_mode) {
  919. /*
  920. * The disk must be active because we're syncing.
  921. * We schedule xfssyncd now (now that the disk is
  922. * active) instead of later (when it might not be).
  923. */
  924. flush_delayed_work_sync(&mp->m_sync_work);
  925. }
  926. return 0;
  927. }
  928. STATIC int
  929. xfs_fs_statfs(
  930. struct dentry *dentry,
  931. struct kstatfs *statp)
  932. {
  933. struct xfs_mount *mp = XFS_M(dentry->d_sb);
  934. xfs_sb_t *sbp = &mp->m_sb;
  935. struct xfs_inode *ip = XFS_I(dentry->d_inode);
  936. __uint64_t fakeinos, id;
  937. xfs_extlen_t lsize;
  938. __int64_t ffree;
  939. statp->f_type = XFS_SB_MAGIC;
  940. statp->f_namelen = MAXNAMELEN - 1;
  941. id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
  942. statp->f_fsid.val[0] = (u32)id;
  943. statp->f_fsid.val[1] = (u32)(id >> 32);
  944. xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
  945. spin_lock(&mp->m_sb_lock);
  946. statp->f_bsize = sbp->sb_blocksize;
  947. lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
  948. statp->f_blocks = sbp->sb_dblocks - lsize;
  949. statp->f_bfree = statp->f_bavail =
  950. sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
  951. fakeinos = statp->f_bfree << sbp->sb_inopblog;
  952. statp->f_files =
  953. MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
  954. if (mp->m_maxicount)
  955. statp->f_files = min_t(typeof(statp->f_files),
  956. statp->f_files,
  957. mp->m_maxicount);
  958. /* make sure statp->f_ffree does not underflow */
  959. ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
  960. statp->f_ffree = max_t(__int64_t, ffree, 0);
  961. spin_unlock(&mp->m_sb_lock);
  962. if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
  963. ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) ==
  964. (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
  965. xfs_qm_statvfs(ip, statp);
  966. return 0;
  967. }
  968. STATIC void
  969. xfs_save_resvblks(struct xfs_mount *mp)
  970. {
  971. __uint64_t resblks = 0;
  972. mp->m_resblks_save = mp->m_resblks;
  973. xfs_reserve_blocks(mp, &resblks, NULL);
  974. }
  975. STATIC void
  976. xfs_restore_resvblks(struct xfs_mount *mp)
  977. {
  978. __uint64_t resblks;
  979. if (mp->m_resblks_save) {
  980. resblks = mp->m_resblks_save;
  981. mp->m_resblks_save = 0;
  982. } else
  983. resblks = xfs_default_resblks(mp);
  984. xfs_reserve_blocks(mp, &resblks, NULL);
  985. }
  986. STATIC int
  987. xfs_fs_remount(
  988. struct super_block *sb,
  989. int *flags,
  990. char *options)
  991. {
  992. struct xfs_mount *mp = XFS_M(sb);
  993. substring_t args[MAX_OPT_ARGS];
  994. char *p;
  995. int error;
  996. while ((p = strsep(&options, ",")) != NULL) {
  997. int token;
  998. if (!*p)
  999. continue;
  1000. token = match_token(p, tokens, args);
  1001. switch (token) {
  1002. case Opt_barrier:
  1003. mp->m_flags |= XFS_MOUNT_BARRIER;
  1004. break;
  1005. case Opt_nobarrier:
  1006. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  1007. break;
  1008. case Opt_inode64:
  1009. mp->m_maxagi = xfs_set_inode64(mp);
  1010. break;
  1011. default:
  1012. /*
  1013. * Logically we would return an error here to prevent
  1014. * users from believing they might have changed
  1015. * mount options using remount which can't be changed.
  1016. *
  1017. * But unfortunately mount(8) adds all options from
  1018. * mtab and fstab to the mount arguments in some cases
  1019. * so we can't blindly reject options, but have to
  1020. * check for each specified option if it actually
  1021. * differs from the currently set option and only
  1022. * reject it if that's the case.
  1023. *
  1024. * Until that is implemented we return success for
  1025. * every remount request, and silently ignore all
  1026. * options that we can't actually change.
  1027. */
  1028. #if 0
  1029. xfs_info(mp,
  1030. "mount option \"%s\" not supported for remount\n", p);
  1031. return -EINVAL;
  1032. #else
  1033. break;
  1034. #endif
  1035. }
  1036. }
  1037. /* ro -> rw */
  1038. if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
  1039. mp->m_flags &= ~XFS_MOUNT_RDONLY;
  1040. /*
  1041. * If this is the first remount to writeable state we
  1042. * might have some superblock changes to update.
  1043. */
  1044. if (mp->m_update_flags) {
  1045. error = xfs_mount_log_sb(mp, mp->m_update_flags);
  1046. if (error) {
  1047. xfs_warn(mp, "failed to write sb changes");
  1048. return error;
  1049. }
  1050. mp->m_update_flags = 0;
  1051. }
  1052. /*
  1053. * Fill out the reserve pool if it is empty. Use the stashed
  1054. * value if it is non-zero, otherwise go with the default.
  1055. */
  1056. xfs_restore_resvblks(mp);
  1057. }
  1058. /* rw -> ro */
  1059. if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
  1060. /*
  1061. * After we have synced the data but before we sync the
  1062. * metadata, we need to free up the reserve block pool so that
  1063. * the used block count in the superblock on disk is correct at
  1064. * the end of the remount. Stash the current reserve pool size
  1065. * so that if we get remounted rw, we can return it to the same
  1066. * size.
  1067. */
  1068. xfs_quiesce_data(mp);
  1069. xfs_save_resvblks(mp);
  1070. xfs_quiesce_attr(mp);
  1071. mp->m_flags |= XFS_MOUNT_RDONLY;
  1072. }
  1073. return 0;
  1074. }
  1075. /*
  1076. * Second stage of a freeze. The data is already frozen so we only
  1077. * need to take care of the metadata. Once that's done write a dummy
  1078. * record to dirty the log in case of a crash while frozen.
  1079. */
  1080. STATIC int
  1081. xfs_fs_freeze(
  1082. struct super_block *sb)
  1083. {
  1084. struct xfs_mount *mp = XFS_M(sb);
  1085. xfs_save_resvblks(mp);
  1086. xfs_quiesce_attr(mp);
  1087. return -xfs_fs_log_dummy(mp);
  1088. }
  1089. STATIC int
  1090. xfs_fs_unfreeze(
  1091. struct super_block *sb)
  1092. {
  1093. struct xfs_mount *mp = XFS_M(sb);
  1094. xfs_restore_resvblks(mp);
  1095. return 0;
  1096. }
  1097. STATIC int
  1098. xfs_fs_show_options(
  1099. struct seq_file *m,
  1100. struct dentry *root)
  1101. {
  1102. return -xfs_showargs(XFS_M(root->d_sb), m);
  1103. }
  1104. /*
  1105. * This function fills in xfs_mount_t fields based on mount args.
  1106. * Note: the superblock _has_ now been read in.
  1107. */
  1108. STATIC int
  1109. xfs_finish_flags(
  1110. struct xfs_mount *mp)
  1111. {
  1112. int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
  1113. /* Fail a mount where the logbuf is smaller than the log stripe */
  1114. if (xfs_sb_version_haslogv2(&mp->m_sb)) {
  1115. if (mp->m_logbsize <= 0 &&
  1116. mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
  1117. mp->m_logbsize = mp->m_sb.sb_logsunit;
  1118. } else if (mp->m_logbsize > 0 &&
  1119. mp->m_logbsize < mp->m_sb.sb_logsunit) {
  1120. xfs_warn(mp,
  1121. "logbuf size must be greater than or equal to log stripe size");
  1122. return XFS_ERROR(EINVAL);
  1123. }
  1124. } else {
  1125. /* Fail a mount if the logbuf is larger than 32K */
  1126. if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
  1127. xfs_warn(mp,
  1128. "logbuf size for version 1 logs must be 16K or 32K");
  1129. return XFS_ERROR(EINVAL);
  1130. }
  1131. }
  1132. /*
  1133. * mkfs'ed attr2 will turn on attr2 mount unless explicitly
  1134. * told by noattr2 to turn it off
  1135. */
  1136. if (xfs_sb_version_hasattr2(&mp->m_sb) &&
  1137. !(mp->m_flags & XFS_MOUNT_NOATTR2))
  1138. mp->m_flags |= XFS_MOUNT_ATTR2;
  1139. /*
  1140. * prohibit r/w mounts of read-only filesystems
  1141. */
  1142. if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
  1143. xfs_warn(mp,
  1144. "cannot mount a read-only filesystem as read-write");
  1145. return XFS_ERROR(EROFS);
  1146. }
  1147. return 0;
  1148. }
  1149. STATIC int
  1150. xfs_fs_fill_super(
  1151. struct super_block *sb,
  1152. void *data,
  1153. int silent)
  1154. {
  1155. struct inode *root;
  1156. struct xfs_mount *mp = NULL;
  1157. int flags = 0, error = ENOMEM;
  1158. mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
  1159. if (!mp)
  1160. goto out;
  1161. spin_lock_init(&mp->m_sb_lock);
  1162. mutex_init(&mp->m_growlock);
  1163. atomic_set(&mp->m_active_trans, 0);
  1164. mp->m_super = sb;
  1165. sb->s_fs_info = mp;
  1166. error = xfs_parseargs(mp, (char *)data);
  1167. if (error)
  1168. goto out_free_fsname;
  1169. sb_min_blocksize(sb, BBSIZE);
  1170. sb->s_xattr = xfs_xattr_handlers;
  1171. sb->s_export_op = &xfs_export_operations;
  1172. #ifdef CONFIG_XFS_QUOTA
  1173. sb->s_qcop = &xfs_quotactl_operations;
  1174. #endif
  1175. sb->s_op = &xfs_super_operations;
  1176. if (silent)
  1177. flags |= XFS_MFSI_QUIET;
  1178. error = xfs_open_devices(mp);
  1179. if (error)
  1180. goto out_free_fsname;
  1181. error = xfs_init_mount_workqueues(mp);
  1182. if (error)
  1183. goto out_close_devices;
  1184. error = xfs_icsb_init_counters(mp);
  1185. if (error)
  1186. goto out_destroy_workqueues;
  1187. error = xfs_readsb(mp, flags);
  1188. if (error)
  1189. goto out_destroy_counters;
  1190. error = xfs_finish_flags(mp);
  1191. if (error)
  1192. goto out_free_sb;
  1193. error = xfs_setup_devices(mp);
  1194. if (error)
  1195. goto out_free_sb;
  1196. error = xfs_filestream_mount(mp);
  1197. if (error)
  1198. goto out_free_sb;
  1199. /*
  1200. * we must configure the block size in the superblock before we run the
  1201. * full mount process as the mount process can lookup and cache inodes.
  1202. * For the same reason we must also initialise the syncd and register
  1203. * the inode cache shrinker so that inodes can be reclaimed during
  1204. * operations like a quotacheck that iterate all inodes in the
  1205. * filesystem.
  1206. */
  1207. sb->s_magic = XFS_SB_MAGIC;
  1208. sb->s_blocksize = mp->m_sb.sb_blocksize;
  1209. sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
  1210. sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
  1211. sb->s_max_links = XFS_MAXLINK;
  1212. sb->s_time_gran = 1;
  1213. set_posix_acl_flag(sb);
  1214. error = xfs_syncd_init(mp);
  1215. if (error)
  1216. goto out_filestream_unmount;
  1217. error = xfs_mountfs(mp);
  1218. if (error)
  1219. goto out_syncd_stop;
  1220. root = igrab(VFS_I(mp->m_rootip));
  1221. if (!root) {
  1222. error = ENOENT;
  1223. goto out_unmount;
  1224. }
  1225. if (is_bad_inode(root)) {
  1226. error = EINVAL;
  1227. goto out_unmount;
  1228. }
  1229. sb->s_root = d_make_root(root);
  1230. if (!sb->s_root) {
  1231. error = ENOMEM;
  1232. goto out_unmount;
  1233. }
  1234. return 0;
  1235. out_syncd_stop:
  1236. xfs_syncd_stop(mp);
  1237. out_filestream_unmount:
  1238. xfs_filestream_unmount(mp);
  1239. out_free_sb:
  1240. xfs_freesb(mp);
  1241. out_destroy_counters:
  1242. xfs_icsb_destroy_counters(mp);
  1243. out_destroy_workqueues:
  1244. xfs_destroy_mount_workqueues(mp);
  1245. out_close_devices:
  1246. xfs_close_devices(mp);
  1247. out_free_fsname:
  1248. xfs_free_fsname(mp);
  1249. kfree(mp);
  1250. out:
  1251. return -error;
  1252. out_unmount:
  1253. xfs_filestream_unmount(mp);
  1254. xfs_unmountfs(mp);
  1255. xfs_syncd_stop(mp);
  1256. goto out_free_sb;
  1257. }
  1258. STATIC struct dentry *
  1259. xfs_fs_mount(
  1260. struct file_system_type *fs_type,
  1261. int flags,
  1262. const char *dev_name,
  1263. void *data)
  1264. {
  1265. return mount_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
  1266. }
  1267. static int
  1268. xfs_fs_nr_cached_objects(
  1269. struct super_block *sb)
  1270. {
  1271. return xfs_reclaim_inodes_count(XFS_M(sb));
  1272. }
  1273. static void
  1274. xfs_fs_free_cached_objects(
  1275. struct super_block *sb,
  1276. int nr_to_scan)
  1277. {
  1278. xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan);
  1279. }
  1280. static const struct super_operations xfs_super_operations = {
  1281. .alloc_inode = xfs_fs_alloc_inode,
  1282. .destroy_inode = xfs_fs_destroy_inode,
  1283. .evict_inode = xfs_fs_evict_inode,
  1284. .drop_inode = xfs_fs_drop_inode,
  1285. .put_super = xfs_fs_put_super,
  1286. .sync_fs = xfs_fs_sync_fs,
  1287. .freeze_fs = xfs_fs_freeze,
  1288. .unfreeze_fs = xfs_fs_unfreeze,
  1289. .statfs = xfs_fs_statfs,
  1290. .remount_fs = xfs_fs_remount,
  1291. .show_options = xfs_fs_show_options,
  1292. .nr_cached_objects = xfs_fs_nr_cached_objects,
  1293. .free_cached_objects = xfs_fs_free_cached_objects,
  1294. };
  1295. static struct file_system_type xfs_fs_type = {
  1296. .owner = THIS_MODULE,
  1297. .name = "xfs",
  1298. .mount = xfs_fs_mount,
  1299. .kill_sb = kill_block_super,
  1300. .fs_flags = FS_REQUIRES_DEV,
  1301. };
  1302. STATIC int __init
  1303. xfs_init_zones(void)
  1304. {
  1305. xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
  1306. if (!xfs_ioend_zone)
  1307. goto out;
  1308. xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
  1309. xfs_ioend_zone);
  1310. if (!xfs_ioend_pool)
  1311. goto out_destroy_ioend_zone;
  1312. xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
  1313. "xfs_log_ticket");
  1314. if (!xfs_log_ticket_zone)
  1315. goto out_destroy_ioend_pool;
  1316. xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
  1317. "xfs_bmap_free_item");
  1318. if (!xfs_bmap_free_item_zone)
  1319. goto out_destroy_log_ticket_zone;
  1320. xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
  1321. "xfs_btree_cur");
  1322. if (!xfs_btree_cur_zone)
  1323. goto out_destroy_bmap_free_item_zone;
  1324. xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
  1325. "xfs_da_state");
  1326. if (!xfs_da_state_zone)
  1327. goto out_destroy_btree_cur_zone;
  1328. xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
  1329. if (!xfs_ifork_zone)
  1330. goto out_destroy_da_state_zone;
  1331. xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
  1332. if (!xfs_trans_zone)
  1333. goto out_destroy_ifork_zone;
  1334. xfs_log_item_desc_zone =
  1335. kmem_zone_init(sizeof(struct xfs_log_item_desc),
  1336. "xfs_log_item_desc");
  1337. if (!xfs_log_item_desc_zone)
  1338. goto out_destroy_trans_zone;
  1339. /*
  1340. * The size of the zone allocated buf log item is the maximum
  1341. * size possible under XFS. This wastes a little bit of memory,
  1342. * but it is much faster.
  1343. */
  1344. xfs_buf_item_zone = kmem_zone_init(sizeof(struct xfs_buf_log_item),
  1345. "xfs_buf_item");
  1346. if (!xfs_buf_item_zone)
  1347. goto out_destroy_log_item_desc_zone;
  1348. xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
  1349. ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
  1350. sizeof(xfs_extent_t))), "xfs_efd_item");
  1351. if (!xfs_efd_zone)
  1352. goto out_destroy_buf_item_zone;
  1353. xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
  1354. ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
  1355. sizeof(xfs_extent_t))), "xfs_efi_item");
  1356. if (!xfs_efi_zone)
  1357. goto out_destroy_efd_zone;
  1358. xfs_inode_zone =
  1359. kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
  1360. KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD,
  1361. xfs_fs_inode_init_once);
  1362. if (!xfs_inode_zone)
  1363. goto out_destroy_efi_zone;
  1364. xfs_ili_zone =
  1365. kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
  1366. KM_ZONE_SPREAD, NULL);
  1367. if (!xfs_ili_zone)
  1368. goto out_destroy_inode_zone;
  1369. return 0;
  1370. out_destroy_inode_zone:
  1371. kmem_zone_destroy(xfs_inode_zone);
  1372. out_destroy_efi_zone:
  1373. kmem_zone_destroy(xfs_efi_zone);
  1374. out_destroy_efd_zone:
  1375. kmem_zone_destroy(xfs_efd_zone);
  1376. out_destroy_buf_item_zone:
  1377. kmem_zone_destroy(xfs_buf_item_zone);
  1378. out_destroy_log_item_desc_zone:
  1379. kmem_zone_destroy(xfs_log_item_desc_zone);
  1380. out_destroy_trans_zone:
  1381. kmem_zone_destroy(xfs_trans_zone);
  1382. out_destroy_ifork_zone:
  1383. kmem_zone_destroy(xfs_ifork_zone);
  1384. out_destroy_da_state_zone:
  1385. kmem_zone_destroy(xfs_da_state_zone);
  1386. out_destroy_btree_cur_zone:
  1387. kmem_zone_destroy(xfs_btree_cur_zone);
  1388. out_destroy_bmap_free_item_zone:
  1389. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1390. out_destroy_log_ticket_zone:
  1391. kmem_zone_destroy(xfs_log_ticket_zone);
  1392. out_destroy_ioend_pool:
  1393. mempool_destroy(xfs_ioend_pool);
  1394. out_destroy_ioend_zone:
  1395. kmem_zone_destroy(xfs_ioend_zone);
  1396. out:
  1397. return -ENOMEM;
  1398. }
  1399. STATIC void
  1400. xfs_destroy_zones(void)
  1401. {
  1402. kmem_zone_destroy(xfs_ili_zone);
  1403. kmem_zone_destroy(xfs_inode_zone);
  1404. kmem_zone_destroy(xfs_efi_zone);
  1405. kmem_zone_destroy(xfs_efd_zone);
  1406. kmem_zone_destroy(xfs_buf_item_zone);
  1407. kmem_zone_destroy(xfs_log_item_desc_zone);
  1408. kmem_zone_destroy(xfs_trans_zone);
  1409. kmem_zone_destroy(xfs_ifork_zone);
  1410. kmem_zone_destroy(xfs_da_state_zone);
  1411. kmem_zone_destroy(xfs_btree_cur_zone);
  1412. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1413. kmem_zone_destroy(xfs_log_ticket_zone);
  1414. mempool_destroy(xfs_ioend_pool);
  1415. kmem_zone_destroy(xfs_ioend_zone);
  1416. }
  1417. STATIC int __init
  1418. xfs_init_workqueues(void)
  1419. {
  1420. /*
  1421. * We never want to the same work item to run twice, reclaiming inodes
  1422. * or idling the log is not going to get any faster by multiple CPUs
  1423. * competing for ressources. Use the default large max_active value
  1424. * so that even lots of filesystems can perform these task in parallel.
  1425. */
  1426. xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0);
  1427. if (!xfs_syncd_wq)
  1428. return -ENOMEM;
  1429. /*
  1430. * The allocation workqueue can be used in memory reclaim situations
  1431. * (writepage path), and parallelism is only limited by the number of
  1432. * AGs in all the filesystems mounted. Hence use the default large
  1433. * max_active value for this workqueue.
  1434. */
  1435. xfs_alloc_wq = alloc_workqueue("xfsalloc", WQ_MEM_RECLAIM, 0);
  1436. if (!xfs_alloc_wq)
  1437. goto out_destroy_syncd;
  1438. return 0;
  1439. out_destroy_syncd:
  1440. destroy_workqueue(xfs_syncd_wq);
  1441. return -ENOMEM;
  1442. }
  1443. STATIC void
  1444. xfs_destroy_workqueues(void)
  1445. {
  1446. destroy_workqueue(xfs_alloc_wq);
  1447. destroy_workqueue(xfs_syncd_wq);
  1448. }
  1449. STATIC int __init
  1450. init_xfs_fs(void)
  1451. {
  1452. int error;
  1453. printk(KERN_INFO XFS_VERSION_STRING " with "
  1454. XFS_BUILD_OPTIONS " enabled\n");
  1455. xfs_dir_startup();
  1456. error = xfs_init_zones();
  1457. if (error)
  1458. goto out;
  1459. error = xfs_init_workqueues();
  1460. if (error)
  1461. goto out_destroy_zones;
  1462. error = xfs_mru_cache_init();
  1463. if (error)
  1464. goto out_destroy_wq;
  1465. error = xfs_filestream_init();
  1466. if (error)
  1467. goto out_mru_cache_uninit;
  1468. error = xfs_buf_init();
  1469. if (error)
  1470. goto out_filestream_uninit;
  1471. error = xfs_init_procfs();
  1472. if (error)
  1473. goto out_buf_terminate;
  1474. error = xfs_sysctl_register();
  1475. if (error)
  1476. goto out_cleanup_procfs;
  1477. error = xfs_qm_init();
  1478. if (error)
  1479. goto out_sysctl_unregister;
  1480. error = register_filesystem(&xfs_fs_type);
  1481. if (error)
  1482. goto out_qm_exit;
  1483. return 0;
  1484. out_qm_exit:
  1485. xfs_qm_exit();
  1486. out_sysctl_unregister:
  1487. xfs_sysctl_unregister();
  1488. out_cleanup_procfs:
  1489. xfs_cleanup_procfs();
  1490. out_buf_terminate:
  1491. xfs_buf_terminate();
  1492. out_filestream_uninit:
  1493. xfs_filestream_uninit();
  1494. out_mru_cache_uninit:
  1495. xfs_mru_cache_uninit();
  1496. out_destroy_wq:
  1497. xfs_destroy_workqueues();
  1498. out_destroy_zones:
  1499. xfs_destroy_zones();
  1500. out:
  1501. return error;
  1502. }
  1503. STATIC void __exit
  1504. exit_xfs_fs(void)
  1505. {
  1506. xfs_qm_exit();
  1507. unregister_filesystem(&xfs_fs_type);
  1508. xfs_sysctl_unregister();
  1509. xfs_cleanup_procfs();
  1510. xfs_buf_terminate();
  1511. xfs_filestream_uninit();
  1512. xfs_mru_cache_uninit();
  1513. xfs_destroy_workqueues();
  1514. xfs_destroy_zones();
  1515. }
  1516. module_init(init_xfs_fs);
  1517. module_exit(exit_xfs_fs);
  1518. MODULE_AUTHOR("Silicon Graphics, Inc.");
  1519. MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
  1520. MODULE_LICENSE("GPL");