xfs_inode_item.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. /*
  2. * Copyright (c) 2000-2002,2005 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_fs.h"
  20. #include "xfs_types.h"
  21. #include "xfs_bit.h"
  22. #include "xfs_log.h"
  23. #include "xfs_inum.h"
  24. #include "xfs_trans.h"
  25. #include "xfs_buf_item.h"
  26. #include "xfs_sb.h"
  27. #include "xfs_ag.h"
  28. #include "xfs_dir2.h"
  29. #include "xfs_dmapi.h"
  30. #include "xfs_mount.h"
  31. #include "xfs_trans_priv.h"
  32. #include "xfs_bmap_btree.h"
  33. #include "xfs_alloc_btree.h"
  34. #include "xfs_ialloc_btree.h"
  35. #include "xfs_dir2_sf.h"
  36. #include "xfs_attr_sf.h"
  37. #include "xfs_dinode.h"
  38. #include "xfs_inode.h"
  39. #include "xfs_inode_item.h"
  40. #include "xfs_btree.h"
  41. #include "xfs_ialloc.h"
  42. #include "xfs_rw.h"
  43. #include "xfs_error.h"
  44. kmem_zone_t *xfs_ili_zone; /* inode log item zone */
  45. /*
  46. * This returns the number of iovecs needed to log the given inode item.
  47. *
  48. * We need one iovec for the inode log format structure, one for the
  49. * inode core, and possibly one for the inode data/extents/b-tree root
  50. * and one for the inode attribute data/extents/b-tree root.
  51. */
  52. STATIC uint
  53. xfs_inode_item_size(
  54. xfs_inode_log_item_t *iip)
  55. {
  56. uint nvecs;
  57. xfs_inode_t *ip;
  58. ip = iip->ili_inode;
  59. nvecs = 2;
  60. /*
  61. * Only log the data/extents/b-tree root if there is something
  62. * left to log.
  63. */
  64. iip->ili_format.ilf_fields |= XFS_ILOG_CORE;
  65. switch (ip->i_d.di_format) {
  66. case XFS_DINODE_FMT_EXTENTS:
  67. iip->ili_format.ilf_fields &=
  68. ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
  69. XFS_ILOG_DEV | XFS_ILOG_UUID);
  70. if ((iip->ili_format.ilf_fields & XFS_ILOG_DEXT) &&
  71. (ip->i_d.di_nextents > 0) &&
  72. (ip->i_df.if_bytes > 0)) {
  73. ASSERT(ip->i_df.if_u1.if_extents != NULL);
  74. nvecs++;
  75. } else {
  76. iip->ili_format.ilf_fields &= ~XFS_ILOG_DEXT;
  77. }
  78. break;
  79. case XFS_DINODE_FMT_BTREE:
  80. ASSERT(ip->i_df.if_ext_max ==
  81. XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
  82. iip->ili_format.ilf_fields &=
  83. ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT |
  84. XFS_ILOG_DEV | XFS_ILOG_UUID);
  85. if ((iip->ili_format.ilf_fields & XFS_ILOG_DBROOT) &&
  86. (ip->i_df.if_broot_bytes > 0)) {
  87. ASSERT(ip->i_df.if_broot != NULL);
  88. nvecs++;
  89. } else {
  90. ASSERT(!(iip->ili_format.ilf_fields &
  91. XFS_ILOG_DBROOT));
  92. #ifdef XFS_TRANS_DEBUG
  93. if (iip->ili_root_size > 0) {
  94. ASSERT(iip->ili_root_size ==
  95. ip->i_df.if_broot_bytes);
  96. ASSERT(memcmp(iip->ili_orig_root,
  97. ip->i_df.if_broot,
  98. iip->ili_root_size) == 0);
  99. } else {
  100. ASSERT(ip->i_df.if_broot_bytes == 0);
  101. }
  102. #endif
  103. iip->ili_format.ilf_fields &= ~XFS_ILOG_DBROOT;
  104. }
  105. break;
  106. case XFS_DINODE_FMT_LOCAL:
  107. iip->ili_format.ilf_fields &=
  108. ~(XFS_ILOG_DEXT | XFS_ILOG_DBROOT |
  109. XFS_ILOG_DEV | XFS_ILOG_UUID);
  110. if ((iip->ili_format.ilf_fields & XFS_ILOG_DDATA) &&
  111. (ip->i_df.if_bytes > 0)) {
  112. ASSERT(ip->i_df.if_u1.if_data != NULL);
  113. ASSERT(ip->i_d.di_size > 0);
  114. nvecs++;
  115. } else {
  116. iip->ili_format.ilf_fields &= ~XFS_ILOG_DDATA;
  117. }
  118. break;
  119. case XFS_DINODE_FMT_DEV:
  120. iip->ili_format.ilf_fields &=
  121. ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
  122. XFS_ILOG_DEXT | XFS_ILOG_UUID);
  123. break;
  124. case XFS_DINODE_FMT_UUID:
  125. iip->ili_format.ilf_fields &=
  126. ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
  127. XFS_ILOG_DEXT | XFS_ILOG_DEV);
  128. break;
  129. default:
  130. ASSERT(0);
  131. break;
  132. }
  133. /*
  134. * If there are no attributes associated with this file,
  135. * then there cannot be anything more to log.
  136. * Clear all attribute-related log flags.
  137. */
  138. if (!XFS_IFORK_Q(ip)) {
  139. iip->ili_format.ilf_fields &=
  140. ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
  141. return nvecs;
  142. }
  143. /*
  144. * Log any necessary attribute data.
  145. */
  146. switch (ip->i_d.di_aformat) {
  147. case XFS_DINODE_FMT_EXTENTS:
  148. iip->ili_format.ilf_fields &=
  149. ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT);
  150. if ((iip->ili_format.ilf_fields & XFS_ILOG_AEXT) &&
  151. (ip->i_d.di_anextents > 0) &&
  152. (ip->i_afp->if_bytes > 0)) {
  153. ASSERT(ip->i_afp->if_u1.if_extents != NULL);
  154. nvecs++;
  155. } else {
  156. iip->ili_format.ilf_fields &= ~XFS_ILOG_AEXT;
  157. }
  158. break;
  159. case XFS_DINODE_FMT_BTREE:
  160. iip->ili_format.ilf_fields &=
  161. ~(XFS_ILOG_ADATA | XFS_ILOG_AEXT);
  162. if ((iip->ili_format.ilf_fields & XFS_ILOG_ABROOT) &&
  163. (ip->i_afp->if_broot_bytes > 0)) {
  164. ASSERT(ip->i_afp->if_broot != NULL);
  165. nvecs++;
  166. } else {
  167. iip->ili_format.ilf_fields &= ~XFS_ILOG_ABROOT;
  168. }
  169. break;
  170. case XFS_DINODE_FMT_LOCAL:
  171. iip->ili_format.ilf_fields &=
  172. ~(XFS_ILOG_AEXT | XFS_ILOG_ABROOT);
  173. if ((iip->ili_format.ilf_fields & XFS_ILOG_ADATA) &&
  174. (ip->i_afp->if_bytes > 0)) {
  175. ASSERT(ip->i_afp->if_u1.if_data != NULL);
  176. nvecs++;
  177. } else {
  178. iip->ili_format.ilf_fields &= ~XFS_ILOG_ADATA;
  179. }
  180. break;
  181. default:
  182. ASSERT(0);
  183. break;
  184. }
  185. return nvecs;
  186. }
  187. /*
  188. * This is called to fill in the vector of log iovecs for the
  189. * given inode log item. It fills the first item with an inode
  190. * log format structure, the second with the on-disk inode structure,
  191. * and a possible third and/or fourth with the inode data/extents/b-tree
  192. * root and inode attributes data/extents/b-tree root.
  193. */
  194. STATIC void
  195. xfs_inode_item_format(
  196. xfs_inode_log_item_t *iip,
  197. xfs_log_iovec_t *log_vector)
  198. {
  199. uint nvecs;
  200. xfs_log_iovec_t *vecp;
  201. xfs_inode_t *ip;
  202. size_t data_bytes;
  203. xfs_bmbt_rec_t *ext_buffer;
  204. int nrecs;
  205. xfs_mount_t *mp;
  206. ip = iip->ili_inode;
  207. vecp = log_vector;
  208. vecp->i_addr = (xfs_caddr_t)&iip->ili_format;
  209. vecp->i_len = sizeof(xfs_inode_log_format_t);
  210. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IFORMAT);
  211. vecp++;
  212. nvecs = 1;
  213. /*
  214. * Make sure the linux inode is dirty. We do this before
  215. * clearing i_update_core as the VFS will call back into
  216. * XFS here and set i_update_core, so we need to dirty the
  217. * inode first so that the ordering of i_update_core and
  218. * unlogged modifications still works as described below.
  219. */
  220. xfs_mark_inode_dirty_sync(ip);
  221. /*
  222. * Clear i_update_core if the timestamps (or any other
  223. * non-transactional modification) need flushing/logging
  224. * and we're about to log them with the rest of the core.
  225. *
  226. * This is the same logic as xfs_iflush() but this code can't
  227. * run at the same time as xfs_iflush because we're in commit
  228. * processing here and so we have the inode lock held in
  229. * exclusive mode. Although it doesn't really matter
  230. * for the timestamps if both routines were to grab the
  231. * timestamps or not. That would be ok.
  232. *
  233. * We clear i_update_core before copying out the data.
  234. * This is for coordination with our timestamp updates
  235. * that don't hold the inode lock. They will always
  236. * update the timestamps BEFORE setting i_update_core,
  237. * so if we clear i_update_core after they set it we
  238. * are guaranteed to see their updates to the timestamps
  239. * either here. Likewise, if they set it after we clear it
  240. * here, we'll see it either on the next commit of this
  241. * inode or the next time the inode gets flushed via
  242. * xfs_iflush(). This depends on strongly ordered memory
  243. * semantics, but we have that. We use the SYNCHRONIZE
  244. * macro to make sure that the compiler does not reorder
  245. * the i_update_core access below the data copy below.
  246. */
  247. if (ip->i_update_core) {
  248. ip->i_update_core = 0;
  249. SYNCHRONIZE();
  250. }
  251. /*
  252. * Make sure to get the latest timestamps from the Linux inode.
  253. */
  254. xfs_synchronize_times(ip);
  255. vecp->i_addr = (xfs_caddr_t)&ip->i_d;
  256. vecp->i_len = sizeof(struct xfs_icdinode);
  257. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_ICORE);
  258. vecp++;
  259. nvecs++;
  260. iip->ili_format.ilf_fields |= XFS_ILOG_CORE;
  261. /*
  262. * If this is really an old format inode, then we need to
  263. * log it as such. This means that we have to copy the link
  264. * count from the new field to the old. We don't have to worry
  265. * about the new fields, because nothing trusts them as long as
  266. * the old inode version number is there. If the superblock already
  267. * has a new version number, then we don't bother converting back.
  268. */
  269. mp = ip->i_mount;
  270. ASSERT(ip->i_d.di_version == 1 || xfs_sb_version_hasnlink(&mp->m_sb));
  271. if (ip->i_d.di_version == 1) {
  272. if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
  273. /*
  274. * Convert it back.
  275. */
  276. ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
  277. ip->i_d.di_onlink = ip->i_d.di_nlink;
  278. } else {
  279. /*
  280. * The superblock version has already been bumped,
  281. * so just make the conversion to the new inode
  282. * format permanent.
  283. */
  284. ip->i_d.di_version = 2;
  285. ip->i_d.di_onlink = 0;
  286. memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
  287. }
  288. }
  289. switch (ip->i_d.di_format) {
  290. case XFS_DINODE_FMT_EXTENTS:
  291. ASSERT(!(iip->ili_format.ilf_fields &
  292. (XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
  293. XFS_ILOG_DEV | XFS_ILOG_UUID)));
  294. if (iip->ili_format.ilf_fields & XFS_ILOG_DEXT) {
  295. ASSERT(ip->i_df.if_bytes > 0);
  296. ASSERT(ip->i_df.if_u1.if_extents != NULL);
  297. ASSERT(ip->i_d.di_nextents > 0);
  298. ASSERT(iip->ili_extents_buf == NULL);
  299. nrecs = ip->i_df.if_bytes /
  300. (uint)sizeof(xfs_bmbt_rec_t);
  301. ASSERT(nrecs > 0);
  302. #ifdef XFS_NATIVE_HOST
  303. if (nrecs == ip->i_d.di_nextents) {
  304. /*
  305. * There are no delayed allocation
  306. * extents, so just point to the
  307. * real extents array.
  308. */
  309. vecp->i_addr =
  310. (char *)(ip->i_df.if_u1.if_extents);
  311. vecp->i_len = ip->i_df.if_bytes;
  312. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IEXT);
  313. } else
  314. #endif
  315. {
  316. /*
  317. * There are delayed allocation extents
  318. * in the inode, or we need to convert
  319. * the extents to on disk format.
  320. * Use xfs_iextents_copy()
  321. * to copy only the real extents into
  322. * a separate buffer. We'll free the
  323. * buffer in the unlock routine.
  324. */
  325. ext_buffer = kmem_alloc(ip->i_df.if_bytes,
  326. KM_SLEEP);
  327. iip->ili_extents_buf = ext_buffer;
  328. vecp->i_addr = (xfs_caddr_t)ext_buffer;
  329. vecp->i_len = xfs_iextents_copy(ip, ext_buffer,
  330. XFS_DATA_FORK);
  331. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IEXT);
  332. }
  333. ASSERT(vecp->i_len <= ip->i_df.if_bytes);
  334. iip->ili_format.ilf_dsize = vecp->i_len;
  335. vecp++;
  336. nvecs++;
  337. }
  338. break;
  339. case XFS_DINODE_FMT_BTREE:
  340. ASSERT(!(iip->ili_format.ilf_fields &
  341. (XFS_ILOG_DDATA | XFS_ILOG_DEXT |
  342. XFS_ILOG_DEV | XFS_ILOG_UUID)));
  343. if (iip->ili_format.ilf_fields & XFS_ILOG_DBROOT) {
  344. ASSERT(ip->i_df.if_broot_bytes > 0);
  345. ASSERT(ip->i_df.if_broot != NULL);
  346. vecp->i_addr = (xfs_caddr_t)ip->i_df.if_broot;
  347. vecp->i_len = ip->i_df.if_broot_bytes;
  348. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IBROOT);
  349. vecp++;
  350. nvecs++;
  351. iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes;
  352. }
  353. break;
  354. case XFS_DINODE_FMT_LOCAL:
  355. ASSERT(!(iip->ili_format.ilf_fields &
  356. (XFS_ILOG_DBROOT | XFS_ILOG_DEXT |
  357. XFS_ILOG_DEV | XFS_ILOG_UUID)));
  358. if (iip->ili_format.ilf_fields & XFS_ILOG_DDATA) {
  359. ASSERT(ip->i_df.if_bytes > 0);
  360. ASSERT(ip->i_df.if_u1.if_data != NULL);
  361. ASSERT(ip->i_d.di_size > 0);
  362. vecp->i_addr = (xfs_caddr_t)ip->i_df.if_u1.if_data;
  363. /*
  364. * Round i_bytes up to a word boundary.
  365. * The underlying memory is guaranteed to
  366. * to be there by xfs_idata_realloc().
  367. */
  368. data_bytes = roundup(ip->i_df.if_bytes, 4);
  369. ASSERT((ip->i_df.if_real_bytes == 0) ||
  370. (ip->i_df.if_real_bytes == data_bytes));
  371. vecp->i_len = (int)data_bytes;
  372. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_ILOCAL);
  373. vecp++;
  374. nvecs++;
  375. iip->ili_format.ilf_dsize = (unsigned)data_bytes;
  376. }
  377. break;
  378. case XFS_DINODE_FMT_DEV:
  379. ASSERT(!(iip->ili_format.ilf_fields &
  380. (XFS_ILOG_DBROOT | XFS_ILOG_DEXT |
  381. XFS_ILOG_DDATA | XFS_ILOG_UUID)));
  382. if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) {
  383. iip->ili_format.ilf_u.ilfu_rdev =
  384. ip->i_df.if_u2.if_rdev;
  385. }
  386. break;
  387. case XFS_DINODE_FMT_UUID:
  388. ASSERT(!(iip->ili_format.ilf_fields &
  389. (XFS_ILOG_DBROOT | XFS_ILOG_DEXT |
  390. XFS_ILOG_DDATA | XFS_ILOG_DEV)));
  391. if (iip->ili_format.ilf_fields & XFS_ILOG_UUID) {
  392. iip->ili_format.ilf_u.ilfu_uuid =
  393. ip->i_df.if_u2.if_uuid;
  394. }
  395. break;
  396. default:
  397. ASSERT(0);
  398. break;
  399. }
  400. /*
  401. * If there are no attributes associated with the file,
  402. * then we're done.
  403. * Assert that no attribute-related log flags are set.
  404. */
  405. if (!XFS_IFORK_Q(ip)) {
  406. ASSERT(nvecs == iip->ili_item.li_desc->lid_size);
  407. iip->ili_format.ilf_size = nvecs;
  408. ASSERT(!(iip->ili_format.ilf_fields &
  409. (XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT)));
  410. return;
  411. }
  412. switch (ip->i_d.di_aformat) {
  413. case XFS_DINODE_FMT_EXTENTS:
  414. ASSERT(!(iip->ili_format.ilf_fields &
  415. (XFS_ILOG_ADATA | XFS_ILOG_ABROOT)));
  416. if (iip->ili_format.ilf_fields & XFS_ILOG_AEXT) {
  417. ASSERT(ip->i_afp->if_bytes > 0);
  418. ASSERT(ip->i_afp->if_u1.if_extents != NULL);
  419. ASSERT(ip->i_d.di_anextents > 0);
  420. #ifdef DEBUG
  421. nrecs = ip->i_afp->if_bytes /
  422. (uint)sizeof(xfs_bmbt_rec_t);
  423. #endif
  424. ASSERT(nrecs > 0);
  425. ASSERT(nrecs == ip->i_d.di_anextents);
  426. #ifdef XFS_NATIVE_HOST
  427. /*
  428. * There are not delayed allocation extents
  429. * for attributes, so just point at the array.
  430. */
  431. vecp->i_addr = (char *)(ip->i_afp->if_u1.if_extents);
  432. vecp->i_len = ip->i_afp->if_bytes;
  433. #else
  434. ASSERT(iip->ili_aextents_buf == NULL);
  435. /*
  436. * Need to endian flip before logging
  437. */
  438. ext_buffer = kmem_alloc(ip->i_afp->if_bytes,
  439. KM_SLEEP);
  440. iip->ili_aextents_buf = ext_buffer;
  441. vecp->i_addr = (xfs_caddr_t)ext_buffer;
  442. vecp->i_len = xfs_iextents_copy(ip, ext_buffer,
  443. XFS_ATTR_FORK);
  444. #endif
  445. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IATTR_EXT);
  446. iip->ili_format.ilf_asize = vecp->i_len;
  447. vecp++;
  448. nvecs++;
  449. }
  450. break;
  451. case XFS_DINODE_FMT_BTREE:
  452. ASSERT(!(iip->ili_format.ilf_fields &
  453. (XFS_ILOG_ADATA | XFS_ILOG_AEXT)));
  454. if (iip->ili_format.ilf_fields & XFS_ILOG_ABROOT) {
  455. ASSERT(ip->i_afp->if_broot_bytes > 0);
  456. ASSERT(ip->i_afp->if_broot != NULL);
  457. vecp->i_addr = (xfs_caddr_t)ip->i_afp->if_broot;
  458. vecp->i_len = ip->i_afp->if_broot_bytes;
  459. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IATTR_BROOT);
  460. vecp++;
  461. nvecs++;
  462. iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes;
  463. }
  464. break;
  465. case XFS_DINODE_FMT_LOCAL:
  466. ASSERT(!(iip->ili_format.ilf_fields &
  467. (XFS_ILOG_ABROOT | XFS_ILOG_AEXT)));
  468. if (iip->ili_format.ilf_fields & XFS_ILOG_ADATA) {
  469. ASSERT(ip->i_afp->if_bytes > 0);
  470. ASSERT(ip->i_afp->if_u1.if_data != NULL);
  471. vecp->i_addr = (xfs_caddr_t)ip->i_afp->if_u1.if_data;
  472. /*
  473. * Round i_bytes up to a word boundary.
  474. * The underlying memory is guaranteed to
  475. * to be there by xfs_idata_realloc().
  476. */
  477. data_bytes = roundup(ip->i_afp->if_bytes, 4);
  478. ASSERT((ip->i_afp->if_real_bytes == 0) ||
  479. (ip->i_afp->if_real_bytes == data_bytes));
  480. vecp->i_len = (int)data_bytes;
  481. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_IATTR_LOCAL);
  482. vecp++;
  483. nvecs++;
  484. iip->ili_format.ilf_asize = (unsigned)data_bytes;
  485. }
  486. break;
  487. default:
  488. ASSERT(0);
  489. break;
  490. }
  491. ASSERT(nvecs == iip->ili_item.li_desc->lid_size);
  492. iip->ili_format.ilf_size = nvecs;
  493. }
  494. /*
  495. * This is called to pin the inode associated with the inode log
  496. * item in memory so it cannot be written out. Do this by calling
  497. * xfs_ipin() to bump the pin count in the inode while holding the
  498. * inode pin lock.
  499. */
  500. STATIC void
  501. xfs_inode_item_pin(
  502. xfs_inode_log_item_t *iip)
  503. {
  504. ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL));
  505. xfs_ipin(iip->ili_inode);
  506. }
  507. /*
  508. * This is called to unpin the inode associated with the inode log
  509. * item which was previously pinned with a call to xfs_inode_item_pin().
  510. * Just call xfs_iunpin() on the inode to do this.
  511. */
  512. /* ARGSUSED */
  513. STATIC void
  514. xfs_inode_item_unpin(
  515. xfs_inode_log_item_t *iip,
  516. int stale)
  517. {
  518. xfs_iunpin(iip->ili_inode);
  519. }
  520. /* ARGSUSED */
  521. STATIC void
  522. xfs_inode_item_unpin_remove(
  523. xfs_inode_log_item_t *iip,
  524. xfs_trans_t *tp)
  525. {
  526. xfs_iunpin(iip->ili_inode);
  527. }
  528. /*
  529. * This is called to attempt to lock the inode associated with this
  530. * inode log item, in preparation for the push routine which does the actual
  531. * iflush. Don't sleep on the inode lock or the flush lock.
  532. *
  533. * If the flush lock is already held, indicating that the inode has
  534. * been or is in the process of being flushed, then (ideally) we'd like to
  535. * see if the inode's buffer is still incore, and if so give it a nudge.
  536. * We delay doing so until the pushbuf routine, though, to avoid holding
  537. * the AIL lock across a call to the blackhole which is the buffer cache.
  538. * Also we don't want to sleep in any device strategy routines, which can happen
  539. * if we do the subsequent bawrite in here.
  540. */
  541. STATIC uint
  542. xfs_inode_item_trylock(
  543. xfs_inode_log_item_t *iip)
  544. {
  545. register xfs_inode_t *ip;
  546. ip = iip->ili_inode;
  547. if (xfs_ipincount(ip) > 0) {
  548. return XFS_ITEM_PINNED;
  549. }
  550. if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
  551. return XFS_ITEM_LOCKED;
  552. }
  553. if (!xfs_iflock_nowait(ip)) {
  554. /*
  555. * If someone else isn't already trying to push the inode
  556. * buffer, we get to do it.
  557. */
  558. if (iip->ili_pushbuf_flag == 0) {
  559. iip->ili_pushbuf_flag = 1;
  560. #ifdef DEBUG
  561. iip->ili_push_owner = current_pid();
  562. #endif
  563. /*
  564. * Inode is left locked in shared mode.
  565. * Pushbuf routine gets to unlock it.
  566. */
  567. return XFS_ITEM_PUSHBUF;
  568. } else {
  569. /*
  570. * We hold the AIL lock, so we must specify the
  571. * NONOTIFY flag so that we won't double trip.
  572. */
  573. xfs_iunlock(ip, XFS_ILOCK_SHARED|XFS_IUNLOCK_NONOTIFY);
  574. return XFS_ITEM_FLUSHING;
  575. }
  576. /* NOTREACHED */
  577. }
  578. /* Stale items should force out the iclog */
  579. if (ip->i_flags & XFS_ISTALE) {
  580. xfs_ifunlock(ip);
  581. xfs_iunlock(ip, XFS_ILOCK_SHARED|XFS_IUNLOCK_NONOTIFY);
  582. return XFS_ITEM_PINNED;
  583. }
  584. #ifdef DEBUG
  585. if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
  586. ASSERT(iip->ili_format.ilf_fields != 0);
  587. ASSERT(iip->ili_logged == 0);
  588. ASSERT(iip->ili_item.li_flags & XFS_LI_IN_AIL);
  589. }
  590. #endif
  591. return XFS_ITEM_SUCCESS;
  592. }
  593. /*
  594. * Unlock the inode associated with the inode log item.
  595. * Clear the fields of the inode and inode log item that
  596. * are specific to the current transaction. If the
  597. * hold flags is set, do not unlock the inode.
  598. */
  599. STATIC void
  600. xfs_inode_item_unlock(
  601. xfs_inode_log_item_t *iip)
  602. {
  603. uint hold;
  604. uint iolocked;
  605. uint lock_flags;
  606. xfs_inode_t *ip;
  607. ASSERT(iip != NULL);
  608. ASSERT(iip->ili_inode->i_itemp != NULL);
  609. ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL));
  610. ASSERT((!(iip->ili_inode->i_itemp->ili_flags &
  611. XFS_ILI_IOLOCKED_EXCL)) ||
  612. xfs_isilocked(iip->ili_inode, XFS_IOLOCK_EXCL));
  613. ASSERT((!(iip->ili_inode->i_itemp->ili_flags &
  614. XFS_ILI_IOLOCKED_SHARED)) ||
  615. xfs_isilocked(iip->ili_inode, XFS_IOLOCK_SHARED));
  616. /*
  617. * Clear the transaction pointer in the inode.
  618. */
  619. ip = iip->ili_inode;
  620. ip->i_transp = NULL;
  621. /*
  622. * If the inode needed a separate buffer with which to log
  623. * its extents, then free it now.
  624. */
  625. if (iip->ili_extents_buf != NULL) {
  626. ASSERT(ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS);
  627. ASSERT(ip->i_d.di_nextents > 0);
  628. ASSERT(iip->ili_format.ilf_fields & XFS_ILOG_DEXT);
  629. ASSERT(ip->i_df.if_bytes > 0);
  630. kmem_free(iip->ili_extents_buf);
  631. iip->ili_extents_buf = NULL;
  632. }
  633. if (iip->ili_aextents_buf != NULL) {
  634. ASSERT(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS);
  635. ASSERT(ip->i_d.di_anextents > 0);
  636. ASSERT(iip->ili_format.ilf_fields & XFS_ILOG_AEXT);
  637. ASSERT(ip->i_afp->if_bytes > 0);
  638. kmem_free(iip->ili_aextents_buf);
  639. iip->ili_aextents_buf = NULL;
  640. }
  641. /*
  642. * Figure out if we should unlock the inode or not.
  643. */
  644. hold = iip->ili_flags & XFS_ILI_HOLD;
  645. /*
  646. * Before clearing out the flags, remember whether we
  647. * are holding the inode's IO lock.
  648. */
  649. iolocked = iip->ili_flags & XFS_ILI_IOLOCKED_ANY;
  650. /*
  651. * Clear out the fields of the inode log item particular
  652. * to the current transaction.
  653. */
  654. iip->ili_flags = 0;
  655. /*
  656. * Unlock the inode if XFS_ILI_HOLD was not set.
  657. */
  658. if (!hold) {
  659. lock_flags = XFS_ILOCK_EXCL;
  660. if (iolocked & XFS_ILI_IOLOCKED_EXCL) {
  661. lock_flags |= XFS_IOLOCK_EXCL;
  662. } else if (iolocked & XFS_ILI_IOLOCKED_SHARED) {
  663. lock_flags |= XFS_IOLOCK_SHARED;
  664. }
  665. xfs_iput(iip->ili_inode, lock_flags);
  666. }
  667. }
  668. /*
  669. * This is called to find out where the oldest active copy of the
  670. * inode log item in the on disk log resides now that the last log
  671. * write of it completed at the given lsn. Since we always re-log
  672. * all dirty data in an inode, the latest copy in the on disk log
  673. * is the only one that matters. Therefore, simply return the
  674. * given lsn.
  675. */
  676. /*ARGSUSED*/
  677. STATIC xfs_lsn_t
  678. xfs_inode_item_committed(
  679. xfs_inode_log_item_t *iip,
  680. xfs_lsn_t lsn)
  681. {
  682. return (lsn);
  683. }
  684. /*
  685. * This gets called by xfs_trans_push_ail(), when IOP_TRYLOCK
  686. * failed to get the inode flush lock but did get the inode locked SHARED.
  687. * Here we're trying to see if the inode buffer is incore, and if so whether it's
  688. * marked delayed write. If that's the case, we'll initiate a bawrite on that
  689. * buffer to expedite the process.
  690. *
  691. * We aren't holding the AIL lock (or the flush lock) when this gets called,
  692. * so it is inherently race-y.
  693. */
  694. STATIC void
  695. xfs_inode_item_pushbuf(
  696. xfs_inode_log_item_t *iip)
  697. {
  698. xfs_inode_t *ip;
  699. xfs_mount_t *mp;
  700. xfs_buf_t *bp;
  701. uint dopush;
  702. ip = iip->ili_inode;
  703. ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
  704. /*
  705. * The ili_pushbuf_flag keeps others from
  706. * trying to duplicate our effort.
  707. */
  708. ASSERT(iip->ili_pushbuf_flag != 0);
  709. ASSERT(iip->ili_push_owner == current_pid());
  710. /*
  711. * If a flush is not in progress anymore, chances are that the
  712. * inode was taken off the AIL. So, just get out.
  713. */
  714. if (completion_done(&ip->i_flush) ||
  715. ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) {
  716. iip->ili_pushbuf_flag = 0;
  717. xfs_iunlock(ip, XFS_ILOCK_SHARED);
  718. return;
  719. }
  720. mp = ip->i_mount;
  721. bp = xfs_incore(mp->m_ddev_targp, iip->ili_format.ilf_blkno,
  722. iip->ili_format.ilf_len, XFS_INCORE_TRYLOCK);
  723. if (bp != NULL) {
  724. if (XFS_BUF_ISDELAYWRITE(bp)) {
  725. /*
  726. * We were racing with iflush because we don't hold
  727. * the AIL lock or the flush lock. However, at this point,
  728. * we have the buffer, and we know that it's dirty.
  729. * So, it's possible that iflush raced with us, and
  730. * this item is already taken off the AIL.
  731. * If not, we can flush it async.
  732. */
  733. dopush = ((iip->ili_item.li_flags & XFS_LI_IN_AIL) &&
  734. !completion_done(&ip->i_flush));
  735. iip->ili_pushbuf_flag = 0;
  736. xfs_iunlock(ip, XFS_ILOCK_SHARED);
  737. xfs_buftrace("INODE ITEM PUSH", bp);
  738. if (XFS_BUF_ISPINNED(bp)) {
  739. xfs_log_force(mp, (xfs_lsn_t)0,
  740. XFS_LOG_FORCE);
  741. }
  742. if (dopush) {
  743. int error;
  744. error = xfs_bawrite(mp, bp);
  745. if (error)
  746. xfs_fs_cmn_err(CE_WARN, mp,
  747. "xfs_inode_item_pushbuf: pushbuf error %d on iip %p, bp %p",
  748. error, iip, bp);
  749. } else {
  750. xfs_buf_relse(bp);
  751. }
  752. } else {
  753. iip->ili_pushbuf_flag = 0;
  754. xfs_iunlock(ip, XFS_ILOCK_SHARED);
  755. xfs_buf_relse(bp);
  756. }
  757. return;
  758. }
  759. /*
  760. * We have to be careful about resetting pushbuf flag too early (above).
  761. * Even though in theory we can do it as soon as we have the buflock,
  762. * we don't want others to be doing work needlessly. They'll come to
  763. * this function thinking that pushing the buffer is their
  764. * responsibility only to find that the buffer is still locked by
  765. * another doing the same thing
  766. */
  767. iip->ili_pushbuf_flag = 0;
  768. xfs_iunlock(ip, XFS_ILOCK_SHARED);
  769. return;
  770. }
  771. /*
  772. * This is called to asynchronously write the inode associated with this
  773. * inode log item out to disk. The inode will already have been locked by
  774. * a successful call to xfs_inode_item_trylock().
  775. */
  776. STATIC void
  777. xfs_inode_item_push(
  778. xfs_inode_log_item_t *iip)
  779. {
  780. xfs_inode_t *ip;
  781. ip = iip->ili_inode;
  782. ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
  783. ASSERT(!completion_done(&ip->i_flush));
  784. /*
  785. * Since we were able to lock the inode's flush lock and
  786. * we found it on the AIL, the inode must be dirty. This
  787. * is because the inode is removed from the AIL while still
  788. * holding the flush lock in xfs_iflush_done(). Thus, if
  789. * we found it in the AIL and were able to obtain the flush
  790. * lock without sleeping, then there must not have been
  791. * anyone in the process of flushing the inode.
  792. */
  793. ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) ||
  794. iip->ili_format.ilf_fields != 0);
  795. /*
  796. * Write out the inode. The completion routine ('iflush_done') will
  797. * pull it from the AIL, mark it clean, unlock the flush lock.
  798. */
  799. (void) xfs_iflush(ip, XFS_IFLUSH_ASYNC);
  800. xfs_iunlock(ip, XFS_ILOCK_SHARED);
  801. return;
  802. }
  803. /*
  804. * XXX rcc - this one really has to do something. Probably needs
  805. * to stamp in a new field in the incore inode.
  806. */
  807. /* ARGSUSED */
  808. STATIC void
  809. xfs_inode_item_committing(
  810. xfs_inode_log_item_t *iip,
  811. xfs_lsn_t lsn)
  812. {
  813. iip->ili_last_lsn = lsn;
  814. return;
  815. }
  816. /*
  817. * This is the ops vector shared by all buf log items.
  818. */
  819. static struct xfs_item_ops xfs_inode_item_ops = {
  820. .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size,
  821. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  822. xfs_inode_item_format,
  823. .iop_pin = (void(*)(xfs_log_item_t*))xfs_inode_item_pin,
  824. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_inode_item_unpin,
  825. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
  826. xfs_inode_item_unpin_remove,
  827. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_inode_item_trylock,
  828. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_inode_item_unlock,
  829. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  830. xfs_inode_item_committed,
  831. .iop_push = (void(*)(xfs_log_item_t*))xfs_inode_item_push,
  832. .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_inode_item_pushbuf,
  833. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  834. xfs_inode_item_committing
  835. };
  836. /*
  837. * Initialize the inode log item for a newly allocated (in-core) inode.
  838. */
  839. void
  840. xfs_inode_item_init(
  841. xfs_inode_t *ip,
  842. xfs_mount_t *mp)
  843. {
  844. xfs_inode_log_item_t *iip;
  845. ASSERT(ip->i_itemp == NULL);
  846. iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);
  847. iip->ili_item.li_type = XFS_LI_INODE;
  848. iip->ili_item.li_ops = &xfs_inode_item_ops;
  849. iip->ili_item.li_mountp = mp;
  850. iip->ili_item.li_ailp = mp->m_ail;
  851. iip->ili_inode = ip;
  852. /*
  853. We have zeroed memory. No need ...
  854. iip->ili_extents_buf = NULL;
  855. iip->ili_pushbuf_flag = 0;
  856. */
  857. iip->ili_format.ilf_type = XFS_LI_INODE;
  858. iip->ili_format.ilf_ino = ip->i_ino;
  859. iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
  860. iip->ili_format.ilf_len = ip->i_imap.im_len;
  861. iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
  862. }
  863. /*
  864. * Free the inode log item and any memory hanging off of it.
  865. */
  866. void
  867. xfs_inode_item_destroy(
  868. xfs_inode_t *ip)
  869. {
  870. #ifdef XFS_TRANS_DEBUG
  871. if (ip->i_itemp->ili_root_size != 0) {
  872. kmem_free(ip->i_itemp->ili_orig_root);
  873. }
  874. #endif
  875. kmem_zone_free(xfs_ili_zone, ip->i_itemp);
  876. }
  877. /*
  878. * This is the inode flushing I/O completion routine. It is called
  879. * from interrupt level when the buffer containing the inode is
  880. * flushed to disk. It is responsible for removing the inode item
  881. * from the AIL if it has not been re-logged, and unlocking the inode's
  882. * flush lock.
  883. */
  884. /*ARGSUSED*/
  885. void
  886. xfs_iflush_done(
  887. xfs_buf_t *bp,
  888. xfs_inode_log_item_t *iip)
  889. {
  890. xfs_inode_t *ip = iip->ili_inode;
  891. struct xfs_ail *ailp = iip->ili_item.li_ailp;
  892. /*
  893. * We only want to pull the item from the AIL if it is
  894. * actually there and its location in the log has not
  895. * changed since we started the flush. Thus, we only bother
  896. * if the ili_logged flag is set and the inode's lsn has not
  897. * changed. First we check the lsn outside
  898. * the lock since it's cheaper, and then we recheck while
  899. * holding the lock before removing the inode from the AIL.
  900. */
  901. if (iip->ili_logged &&
  902. (iip->ili_item.li_lsn == iip->ili_flush_lsn)) {
  903. spin_lock(&ailp->xa_lock);
  904. if (iip->ili_item.li_lsn == iip->ili_flush_lsn) {
  905. /* xfs_trans_ail_delete() drops the AIL lock. */
  906. xfs_trans_ail_delete(ailp, (xfs_log_item_t*)iip);
  907. } else {
  908. spin_unlock(&ailp->xa_lock);
  909. }
  910. }
  911. iip->ili_logged = 0;
  912. /*
  913. * Clear the ili_last_fields bits now that we know that the
  914. * data corresponding to them is safely on disk.
  915. */
  916. iip->ili_last_fields = 0;
  917. /*
  918. * Release the inode's flush lock since we're done with it.
  919. */
  920. xfs_ifunlock(ip);
  921. return;
  922. }
  923. /*
  924. * This is the inode flushing abort routine. It is called
  925. * from xfs_iflush when the filesystem is shutting down to clean
  926. * up the inode state.
  927. * It is responsible for removing the inode item
  928. * from the AIL if it has not been re-logged, and unlocking the inode's
  929. * flush lock.
  930. */
  931. void
  932. xfs_iflush_abort(
  933. xfs_inode_t *ip)
  934. {
  935. xfs_inode_log_item_t *iip = ip->i_itemp;
  936. xfs_mount_t *mp;
  937. iip = ip->i_itemp;
  938. mp = ip->i_mount;
  939. if (iip) {
  940. struct xfs_ail *ailp = iip->ili_item.li_ailp;
  941. if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
  942. spin_lock(&ailp->xa_lock);
  943. if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
  944. /* xfs_trans_ail_delete() drops the AIL lock. */
  945. xfs_trans_ail_delete(ailp, (xfs_log_item_t *)iip);
  946. } else
  947. spin_unlock(&ailp->xa_lock);
  948. }
  949. iip->ili_logged = 0;
  950. /*
  951. * Clear the ili_last_fields bits now that we know that the
  952. * data corresponding to them is safely on disk.
  953. */
  954. iip->ili_last_fields = 0;
  955. /*
  956. * Clear the inode logging fields so no more flushes are
  957. * attempted.
  958. */
  959. iip->ili_format.ilf_fields = 0;
  960. }
  961. /*
  962. * Release the inode's flush lock since we're done with it.
  963. */
  964. xfs_ifunlock(ip);
  965. }
  966. void
  967. xfs_istale_done(
  968. xfs_buf_t *bp,
  969. xfs_inode_log_item_t *iip)
  970. {
  971. xfs_iflush_abort(iip->ili_inode);
  972. }
  973. /*
  974. * convert an xfs_inode_log_format struct from either 32 or 64 bit versions
  975. * (which can have different field alignments) to the native version
  976. */
  977. int
  978. xfs_inode_item_format_convert(
  979. xfs_log_iovec_t *buf,
  980. xfs_inode_log_format_t *in_f)
  981. {
  982. if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) {
  983. xfs_inode_log_format_32_t *in_f32;
  984. in_f32 = (xfs_inode_log_format_32_t *)buf->i_addr;
  985. in_f->ilf_type = in_f32->ilf_type;
  986. in_f->ilf_size = in_f32->ilf_size;
  987. in_f->ilf_fields = in_f32->ilf_fields;
  988. in_f->ilf_asize = in_f32->ilf_asize;
  989. in_f->ilf_dsize = in_f32->ilf_dsize;
  990. in_f->ilf_ino = in_f32->ilf_ino;
  991. /* copy biggest field of ilf_u */
  992. memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
  993. in_f32->ilf_u.ilfu_uuid.__u_bits,
  994. sizeof(uuid_t));
  995. in_f->ilf_blkno = in_f32->ilf_blkno;
  996. in_f->ilf_len = in_f32->ilf_len;
  997. in_f->ilf_boffset = in_f32->ilf_boffset;
  998. return 0;
  999. } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){
  1000. xfs_inode_log_format_64_t *in_f64;
  1001. in_f64 = (xfs_inode_log_format_64_t *)buf->i_addr;
  1002. in_f->ilf_type = in_f64->ilf_type;
  1003. in_f->ilf_size = in_f64->ilf_size;
  1004. in_f->ilf_fields = in_f64->ilf_fields;
  1005. in_f->ilf_asize = in_f64->ilf_asize;
  1006. in_f->ilf_dsize = in_f64->ilf_dsize;
  1007. in_f->ilf_ino = in_f64->ilf_ino;
  1008. /* copy biggest field of ilf_u */
  1009. memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
  1010. in_f64->ilf_u.ilfu_uuid.__u_bits,
  1011. sizeof(uuid_t));
  1012. in_f->ilf_blkno = in_f64->ilf_blkno;
  1013. in_f->ilf_len = in_f64->ilf_len;
  1014. in_f->ilf_boffset = in_f64->ilf_boffset;
  1015. return 0;
  1016. }
  1017. return EFSCORRUPTED;
  1018. }