xfs_inode_item.c 31 KB

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