xfs_attr_remote.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * Copyright (c) 2013 Red Hat, Inc.
  4. * All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it would be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write the Free Software Foundation,
  17. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include "xfs.h"
  20. #include "xfs_fs.h"
  21. #include "xfs_shared.h"
  22. #include "xfs_format.h"
  23. #include "xfs_log_format.h"
  24. #include "xfs_trans_resv.h"
  25. #include "xfs_bit.h"
  26. #include "xfs_mount.h"
  27. #include "xfs_defer.h"
  28. #include "xfs_da_format.h"
  29. #include "xfs_da_btree.h"
  30. #include "xfs_inode.h"
  31. #include "xfs_alloc.h"
  32. #include "xfs_trans.h"
  33. #include "xfs_inode_item.h"
  34. #include "xfs_bmap.h"
  35. #include "xfs_bmap_util.h"
  36. #include "xfs_attr.h"
  37. #include "xfs_attr_leaf.h"
  38. #include "xfs_attr_remote.h"
  39. #include "xfs_trans_space.h"
  40. #include "xfs_trace.h"
  41. #include "xfs_cksum.h"
  42. #include "xfs_buf_item.h"
  43. #include "xfs_error.h"
  44. #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */
  45. /*
  46. * Each contiguous block has a header, so it is not just a simple attribute
  47. * length to FSB conversion.
  48. */
  49. int
  50. xfs_attr3_rmt_blocks(
  51. struct xfs_mount *mp,
  52. int attrlen)
  53. {
  54. if (xfs_sb_version_hascrc(&mp->m_sb)) {
  55. int buflen = XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize);
  56. return (attrlen + buflen - 1) / buflen;
  57. }
  58. return XFS_B_TO_FSB(mp, attrlen);
  59. }
  60. /*
  61. * Checking of the remote attribute header is split into two parts. The verifier
  62. * does CRC, location and bounds checking, the unpacking function checks the
  63. * attribute parameters and owner.
  64. */
  65. static xfs_failaddr_t
  66. xfs_attr3_rmt_hdr_ok(
  67. void *ptr,
  68. xfs_ino_t ino,
  69. uint32_t offset,
  70. uint32_t size,
  71. xfs_daddr_t bno)
  72. {
  73. struct xfs_attr3_rmt_hdr *rmt = ptr;
  74. if (bno != be64_to_cpu(rmt->rm_blkno))
  75. return __this_address;
  76. if (offset != be32_to_cpu(rmt->rm_offset))
  77. return __this_address;
  78. if (size != be32_to_cpu(rmt->rm_bytes))
  79. return __this_address;
  80. if (ino != be64_to_cpu(rmt->rm_owner))
  81. return __this_address;
  82. /* ok */
  83. return NULL;
  84. }
  85. static xfs_failaddr_t
  86. xfs_attr3_rmt_verify(
  87. struct xfs_mount *mp,
  88. void *ptr,
  89. int fsbsize,
  90. xfs_daddr_t bno)
  91. {
  92. struct xfs_attr3_rmt_hdr *rmt = ptr;
  93. if (!xfs_sb_version_hascrc(&mp->m_sb))
  94. return __this_address;
  95. if (rmt->rm_magic != cpu_to_be32(XFS_ATTR3_RMT_MAGIC))
  96. return __this_address;
  97. if (!uuid_equal(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid))
  98. return __this_address;
  99. if (be64_to_cpu(rmt->rm_blkno) != bno)
  100. return __this_address;
  101. if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
  102. return __this_address;
  103. if (be32_to_cpu(rmt->rm_offset) +
  104. be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX)
  105. return __this_address;
  106. if (rmt->rm_owner == 0)
  107. return __this_address;
  108. return NULL;
  109. }
  110. static void
  111. xfs_attr3_rmt_read_verify(
  112. struct xfs_buf *bp)
  113. {
  114. struct xfs_mount *mp = bp->b_target->bt_mount;
  115. char *ptr;
  116. int len;
  117. xfs_daddr_t bno;
  118. int blksize = mp->m_attr_geo->blksize;
  119. /* no verification of non-crc buffers */
  120. if (!xfs_sb_version_hascrc(&mp->m_sb))
  121. return;
  122. ptr = bp->b_addr;
  123. bno = bp->b_bn;
  124. len = BBTOB(bp->b_length);
  125. ASSERT(len >= blksize);
  126. while (len > 0) {
  127. if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
  128. xfs_verifier_error(bp, -EFSBADCRC);
  129. return;
  130. }
  131. if (xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
  132. xfs_verifier_error(bp, -EFSCORRUPTED);
  133. return;
  134. }
  135. len -= blksize;
  136. ptr += blksize;
  137. bno += BTOBB(blksize);
  138. }
  139. if (len != 0)
  140. xfs_verifier_error(bp, -EFSCORRUPTED);
  141. }
  142. static void
  143. xfs_attr3_rmt_write_verify(
  144. struct xfs_buf *bp)
  145. {
  146. struct xfs_mount *mp = bp->b_target->bt_mount;
  147. int blksize = mp->m_attr_geo->blksize;
  148. char *ptr;
  149. int len;
  150. xfs_daddr_t bno;
  151. /* no verification of non-crc buffers */
  152. if (!xfs_sb_version_hascrc(&mp->m_sb))
  153. return;
  154. ptr = bp->b_addr;
  155. bno = bp->b_bn;
  156. len = BBTOB(bp->b_length);
  157. ASSERT(len >= blksize);
  158. while (len > 0) {
  159. struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
  160. if (xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
  161. xfs_verifier_error(bp, -EFSCORRUPTED);
  162. return;
  163. }
  164. /*
  165. * Ensure we aren't writing bogus LSNs to disk. See
  166. * xfs_attr3_rmt_hdr_set() for the explanation.
  167. */
  168. if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
  169. xfs_verifier_error(bp, -EFSCORRUPTED);
  170. return;
  171. }
  172. xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
  173. len -= blksize;
  174. ptr += blksize;
  175. bno += BTOBB(blksize);
  176. }
  177. if (len != 0)
  178. xfs_verifier_error(bp, -EFSCORRUPTED);
  179. }
  180. const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
  181. .name = "xfs_attr3_rmt",
  182. .verify_read = xfs_attr3_rmt_read_verify,
  183. .verify_write = xfs_attr3_rmt_write_verify,
  184. };
  185. STATIC int
  186. xfs_attr3_rmt_hdr_set(
  187. struct xfs_mount *mp,
  188. void *ptr,
  189. xfs_ino_t ino,
  190. uint32_t offset,
  191. uint32_t size,
  192. xfs_daddr_t bno)
  193. {
  194. struct xfs_attr3_rmt_hdr *rmt = ptr;
  195. if (!xfs_sb_version_hascrc(&mp->m_sb))
  196. return 0;
  197. rmt->rm_magic = cpu_to_be32(XFS_ATTR3_RMT_MAGIC);
  198. rmt->rm_offset = cpu_to_be32(offset);
  199. rmt->rm_bytes = cpu_to_be32(size);
  200. uuid_copy(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid);
  201. rmt->rm_owner = cpu_to_be64(ino);
  202. rmt->rm_blkno = cpu_to_be64(bno);
  203. /*
  204. * Remote attribute blocks are written synchronously, so we don't
  205. * have an LSN that we can stamp in them that makes any sense to log
  206. * recovery. To ensure that log recovery handles overwrites of these
  207. * blocks sanely (i.e. once they've been freed and reallocated as some
  208. * other type of metadata) we need to ensure that the LSN has a value
  209. * that tells log recovery to ignore the LSN and overwrite the buffer
  210. * with whatever is in it's log. To do this, we use the magic
  211. * NULLCOMMITLSN to indicate that the LSN is invalid.
  212. */
  213. rmt->rm_lsn = cpu_to_be64(NULLCOMMITLSN);
  214. return sizeof(struct xfs_attr3_rmt_hdr);
  215. }
  216. /*
  217. * Helper functions to copy attribute data in and out of the one disk extents
  218. */
  219. STATIC int
  220. xfs_attr_rmtval_copyout(
  221. struct xfs_mount *mp,
  222. struct xfs_buf *bp,
  223. xfs_ino_t ino,
  224. int *offset,
  225. int *valuelen,
  226. uint8_t **dst)
  227. {
  228. char *src = bp->b_addr;
  229. xfs_daddr_t bno = bp->b_bn;
  230. int len = BBTOB(bp->b_length);
  231. int blksize = mp->m_attr_geo->blksize;
  232. ASSERT(len >= blksize);
  233. while (len > 0 && *valuelen > 0) {
  234. int hdr_size = 0;
  235. int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, blksize);
  236. byte_cnt = min(*valuelen, byte_cnt);
  237. if (xfs_sb_version_hascrc(&mp->m_sb)) {
  238. if (xfs_attr3_rmt_hdr_ok(src, ino, *offset,
  239. byte_cnt, bno)) {
  240. xfs_alert(mp,
  241. "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
  242. bno, *offset, byte_cnt, ino);
  243. return -EFSCORRUPTED;
  244. }
  245. hdr_size = sizeof(struct xfs_attr3_rmt_hdr);
  246. }
  247. memcpy(*dst, src + hdr_size, byte_cnt);
  248. /* roll buffer forwards */
  249. len -= blksize;
  250. src += blksize;
  251. bno += BTOBB(blksize);
  252. /* roll attribute data forwards */
  253. *valuelen -= byte_cnt;
  254. *dst += byte_cnt;
  255. *offset += byte_cnt;
  256. }
  257. return 0;
  258. }
  259. STATIC void
  260. xfs_attr_rmtval_copyin(
  261. struct xfs_mount *mp,
  262. struct xfs_buf *bp,
  263. xfs_ino_t ino,
  264. int *offset,
  265. int *valuelen,
  266. uint8_t **src)
  267. {
  268. char *dst = bp->b_addr;
  269. xfs_daddr_t bno = bp->b_bn;
  270. int len = BBTOB(bp->b_length);
  271. int blksize = mp->m_attr_geo->blksize;
  272. ASSERT(len >= blksize);
  273. while (len > 0 && *valuelen > 0) {
  274. int hdr_size;
  275. int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, blksize);
  276. byte_cnt = min(*valuelen, byte_cnt);
  277. hdr_size = xfs_attr3_rmt_hdr_set(mp, dst, ino, *offset,
  278. byte_cnt, bno);
  279. memcpy(dst + hdr_size, *src, byte_cnt);
  280. /*
  281. * If this is the last block, zero the remainder of it.
  282. * Check that we are actually the last block, too.
  283. */
  284. if (byte_cnt + hdr_size < blksize) {
  285. ASSERT(*valuelen - byte_cnt == 0);
  286. ASSERT(len == blksize);
  287. memset(dst + hdr_size + byte_cnt, 0,
  288. blksize - hdr_size - byte_cnt);
  289. }
  290. /* roll buffer forwards */
  291. len -= blksize;
  292. dst += blksize;
  293. bno += BTOBB(blksize);
  294. /* roll attribute data forwards */
  295. *valuelen -= byte_cnt;
  296. *src += byte_cnt;
  297. *offset += byte_cnt;
  298. }
  299. }
  300. /*
  301. * Read the value associated with an attribute from the out-of-line buffer
  302. * that we stored it in.
  303. */
  304. int
  305. xfs_attr_rmtval_get(
  306. struct xfs_da_args *args)
  307. {
  308. struct xfs_bmbt_irec map[ATTR_RMTVALUE_MAPSIZE];
  309. struct xfs_mount *mp = args->dp->i_mount;
  310. struct xfs_buf *bp;
  311. xfs_dablk_t lblkno = args->rmtblkno;
  312. uint8_t *dst = args->value;
  313. int valuelen;
  314. int nmap;
  315. int error;
  316. int blkcnt = args->rmtblkcnt;
  317. int i;
  318. int offset = 0;
  319. trace_xfs_attr_rmtval_get(args);
  320. ASSERT(!(args->flags & ATTR_KERNOVAL));
  321. ASSERT(args->rmtvaluelen == args->valuelen);
  322. valuelen = args->rmtvaluelen;
  323. while (valuelen > 0) {
  324. nmap = ATTR_RMTVALUE_MAPSIZE;
  325. error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
  326. blkcnt, map, &nmap,
  327. XFS_BMAPI_ATTRFORK);
  328. if (error)
  329. return error;
  330. ASSERT(nmap >= 1);
  331. for (i = 0; (i < nmap) && (valuelen > 0); i++) {
  332. xfs_daddr_t dblkno;
  333. int dblkcnt;
  334. ASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&
  335. (map[i].br_startblock != HOLESTARTBLOCK));
  336. dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
  337. dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
  338. error = xfs_trans_read_buf(mp, args->trans,
  339. mp->m_ddev_targp,
  340. dblkno, dblkcnt, 0, &bp,
  341. &xfs_attr3_rmt_buf_ops);
  342. if (error)
  343. return error;
  344. error = xfs_attr_rmtval_copyout(mp, bp, args->dp->i_ino,
  345. &offset, &valuelen,
  346. &dst);
  347. xfs_trans_brelse(args->trans, bp);
  348. if (error)
  349. return error;
  350. /* roll attribute extent map forwards */
  351. lblkno += map[i].br_blockcount;
  352. blkcnt -= map[i].br_blockcount;
  353. }
  354. }
  355. ASSERT(valuelen == 0);
  356. return 0;
  357. }
  358. /*
  359. * Write the value associated with an attribute into the out-of-line buffer
  360. * that we have defined for it.
  361. */
  362. int
  363. xfs_attr_rmtval_set(
  364. struct xfs_da_args *args)
  365. {
  366. struct xfs_inode *dp = args->dp;
  367. struct xfs_mount *mp = dp->i_mount;
  368. struct xfs_bmbt_irec map;
  369. xfs_dablk_t lblkno;
  370. xfs_fileoff_t lfileoff = 0;
  371. uint8_t *src = args->value;
  372. int blkcnt;
  373. int valuelen;
  374. int nmap;
  375. int error;
  376. int offset = 0;
  377. trace_xfs_attr_rmtval_set(args);
  378. /*
  379. * Find a "hole" in the attribute address space large enough for
  380. * us to drop the new attribute's value into. Because CRC enable
  381. * attributes have headers, we can't just do a straight byte to FSB
  382. * conversion and have to take the header space into account.
  383. */
  384. blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen);
  385. error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff,
  386. XFS_ATTR_FORK);
  387. if (error)
  388. return error;
  389. args->rmtblkno = lblkno = (xfs_dablk_t)lfileoff;
  390. args->rmtblkcnt = blkcnt;
  391. /*
  392. * Roll through the "value", allocating blocks on disk as required.
  393. */
  394. while (blkcnt > 0) {
  395. /*
  396. * Allocate a single extent, up to the size of the value.
  397. *
  398. * Note that we have to consider this a data allocation as we
  399. * write the remote attribute without logging the contents.
  400. * Hence we must ensure that we aren't using blocks that are on
  401. * the busy list so that we don't overwrite blocks which have
  402. * recently been freed but their transactions are not yet
  403. * committed to disk. If we overwrite the contents of a busy
  404. * extent and then crash then the block may not contain the
  405. * correct metadata after log recovery occurs.
  406. */
  407. xfs_defer_init(args->dfops, args->firstblock);
  408. nmap = 1;
  409. error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
  410. blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
  411. args->total, &map, &nmap, args->dfops);
  412. if (error)
  413. goto out_defer_cancel;
  414. xfs_defer_ijoin(args->dfops, dp);
  415. error = xfs_defer_finish(&args->trans, args->dfops);
  416. if (error)
  417. goto out_defer_cancel;
  418. ASSERT(nmap == 1);
  419. ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
  420. (map.br_startblock != HOLESTARTBLOCK));
  421. lblkno += map.br_blockcount;
  422. blkcnt -= map.br_blockcount;
  423. /*
  424. * Start the next trans in the chain.
  425. */
  426. error = xfs_trans_roll_inode(&args->trans, dp);
  427. if (error)
  428. return error;
  429. }
  430. /*
  431. * Roll through the "value", copying the attribute value to the
  432. * already-allocated blocks. Blocks are written synchronously
  433. * so that we can know they are all on disk before we turn off
  434. * the INCOMPLETE flag.
  435. */
  436. lblkno = args->rmtblkno;
  437. blkcnt = args->rmtblkcnt;
  438. valuelen = args->rmtvaluelen;
  439. while (valuelen > 0) {
  440. struct xfs_buf *bp;
  441. xfs_daddr_t dblkno;
  442. int dblkcnt;
  443. ASSERT(blkcnt > 0);
  444. xfs_defer_init(args->dfops, args->firstblock);
  445. nmap = 1;
  446. error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
  447. blkcnt, &map, &nmap,
  448. XFS_BMAPI_ATTRFORK);
  449. if (error)
  450. return error;
  451. ASSERT(nmap == 1);
  452. ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
  453. (map.br_startblock != HOLESTARTBLOCK));
  454. dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
  455. dblkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
  456. bp = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, 0);
  457. if (!bp)
  458. return -ENOMEM;
  459. bp->b_ops = &xfs_attr3_rmt_buf_ops;
  460. xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset,
  461. &valuelen, &src);
  462. error = xfs_bwrite(bp); /* GROT: NOTE: synchronous write */
  463. xfs_buf_relse(bp);
  464. if (error)
  465. return error;
  466. /* roll attribute extent map forwards */
  467. lblkno += map.br_blockcount;
  468. blkcnt -= map.br_blockcount;
  469. }
  470. ASSERT(valuelen == 0);
  471. return 0;
  472. out_defer_cancel:
  473. xfs_defer_cancel(args->dfops);
  474. args->trans = NULL;
  475. return error;
  476. }
  477. /*
  478. * Remove the value associated with an attribute by deleting the
  479. * out-of-line buffer that it is stored on.
  480. */
  481. int
  482. xfs_attr_rmtval_remove(
  483. struct xfs_da_args *args)
  484. {
  485. struct xfs_mount *mp = args->dp->i_mount;
  486. xfs_dablk_t lblkno;
  487. int blkcnt;
  488. int error;
  489. int done;
  490. trace_xfs_attr_rmtval_remove(args);
  491. /*
  492. * Roll through the "value", invalidating the attribute value's blocks.
  493. */
  494. lblkno = args->rmtblkno;
  495. blkcnt = args->rmtblkcnt;
  496. while (blkcnt > 0) {
  497. struct xfs_bmbt_irec map;
  498. struct xfs_buf *bp;
  499. xfs_daddr_t dblkno;
  500. int dblkcnt;
  501. int nmap;
  502. /*
  503. * Try to remember where we decided to put the value.
  504. */
  505. nmap = 1;
  506. error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
  507. blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);
  508. if (error)
  509. return error;
  510. ASSERT(nmap == 1);
  511. ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
  512. (map.br_startblock != HOLESTARTBLOCK));
  513. dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
  514. dblkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
  515. /*
  516. * If the "remote" value is in the cache, remove it.
  517. */
  518. bp = xfs_incore(mp->m_ddev_targp, dblkno, dblkcnt, XBF_TRYLOCK);
  519. if (bp) {
  520. xfs_buf_stale(bp);
  521. xfs_buf_relse(bp);
  522. bp = NULL;
  523. }
  524. lblkno += map.br_blockcount;
  525. blkcnt -= map.br_blockcount;
  526. }
  527. /*
  528. * Keep de-allocating extents until the remote-value region is gone.
  529. */
  530. lblkno = args->rmtblkno;
  531. blkcnt = args->rmtblkcnt;
  532. done = 0;
  533. while (!done) {
  534. xfs_defer_init(args->dfops, args->firstblock);
  535. error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
  536. XFS_BMAPI_ATTRFORK, 1, args->firstblock,
  537. args->dfops, &done);
  538. if (error)
  539. goto out_defer_cancel;
  540. xfs_defer_ijoin(args->dfops, args->dp);
  541. error = xfs_defer_finish(&args->trans, args->dfops);
  542. if (error)
  543. goto out_defer_cancel;
  544. /*
  545. * Close out trans and start the next one in the chain.
  546. */
  547. error = xfs_trans_roll_inode(&args->trans, args->dp);
  548. if (error)
  549. return error;
  550. }
  551. return 0;
  552. out_defer_cancel:
  553. xfs_defer_cancel(args->dfops);
  554. args->trans = NULL;
  555. return error;
  556. }