xfs_super.c 56 KB

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