/*
- * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
static int ClearBTNodes(struct vnode *vp, long blksize, off_t offset, off_t amount);
static int btree_journal_modify_block_end(struct hfsmount *hfsmp, struct buf *bp);
+void btree_swap_node(struct buf *bp, __unused void *arg);
+
+/*
+ * Return btree node size for given vnode.
+ *
+ * Returns:
+ * For btree vnode, returns btree node size.
+ * For non-btree vnodes, returns 0.
+ */
+u_int16_t get_btree_nodesize(struct vnode *vp)
+{
+ BTreeControlBlockPtr btree;
+ u_int16_t node_size = 0;
+
+ if (vnode_issystem(vp)) {
+ btree = (BTreeControlBlockPtr) VTOF(vp)->fcbBTCBPtr;
+ if (btree) {
+ node_size = btree->nodeSize;
+ }
+ }
+
+ return node_size;
+}
-__private_extern__
OSStatus SetBTreeBlockSize(FileReference vp, ByteCount blockSize, __unused ItemCount minBlockCount)
{
BTreeControlBlockPtr bTreePtr;
}
-__private_extern__
OSStatus GetBTreeBlock(FileReference vp, u_int32_t blockNum, GetBlockOptions options, BlockDescriptor *block)
{
OSStatus retval = E_NONE;
}
-__private_extern__
void ModifyBlockStart(FileReference vp, BlockDescPtr blockPtr)
{
struct hfsmount *hfsmp = VTOHFS(vp);
blockPtr->isModified = 1;
}
-static void
+void
btree_swap_node(struct buf *bp, __unused void *arg)
{
// struct hfsmount *hfsmp = (struct hfsmount *)arg;
}
-__private_extern__
OSStatus ReleaseBTreeBlock(FileReference vp, BlockDescPtr blockPtr, ReleaseBlockOptions options)
{
struct hfsmount *hfsmp = VTOHFS(vp);
} else {
buf_brelse(bp); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
}
+
+ /* Don't let anyone else try to use this bp, it's been consumed */
+ blockPtr->blockHeader = NULL;
+
} else {
if (options & kForceWriteBlock) {
if (hfsmp->jnl) {
} else {
retval = VNOP_BWRITE(bp);
}
+
+ /* Don't let anyone else try to use this bp, it's been consumed */
+ blockPtr->blockHeader = NULL;
+
} else if (options & kMarkBlockDirty) {
struct timeval tv;
microuptime(&tv);
buf_clearflags(bp, B_LOCKED);
buf_bawrite(bp);
}
+
+ /* Don't let anyone else try to use this bp, it's been consumed */
+ blockPtr->blockHeader = NULL;
+
} else {
// check if we had previously called journal_modify_block_start()
// on this block and if so, abort it (which will call buf_brelse()).
} else {
buf_brelse(bp); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
}
- };
- };
+
+ /* Don't let anyone else try to use this bp, it's been consumed */
+ blockPtr->blockHeader = NULL;
+ }
+ }
exit:
return (retval);
}
-__private_extern__
OSStatus ExtendBTreeFile(FileReference vp, FSSize minEOF, FSSize maxEOF)
{
#pragma unused (maxEOF)
trim = ((filePtr->fcbEOF - origSize) % btInfo.nodeSize);
}
- ret = TruncateFileC(vcb, filePtr, filePtr->fcbEOF - trim, 0);
+ ret = TruncateFileC(vcb, filePtr, filePtr->fcbEOF - trim, 0, 0, FTOC(filePtr)->c_fileid, 0);
filePtr->fcbEOF = (u_int64_t)filePtr->ff_blocks * (u_int64_t)vcb->blockSize;
// XXXdbg - panic if the file didn't get trimmed back properly
u_int16_t offset;
int intrans = 0;
int result;
+ int newvnode_flags = 0;
+
again:
/*
* Serialize creation using HFS_CREATING_BTREE flag.
bzero(&cfork, sizeof(cfork));
cfork.cf_clump = nodesize * nodecnt;
- result = hfs_getnewvnode(hfsmp, NULL, NULL, &cndesc, 0, &cnattr, &cfork, &vp);
+ result = hfs_getnewvnode(hfsmp, NULL, NULL, &cndesc, 0, &cnattr,
+ &cfork, &vp, &newvnode_flags);
if (result) {
goto exit;
}