xfs_extfree_item.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * Copyright (c) 2000-2001,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_log.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_buf_item.h"
  25. #include "xfs_sb.h"
  26. #include "xfs_dir.h"
  27. #include "xfs_dmapi.h"
  28. #include "xfs_mount.h"
  29. #include "xfs_trans_priv.h"
  30. #include "xfs_extfree_item.h"
  31. kmem_zone_t *xfs_efi_zone;
  32. kmem_zone_t *xfs_efd_zone;
  33. STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *);
  34. STATIC void xfs_efi_item_abort(xfs_efi_log_item_t *);
  35. STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *);
  36. void
  37. xfs_efi_item_free(xfs_efi_log_item_t *efip)
  38. {
  39. int nexts = efip->efi_format.efi_nextents;
  40. if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
  41. kmem_free(efip, sizeof(xfs_efi_log_item_t) +
  42. (nexts - 1) * sizeof(xfs_extent_t));
  43. } else {
  44. kmem_zone_free(xfs_efi_zone, efip);
  45. }
  46. }
  47. /*
  48. * This returns the number of iovecs needed to log the given efi item.
  49. * We only need 1 iovec for an efi item. It just logs the efi_log_format
  50. * structure.
  51. */
  52. /*ARGSUSED*/
  53. STATIC uint
  54. xfs_efi_item_size(xfs_efi_log_item_t *efip)
  55. {
  56. return 1;
  57. }
  58. /*
  59. * This is called to fill in the vector of log iovecs for the
  60. * given efi log item. We use only 1 iovec, and we point that
  61. * at the efi_log_format structure embedded in the efi item.
  62. * It is at this point that we assert that all of the extent
  63. * slots in the efi item have been filled.
  64. */
  65. STATIC void
  66. xfs_efi_item_format(xfs_efi_log_item_t *efip,
  67. xfs_log_iovec_t *log_vector)
  68. {
  69. uint size;
  70. ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents);
  71. efip->efi_format.efi_type = XFS_LI_EFI;
  72. size = sizeof(xfs_efi_log_format_t);
  73. size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t);
  74. efip->efi_format.efi_size = 1;
  75. log_vector->i_addr = (xfs_caddr_t)&(efip->efi_format);
  76. log_vector->i_len = size;
  77. XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_EFI_FORMAT);
  78. ASSERT(size >= sizeof(xfs_efi_log_format_t));
  79. }
  80. /*
  81. * Pinning has no meaning for an efi item, so just return.
  82. */
  83. /*ARGSUSED*/
  84. STATIC void
  85. xfs_efi_item_pin(xfs_efi_log_item_t *efip)
  86. {
  87. return;
  88. }
  89. /*
  90. * While EFIs cannot really be pinned, the unpin operation is the
  91. * last place at which the EFI is manipulated during a transaction.
  92. * Here we coordinate with xfs_efi_cancel() to determine who gets to
  93. * free the EFI.
  94. */
  95. /*ARGSUSED*/
  96. STATIC void
  97. xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
  98. {
  99. xfs_mount_t *mp;
  100. SPLDECL(s);
  101. mp = efip->efi_item.li_mountp;
  102. AIL_LOCK(mp, s);
  103. if (efip->efi_flags & XFS_EFI_CANCELED) {
  104. /*
  105. * xfs_trans_delete_ail() drops the AIL lock.
  106. */
  107. xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
  108. xfs_efi_item_free(efip);
  109. } else {
  110. efip->efi_flags |= XFS_EFI_COMMITTED;
  111. AIL_UNLOCK(mp, s);
  112. }
  113. }
  114. /*
  115. * like unpin only we have to also clear the xaction descriptor
  116. * pointing the log item if we free the item. This routine duplicates
  117. * unpin because efi_flags is protected by the AIL lock. Freeing
  118. * the descriptor and then calling unpin would force us to drop the AIL
  119. * lock which would open up a race condition.
  120. */
  121. STATIC void
  122. xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
  123. {
  124. xfs_mount_t *mp;
  125. xfs_log_item_desc_t *lidp;
  126. SPLDECL(s);
  127. mp = efip->efi_item.li_mountp;
  128. AIL_LOCK(mp, s);
  129. if (efip->efi_flags & XFS_EFI_CANCELED) {
  130. /*
  131. * free the xaction descriptor pointing to this item
  132. */
  133. lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) efip);
  134. xfs_trans_free_item(tp, lidp);
  135. /*
  136. * pull the item off the AIL.
  137. * xfs_trans_delete_ail() drops the AIL lock.
  138. */
  139. xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
  140. xfs_efi_item_free(efip);
  141. } else {
  142. efip->efi_flags |= XFS_EFI_COMMITTED;
  143. AIL_UNLOCK(mp, s);
  144. }
  145. }
  146. /*
  147. * Efi items have no locking or pushing. However, since EFIs are
  148. * pulled from the AIL when their corresponding EFDs are committed
  149. * to disk, their situation is very similar to being pinned. Return
  150. * XFS_ITEM_PINNED so that the caller will eventually flush the log.
  151. * This should help in getting the EFI out of the AIL.
  152. */
  153. /*ARGSUSED*/
  154. STATIC uint
  155. xfs_efi_item_trylock(xfs_efi_log_item_t *efip)
  156. {
  157. return XFS_ITEM_PINNED;
  158. }
  159. /*
  160. * Efi items have no locking, so just return.
  161. */
  162. /*ARGSUSED*/
  163. STATIC void
  164. xfs_efi_item_unlock(xfs_efi_log_item_t *efip)
  165. {
  166. if (efip->efi_item.li_flags & XFS_LI_ABORTED)
  167. xfs_efi_item_abort(efip);
  168. return;
  169. }
  170. /*
  171. * The EFI is logged only once and cannot be moved in the log, so
  172. * simply return the lsn at which it's been logged. The canceled
  173. * flag is not paid any attention here. Checking for that is delayed
  174. * until the EFI is unpinned.
  175. */
  176. /*ARGSUSED*/
  177. STATIC xfs_lsn_t
  178. xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
  179. {
  180. return lsn;
  181. }
  182. /*
  183. * This is called when the transaction logging the EFI is aborted.
  184. * Free up the EFI and return. No need to clean up the slot for
  185. * the item in the transaction. That was done by the unpin code
  186. * which is called prior to this routine in the abort/fs-shutdown path.
  187. */
  188. STATIC void
  189. xfs_efi_item_abort(xfs_efi_log_item_t *efip)
  190. {
  191. xfs_efi_item_free(efip);
  192. }
  193. /*
  194. * There isn't much you can do to push on an efi item. It is simply
  195. * stuck waiting for all of its corresponding efd items to be
  196. * committed to disk.
  197. */
  198. /*ARGSUSED*/
  199. STATIC void
  200. xfs_efi_item_push(xfs_efi_log_item_t *efip)
  201. {
  202. return;
  203. }
  204. /*
  205. * The EFI dependency tracking op doesn't do squat. It can't because
  206. * it doesn't know where the free extent is coming from. The dependency
  207. * tracking has to be handled by the "enclosing" metadata object. For
  208. * example, for inodes, the inode is locked throughout the extent freeing
  209. * so the dependency should be recorded there.
  210. */
  211. /*ARGSUSED*/
  212. STATIC void
  213. xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
  214. {
  215. return;
  216. }
  217. /*
  218. * This is the ops vector shared by all efi log items.
  219. */
  220. STATIC struct xfs_item_ops xfs_efi_item_ops = {
  221. .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size,
  222. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  223. xfs_efi_item_format,
  224. .iop_pin = (void(*)(xfs_log_item_t*))xfs_efi_item_pin,
  225. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efi_item_unpin,
  226. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
  227. xfs_efi_item_unpin_remove,
  228. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efi_item_trylock,
  229. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efi_item_unlock,
  230. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  231. xfs_efi_item_committed,
  232. .iop_push = (void(*)(xfs_log_item_t*))xfs_efi_item_push,
  233. .iop_abort = (void(*)(xfs_log_item_t*))xfs_efi_item_abort,
  234. .iop_pushbuf = NULL,
  235. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  236. xfs_efi_item_committing
  237. };
  238. /*
  239. * Allocate and initialize an efi item with the given number of extents.
  240. */
  241. xfs_efi_log_item_t *
  242. xfs_efi_init(xfs_mount_t *mp,
  243. uint nextents)
  244. {
  245. xfs_efi_log_item_t *efip;
  246. uint size;
  247. ASSERT(nextents > 0);
  248. if (nextents > XFS_EFI_MAX_FAST_EXTENTS) {
  249. size = (uint)(sizeof(xfs_efi_log_item_t) +
  250. ((nextents - 1) * sizeof(xfs_extent_t)));
  251. efip = (xfs_efi_log_item_t*)kmem_zalloc(size, KM_SLEEP);
  252. } else {
  253. efip = (xfs_efi_log_item_t*)kmem_zone_zalloc(xfs_efi_zone,
  254. KM_SLEEP);
  255. }
  256. efip->efi_item.li_type = XFS_LI_EFI;
  257. efip->efi_item.li_ops = &xfs_efi_item_ops;
  258. efip->efi_item.li_mountp = mp;
  259. efip->efi_format.efi_nextents = nextents;
  260. efip->efi_format.efi_id = (__psint_t)(void*)efip;
  261. return (efip);
  262. }
  263. /*
  264. * Copy an EFI format buffer from the given buf, and into the destination
  265. * EFI format structure.
  266. * The given buffer can be in 32 bit or 64 bit form (which has different padding),
  267. * one of which will be the native format for this kernel.
  268. * It will handle the conversion of formats if necessary.
  269. */
  270. int
  271. xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
  272. {
  273. xfs_efi_log_format_t *src_efi_fmt = (xfs_efi_log_format_t *)buf->i_addr;
  274. uint i;
  275. uint len = sizeof(xfs_efi_log_format_t) +
  276. (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t);
  277. uint len32 = sizeof(xfs_efi_log_format_32_t) +
  278. (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_32_t);
  279. uint len64 = sizeof(xfs_efi_log_format_64_t) +
  280. (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_64_t);
  281. if (buf->i_len == len) {
  282. memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len);
  283. return 0;
  284. } else if (buf->i_len == len32) {
  285. xfs_efi_log_format_32_t *src_efi_fmt_32 =
  286. (xfs_efi_log_format_32_t *)buf->i_addr;
  287. dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type;
  288. dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size;
  289. dst_efi_fmt->efi_nextents = src_efi_fmt_32->efi_nextents;
  290. dst_efi_fmt->efi_id = src_efi_fmt_32->efi_id;
  291. for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
  292. dst_efi_fmt->efi_extents[i].ext_start =
  293. src_efi_fmt_32->efi_extents[i].ext_start;
  294. dst_efi_fmt->efi_extents[i].ext_len =
  295. src_efi_fmt_32->efi_extents[i].ext_len;
  296. }
  297. return 0;
  298. } else if (buf->i_len == len64) {
  299. xfs_efi_log_format_64_t *src_efi_fmt_64 =
  300. (xfs_efi_log_format_64_t *)buf->i_addr;
  301. dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type;
  302. dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size;
  303. dst_efi_fmt->efi_nextents = src_efi_fmt_64->efi_nextents;
  304. dst_efi_fmt->efi_id = src_efi_fmt_64->efi_id;
  305. for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
  306. dst_efi_fmt->efi_extents[i].ext_start =
  307. src_efi_fmt_64->efi_extents[i].ext_start;
  308. dst_efi_fmt->efi_extents[i].ext_len =
  309. src_efi_fmt_64->efi_extents[i].ext_len;
  310. }
  311. return 0;
  312. }
  313. return EFSCORRUPTED;
  314. }
  315. /*
  316. * This is called by the efd item code below to release references to
  317. * the given efi item. Each efd calls this with the number of
  318. * extents that it has logged, and when the sum of these reaches
  319. * the total number of extents logged by this efi item we can free
  320. * the efi item.
  321. *
  322. * Freeing the efi item requires that we remove it from the AIL.
  323. * We'll use the AIL lock to protect our counters as well as
  324. * the removal from the AIL.
  325. */
  326. void
  327. xfs_efi_release(xfs_efi_log_item_t *efip,
  328. uint nextents)
  329. {
  330. xfs_mount_t *mp;
  331. int extents_left;
  332. SPLDECL(s);
  333. mp = efip->efi_item.li_mountp;
  334. ASSERT(efip->efi_next_extent > 0);
  335. ASSERT(efip->efi_flags & XFS_EFI_COMMITTED);
  336. AIL_LOCK(mp, s);
  337. ASSERT(efip->efi_next_extent >= nextents);
  338. efip->efi_next_extent -= nextents;
  339. extents_left = efip->efi_next_extent;
  340. if (extents_left == 0) {
  341. /*
  342. * xfs_trans_delete_ail() drops the AIL lock.
  343. */
  344. xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
  345. xfs_efi_item_free(efip);
  346. } else {
  347. AIL_UNLOCK(mp, s);
  348. }
  349. }
  350. /*
  351. * This is called when the transaction that should be committing the
  352. * EFD corresponding to the given EFI is aborted. The committed and
  353. * canceled flags are used to coordinate the freeing of the EFI and
  354. * the references by the transaction that committed it.
  355. */
  356. STATIC void
  357. xfs_efi_cancel(
  358. xfs_efi_log_item_t *efip)
  359. {
  360. xfs_mount_t *mp;
  361. SPLDECL(s);
  362. mp = efip->efi_item.li_mountp;
  363. AIL_LOCK(mp, s);
  364. if (efip->efi_flags & XFS_EFI_COMMITTED) {
  365. /*
  366. * xfs_trans_delete_ail() drops the AIL lock.
  367. */
  368. xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
  369. xfs_efi_item_free(efip);
  370. } else {
  371. efip->efi_flags |= XFS_EFI_CANCELED;
  372. AIL_UNLOCK(mp, s);
  373. }
  374. }
  375. STATIC void
  376. xfs_efd_item_free(xfs_efd_log_item_t *efdp)
  377. {
  378. int nexts = efdp->efd_format.efd_nextents;
  379. if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
  380. kmem_free(efdp, sizeof(xfs_efd_log_item_t) +
  381. (nexts - 1) * sizeof(xfs_extent_t));
  382. } else {
  383. kmem_zone_free(xfs_efd_zone, efdp);
  384. }
  385. }
  386. /*
  387. * This returns the number of iovecs needed to log the given efd item.
  388. * We only need 1 iovec for an efd item. It just logs the efd_log_format
  389. * structure.
  390. */
  391. /*ARGSUSED*/
  392. STATIC uint
  393. xfs_efd_item_size(xfs_efd_log_item_t *efdp)
  394. {
  395. return 1;
  396. }
  397. /*
  398. * This is called to fill in the vector of log iovecs for the
  399. * given efd log item. We use only 1 iovec, and we point that
  400. * at the efd_log_format structure embedded in the efd item.
  401. * It is at this point that we assert that all of the extent
  402. * slots in the efd item have been filled.
  403. */
  404. STATIC void
  405. xfs_efd_item_format(xfs_efd_log_item_t *efdp,
  406. xfs_log_iovec_t *log_vector)
  407. {
  408. uint size;
  409. ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);
  410. efdp->efd_format.efd_type = XFS_LI_EFD;
  411. size = sizeof(xfs_efd_log_format_t);
  412. size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t);
  413. efdp->efd_format.efd_size = 1;
  414. log_vector->i_addr = (xfs_caddr_t)&(efdp->efd_format);
  415. log_vector->i_len = size;
  416. XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_EFD_FORMAT);
  417. ASSERT(size >= sizeof(xfs_efd_log_format_t));
  418. }
  419. /*
  420. * Pinning has no meaning for an efd item, so just return.
  421. */
  422. /*ARGSUSED*/
  423. STATIC void
  424. xfs_efd_item_pin(xfs_efd_log_item_t *efdp)
  425. {
  426. return;
  427. }
  428. /*
  429. * Since pinning has no meaning for an efd item, unpinning does
  430. * not either.
  431. */
  432. /*ARGSUSED*/
  433. STATIC void
  434. xfs_efd_item_unpin(xfs_efd_log_item_t *efdp, int stale)
  435. {
  436. return;
  437. }
  438. /*ARGSUSED*/
  439. STATIC void
  440. xfs_efd_item_unpin_remove(xfs_efd_log_item_t *efdp, xfs_trans_t *tp)
  441. {
  442. return;
  443. }
  444. /*
  445. * Efd items have no locking, so just return success.
  446. */
  447. /*ARGSUSED*/
  448. STATIC uint
  449. xfs_efd_item_trylock(xfs_efd_log_item_t *efdp)
  450. {
  451. return XFS_ITEM_LOCKED;
  452. }
  453. /*
  454. * Efd items have no locking or pushing, so return failure
  455. * so that the caller doesn't bother with us.
  456. */
  457. /*ARGSUSED*/
  458. STATIC void
  459. xfs_efd_item_unlock(xfs_efd_log_item_t *efdp)
  460. {
  461. if (efdp->efd_item.li_flags & XFS_LI_ABORTED)
  462. xfs_efd_item_abort(efdp);
  463. return;
  464. }
  465. /*
  466. * When the efd item is committed to disk, all we need to do
  467. * is delete our reference to our partner efi item and then
  468. * free ourselves. Since we're freeing ourselves we must
  469. * return -1 to keep the transaction code from further referencing
  470. * this item.
  471. */
  472. /*ARGSUSED*/
  473. STATIC xfs_lsn_t
  474. xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
  475. {
  476. /*
  477. * If we got a log I/O error, it's always the case that the LR with the
  478. * EFI got unpinned and freed before the EFD got aborted.
  479. */
  480. if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
  481. xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
  482. xfs_efd_item_free(efdp);
  483. return (xfs_lsn_t)-1;
  484. }
  485. /*
  486. * The transaction of which this EFD is a part has been aborted.
  487. * Inform its companion EFI of this fact and then clean up after
  488. * ourselves. No need to clean up the slot for the item in the
  489. * transaction. That was done by the unpin code which is called
  490. * prior to this routine in the abort/fs-shutdown path.
  491. */
  492. STATIC void
  493. xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
  494. {
  495. /*
  496. * If we got a log I/O error, it's always the case that the LR with the
  497. * EFI got unpinned and freed before the EFD got aborted. So don't
  498. * reference the EFI at all in that case.
  499. */
  500. if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
  501. xfs_efi_cancel(efdp->efd_efip);
  502. xfs_efd_item_free(efdp);
  503. }
  504. /*
  505. * There isn't much you can do to push on an efd item. It is simply
  506. * stuck waiting for the log to be flushed to disk.
  507. */
  508. /*ARGSUSED*/
  509. STATIC void
  510. xfs_efd_item_push(xfs_efd_log_item_t *efdp)
  511. {
  512. return;
  513. }
  514. /*
  515. * The EFD dependency tracking op doesn't do squat. It can't because
  516. * it doesn't know where the free extent is coming from. The dependency
  517. * tracking has to be handled by the "enclosing" metadata object. For
  518. * example, for inodes, the inode is locked throughout the extent freeing
  519. * so the dependency should be recorded there.
  520. */
  521. /*ARGSUSED*/
  522. STATIC void
  523. xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn)
  524. {
  525. return;
  526. }
  527. /*
  528. * This is the ops vector shared by all efd log items.
  529. */
  530. STATIC struct xfs_item_ops xfs_efd_item_ops = {
  531. .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size,
  532. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  533. xfs_efd_item_format,
  534. .iop_pin = (void(*)(xfs_log_item_t*))xfs_efd_item_pin,
  535. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efd_item_unpin,
  536. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
  537. xfs_efd_item_unpin_remove,
  538. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efd_item_trylock,
  539. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efd_item_unlock,
  540. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  541. xfs_efd_item_committed,
  542. .iop_push = (void(*)(xfs_log_item_t*))xfs_efd_item_push,
  543. .iop_abort = (void(*)(xfs_log_item_t*))xfs_efd_item_abort,
  544. .iop_pushbuf = NULL,
  545. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  546. xfs_efd_item_committing
  547. };
  548. /*
  549. * Allocate and initialize an efd item with the given number of extents.
  550. */
  551. xfs_efd_log_item_t *
  552. xfs_efd_init(xfs_mount_t *mp,
  553. xfs_efi_log_item_t *efip,
  554. uint nextents)
  555. {
  556. xfs_efd_log_item_t *efdp;
  557. uint size;
  558. ASSERT(nextents > 0);
  559. if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
  560. size = (uint)(sizeof(xfs_efd_log_item_t) +
  561. ((nextents - 1) * sizeof(xfs_extent_t)));
  562. efdp = (xfs_efd_log_item_t*)kmem_zalloc(size, KM_SLEEP);
  563. } else {
  564. efdp = (xfs_efd_log_item_t*)kmem_zone_zalloc(xfs_efd_zone,
  565. KM_SLEEP);
  566. }
  567. efdp->efd_item.li_type = XFS_LI_EFD;
  568. efdp->efd_item.li_ops = &xfs_efd_item_ops;
  569. efdp->efd_item.li_mountp = mp;
  570. efdp->efd_efip = efip;
  571. efdp->efd_format.efd_nextents = nextents;
  572. efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
  573. return (efdp);
  574. }