xfs_super.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  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. STATIC int
  557. xfs_blkdev_get(
  558. xfs_mount_t *mp,
  559. const char *name,
  560. struct block_device **bdevp)
  561. {
  562. int error = 0;
  563. *bdevp = blkdev_get_by_path(name, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
  564. mp);
  565. if (IS_ERR(*bdevp)) {
  566. error = PTR_ERR(*bdevp);
  567. xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error);
  568. }
  569. return -error;
  570. }
  571. STATIC void
  572. xfs_blkdev_put(
  573. struct block_device *bdev)
  574. {
  575. if (bdev)
  576. blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
  577. }
  578. void
  579. xfs_blkdev_issue_flush(
  580. xfs_buftarg_t *buftarg)
  581. {
  582. blkdev_issue_flush(buftarg->bt_bdev, GFP_NOFS, NULL);
  583. }
  584. STATIC void
  585. xfs_close_devices(
  586. struct xfs_mount *mp)
  587. {
  588. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  589. struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
  590. xfs_free_buftarg(mp, mp->m_logdev_targp);
  591. xfs_blkdev_put(logdev);
  592. }
  593. if (mp->m_rtdev_targp) {
  594. struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
  595. xfs_free_buftarg(mp, mp->m_rtdev_targp);
  596. xfs_blkdev_put(rtdev);
  597. }
  598. xfs_free_buftarg(mp, mp->m_ddev_targp);
  599. }
  600. /*
  601. * The file system configurations are:
  602. * (1) device (partition) with data and internal log
  603. * (2) logical volume with data and log subvolumes.
  604. * (3) logical volume with data, log, and realtime subvolumes.
  605. *
  606. * We only have to handle opening the log and realtime volumes here if
  607. * they are present. The data subvolume has already been opened by
  608. * get_sb_bdev() and is stored in sb->s_bdev.
  609. */
  610. STATIC int
  611. xfs_open_devices(
  612. struct xfs_mount *mp)
  613. {
  614. struct block_device *ddev = mp->m_super->s_bdev;
  615. struct block_device *logdev = NULL, *rtdev = NULL;
  616. int error;
  617. /*
  618. * Open real time and log devices - order is important.
  619. */
  620. if (mp->m_logname) {
  621. error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
  622. if (error)
  623. goto out;
  624. }
  625. if (mp->m_rtname) {
  626. error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
  627. if (error)
  628. goto out_close_logdev;
  629. if (rtdev == ddev || rtdev == logdev) {
  630. xfs_warn(mp,
  631. "Cannot mount filesystem with identical rtdev and ddev/logdev.");
  632. error = EINVAL;
  633. goto out_close_rtdev;
  634. }
  635. }
  636. /*
  637. * Setup xfs_mount buffer target pointers
  638. */
  639. error = ENOMEM;
  640. mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev, 0, mp->m_fsname);
  641. if (!mp->m_ddev_targp)
  642. goto out_close_rtdev;
  643. if (rtdev) {
  644. mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev, 1,
  645. mp->m_fsname);
  646. if (!mp->m_rtdev_targp)
  647. goto out_free_ddev_targ;
  648. }
  649. if (logdev && logdev != ddev) {
  650. mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev, 1,
  651. mp->m_fsname);
  652. if (!mp->m_logdev_targp)
  653. goto out_free_rtdev_targ;
  654. } else {
  655. mp->m_logdev_targp = mp->m_ddev_targp;
  656. }
  657. return 0;
  658. out_free_rtdev_targ:
  659. if (mp->m_rtdev_targp)
  660. xfs_free_buftarg(mp, mp->m_rtdev_targp);
  661. out_free_ddev_targ:
  662. xfs_free_buftarg(mp, mp->m_ddev_targp);
  663. out_close_rtdev:
  664. if (rtdev)
  665. xfs_blkdev_put(rtdev);
  666. out_close_logdev:
  667. if (logdev && logdev != ddev)
  668. xfs_blkdev_put(logdev);
  669. out:
  670. return error;
  671. }
  672. /*
  673. * Setup xfs_mount buffer target pointers based on superblock
  674. */
  675. STATIC int
  676. xfs_setup_devices(
  677. struct xfs_mount *mp)
  678. {
  679. int error;
  680. error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
  681. mp->m_sb.sb_sectsize);
  682. if (error)
  683. return error;
  684. if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
  685. unsigned int log_sector_size = BBSIZE;
  686. if (xfs_sb_version_hassector(&mp->m_sb))
  687. log_sector_size = mp->m_sb.sb_logsectsize;
  688. error = xfs_setsize_buftarg(mp->m_logdev_targp,
  689. mp->m_sb.sb_blocksize,
  690. log_sector_size);
  691. if (error)
  692. return error;
  693. }
  694. if (mp->m_rtdev_targp) {
  695. error = xfs_setsize_buftarg(mp->m_rtdev_targp,
  696. mp->m_sb.sb_blocksize,
  697. mp->m_sb.sb_sectsize);
  698. if (error)
  699. return error;
  700. }
  701. return 0;
  702. }
  703. STATIC int
  704. xfs_init_mount_workqueues(
  705. struct xfs_mount *mp)
  706. {
  707. mp->m_data_workqueue = alloc_workqueue("xfs-data/%s",
  708. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  709. if (!mp->m_data_workqueue)
  710. goto out;
  711. mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
  712. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  713. if (!mp->m_unwritten_workqueue)
  714. goto out_destroy_data_iodone_queue;
  715. mp->m_cil_workqueue = alloc_workqueue("xfs-cil/%s",
  716. WQ_MEM_RECLAIM, 0, mp->m_fsname);
  717. if (!mp->m_cil_workqueue)
  718. goto out_destroy_unwritten;
  719. return 0;
  720. out_destroy_unwritten:
  721. destroy_workqueue(mp->m_unwritten_workqueue);
  722. out_destroy_data_iodone_queue:
  723. destroy_workqueue(mp->m_data_workqueue);
  724. out:
  725. return -ENOMEM;
  726. }
  727. STATIC void
  728. xfs_destroy_mount_workqueues(
  729. struct xfs_mount *mp)
  730. {
  731. destroy_workqueue(mp->m_cil_workqueue);
  732. destroy_workqueue(mp->m_data_workqueue);
  733. destroy_workqueue(mp->m_unwritten_workqueue);
  734. }
  735. /* Catch misguided souls that try to use this interface on XFS */
  736. STATIC struct inode *
  737. xfs_fs_alloc_inode(
  738. struct super_block *sb)
  739. {
  740. BUG();
  741. return NULL;
  742. }
  743. /*
  744. * Now that the generic code is guaranteed not to be accessing
  745. * the linux inode, we can reclaim the inode.
  746. */
  747. STATIC void
  748. xfs_fs_destroy_inode(
  749. struct inode *inode)
  750. {
  751. struct xfs_inode *ip = XFS_I(inode);
  752. trace_xfs_destroy_inode(ip);
  753. XFS_STATS_INC(vn_reclaim);
  754. /* bad inode, get out here ASAP */
  755. if (is_bad_inode(inode))
  756. goto out_reclaim;
  757. ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);
  758. /*
  759. * We should never get here with one of the reclaim flags already set.
  760. */
  761. ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
  762. ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM));
  763. /*
  764. * We always use background reclaim here because even if the
  765. * inode is clean, it still may be under IO and hence we have
  766. * to take the flush lock. The background reclaim path handles
  767. * this more efficiently than we can here, so simply let background
  768. * reclaim tear down all inodes.
  769. */
  770. out_reclaim:
  771. xfs_inode_set_reclaim_tag(ip);
  772. }
  773. /*
  774. * Slab object creation initialisation for the XFS inode.
  775. * This covers only the idempotent fields in the XFS inode;
  776. * all other fields need to be initialised on allocation
  777. * from the slab. This avoids the need to repeatedly initialise
  778. * fields in the xfs inode that left in the initialise state
  779. * when freeing the inode.
  780. */
  781. STATIC void
  782. xfs_fs_inode_init_once(
  783. void *inode)
  784. {
  785. struct xfs_inode *ip = inode;
  786. memset(ip, 0, sizeof(struct xfs_inode));
  787. /* vfs inode */
  788. inode_init_once(VFS_I(ip));
  789. /* xfs inode */
  790. atomic_set(&ip->i_pincount, 0);
  791. spin_lock_init(&ip->i_flags_lock);
  792. mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
  793. "xfsino", ip->i_ino);
  794. }
  795. STATIC void
  796. xfs_fs_evict_inode(
  797. struct inode *inode)
  798. {
  799. xfs_inode_t *ip = XFS_I(inode);
  800. ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
  801. trace_xfs_evict_inode(ip);
  802. truncate_inode_pages(&inode->i_data, 0);
  803. clear_inode(inode);
  804. XFS_STATS_INC(vn_rele);
  805. XFS_STATS_INC(vn_remove);
  806. XFS_STATS_DEC(vn_active);
  807. xfs_inactive(ip);
  808. }
  809. /*
  810. * We do an unlocked check for XFS_IDONTCACHE here because we are already
  811. * serialised against cache hits here via the inode->i_lock and igrab() in
  812. * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
  813. * racing with us, and it avoids needing to grab a spinlock here for every inode
  814. * we drop the final reference on.
  815. */
  816. STATIC int
  817. xfs_fs_drop_inode(
  818. struct inode *inode)
  819. {
  820. struct xfs_inode *ip = XFS_I(inode);
  821. return generic_drop_inode(inode) || (ip->i_flags & XFS_IDONTCACHE);
  822. }
  823. STATIC void
  824. xfs_free_fsname(
  825. struct xfs_mount *mp)
  826. {
  827. kfree(mp->m_fsname);
  828. kfree(mp->m_rtname);
  829. kfree(mp->m_logname);
  830. }
  831. STATIC void
  832. xfs_fs_put_super(
  833. struct super_block *sb)
  834. {
  835. struct xfs_mount *mp = XFS_M(sb);
  836. xfs_filestream_unmount(mp);
  837. cancel_delayed_work_sync(&mp->m_sync_work);
  838. xfs_unmountfs(mp);
  839. xfs_syncd_stop(mp);
  840. xfs_freesb(mp);
  841. xfs_icsb_destroy_counters(mp);
  842. xfs_destroy_mount_workqueues(mp);
  843. xfs_close_devices(mp);
  844. xfs_free_fsname(mp);
  845. kfree(mp);
  846. }
  847. STATIC int
  848. xfs_fs_sync_fs(
  849. struct super_block *sb,
  850. int wait)
  851. {
  852. struct xfs_mount *mp = XFS_M(sb);
  853. int error;
  854. /*
  855. * Doing anything during the async pass would be counterproductive.
  856. */
  857. if (!wait)
  858. return 0;
  859. error = xfs_quiesce_data(mp);
  860. if (error)
  861. return -error;
  862. if (laptop_mode) {
  863. /*
  864. * The disk must be active because we're syncing.
  865. * We schedule xfssyncd now (now that the disk is
  866. * active) instead of later (when it might not be).
  867. */
  868. flush_delayed_work_sync(&mp->m_sync_work);
  869. }
  870. return 0;
  871. }
  872. STATIC int
  873. xfs_fs_statfs(
  874. struct dentry *dentry,
  875. struct kstatfs *statp)
  876. {
  877. struct xfs_mount *mp = XFS_M(dentry->d_sb);
  878. xfs_sb_t *sbp = &mp->m_sb;
  879. struct xfs_inode *ip = XFS_I(dentry->d_inode);
  880. __uint64_t fakeinos, id;
  881. xfs_extlen_t lsize;
  882. __int64_t ffree;
  883. statp->f_type = XFS_SB_MAGIC;
  884. statp->f_namelen = MAXNAMELEN - 1;
  885. id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
  886. statp->f_fsid.val[0] = (u32)id;
  887. statp->f_fsid.val[1] = (u32)(id >> 32);
  888. xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
  889. spin_lock(&mp->m_sb_lock);
  890. statp->f_bsize = sbp->sb_blocksize;
  891. lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
  892. statp->f_blocks = sbp->sb_dblocks - lsize;
  893. statp->f_bfree = statp->f_bavail =
  894. sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
  895. fakeinos = statp->f_bfree << sbp->sb_inopblog;
  896. statp->f_files =
  897. MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
  898. if (mp->m_maxicount)
  899. statp->f_files = min_t(typeof(statp->f_files),
  900. statp->f_files,
  901. mp->m_maxicount);
  902. /* make sure statp->f_ffree does not underflow */
  903. ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
  904. statp->f_ffree = max_t(__int64_t, ffree, 0);
  905. spin_unlock(&mp->m_sb_lock);
  906. if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
  907. ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) ==
  908. (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
  909. xfs_qm_statvfs(ip, statp);
  910. return 0;
  911. }
  912. STATIC void
  913. xfs_save_resvblks(struct xfs_mount *mp)
  914. {
  915. __uint64_t resblks = 0;
  916. mp->m_resblks_save = mp->m_resblks;
  917. xfs_reserve_blocks(mp, &resblks, NULL);
  918. }
  919. STATIC void
  920. xfs_restore_resvblks(struct xfs_mount *mp)
  921. {
  922. __uint64_t resblks;
  923. if (mp->m_resblks_save) {
  924. resblks = mp->m_resblks_save;
  925. mp->m_resblks_save = 0;
  926. } else
  927. resblks = xfs_default_resblks(mp);
  928. xfs_reserve_blocks(mp, &resblks, NULL);
  929. }
  930. STATIC void
  931. xfs_set_inode64(struct xfs_mount *mp)
  932. {
  933. int i = 0;
  934. for (i = 0; i < mp->m_sb.sb_agcount; i++) {
  935. struct xfs_perag *pag;
  936. pag = xfs_perag_get(mp, i);
  937. pag->pagi_inodeok = 1;
  938. pag->pagf_metadata = 0;
  939. xfs_perag_put(pag);
  940. }
  941. /* There is no need for lock protection on m_flags,
  942. * the rw_semaphore of the VFS superblock is locked
  943. * during mount/umount/remount operations, so this is
  944. * enough to avoid concurency on the m_flags field
  945. */
  946. mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
  947. XFS_MOUNT_SMALL_INUMS);
  948. mp->m_maxagi = i;
  949. }
  950. STATIC int
  951. xfs_fs_remount(
  952. struct super_block *sb,
  953. int *flags,
  954. char *options)
  955. {
  956. struct xfs_mount *mp = XFS_M(sb);
  957. substring_t args[MAX_OPT_ARGS];
  958. char *p;
  959. int error;
  960. while ((p = strsep(&options, ",")) != NULL) {
  961. int token;
  962. if (!*p)
  963. continue;
  964. token = match_token(p, tokens, args);
  965. switch (token) {
  966. case Opt_barrier:
  967. mp->m_flags |= XFS_MOUNT_BARRIER;
  968. break;
  969. case Opt_nobarrier:
  970. mp->m_flags &= ~XFS_MOUNT_BARRIER;
  971. break;
  972. case Opt_inode64:
  973. xfs_set_inode64(mp);
  974. break;
  975. default:
  976. /*
  977. * Logically we would return an error here to prevent
  978. * users from believing they might have changed
  979. * mount options using remount which can't be changed.
  980. *
  981. * But unfortunately mount(8) adds all options from
  982. * mtab and fstab to the mount arguments in some cases
  983. * so we can't blindly reject options, but have to
  984. * check for each specified option if it actually
  985. * differs from the currently set option and only
  986. * reject it if that's the case.
  987. *
  988. * Until that is implemented we return success for
  989. * every remount request, and silently ignore all
  990. * options that we can't actually change.
  991. */
  992. #if 0
  993. xfs_info(mp,
  994. "mount option \"%s\" not supported for remount\n", p);
  995. return -EINVAL;
  996. #else
  997. break;
  998. #endif
  999. }
  1000. }
  1001. /* ro -> rw */
  1002. if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
  1003. mp->m_flags &= ~XFS_MOUNT_RDONLY;
  1004. /*
  1005. * If this is the first remount to writeable state we
  1006. * might have some superblock changes to update.
  1007. */
  1008. if (mp->m_update_flags) {
  1009. error = xfs_mount_log_sb(mp, mp->m_update_flags);
  1010. if (error) {
  1011. xfs_warn(mp, "failed to write sb changes");
  1012. return error;
  1013. }
  1014. mp->m_update_flags = 0;
  1015. }
  1016. /*
  1017. * Fill out the reserve pool if it is empty. Use the stashed
  1018. * value if it is non-zero, otherwise go with the default.
  1019. */
  1020. xfs_restore_resvblks(mp);
  1021. }
  1022. /* rw -> ro */
  1023. if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
  1024. /*
  1025. * After we have synced the data but before we sync the
  1026. * metadata, we need to free up the reserve block pool so that
  1027. * the used block count in the superblock on disk is correct at
  1028. * the end of the remount. Stash the current reserve pool size
  1029. * so that if we get remounted rw, we can return it to the same
  1030. * size.
  1031. */
  1032. xfs_quiesce_data(mp);
  1033. xfs_save_resvblks(mp);
  1034. xfs_quiesce_attr(mp);
  1035. mp->m_flags |= XFS_MOUNT_RDONLY;
  1036. }
  1037. return 0;
  1038. }
  1039. /*
  1040. * Second stage of a freeze. The data is already frozen so we only
  1041. * need to take care of the metadata. Once that's done write a dummy
  1042. * record to dirty the log in case of a crash while frozen.
  1043. */
  1044. STATIC int
  1045. xfs_fs_freeze(
  1046. struct super_block *sb)
  1047. {
  1048. struct xfs_mount *mp = XFS_M(sb);
  1049. xfs_save_resvblks(mp);
  1050. xfs_quiesce_attr(mp);
  1051. return -xfs_fs_log_dummy(mp);
  1052. }
  1053. STATIC int
  1054. xfs_fs_unfreeze(
  1055. struct super_block *sb)
  1056. {
  1057. struct xfs_mount *mp = XFS_M(sb);
  1058. xfs_restore_resvblks(mp);
  1059. return 0;
  1060. }
  1061. STATIC int
  1062. xfs_fs_show_options(
  1063. struct seq_file *m,
  1064. struct dentry *root)
  1065. {
  1066. return -xfs_showargs(XFS_M(root->d_sb), m);
  1067. }
  1068. /*
  1069. * This function fills in xfs_mount_t fields based on mount args.
  1070. * Note: the superblock _has_ now been read in.
  1071. */
  1072. STATIC int
  1073. xfs_finish_flags(
  1074. struct xfs_mount *mp)
  1075. {
  1076. int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
  1077. /* Fail a mount where the logbuf is smaller than the log stripe */
  1078. if (xfs_sb_version_haslogv2(&mp->m_sb)) {
  1079. if (mp->m_logbsize <= 0 &&
  1080. mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
  1081. mp->m_logbsize = mp->m_sb.sb_logsunit;
  1082. } else if (mp->m_logbsize > 0 &&
  1083. mp->m_logbsize < mp->m_sb.sb_logsunit) {
  1084. xfs_warn(mp,
  1085. "logbuf size must be greater than or equal to log stripe size");
  1086. return XFS_ERROR(EINVAL);
  1087. }
  1088. } else {
  1089. /* Fail a mount if the logbuf is larger than 32K */
  1090. if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
  1091. xfs_warn(mp,
  1092. "logbuf size for version 1 logs must be 16K or 32K");
  1093. return XFS_ERROR(EINVAL);
  1094. }
  1095. }
  1096. /*
  1097. * mkfs'ed attr2 will turn on attr2 mount unless explicitly
  1098. * told by noattr2 to turn it off
  1099. */
  1100. if (xfs_sb_version_hasattr2(&mp->m_sb) &&
  1101. !(mp->m_flags & XFS_MOUNT_NOATTR2))
  1102. mp->m_flags |= XFS_MOUNT_ATTR2;
  1103. /*
  1104. * prohibit r/w mounts of read-only filesystems
  1105. */
  1106. if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
  1107. xfs_warn(mp,
  1108. "cannot mount a read-only filesystem as read-write");
  1109. return XFS_ERROR(EROFS);
  1110. }
  1111. return 0;
  1112. }
  1113. STATIC int
  1114. xfs_fs_fill_super(
  1115. struct super_block *sb,
  1116. void *data,
  1117. int silent)
  1118. {
  1119. struct inode *root;
  1120. struct xfs_mount *mp = NULL;
  1121. int flags = 0, error = ENOMEM;
  1122. mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
  1123. if (!mp)
  1124. goto out;
  1125. spin_lock_init(&mp->m_sb_lock);
  1126. mutex_init(&mp->m_growlock);
  1127. atomic_set(&mp->m_active_trans, 0);
  1128. mp->m_super = sb;
  1129. sb->s_fs_info = mp;
  1130. error = xfs_parseargs(mp, (char *)data);
  1131. if (error)
  1132. goto out_free_fsname;
  1133. sb_min_blocksize(sb, BBSIZE);
  1134. sb->s_xattr = xfs_xattr_handlers;
  1135. sb->s_export_op = &xfs_export_operations;
  1136. #ifdef CONFIG_XFS_QUOTA
  1137. sb->s_qcop = &xfs_quotactl_operations;
  1138. #endif
  1139. sb->s_op = &xfs_super_operations;
  1140. if (silent)
  1141. flags |= XFS_MFSI_QUIET;
  1142. error = xfs_open_devices(mp);
  1143. if (error)
  1144. goto out_free_fsname;
  1145. error = xfs_init_mount_workqueues(mp);
  1146. if (error)
  1147. goto out_close_devices;
  1148. error = xfs_icsb_init_counters(mp);
  1149. if (error)
  1150. goto out_destroy_workqueues;
  1151. error = xfs_readsb(mp, flags);
  1152. if (error)
  1153. goto out_destroy_counters;
  1154. error = xfs_finish_flags(mp);
  1155. if (error)
  1156. goto out_free_sb;
  1157. error = xfs_setup_devices(mp);
  1158. if (error)
  1159. goto out_free_sb;
  1160. error = xfs_filestream_mount(mp);
  1161. if (error)
  1162. goto out_free_sb;
  1163. /*
  1164. * we must configure the block size in the superblock before we run the
  1165. * full mount process as the mount process can lookup and cache inodes.
  1166. * For the same reason we must also initialise the syncd and register
  1167. * the inode cache shrinker so that inodes can be reclaimed during
  1168. * operations like a quotacheck that iterate all inodes in the
  1169. * filesystem.
  1170. */
  1171. sb->s_magic = XFS_SB_MAGIC;
  1172. sb->s_blocksize = mp->m_sb.sb_blocksize;
  1173. sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
  1174. sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
  1175. sb->s_max_links = XFS_MAXLINK;
  1176. sb->s_time_gran = 1;
  1177. set_posix_acl_flag(sb);
  1178. error = xfs_syncd_init(mp);
  1179. if (error)
  1180. goto out_filestream_unmount;
  1181. error = xfs_mountfs(mp);
  1182. if (error)
  1183. goto out_syncd_stop;
  1184. root = igrab(VFS_I(mp->m_rootip));
  1185. if (!root) {
  1186. error = ENOENT;
  1187. goto out_unmount;
  1188. }
  1189. if (is_bad_inode(root)) {
  1190. error = EINVAL;
  1191. goto out_unmount;
  1192. }
  1193. sb->s_root = d_make_root(root);
  1194. if (!sb->s_root) {
  1195. error = ENOMEM;
  1196. goto out_unmount;
  1197. }
  1198. return 0;
  1199. out_syncd_stop:
  1200. xfs_syncd_stop(mp);
  1201. out_filestream_unmount:
  1202. xfs_filestream_unmount(mp);
  1203. out_free_sb:
  1204. xfs_freesb(mp);
  1205. out_destroy_counters:
  1206. xfs_icsb_destroy_counters(mp);
  1207. out_destroy_workqueues:
  1208. xfs_destroy_mount_workqueues(mp);
  1209. out_close_devices:
  1210. xfs_close_devices(mp);
  1211. out_free_fsname:
  1212. xfs_free_fsname(mp);
  1213. kfree(mp);
  1214. out:
  1215. return -error;
  1216. out_unmount:
  1217. xfs_filestream_unmount(mp);
  1218. xfs_unmountfs(mp);
  1219. xfs_syncd_stop(mp);
  1220. goto out_free_sb;
  1221. }
  1222. STATIC struct dentry *
  1223. xfs_fs_mount(
  1224. struct file_system_type *fs_type,
  1225. int flags,
  1226. const char *dev_name,
  1227. void *data)
  1228. {
  1229. return mount_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
  1230. }
  1231. static int
  1232. xfs_fs_nr_cached_objects(
  1233. struct super_block *sb)
  1234. {
  1235. return xfs_reclaim_inodes_count(XFS_M(sb));
  1236. }
  1237. static void
  1238. xfs_fs_free_cached_objects(
  1239. struct super_block *sb,
  1240. int nr_to_scan)
  1241. {
  1242. xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan);
  1243. }
  1244. static const struct super_operations xfs_super_operations = {
  1245. .alloc_inode = xfs_fs_alloc_inode,
  1246. .destroy_inode = xfs_fs_destroy_inode,
  1247. .evict_inode = xfs_fs_evict_inode,
  1248. .drop_inode = xfs_fs_drop_inode,
  1249. .put_super = xfs_fs_put_super,
  1250. .sync_fs = xfs_fs_sync_fs,
  1251. .freeze_fs = xfs_fs_freeze,
  1252. .unfreeze_fs = xfs_fs_unfreeze,
  1253. .statfs = xfs_fs_statfs,
  1254. .remount_fs = xfs_fs_remount,
  1255. .show_options = xfs_fs_show_options,
  1256. .nr_cached_objects = xfs_fs_nr_cached_objects,
  1257. .free_cached_objects = xfs_fs_free_cached_objects,
  1258. };
  1259. static struct file_system_type xfs_fs_type = {
  1260. .owner = THIS_MODULE,
  1261. .name = "xfs",
  1262. .mount = xfs_fs_mount,
  1263. .kill_sb = kill_block_super,
  1264. .fs_flags = FS_REQUIRES_DEV,
  1265. };
  1266. STATIC int __init
  1267. xfs_init_zones(void)
  1268. {
  1269. xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
  1270. if (!xfs_ioend_zone)
  1271. goto out;
  1272. xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
  1273. xfs_ioend_zone);
  1274. if (!xfs_ioend_pool)
  1275. goto out_destroy_ioend_zone;
  1276. xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
  1277. "xfs_log_ticket");
  1278. if (!xfs_log_ticket_zone)
  1279. goto out_destroy_ioend_pool;
  1280. xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
  1281. "xfs_bmap_free_item");
  1282. if (!xfs_bmap_free_item_zone)
  1283. goto out_destroy_log_ticket_zone;
  1284. xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
  1285. "xfs_btree_cur");
  1286. if (!xfs_btree_cur_zone)
  1287. goto out_destroy_bmap_free_item_zone;
  1288. xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
  1289. "xfs_da_state");
  1290. if (!xfs_da_state_zone)
  1291. goto out_destroy_btree_cur_zone;
  1292. xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
  1293. if (!xfs_ifork_zone)
  1294. goto out_destroy_da_state_zone;
  1295. xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
  1296. if (!xfs_trans_zone)
  1297. goto out_destroy_ifork_zone;
  1298. xfs_log_item_desc_zone =
  1299. kmem_zone_init(sizeof(struct xfs_log_item_desc),
  1300. "xfs_log_item_desc");
  1301. if (!xfs_log_item_desc_zone)
  1302. goto out_destroy_trans_zone;
  1303. /*
  1304. * The size of the zone allocated buf log item is the maximum
  1305. * size possible under XFS. This wastes a little bit of memory,
  1306. * but it is much faster.
  1307. */
  1308. xfs_buf_item_zone = kmem_zone_init(sizeof(struct xfs_buf_log_item),
  1309. "xfs_buf_item");
  1310. if (!xfs_buf_item_zone)
  1311. goto out_destroy_log_item_desc_zone;
  1312. xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
  1313. ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
  1314. sizeof(xfs_extent_t))), "xfs_efd_item");
  1315. if (!xfs_efd_zone)
  1316. goto out_destroy_buf_item_zone;
  1317. xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
  1318. ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
  1319. sizeof(xfs_extent_t))), "xfs_efi_item");
  1320. if (!xfs_efi_zone)
  1321. goto out_destroy_efd_zone;
  1322. xfs_inode_zone =
  1323. kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
  1324. KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD,
  1325. xfs_fs_inode_init_once);
  1326. if (!xfs_inode_zone)
  1327. goto out_destroy_efi_zone;
  1328. xfs_ili_zone =
  1329. kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
  1330. KM_ZONE_SPREAD, NULL);
  1331. if (!xfs_ili_zone)
  1332. goto out_destroy_inode_zone;
  1333. return 0;
  1334. out_destroy_inode_zone:
  1335. kmem_zone_destroy(xfs_inode_zone);
  1336. out_destroy_efi_zone:
  1337. kmem_zone_destroy(xfs_efi_zone);
  1338. out_destroy_efd_zone:
  1339. kmem_zone_destroy(xfs_efd_zone);
  1340. out_destroy_buf_item_zone:
  1341. kmem_zone_destroy(xfs_buf_item_zone);
  1342. out_destroy_log_item_desc_zone:
  1343. kmem_zone_destroy(xfs_log_item_desc_zone);
  1344. out_destroy_trans_zone:
  1345. kmem_zone_destroy(xfs_trans_zone);
  1346. out_destroy_ifork_zone:
  1347. kmem_zone_destroy(xfs_ifork_zone);
  1348. out_destroy_da_state_zone:
  1349. kmem_zone_destroy(xfs_da_state_zone);
  1350. out_destroy_btree_cur_zone:
  1351. kmem_zone_destroy(xfs_btree_cur_zone);
  1352. out_destroy_bmap_free_item_zone:
  1353. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1354. out_destroy_log_ticket_zone:
  1355. kmem_zone_destroy(xfs_log_ticket_zone);
  1356. out_destroy_ioend_pool:
  1357. mempool_destroy(xfs_ioend_pool);
  1358. out_destroy_ioend_zone:
  1359. kmem_zone_destroy(xfs_ioend_zone);
  1360. out:
  1361. return -ENOMEM;
  1362. }
  1363. STATIC void
  1364. xfs_destroy_zones(void)
  1365. {
  1366. kmem_zone_destroy(xfs_ili_zone);
  1367. kmem_zone_destroy(xfs_inode_zone);
  1368. kmem_zone_destroy(xfs_efi_zone);
  1369. kmem_zone_destroy(xfs_efd_zone);
  1370. kmem_zone_destroy(xfs_buf_item_zone);
  1371. kmem_zone_destroy(xfs_log_item_desc_zone);
  1372. kmem_zone_destroy(xfs_trans_zone);
  1373. kmem_zone_destroy(xfs_ifork_zone);
  1374. kmem_zone_destroy(xfs_da_state_zone);
  1375. kmem_zone_destroy(xfs_btree_cur_zone);
  1376. kmem_zone_destroy(xfs_bmap_free_item_zone);
  1377. kmem_zone_destroy(xfs_log_ticket_zone);
  1378. mempool_destroy(xfs_ioend_pool);
  1379. kmem_zone_destroy(xfs_ioend_zone);
  1380. }
  1381. STATIC int __init
  1382. xfs_init_workqueues(void)
  1383. {
  1384. /*
  1385. * We never want to the same work item to run twice, reclaiming inodes
  1386. * or idling the log is not going to get any faster by multiple CPUs
  1387. * competing for ressources. Use the default large max_active value
  1388. * so that even lots of filesystems can perform these task in parallel.
  1389. */
  1390. xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0);
  1391. if (!xfs_syncd_wq)
  1392. return -ENOMEM;
  1393. /*
  1394. * The allocation workqueue can be used in memory reclaim situations
  1395. * (writepage path), and parallelism is only limited by the number of
  1396. * AGs in all the filesystems mounted. Hence use the default large
  1397. * max_active value for this workqueue.
  1398. */
  1399. xfs_alloc_wq = alloc_workqueue("xfsalloc", WQ_MEM_RECLAIM, 0);
  1400. if (!xfs_alloc_wq)
  1401. goto out_destroy_syncd;
  1402. return 0;
  1403. out_destroy_syncd:
  1404. destroy_workqueue(xfs_syncd_wq);
  1405. return -ENOMEM;
  1406. }
  1407. STATIC void
  1408. xfs_destroy_workqueues(void)
  1409. {
  1410. destroy_workqueue(xfs_alloc_wq);
  1411. destroy_workqueue(xfs_syncd_wq);
  1412. }
  1413. STATIC int __init
  1414. init_xfs_fs(void)
  1415. {
  1416. int error;
  1417. printk(KERN_INFO XFS_VERSION_STRING " with "
  1418. XFS_BUILD_OPTIONS " enabled\n");
  1419. xfs_dir_startup();
  1420. error = xfs_init_zones();
  1421. if (error)
  1422. goto out;
  1423. error = xfs_init_workqueues();
  1424. if (error)
  1425. goto out_destroy_zones;
  1426. error = xfs_mru_cache_init();
  1427. if (error)
  1428. goto out_destroy_wq;
  1429. error = xfs_filestream_init();
  1430. if (error)
  1431. goto out_mru_cache_uninit;
  1432. error = xfs_buf_init();
  1433. if (error)
  1434. goto out_filestream_uninit;
  1435. error = xfs_init_procfs();
  1436. if (error)
  1437. goto out_buf_terminate;
  1438. error = xfs_sysctl_register();
  1439. if (error)
  1440. goto out_cleanup_procfs;
  1441. error = xfs_qm_init();
  1442. if (error)
  1443. goto out_sysctl_unregister;
  1444. error = register_filesystem(&xfs_fs_type);
  1445. if (error)
  1446. goto out_qm_exit;
  1447. return 0;
  1448. out_qm_exit:
  1449. xfs_qm_exit();
  1450. out_sysctl_unregister:
  1451. xfs_sysctl_unregister();
  1452. out_cleanup_procfs:
  1453. xfs_cleanup_procfs();
  1454. out_buf_terminate:
  1455. xfs_buf_terminate();
  1456. out_filestream_uninit:
  1457. xfs_filestream_uninit();
  1458. out_mru_cache_uninit:
  1459. xfs_mru_cache_uninit();
  1460. out_destroy_wq:
  1461. xfs_destroy_workqueues();
  1462. out_destroy_zones:
  1463. xfs_destroy_zones();
  1464. out:
  1465. return error;
  1466. }
  1467. STATIC void __exit
  1468. exit_xfs_fs(void)
  1469. {
  1470. xfs_qm_exit();
  1471. unregister_filesystem(&xfs_fs_type);
  1472. xfs_sysctl_unregister();
  1473. xfs_cleanup_procfs();
  1474. xfs_buf_terminate();
  1475. xfs_filestream_uninit();
  1476. xfs_mru_cache_uninit();
  1477. xfs_destroy_workqueues();
  1478. xfs_destroy_zones();
  1479. }
  1480. module_init(init_xfs_fs);
  1481. module_exit(exit_xfs_fs);
  1482. MODULE_AUTHOR("Silicon Graphics, Inc.");
  1483. MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
  1484. MODULE_LICENSE("GPL");