fs/jfs/jfs_xtree.c

Source file repositories/reference/linux-study-clean/fs/jfs/jfs_xtree.c

File Facts

System
Linux kernel
Corpus path
fs/jfs/jfs_xtree.c
Extension
.c
Size
69875 bytes
Lines
2931
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

struct xtsplit {
	struct metapage *mp;
	s16 index;
	u8 flag;
	s64 off;
	s64 addr;
	int len;
	struct pxdlist *pxdlist;
};


/*
 *	statistics
 */
#ifdef CONFIG_JFS_STATISTICS
static struct {
	uint search;
	uint fastSearch;
	uint split;
} xtStat;
#endif


/*
 * forward references
 */
static int xtSearch(struct inode *ip, s64 xoff, s64 *next, int *cmpp,
		    struct btstack * btstack, int flag);

static int xtSplitUp(tid_t tid,
		     struct inode *ip,
		     struct xtsplit * split, struct btstack * btstack);

static int xtSplitPage(tid_t tid, struct inode *ip, struct xtsplit * split,
		       struct metapage ** rmpp, s64 * rbnp);

static int xtSplitRoot(tid_t tid, struct inode *ip,
		       struct xtsplit * split, struct metapage ** rmpp);

/*
 *	xt_getpage()
 *
 * function:	get the page buffer for a specified block address.
 *
 * parameters:
 *	ip      - pointer to the inode
 *	bn      - block number (s64) of the xtree page to be retrieved;
 *	mp      - pointer to a metapage pointer where the page buffer is returned;
 *
 * returns:
 *      A pointer to the xtree page (xtpage_t) on success, -EIO on error.
 */

static inline xtpage_t *xt_getpage(struct inode *ip, s64 bn, struct metapage **mp)
{
	xtpage_t *p;
	int rc;

	BT_GETPAGE(ip, bn, *mp, xtpage_t, PSIZE, p, rc, i_xtroot);

	if (rc)
		return ERR_PTR(rc);
	if ((le16_to_cpu(p->header.nextindex) < XTENTRYSTART) ||
		(le16_to_cpu(p->header.nextindex) >
			le16_to_cpu(p->header.maxentry)) ||
		(le16_to_cpu(p->header.maxentry) >
			((bn == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) {
		jfs_error(ip->i_sb, "xt_getpage: xtree page corrupt\n");
		BT_PUTPAGE(*mp);
		*mp = NULL;
		return ERR_PTR(-EIO);
	}
	return p;
}

/*
 *	xtLookup()
 *
 * function: map a single page into a physical extent;
 */
int xtLookup(struct inode *ip, s64 lstart,
	     s64 llen, int *pflag, s64 * paddr, s32 * plen, int no_check)
{
	int rc = 0;
	struct btstack btstack;
	int cmp;
	s64 bn;
	struct metapage *mp;
	xtpage_t *p;
	int index;

Annotation

Implementation Notes