2 * Copyright (c) 2011-2018 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * TRANSACTION AND FLUSH HANDLING
38 * Deceptively simple but actually fairly difficult to implement properly is
39 * how I would describe it.
41 * Flushing generally occurs bottom-up but requires a top-down scan to
42 * locate chains with MODIFIED and/or UPDATE bits set. The ONFLUSH flag
43 * tells how to recurse downward to find these chains.
46 #include <sys/cdefs.h>
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/types.h>
57 #define HAMMER2_FLUSH_DEPTH_LIMIT 60 /* stack recursion limit */
61 * Recursively flush the specified chain. The chain is locked and
62 * referenced by the caller and will remain so on return. The chain
63 * will remain referenced throughout but can temporarily lose its
64 * lock during the recursion to avoid unnecessarily stalling user
67 struct hammer2_flush_info {
68 hammer2_chain_t *parent;
70 int error; /* cumulative error */
72 #ifdef HAMMER2_SCAN_DEBUG
80 hammer2_chain_t *debug;
83 typedef struct hammer2_flush_info hammer2_flush_info_t;
85 static int hammer2_flush_core(hammer2_flush_info_t *info,
86 hammer2_chain_t *chain, int flags);
87 static int hammer2_flush_recurse(hammer2_chain_t *child, void *data);
90 * Any per-pfs transaction initialization goes here.
93 hammer2_trans_manage_init(hammer2_pfs_t *pmp)
98 * Transaction support for any modifying operation. Transactions are used
99 * in the pmp layer by the frontend and in the spmp layer by the backend.
101 * 0 - Normal transaction. Interlocks against just the
102 * COPYQ portion of an ISFLUSH transaction.
104 * TRANS_ISFLUSH - Flush transaction. Interlocks against other flush
107 * When COPYQ is also specified, waits for the count
110 * TRANS_BUFCACHE - Buffer cache transaction. No interlock.
112 * TRANS_SIDEQ - Run the sideq (only tested in trans_done())
114 * Initializing a new transaction allocates a transaction ID. Typically
115 * passed a pmp (hmp passed as NULL), indicating a cluster transaction. Can
116 * be passed a NULL pmp and non-NULL hmp to indicate a transaction on a single
117 * media target. The latter mode is used by the recovery code.
120 hammer2_trans_init(hammer2_pfs_t *pmp, uint32_t flags)
127 oflags = pmp->trans.flags;
131 if (flags & HAMMER2_TRANS_ISFLUSH) {
133 * Interlock against other flush transactions.
135 if (oflags & HAMMER2_TRANS_ISFLUSH) {
136 nflags = oflags | HAMMER2_TRANS_WAITING;
139 nflags = (oflags | flags) + 1;
141 } else if (flags & HAMMER2_TRANS_BUFCACHE) {
143 * Requesting strategy transaction from buffer-cache,
144 * or a VM getpages/putpages through the buffer cache.
145 * We must allow such transactions in all situations
146 * to avoid deadlocks.
148 nflags = (oflags | flags) + 1;
151 * Normal transaction. We do not interlock against
152 * BUFCACHE or ISFLUSH.
154 * Note that vnode locks may be held going into
157 * NOTE: Remember that non-modifying operations
158 * such as read, stat, readdir, etc, do
159 * not use transactions.
161 nflags = (oflags | flags) + 1;
164 tsleep_interlock(&pmp->trans.sync_wait, 0);
165 if (atomic_cmpset_int(&pmp->trans.flags, oflags, nflags)) {
168 tsleep(&pmp->trans.sync_wait, PINTERLOCKED,
180 * When entering a FLUSH transaction with COPYQ set, wait for the
181 * transaction count to drop to 1 (our flush transaction only)
184 * This waits for all non-flush transactions to complete and blocks
185 * new non-flush transactions from starting until COPYQ is cleared.
186 * (the flush will then proceed after clearing COPYQ). This should
187 * be a very short stall on modifying operations.
189 while ((flags & HAMMER2_TRANS_ISFLUSH) &&
190 (flags & HAMMER2_TRANS_COPYQ)) {
191 oflags = pmp->trans.flags;
193 if ((oflags & HAMMER2_TRANS_MASK) == 1)
195 nflags = oflags | HAMMER2_TRANS_WAITING;
196 tsleep_interlock(&pmp->trans.sync_wait, 0);
197 if (atomic_cmpset_int(&pmp->trans.flags, oflags, nflags)) {
198 tsleep(&pmp->trans.sync_wait, PINTERLOCKED,
206 * Start a sub-transaction, there is no 'subdone' function. This will
207 * issue a new modify_tid (mtid) for the current transaction, which is a
208 * CLC (cluster level change) id and not a per-node id.
210 * This function must be called for each XOP when multiple XOPs are run in
211 * sequence within a transaction.
213 * Callers typically update the inode with the transaction mtid manually
214 * to enforce sequencing.
217 hammer2_trans_sub(hammer2_pfs_t *pmp)
221 mtid = atomic_fetchadd_64(&pmp->modify_tid, 1);
227 hammer2_trans_setflags(hammer2_pfs_t *pmp, uint32_t flags)
229 atomic_set_int(&pmp->trans.flags, flags);
233 * Typically used to clear trans flags asynchronously. If TRANS_WAITING
234 * is in the mask, and was previously set, this function will wake up
238 hammer2_trans_clearflags(hammer2_pfs_t *pmp, uint32_t flags)
244 oflags = pmp->trans.flags;
246 nflags = oflags & ~flags;
247 if (atomic_cmpset_int(&pmp->trans.flags, oflags, nflags)) {
248 if ((oflags ^ nflags) & HAMMER2_TRANS_WAITING)
249 wakeup(&pmp->trans.sync_wait);
258 hammer2_trans_done(hammer2_pfs_t *pmp, uint32_t flags)
265 * Modifying ops on the front-end can cause dirty inodes to
266 * build up in the sideq. We don't flush these on inactive/reclaim
267 * due to potential deadlocks, so we have to deal with them from
268 * inside other nominal modifying front-end transactions.
270 if ((flags & HAMMER2_TRANS_SIDEQ) &&
271 pmp->sideq_count > hammer2_limit_dirty_inodes / 2 &&
272 pmp->sideq_count > (pmp->inum_count >> 3) &&
274 speedup_syncer(pmp->mp);
279 * Clean-up the transaction. Wakeup any waiters when finishing
280 * a flush transaction or transitioning the non-flush transaction
281 * count from 2->1 while a flush transaction is pending.
284 oflags = pmp->trans.flags;
286 KKASSERT(oflags & HAMMER2_TRANS_MASK);
288 nflags = (oflags - 1) & ~flags;
289 if (flags & HAMMER2_TRANS_ISFLUSH) {
290 nflags &= ~HAMMER2_TRANS_WAITING;
292 if ((oflags & (HAMMER2_TRANS_ISFLUSH|HAMMER2_TRANS_MASK)) ==
293 (HAMMER2_TRANS_ISFLUSH|2)) {
294 nflags &= ~HAMMER2_TRANS_WAITING;
296 if (atomic_cmpset_int(&pmp->trans.flags, oflags, nflags)) {
297 if ((oflags ^ nflags) & HAMMER2_TRANS_WAITING)
298 wakeup(&pmp->trans.sync_wait);
307 * Obtain new, unique inode number (not serialized by caller).
310 hammer2_trans_newinum(hammer2_pfs_t *pmp)
314 tid = atomic_fetchadd_64(&pmp->inode_tid, 1);
320 * Assert that a strategy call is ok here. Currently we allow strategy
321 * calls in all situations, including during flushes. Previously:
322 * (old) (1) In a normal transaction.
323 * (old) (2) In a flush transaction only if PREFLUSH is also set.
326 hammer2_trans_assert_strategy(hammer2_pfs_t *pmp)
329 KKASSERT((pmp->trans.flags & HAMMER2_TRANS_ISFLUSH) == 0 ||
330 (pmp->trans.flags & HAMMER2_TRANS_PREFLUSH));
335 * Flush the chain and all modified sub-chains through the specified
336 * synchronization point, propagating blockref updates back up. As
337 * part of this propagation, mirror_tid and inode/data usage statistics
338 * propagates back upward.
340 * Returns a HAMMER2 error code, 0 if no error. Note that I/O errors from
341 * buffers dirtied during the flush operation can occur later.
343 * modify_tid (clc - cluster level change) is not propagated.
345 * update_tid (clc) is used for validation and is not propagated by this
348 * This routine can be called from several places but the most important
349 * is from VFS_SYNC (frontend) via hammer2_xop_inode_flush (backend).
351 * chain is locked on call and will remain locked on return. The chain's
352 * UPDATE flag indicates that its parent's block table (which is not yet
353 * part of the flush) should be updated.
356 * HAMMER2_FLUSH_TOP Indicates that this is the top of the flush.
357 * Is cleared for the recursion.
359 * HAMMER2_FLUSH_ALL Recurse everything
361 * HAMMER2_FLUSH_INODE_STOP
362 * Stop at PFS inode or normal inode boundary
365 hammer2_flush(hammer2_chain_t *chain, int flags)
367 hammer2_flush_info_t info;
372 * Execute the recursive flush and handle deferrals.
374 * Chains can be ridiculously long (thousands deep), so to
375 * avoid blowing out the kernel stack the recursive flush has a
376 * depth limit. Elements at the limit are placed on a list
377 * for re-execution after the stack has been popped.
379 bzero(&info, sizeof(info));
380 info.flags = flags & ~HAMMER2_FLUSH_TOP;
383 * Calculate parent (can be NULL), if not NULL the flush core
384 * expects the parent to be referenced so it can easily lock/unlock
385 * it without it getting ripped up.
387 if ((info.parent = chain->parent) != NULL)
388 hammer2_chain_ref(info.parent);
391 * Extra ref needed because flush_core expects it when replacing
394 hammer2_chain_ref(chain);
400 * [re]flush chain as the deep recursion may have generated
401 * additional modifications.
403 if (info.parent != chain->parent) {
404 if (hammer2_debug & 0x0040) {
405 kprintf("LOST CHILD4 %p->%p "
406 "(actual parent %p)\n",
407 info.parent, chain, chain->parent);
409 hammer2_chain_drop(info.parent);
410 info.parent = chain->parent;
411 hammer2_chain_ref(info.parent);
413 if (hammer2_flush_core(&info, chain, flags) == 0)
416 if (++loops % 1000 == 0) {
417 kprintf("hammer2_flush: excessive loops on %p\n",
419 if (hammer2_debug & 0x100000)
423 #ifdef HAMMER2_SCAN_DEBUG
424 if (info.scan_count >= 10)
425 kprintf("hammer2_flush: scan_count %ld (%ld,%ld,%ld,%ld) "
426 "bt(%ld,%ld,%ld,%ld,%ld,%ld)\n",
439 hammer2_chain_drop(chain);
441 hammer2_chain_drop(info.parent);
446 * This is the core of the chain flushing code. The chain is locked by the
447 * caller and must also have an extra ref on it by the caller, and remains
448 * locked and will have an extra ref on return. info.parent is referenced
451 * Upon return, the caller can test the UPDATE bit on the chain to determine
452 * if the parent needs updating.
454 * If non-zero is returned, the chain's parent changed during the flush and
455 * the caller must retry the operation.
457 * (1) Determine if this node is a candidate for the flush, return if it is
458 * not. fchain and vchain are always candidates for the flush.
460 * (2) If we recurse too deep the chain is entered onto the deferral list and
461 * the current flush stack is aborted until after the deferral list is
464 * (3) Recursively flush live children (rbtree). This can create deferrals.
465 * A successful flush clears the MODIFIED and UPDATE bits on the children
466 * and typically causes the parent to be marked MODIFIED as the children
467 * update the parent's block table. A parent might already be marked
468 * MODIFIED due to a deletion (whos blocktable update in the parent is
469 * handled by the frontend), or if the parent itself is modified by the
470 * frontend for other reasons.
472 * (4) Permanently disconnected sub-trees are cleaned up by the front-end.
473 * Deleted-but-open inodes can still be individually flushed via the
476 * (5) Delete parents on the way back up if they are normal indirect blocks
477 * and have no children.
479 * (6) Note that an unmodified child may still need the block table in its
480 * parent updated (e.g. rename/move). The child will have UPDATE set
483 * WARNING ON BREF MODIFY_TID/MIRROR_TID
485 * blockref.modify_tid is consistent only within a PFS, and will not be
486 * consistent during synchronization. mirror_tid is consistent across the
487 * block device regardless of the PFS.
490 hammer2_flush_core(hammer2_flush_info_t *info, hammer2_chain_t *chain,
493 hammer2_chain_t *parent;
501 * (1) Optimize downward recursion to locate nodes needing action.
502 * Nothing to do if none of these flags are set.
504 if ((chain->flags & HAMMER2_CHAIN_FLUSH_MASK) == 0) {
505 if (hammer2_debug & 0x200) {
506 if (info->debug == NULL)
516 * NOTE: parent can be NULL, usually due to destroy races.
518 parent = info->parent;
519 KKASSERT(chain->parent == parent);
522 * Downward search recursion
524 * We must be careful on cold stops, which often occur on inode
525 * boundaries due to the way hammer2_vfs_sync() sequences the flush.
526 * Be sure to issue an appropriate chain_setflush()
528 if ((chain->flags & HAMMER2_CHAIN_PFSBOUNDARY) &&
529 (flags & HAMMER2_FLUSH_ALL) == 0 &&
530 (flags & HAMMER2_FLUSH_TOP) == 0 &&
531 chain->pmp && chain->pmp->mp) {
533 * If FLUSH_ALL is not specified the caller does not want
534 * to recurse through PFS roots that have been mounted.
536 * (If the PFS has not been mounted there may not be
537 * anything monitoring its chains and its up to us
540 * The typical sequence is to flush dirty PFS's starting at
541 * their root downward, then flush the device root (vchain).
542 * It is this second flush that typically leaves out the
545 * However we must still process the PFSROOT chains for block
546 * table updates in their parent (which IS part of our flush).
548 * NOTE: The volume root, vchain, does not set PFSBOUNDARY.
550 * NOTE: We must re-set ONFLUSH in the parent to retain if
551 * this chain (that we are skipping) requires work.
553 if (chain->flags & (HAMMER2_CHAIN_ONFLUSH |
554 HAMMER2_CHAIN_DESTROY |
555 HAMMER2_CHAIN_MODIFIED)) {
556 hammer2_chain_setflush(parent);
559 } else if (chain->bref.type == HAMMER2_BREF_TYPE_INODE &&
560 (flags & HAMMER2_FLUSH_INODE_STOP) &&
561 (flags & HAMMER2_FLUSH_ALL) == 0 &&
562 (flags & HAMMER2_FLUSH_TOP) == 0 &&
563 chain->pmp && chain->pmp->mp) {
565 * When FLUSH_INODE_STOP is specified we are being asked not
566 * to include any inode changes for inodes we encounter,
567 * with the exception of the inode that the flush began with.
568 * So: INODE, INODE_STOP, and TOP==0 basically.
570 * Dirty inodes are flushed based on the hammer2_inode
571 * in-memory structure, issuing a chain_setflush() here
572 * will only cause unnecessary traversals of the topology.
577 * If FLUSH_INODE_STOP is specified and both ALL and TOP
578 * are clear, we must not flush the chain. The chain should
579 * have already been flushed and any further ONFLUSH/UPDATE
580 * setting will be related to the next flush.
582 * This features allows us to flush inodes independently of
583 * each other and meta-data above the inodes separately.
585 if (chain->flags & (HAMMER2_CHAIN_ONFLUSH |
586 HAMMER2_CHAIN_DESTROY |
587 HAMMER2_CHAIN_MODIFIED)) {
589 hammer2_chain_setflush(parent);
592 } else if (info->depth == HAMMER2_FLUSH_DEPTH_LIMIT) {
594 * Recursion depth reached.
596 panic("hammer2: flush depth limit");
597 } else if (chain->flags & (HAMMER2_CHAIN_ONFLUSH |
598 HAMMER2_CHAIN_DESTROY)) {
600 * Downward recursion search (actual flush occurs bottom-up).
601 * pre-clear ONFLUSH. It can get set again due to races or
602 * flush errors, which we want so the scan finds us again in
605 * We must also recurse if DESTROY is set so we can finally
606 * get rid of the related children, otherwise the node will
607 * just get re-flushed on lastdrop.
609 * WARNING! The recursion will unlock/relock info->parent
610 * (which is 'chain'), potentially allowing it
613 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_ONFLUSH);
614 save_error = info->error;
616 info->parent = chain;
619 * We may have to do this twice to catch any indirect
620 * block maintenance that occurs.
622 hammer2_spin_ex(&chain->core.spin);
623 RB_SCAN(hammer2_chain_tree, &chain->core.rbtree,
624 NULL, hammer2_flush_recurse, info);
625 if (chain->flags & HAMMER2_CHAIN_ONFLUSH) {
626 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_ONFLUSH);
627 RB_SCAN(hammer2_chain_tree, &chain->core.rbtree,
628 NULL, hammer2_flush_recurse, info);
630 hammer2_spin_unex(&chain->core.spin);
631 info->parent = parent;
634 * Re-set the flush bits if the flush was incomplete or
635 * an error occurred. If an error occurs it is typically
636 * an allocation error. Errors do not cause deferrals.
639 hammer2_chain_setflush(chain);
640 info->error |= save_error;
643 * If we lost the parent->chain association we have to
644 * stop processing this chain because it is no longer
645 * in this recursion. If it moved, it will be handled
646 * by the ONFLUSH flag elsewhere.
648 if (chain->parent != parent) {
649 kprintf("LOST CHILD2 %p->%p (actual parent %p)\n",
650 parent, chain, chain->parent);
656 * Now we are in the bottom-up part of the recursion.
658 * We continue to try to update the chain on lower-level errors, but
659 * the flush code may decide not to flush the volume root.
661 * XXX should we continue to try to update the chain if an error
666 * Both parent and chain must be locked in order to flush chain,
667 * in order to properly update the parent under certain conditions.
669 * In addition, we can't safely unlock/relock the chain once we
670 * start flushing the chain itself, which we would have to do later
671 * on in order to lock the parent if we didn't do that now.
673 hammer2_chain_ref_hold(chain);
674 hammer2_chain_unlock(chain);
676 hammer2_chain_lock(parent, HAMMER2_RESOLVE_ALWAYS);
677 hammer2_chain_lock(chain, HAMMER2_RESOLVE_MAYBE);
678 hammer2_chain_drop_unhold(chain);
681 * Can't process if we can't access their content.
683 if ((parent && parent->error) || chain->error) {
684 kprintf("hammer2: chain error during flush\n");
685 info->error |= chain->error;
687 info->error |= parent->error;
688 hammer2_chain_unlock(parent);
693 if (chain->parent != parent) {
694 if (hammer2_debug & 0x0040) {
695 kprintf("LOST CHILD3 %p->%p (actual parent %p)\n",
696 parent, chain, chain->parent);
698 KKASSERT(parent != NULL);
699 hammer2_chain_unlock(parent);
705 * Propagate the DESTROY flag downwards. This dummies up the flush
706 * code and tries to invalidate related buffer cache buffers to
707 * avoid the disk write.
709 if (parent && (parent->flags & HAMMER2_CHAIN_DESTROY))
710 atomic_set_int(&chain->flags, HAMMER2_CHAIN_DESTROY);
713 * Dispose of the modified bit.
715 * If parent is present, the UPDATE bit should already be set.
716 * UPDATE should already be set.
717 * bref.mirror_tid should already be set.
719 if (chain->flags & HAMMER2_CHAIN_MODIFIED) {
720 KKASSERT((chain->flags & HAMMER2_CHAIN_UPDATE) ||
721 chain->parent == NULL);
722 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_MODIFIED);
723 atomic_add_long(&hammer2_count_modified_chains, -1);
726 * Manage threads waiting for excessive dirty memory to
730 hammer2_pfs_memory_wakeup(chain->pmp);
733 if ((chain->flags & HAMMER2_CHAIN_UPDATE) == 0 &&
734 chain != &hmp->vchain &&
735 chain != &hmp->fchain) {
737 * Set UPDATE bit indicating that the parent block
738 * table requires updating.
740 atomic_set_int(&chain->flags, HAMMER2_CHAIN_UPDATE);
745 * Issue the flush. This is indirect via the DIO.
747 * NOTE: A DELETED node that reaches this point must be
748 * flushed for synchronization point consistency.
750 * NOTE: Even though MODIFIED was already set, the related DIO
751 * might not be dirty due to a system buffer cache
752 * flush and must be set dirty if we are going to make
753 * further modifications to the buffer. Chains with
754 * embedded data don't need this.
756 if (hammer2_debug & 0x1000) {
757 kprintf("Flush %p.%d %016jx/%d data=%016jx\n",
758 chain, chain->bref.type,
759 (uintmax_t)chain->bref.key,
761 (uintmax_t)chain->bref.data_off);
763 if (hammer2_debug & 0x2000) {
764 Debugger("Flush hell");
768 * Update chain CRCs for flush.
770 * NOTE: Volume headers are NOT flushed here as they require
771 * special processing.
773 switch(chain->bref.type) {
774 case HAMMER2_BREF_TYPE_FREEMAP:
776 * Update the volume header's freemap_tid to the
777 * freemap's flushing mirror_tid.
779 * (note: embedded data, do not call setdirty)
781 KKASSERT(hmp->vchain.flags & HAMMER2_CHAIN_MODIFIED);
782 KKASSERT(chain == &hmp->fchain);
783 hmp->voldata.freemap_tid = chain->bref.mirror_tid;
784 if (hammer2_debug & 0x8000) {
785 /* debug only, avoid syslogd loop */
786 kprintf("sync freemap mirror_tid %08jx\n",
787 (intmax_t)chain->bref.mirror_tid);
791 * The freemap can be flushed independently of the
792 * main topology, but for the case where it is
793 * flushed in the same transaction, and flushed
794 * before vchain (a case we want to allow for
795 * performance reasons), make sure modifications
796 * made during the flush under vchain use a new
799 * Otherwise the mount recovery code will get confused.
801 ++hmp->voldata.mirror_tid;
803 case HAMMER2_BREF_TYPE_VOLUME:
805 * The free block table is flushed by
806 * hammer2_vfs_sync() before it flushes vchain.
807 * We must still hold fchain locked while copying
808 * voldata to volsync, however.
810 * These do not error per-say since their data does
811 * not need to be re-read from media on lock.
813 * (note: embedded data, do not call setdirty)
815 hammer2_chain_lock(&hmp->fchain,
816 HAMMER2_RESOLVE_ALWAYS);
817 hammer2_voldata_lock(hmp);
818 if (hammer2_debug & 0x8000) {
819 /* debug only, avoid syslogd loop */
820 kprintf("sync volume mirror_tid %08jx\n",
821 (intmax_t)chain->bref.mirror_tid);
825 * Update the volume header's mirror_tid to the
826 * main topology's flushing mirror_tid. It is
827 * possible that voldata.mirror_tid is already
828 * beyond bref.mirror_tid due to the bump we made
829 * above in BREF_TYPE_FREEMAP.
831 if (hmp->voldata.mirror_tid < chain->bref.mirror_tid) {
832 hmp->voldata.mirror_tid =
833 chain->bref.mirror_tid;
837 * The volume header is flushed manually by the
838 * syncer, not here. All we do here is adjust the
841 KKASSERT(chain->data != NULL);
842 KKASSERT(chain->dio == NULL);
844 hmp->voldata.icrc_sects[HAMMER2_VOL_ICRC_SECT1]=
846 (char *)&hmp->voldata +
847 HAMMER2_VOLUME_ICRC1_OFF,
848 HAMMER2_VOLUME_ICRC1_SIZE);
849 hmp->voldata.icrc_sects[HAMMER2_VOL_ICRC_SECT0]=
851 (char *)&hmp->voldata +
852 HAMMER2_VOLUME_ICRC0_OFF,
853 HAMMER2_VOLUME_ICRC0_SIZE);
854 hmp->voldata.icrc_volheader =
856 (char *)&hmp->voldata +
857 HAMMER2_VOLUME_ICRCVH_OFF,
858 HAMMER2_VOLUME_ICRCVH_SIZE);
860 if (hammer2_debug & 0x8000) {
861 /* debug only, avoid syslogd loop */
862 kprintf("syncvolhdr %016jx %016jx\n",
863 hmp->voldata.mirror_tid,
864 hmp->vchain.bref.mirror_tid);
866 hmp->volsync = hmp->voldata;
867 atomic_set_int(&chain->flags, HAMMER2_CHAIN_VOLUMESYNC);
868 hammer2_voldata_unlock(hmp);
869 hammer2_chain_unlock(&hmp->fchain);
871 case HAMMER2_BREF_TYPE_DATA:
873 * Data elements have already been flushed via the
874 * logical file buffer cache. Their hash was set in
875 * the bref by the vop_write code. Do not re-dirty.
877 * Make sure any device buffer(s) have been flushed
878 * out here (there aren't usually any to flush) XXX.
881 case HAMMER2_BREF_TYPE_INDIRECT:
882 case HAMMER2_BREF_TYPE_FREEMAP_NODE:
883 case HAMMER2_BREF_TYPE_FREEMAP_LEAF:
885 * Buffer I/O will be cleaned up when the volume is
886 * flushed (but the kernel is free to flush it before
889 KKASSERT((chain->flags & HAMMER2_CHAIN_EMBEDDED) == 0);
890 hammer2_chain_setcheck(chain, chain->data);
892 case HAMMER2_BREF_TYPE_DIRENT:
894 * A directory entry can use the check area to store
895 * the filename for filenames <= 64 bytes, don't blow
898 KKASSERT((chain->flags & HAMMER2_CHAIN_EMBEDDED) == 0);
900 hammer2_chain_setcheck(chain, chain->data);
902 case HAMMER2_BREF_TYPE_INODE:
904 * NOTE: We must call io_setdirty() to make any late
905 * changes to the inode data, the system might
906 * have already flushed the buffer.
908 if (chain->data->ipdata.meta.op_flags &
909 HAMMER2_OPFLAG_PFSROOT) {
911 * non-NULL pmp if mounted as a PFS. We must
912 * sync fields cached in the pmp? XXX
914 hammer2_inode_data_t *ipdata;
916 hammer2_io_setdirty(chain->dio);
917 ipdata = &chain->data->ipdata;
919 ipdata->meta.pfs_inum =
920 chain->pmp->inode_tid;
923 /* can't be mounted as a PFS */
926 KKASSERT((chain->flags & HAMMER2_CHAIN_EMBEDDED) == 0);
927 hammer2_chain_setcheck(chain, chain->data);
930 KKASSERT(chain->flags & HAMMER2_CHAIN_EMBEDDED);
931 panic("hammer2_flush_core: unsupported "
938 * If the chain was destroyed try to avoid unnecessary I/O
939 * that might not have yet occurred. Remove the data range
940 * from dedup candidacy and attempt to invalidation that
941 * potentially dirty portion of the I/O buffer.
943 if (chain->flags & HAMMER2_CHAIN_DESTROY) {
944 hammer2_io_dedup_delete(hmp,
946 chain->bref.data_off,
951 hammer2_io_inval(chain->dio,
952 chain->bref.data_off,
954 } else if ((dio = hammer2_io_getquick(hmp,
955 chain->bref.data_off,
958 hammer2_io_inval(dio,
959 chain->bref.data_off,
961 hammer2_io_putblk(&dio);
968 * If UPDATE is set the parent block table may need to be updated.
969 * This can fail if the hammer2_chain_modify() fails.
971 * NOTE: UPDATE may be set on vchain or fchain in which case
972 * parent could be NULL, or on an inode that has not yet
973 * been inserted into the radix tree. It's easiest to allow
974 * the case and test for NULL. parent can also wind up being
975 * NULL due to a deletion so we need to handle the case anyway.
977 * NOTE: UPDATE can be set when chains are renamed into or out of
978 * an indirect block, without the chain itself being flagged
981 * If no parent exists we can just clear the UPDATE bit. If the
982 * chain gets reattached later on the bit will simply get set
985 if ((chain->flags & HAMMER2_CHAIN_UPDATE) && parent == NULL)
986 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_UPDATE);
989 * When flushing an inode outside of a FLUSH_FSSYNC we must NOT
990 * update the parent block table to point at the flushed inode.
991 * The block table should only ever be updated by the filesystem
992 * sync code. If we do, inode<->inode dependencies (such as
993 * directory entries vs inode nlink count) can wind up not being
994 * flushed together and result in a broken topology if a crash/reboot
995 * occurs at the wrong time.
997 if (chain->bref.type == HAMMER2_BREF_TYPE_INODE &&
998 (flags & HAMMER2_FLUSH_INODE_STOP) &&
999 (flags & HAMMER2_FLUSH_FSSYNC) == 0 &&
1000 (flags & HAMMER2_FLUSH_ALL) == 0 &&
1001 chain->pmp && chain->pmp->mp) {
1002 #ifdef HAMMER2_DEBUG_SYNC
1003 kprintf("inum %ld do not update parent, non-fssync\n",
1004 (long)chain->bref.key);
1008 #ifdef HAMMER2_DEBUG_SYNC
1009 if (chain->bref.type == HAMMER2_BREF_TYPE_INODE)
1010 kprintf("inum %ld update parent\n", (long)chain->bref.key);
1014 * The chain may need its blockrefs updated in the parent, normal
1017 if (chain->flags & HAMMER2_CHAIN_UPDATE) {
1018 hammer2_blockref_t *base;
1022 * Clear UPDATE flag, mark parent modified, update its
1023 * modify_tid if necessary, and adjust the parent blockmap.
1025 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_UPDATE);
1030 * Avoid actually modifying and updating the parent if it
1031 * was flagged for destruction. This can greatly reduce
1032 * disk I/O in large tree removals because the
1033 * hammer2_io_setinval() call in the upward recursion
1034 * (see MODIFIED code above) can only handle a few cases.
1036 if (parent->flags & HAMMER2_CHAIN_DESTROY) {
1037 if (parent->bref.modify_tid < chain->bref.modify_tid) {
1038 parent->bref.modify_tid =
1039 chain->bref.modify_tid;
1041 atomic_clear_int(&chain->flags, HAMMER2_CHAIN_BMAPPED |
1042 HAMMER2_CHAIN_BMAPUPD);
1047 * The flusher is responsible for deleting empty indirect
1048 * blocks at this point. If we don't do this, no major harm
1049 * will be done but the empty indirect blocks will stay in
1050 * the topology and make it a messy and inefficient.
1052 * The flusher is also responsible for collapsing the
1053 * content of an indirect block into its parent whenever
1054 * possible (with some hysteresis). Not doing this will also
1055 * not harm the topology, but would make it messy and
1058 if (chain->bref.type == HAMMER2_BREF_TYPE_INDIRECT) {
1059 if (hammer2_chain_indirect_maintenance(parent, chain))
1064 * We are updating the parent's blockmap, the parent must
1065 * be set modified. If this fails we re-set the UPDATE flag
1068 * NOTE! A modification error can be ENOSPC. We still want
1069 * to flush modified chains recursively, not break out,
1070 * so we just skip the update in this situation and
1071 * continue. That is, we still need to try to clean
1072 * out dirty chains and buffers.
1074 * This may not help bulkfree though. XXX
1076 save_error = hammer2_chain_modify(parent, 0, 0, 0);
1078 info->error |= save_error;
1079 kprintf("hammer2_flush: %016jx.%02x error=%08x\n",
1080 parent->bref.data_off, parent->bref.type,
1082 atomic_set_int(&chain->flags, HAMMER2_CHAIN_UPDATE);
1085 if (parent->bref.modify_tid < chain->bref.modify_tid)
1086 parent->bref.modify_tid = chain->bref.modify_tid;
1089 * Calculate blockmap pointer
1091 switch(parent->bref.type) {
1092 case HAMMER2_BREF_TYPE_INODE:
1094 * Access the inode's block array. However, there is
1095 * no block array if the inode is flagged DIRECTDATA.
1098 (parent->data->ipdata.meta.op_flags &
1099 HAMMER2_OPFLAG_DIRECTDATA) == 0) {
1100 base = &parent->data->
1101 ipdata.u.blockset.blockref[0];
1105 count = HAMMER2_SET_COUNT;
1107 case HAMMER2_BREF_TYPE_INDIRECT:
1108 case HAMMER2_BREF_TYPE_FREEMAP_NODE:
1110 base = &parent->data->npdata[0];
1113 count = parent->bytes / sizeof(hammer2_blockref_t);
1115 case HAMMER2_BREF_TYPE_VOLUME:
1116 base = &chain->hmp->voldata.sroot_blockset.blockref[0];
1117 count = HAMMER2_SET_COUNT;
1119 case HAMMER2_BREF_TYPE_FREEMAP:
1120 base = &parent->data->npdata[0];
1121 count = HAMMER2_SET_COUNT;
1126 panic("hammer2_flush_core: "
1127 "unrecognized blockref type: %d",
1132 * Blocktable updates
1134 * We synchronize pending statistics at this time. Delta
1135 * adjustments designated for the current and upper level
1138 if (base && (chain->flags & HAMMER2_CHAIN_BMAPUPD)) {
1139 if (chain->flags & HAMMER2_CHAIN_BMAPPED) {
1140 hammer2_spin_ex(&parent->core.spin);
1141 hammer2_base_delete(parent, base, count, chain,
1143 hammer2_spin_unex(&parent->core.spin);
1144 /* base_delete clears both bits */
1146 atomic_clear_int(&chain->flags,
1147 HAMMER2_CHAIN_BMAPUPD);
1150 if (base && (chain->flags & HAMMER2_CHAIN_BMAPPED) == 0) {
1151 hammer2_spin_ex(&parent->core.spin);
1152 hammer2_base_insert(parent, base, count,
1153 chain, &chain->bref);
1154 hammer2_spin_unex(&parent->core.spin);
1155 /* base_insert sets BMAPPED */
1160 hammer2_chain_unlock(parent);
1163 * Final cleanup after flush
1166 KKASSERT(chain->refs > 0);
1167 if (hammer2_debug & 0x200) {
1168 if (info->debug == chain)
1175 * Flush recursion helper, called from flush_core, calls flush_core.
1177 * Flushes the children of the caller's chain (info->parent), restricted
1178 * by sync_tid. Set info->domodify if the child's blockref must propagate
1179 * back up to the parent.
1181 * This function may set info->error as a side effect.
1183 * Ripouts can move child from rbtree to dbtree or dbq but the caller's
1184 * flush scan order prevents any chains from being lost. A child can be
1185 * executes more than once.
1187 * WARNING! If we do not call hammer2_flush_core() we must update
1188 * bref.mirror_tid ourselves to indicate that the flush has
1189 * processed the child.
1191 * WARNING! parent->core spinlock is held on entry and return.
1194 hammer2_flush_recurse(hammer2_chain_t *child, void *data)
1196 hammer2_flush_info_t *info = data;
1197 hammer2_chain_t *parent = info->parent;
1199 #ifdef HAMMER2_SCAN_DEBUG
1201 if (child->flags & HAMMER2_CHAIN_MODIFIED)
1202 ++info->scan_mod_count;
1203 if (child->flags & HAMMER2_CHAIN_UPDATE)
1204 ++info->scan_upd_count;
1205 if (child->flags & HAMMER2_CHAIN_ONFLUSH)
1206 ++info->scan_onf_count;
1210 * (child can never be fchain or vchain so a special check isn't
1213 * We must ref the child before unlocking the spinlock.
1215 * The caller has added a ref to the parent so we can temporarily
1216 * unlock it in order to lock the child. However, if it no longer
1217 * winds up being the child of the parent we must skip this child.
1219 * NOTE! chain locking errors are fatal. They are never out-of-space
1222 hammer2_chain_ref(child);
1223 hammer2_spin_unex(&parent->core.spin);
1225 hammer2_chain_ref_hold(parent);
1226 hammer2_chain_unlock(parent);
1227 hammer2_chain_lock(child, HAMMER2_RESOLVE_MAYBE);
1228 if (child->parent != parent) {
1229 kprintf("LOST CHILD1 %p->%p (actual parent %p)\n",
1230 parent, child, child->parent);
1234 kprintf("CHILD ERROR DURING FLUSH LOCK %p->%p\n",
1236 info->error |= child->error;
1241 * Must propagate the DESTROY flag downwards, otherwise the
1242 * parent could end up never being removed because it will
1243 * be requeued to the flusher if it survives this run due to
1246 if (parent && (parent->flags & HAMMER2_CHAIN_DESTROY))
1247 atomic_set_int(&child->flags, HAMMER2_CHAIN_DESTROY);
1248 #ifdef HAMMER2_SCAN_DEBUG
1249 if (child->flags & HAMMER2_CHAIN_DESTROY)
1250 ++info->scan_del_count;
1253 * Special handling of the root inode. Because the root inode
1254 * contains an index of all the inodes in the PFS in addition to
1255 * its normal directory entries, any flush that is not part of a
1256 * filesystem sync must only flush the directory entries, and not
1259 * The child might be an indirect block, but H2 guarantees that
1260 * the key-range will fully partition the inode index from the
1261 * directory entries so the case just works naturally.
1263 if ((parent->bref.flags & HAMMER2_BREF_FLAG_PFSROOT) &&
1264 (child->flags & HAMMER2_CHAIN_DESTROY) == 0 &&
1265 parent->bref.type == HAMMER2_BREF_TYPE_INODE &&
1266 (info->flags & HAMMER2_FLUSH_FSSYNC) == 0) {
1267 if ((child->bref.key & HAMMER2_DIRHASH_VISIBLE) == 0) {
1268 if (child->flags & HAMMER2_CHAIN_FLUSH_MASK) {
1269 hammer2_chain_setflush(parent);
1276 * Recurse and collect deferral data. We're in the media flush,
1277 * this can cross PFS boundaries.
1279 if (child->flags & HAMMER2_CHAIN_FLUSH_MASK) {
1280 #ifdef HAMMER2_SCAN_DEBUG
1281 if (child->bref.type < 7)
1282 ++info->scan_btype[child->bref.type];
1285 hammer2_flush_core(info, child, info->flags);
1287 } else if (hammer2_debug & 0x200) {
1288 if (info->debug == NULL)
1289 info->debug = child;
1291 hammer2_flush_core(info, child, info->flags);
1293 if (info->debug == child)
1299 * Relock to continue the loop.
1301 hammer2_chain_unlock(child);
1302 hammer2_chain_lock(parent, HAMMER2_RESOLVE_MAYBE);
1303 hammer2_chain_drop_unhold(parent);
1304 if (parent->error) {
1305 kprintf("PARENT ERROR DURING FLUSH LOCK %p->%p\n",
1307 info->error |= parent->error;
1309 hammer2_chain_drop(child);
1310 KKASSERT(info->parent == parent);
1311 hammer2_spin_ex(&parent->core.spin);
1317 * flush helper (backend threaded)
1319 * Flushes chain topology for the specified inode.
1321 * HAMMER2_XOP_INODE_STOP The flush recursion stops at inode boundaries.
1322 * Inodes belonging to the same flush are flushed
1325 * chain->parent can be NULL, usually due to destroy races or detached inodes.
1327 * Primarily called from vfs_sync().
1330 hammer2_xop_inode_flush(hammer2_xop_t *arg, void *scratch __unused, int clindex)
1332 hammer2_xop_flush_t *xop = &arg->xop_flush;
1333 hammer2_chain_t *chain;
1334 hammer2_inode_t *ip;
1337 int flush_error = 0;
1338 int fsync_error = 0;
1339 int total_error = 0;
1344 xflags = HAMMER2_FLUSH_TOP;
1345 if (xop->head.flags & HAMMER2_XOP_INODE_STOP)
1346 xflags |= HAMMER2_FLUSH_INODE_STOP;
1347 if (xop->head.flags & HAMMER2_XOP_FSSYNC)
1348 xflags |= HAMMER2_FLUSH_FSSYNC;
1355 chain = hammer2_inode_chain(ip, clindex, HAMMER2_RESOLVE_ALWAYS);
1358 if (chain->flags & HAMMER2_CHAIN_FLUSH_MASK) {
1360 * Due to flush partitioning the chain topology
1361 * above the inode's chain may no longer be flagged.
1362 * When asked to flush an inode, remark the topology
1363 * leading to that inode.
1366 hammer2_chain_setflush(chain->parent);
1367 hammer2_flush(chain, xflags);
1370 if (ip == pmp->iroot && pmp != hmp->spmp) {
1371 hammer2_spin_ex(&pmp->inum_spin);
1372 pmp->pfs_iroot_blocksets[clindex] =
1373 chain->data->ipdata.u.blockset;
1374 hammer2_spin_unex(&pmp->inum_spin);
1379 * Propogate upwards but only cross an inode boundary
1380 * for inodes associated with the current filesystem
1383 if ((xop->head.flags & HAMMER2_XOP_PARENTONFLUSH) ||
1384 chain->bref.type != HAMMER2_BREF_TYPE_INODE) {
1385 parent = chain->parent;
1387 hammer2_chain_setflush(parent);
1391 if (chain->flags & HAMMER2_CHAIN_PFSBOUNDARY)
1393 hammer2_chain_unlock(chain);
1394 hammer2_chain_drop(chain);
1401 * Only flush the volume header if asked to, plus the inode must also
1404 if ((xop->head.flags & HAMMER2_XOP_VOLHDR) == 0)
1410 * Flush volume roots. Avoid replication, we only want to
1411 * flush each hammer2_dev (hmp) once.
1413 for (j = clindex - 1; j >= 0; --j) {
1414 if ((chain = ip->cluster.array[j].chain) != NULL) {
1415 if (chain->hmp == hmp) {
1416 chain = NULL; /* safety */
1421 chain = NULL; /* safety */
1424 * spmp transaction. The super-root is never directly mounted so
1425 * there shouldn't be any vnodes, let alone any dirty vnodes
1426 * associated with it, so we shouldn't have to mess around with any
1427 * vnode flushes here.
1429 hammer2_trans_init(hmp->spmp, HAMMER2_TRANS_ISFLUSH);
1432 * We must flush the superroot down to the PFS iroot. Remember
1433 * that hammer2_chain_setflush() stops at inode boundaries, so
1434 * the pmp->iroot has been flushed and flagged down to the superroot,
1435 * but the volume root (vchain) probably has not yet been flagged.
1437 if (hmp->spmp->iroot) {
1438 chain = hmp->spmp->iroot->cluster.array[0].chain;
1440 hammer2_chain_ref(chain);
1441 hammer2_chain_lock(chain, HAMMER2_RESOLVE_ALWAYS);
1443 hammer2_flush(chain,
1445 HAMMER2_FLUSH_INODE_STOP |
1446 HAMMER2_FLUSH_FSSYNC);
1447 hammer2_chain_unlock(chain);
1448 hammer2_chain_drop(chain);
1453 * Media mounts have two 'roots', vchain for the topology
1454 * and fchain for the free block table. Flush both.
1456 * Note that the topology and free block table are handled
1457 * independently, so the free block table can wind up being
1458 * ahead of the topology. We depend on the bulk free scan
1459 * code to deal with any loose ends.
1461 * vchain and fchain do not error on-lock since their data does
1462 * not have to be re-read from media.
1464 hammer2_chain_ref(&hmp->vchain);
1465 hammer2_chain_lock(&hmp->vchain, HAMMER2_RESOLVE_ALWAYS);
1466 hammer2_chain_ref(&hmp->fchain);
1467 hammer2_chain_lock(&hmp->fchain, HAMMER2_RESOLVE_ALWAYS);
1468 if (hmp->fchain.flags & HAMMER2_CHAIN_FLUSH_MASK) {
1470 * This will also modify vchain as a side effect,
1471 * mark vchain as modified now.
1473 hammer2_voldata_modify(hmp);
1474 chain = &hmp->fchain;
1475 flush_error |= hammer2_flush(chain, HAMMER2_FLUSH_TOP);
1476 KKASSERT(chain == &hmp->fchain);
1478 hammer2_chain_unlock(&hmp->fchain);
1479 hammer2_chain_unlock(&hmp->vchain);
1480 hammer2_chain_drop(&hmp->fchain);
1481 /* vchain dropped down below */
1483 hammer2_chain_lock(&hmp->vchain, HAMMER2_RESOLVE_ALWAYS);
1484 if (hmp->vchain.flags & HAMMER2_CHAIN_FLUSH_MASK) {
1485 chain = &hmp->vchain;
1486 flush_error |= hammer2_flush(chain, HAMMER2_FLUSH_TOP);
1487 KKASSERT(chain == &hmp->vchain);
1489 hammer2_chain_unlock(&hmp->vchain);
1490 hammer2_chain_drop(&hmp->vchain);
1493 * We can't safely flush the volume header until we have
1494 * flushed any device buffers which have built up.
1496 * XXX this isn't being incremental
1498 vn_lock(hmp->devvp, LK_EXCLUSIVE | LK_RETRY);
1499 fsync_error = VOP_FSYNC(hmp->devvp, MNT_WAIT, 0);
1500 vn_unlock(hmp->devvp);
1501 if (fsync_error || flush_error) {
1502 kprintf("hammer2: sync error fsync=%d h2flush=0x%04x dev=%s\n",
1503 fsync_error, flush_error, hmp->devrepname);
1507 * The flush code sets CHAIN_VOLUMESYNC to indicate that the
1508 * volume header needs synchronization via hmp->volsync.
1510 * XXX synchronize the flag & data with only this flush XXX
1512 if (fsync_error == 0 && flush_error == 0 &&
1513 (hmp->vchain.flags & HAMMER2_CHAIN_VOLUMESYNC)) {
1518 * Synchronize the disk before flushing the volume
1522 bp->b_bio1.bio_offset = 0;
1525 bp->b_cmd = BUF_CMD_FLUSH;
1526 bp->b_bio1.bio_done = biodone_sync;
1527 bp->b_bio1.bio_flags |= BIO_SYNC;
1528 vn_strategy(hmp->devvp, &bp->b_bio1);
1529 fsync_error = biowait(&bp->b_bio1, "h2vol");
1533 * Then we can safely flush the version of the
1534 * volume header synchronized by the flush code.
1536 j = hmp->volhdrno + 1;
1539 if (j >= HAMMER2_NUM_VOLHDRS)
1541 if (j * HAMMER2_ZONE_BYTES64 + HAMMER2_SEGSIZE >
1542 hmp->volsync.volu_size) {
1545 if (hammer2_debug & 0x8000) {
1546 /* debug only, avoid syslogd loop */
1547 kprintf("sync volhdr %d %jd\n",
1548 j, (intmax_t)hmp->volsync.volu_size);
1550 bp = getblk(hmp->devvp, j * HAMMER2_ZONE_BYTES64,
1551 HAMMER2_PBUFSIZE, GETBLK_KVABIO, 0);
1552 atomic_clear_int(&hmp->vchain.flags,
1553 HAMMER2_CHAIN_VOLUMESYNC);
1555 bcopy(&hmp->volsync, bp->b_data, HAMMER2_PBUFSIZE);
1556 vol_error = bwrite(bp);
1559 fsync_error = vol_error;
1562 total_error = flush_error;
1564 total_error = hammer2_errno_to_error(fsync_error);
1567 hammer2_trans_done(hmp->spmp, HAMMER2_TRANS_ISFLUSH);
1569 hammer2_xop_feed(&xop->head, NULL, clindex, total_error);