fs/xfs/libxfs/xfs_btree_mem.c

Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_btree_mem.c

File Facts

System
Linux kernel
Corpus path
fs/xfs/libxfs/xfs_btree_mem.c
Extension
.c
Size
8281 bytes
Lines
347
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!bp) {
			if (test_bit(XFS_LI_DIRTY, &lip->li_flags))
				tp_dirty |= true;
			continue;
		}

		trace_xfbtree_trans_commit_buf(xfbt, bp);

		xmbuf_trans_bdetach(tp, bp);

		/*
		 * If the buffer fails verification, note the failure but
		 * continue walking the transaction items so that we remove all
		 * ephemeral btree buffers.
		 */
		if (!error)
			error = xmbuf_finalize(bp);

		xfs_buf_relse(bp);
	}

	/*
	 * Reset the transaction's dirty flag to reflect the dirty state of the
	 * log items that are still attached.
	 */
	tp->t_flags = (tp->t_flags & ~XFS_TRANS_DIRTY) |
			(tp_dirty ? XFS_TRANS_DIRTY : 0);

	return error;
}

/*
 * Cancel changes to the incore btree by detaching all the xfbtree buffers.
 * Changes are not undone, so callers must not access the btree ever again.
 */
void
xfbtree_trans_cancel(
	struct xfbtree		*xfbt,
	struct xfs_trans	*tp)
{
	struct xfs_log_item	*lip, *n;
	bool			tp_dirty = false;

	list_for_each_entry_safe(lip, n, &tp->t_items, li_trans) {
		struct xfs_buf	*bp = xfbtree_buf_match(xfbt, lip);

		if (!bp) {
			if (test_bit(XFS_LI_DIRTY, &lip->li_flags))
				tp_dirty |= true;
			continue;
		}

		trace_xfbtree_trans_cancel_buf(xfbt, bp);

		xmbuf_trans_bdetach(tp, bp);
		xfs_buf_relse(bp);
	}

	/*
	 * Reset the transaction's dirty flag to reflect the dirty state of the
	 * log items that are still attached.
	 */
	tp->t_flags = (tp->t_flags & ~XFS_TRANS_DIRTY) |
			(tp_dirty ? XFS_TRANS_DIRTY : 0);
}

Annotation

Implementation Notes