xfs_super.c 45 KB

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