fs/xfs/xfs_trans_buf.c

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

File Facts

System
Linux kernel
Corpus path
fs/xfs/xfs_trans_buf.c
Extension
.c
Size
21276 bytes
Lines
795
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 (xfs_is_shutdown(tp->t_mountp)) {
			xfs_buf_stale(bp);
			bp->b_flags |= XBF_DONE;
		}

		ASSERT(bp->b_transp == tp);
		bip = bp->b_log_item;
		ASSERT(bip != NULL);
		ASSERT(atomic_read(&bip->bli_refcount) > 0);
		bip->bli_recur++;
		trace_xfs_trans_get_buf_recur(bip);
		*bpp = bp;
		return 0;
	}

	error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
	if (error)
		return error;

	ASSERT(!bp->b_error);

	_xfs_trans_bjoin(tp, bp, 1);
	trace_xfs_trans_get_buf(bp->b_log_item);
	*bpp = bp;
	return 0;
}

/*
 * Get and lock the superblock buffer for the given transaction.
 */
static struct xfs_buf *
__xfs_trans_getsb(
	struct xfs_trans	*tp,
	struct xfs_buf		*bp)
{
	/*
	 * Just increment the lock recursion count if the buffer is already
	 * attached to this transaction.
	 */
	if (bp->b_transp == tp) {
		struct xfs_buf_log_item	*bip = bp->b_log_item;

		ASSERT(bip != NULL);
		ASSERT(atomic_read(&bip->bli_refcount) > 0);
		bip->bli_recur++;

		trace_xfs_trans_getsb_recur(bip);
	} else {
		xfs_buf_lock(bp);
		xfs_buf_hold(bp);
		_xfs_trans_bjoin(tp, bp, 1);

		trace_xfs_trans_getsb(bp->b_log_item);
	}

	return bp;
}

struct xfs_buf *
xfs_trans_getsb(
	struct xfs_trans	*tp)
{
	return __xfs_trans_getsb(tp, tp->t_mountp->m_sb_bp);
}

struct xfs_buf *
xfs_trans_getrtsb(
	struct xfs_trans	*tp)
{
	if (!tp->t_mountp->m_rtsb_bp)
		return NULL;
	return __xfs_trans_getsb(tp, tp->t_mountp->m_rtsb_bp);
}

/*
 * Get and lock the buffer for the caller if it is not already
 * locked within the given transaction.  If it has not yet been
 * read in, read it from disk. If it is already locked
 * within the transaction and already read in, just increment its
 * lock recursion count and return a pointer to it.
 *
 * If the transaction pointer is NULL, make this just a normal
 * read_buf() call.
 */
int
xfs_trans_read_buf_map(
	struct xfs_mount	*mp,
	struct xfs_trans	*tp,
	struct xfs_buftarg	*target,
	struct xfs_buf_map	*map,

Annotation

Implementation Notes