2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #include <sys/param.h>
32 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/malloc.h>
36 #include <sys/mount.h>
37 #include <sys/vnode.h>
41 #include "hfs_cnode.h"
43 #include "hfs_endian.h"
45 #include "hfscommon/headers/FileMgrInternal.h"
46 #include "hfscommon/headers/BTreesPrivate.h"
48 #define FORCESYNCBTREEWRITES 0
51 static int ClearBTNodes(struct vnode
*vp
, long blksize
, off_t offset
, off_t amount
);
55 OSStatus
SetBTreeBlockSize(FileReference vp
, ByteCount blockSize
, ItemCount minBlockCount
)
57 BTreeControlBlockPtr bTreePtr
;
59 DBG_ASSERT(vp
!= NULL
);
60 DBG_ASSERT(blockSize
>= kMinNodeSize
);
61 if (blockSize
> MAXBSIZE
)
62 return (fsBTBadNodeSize
);
64 bTreePtr
= (BTreeControlBlockPtr
)VTOF(vp
)->fcbBTCBPtr
;
65 bTreePtr
->nodeSize
= blockSize
;
72 OSStatus
GetBTreeBlock(FileReference vp
, UInt32 blockNum
, GetBlockOptions options
, BlockDescriptor
*block
)
74 OSStatus retval
= E_NONE
;
75 struct buf
*bp
= NULL
;
77 if (options
& kGetEmptyBlock
) {
81 offset
= (daddr64_t
)blockNum
* (daddr64_t
)block
->blockSize
;
82 bp
= buf_getblk(vp
, (daddr64_t
)blockNum
, block
->blockSize
, 0, 0, BLK_META
);
84 VNOP_BLOCKMAP(vp
, offset
, block
->blockSize
, &blkno
, NULL
, NULL
, 0, NULL
) == 0) {
85 buf_setblkno(bp
, blkno
);
88 retval
= buf_meta_bread(vp
, (daddr64_t
)blockNum
, block
->blockSize
, NOCRED
, &bp
);
91 retval
= -1; //XXX need better error
93 if (retval
== E_NONE
) {
94 block
->blockHeader
= bp
;
95 block
->buffer
= (char *)buf_dataptr(bp
);
96 block
->blockNum
= buf_lblkno(bp
);
97 block
->blockReadFromDisk
= (buf_fromcache(bp
) == 0); /* not found in cache ==> came from disk */
100 block
->isModified
= 0;
102 /* Check and endian swap B-Tree node (only if it's a valid block) */
103 if (!(options
& kGetEmptyBlock
)) {
104 /* This happens when we first open the b-tree, we might not have all the node data on hand */
105 if ((((BTNodeDescriptor
*)block
->buffer
)->kind
== kBTHeaderNode
) &&
106 (((BTHeaderRec
*)((char *)block
->buffer
+ 14))->nodeSize
!= buf_count(bp
)) &&
107 (SWAP_BE16 (((BTHeaderRec
*)((char *)block
->buffer
+ 14))->nodeSize
) != buf_count(bp
))) {
110 * Don't swap the node descriptor, record offsets, or other records.
111 * This record will be invalidated and re-read with the correct node
112 * size once the B-tree control block is set up with the node size
113 * from the header record.
115 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeHeaderRecordOnly
);
117 } else if (block
->blockReadFromDisk
) {
119 * The node was just read from disk, so always swap/check it.
120 * This is necessary on big endian since the test below won't trigger.
122 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeBigToHost
);
123 } else if (*((UInt16
*)((char *)block
->buffer
+ (block
->blockSize
- sizeof (UInt16
)))) == 0x0e00) {
125 * The node was left in the cache in non-native order, so swap it.
126 * This only happens on little endian, after the node is written
129 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeBigToHost
);
133 * If we got an error, then the node is only partially swapped.
134 * We mark the buffer invalid so that the next attempt to get the
135 * node will read it and attempt to swap again, and will notice
136 * the error again. If we didn't do this, the next attempt to get
137 * the node might use the partially swapped node as-is.
147 block
->blockHeader
= NULL
;
148 block
->buffer
= NULL
;
156 void ModifyBlockStart(FileReference vp
, BlockDescPtr blockPtr
)
158 struct hfsmount
*hfsmp
= VTOHFS(vp
);
159 struct buf
*bp
= NULL
;
161 if (hfsmp
->jnl
== NULL
) {
165 bp
= (struct buf
*) blockPtr
->blockHeader
;
167 panic("ModifyBlockStart: null bp for blockdescptr 0x%x?!?\n", blockPtr
);
171 journal_modify_block_start(hfsmp
->jnl
, bp
);
172 blockPtr
->isModified
= 1;
176 btree_journal_modify_block_end(struct hfsmount
*hfsmp
, struct buf
*bp
)
179 struct vnode
*vp
= buf_vnode(bp
);
180 BlockDescriptor block
;
182 /* Prepare the block pointer */
183 block
.blockHeader
= bp
;
184 block
.buffer
= (char *)buf_dataptr(bp
);
185 block
.blockNum
= buf_lblkno(bp
);
186 /* not found in cache ==> came from disk */
187 block
.blockReadFromDisk
= (buf_fromcache(bp
) == 0);
188 block
.blockSize
= buf_count(bp
);
190 // XXXdbg have to swap the data before it goes in the journal
191 retval
= hfs_swap_BTNode (&block
, vp
, kSwapBTNodeHostToBig
);
193 panic("btree_journal_modify_block_end: about to write corrupt node!\n");
195 return journal_modify_block_end(hfsmp
->jnl
, bp
);
200 OSStatus
ReleaseBTreeBlock(FileReference vp
, BlockDescPtr blockPtr
, ReleaseBlockOptions options
)
202 struct hfsmount
*hfsmp
= VTOHFS(vp
);
203 extern int bdwrite_internal(struct buf
*, int);
204 OSStatus retval
= E_NONE
;
205 struct buf
*bp
= NULL
;
207 bp
= (struct buf
*) blockPtr
->blockHeader
;
214 if (options
& kTrashBlock
) {
217 if (hfsmp
->jnl
&& (buf_flags(bp
) & B_LOCKED
)) {
218 journal_kill_block(hfsmp
->jnl
, bp
);
220 buf_brelse(bp
); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
223 if (options
& kForceWriteBlock
) {
225 if (blockPtr
->isModified
== 0) {
226 panic("hfs: releaseblock: modified is 0 but forcewrite set! bp 0x%x\n", bp
);
229 retval
= btree_journal_modify_block_end(hfsmp
, bp
);
230 blockPtr
->isModified
= 0;
232 retval
= VNOP_BWRITE(bp
);
234 } else if (options
& kMarkBlockDirty
) {
237 if ((options
& kLockTransaction
) && hfsmp
->jnl
== NULL
) {
240 * Set the B_LOCKED flag and unlock the buffer, causing buf_brelse to move
241 * the buffer onto the LOCKED free list. This is necessary, otherwise
242 * getnewbuf() would try to reclaim the buffers using buf_bawrite, which
243 * isn't going to work.
246 extern int count_lock_queue(void);
248 /* Don't hog all the buffers... */
249 if (count_lock_queue() > kMaxLockedMetaBuffers
) {
250 hfs_btsync(vp
, HFS_SYNCTRANS
);
251 /* Rollback sync time to cause a sync on lock release... */
252 (void) BTSetLastSync(VTOF(vp
), tv
.tv_sec
- (kMaxSecsForFsync
+ 1));
254 buf_setflags(bp
, B_LOCKED
);
258 * Delay-write this block.
259 * If the maximum delayed buffers has been exceeded then
260 * free up some buffers and fall back to an asynchronous write.
263 if (blockPtr
->isModified
== 0) {
264 panic("hfs: releaseblock: modified is 0 but markdirty set! bp 0x%x\n", bp
);
266 retval
= btree_journal_modify_block_end(hfsmp
, bp
);
267 blockPtr
->isModified
= 0;
268 } else if (bdwrite_internal(bp
, 1) != 0) {
270 /* Rollback sync time to cause a sync on lock release... */
271 (void) BTSetLastSync(VTOF(vp
), tv
.tv_sec
- (kMaxSecsForFsync
+ 1));
273 buf_clearflags(bp
, B_LOCKED
);
277 // check if we had previously called journal_modify_block_start()
278 // on this block and if so, abort it (which will call buf_brelse()).
279 if (hfsmp
->jnl
&& blockPtr
->isModified
) {
280 // XXXdbg - I don't want to call modify_block_abort()
281 // because I think it may be screwing up the
282 // journal and blowing away a block that has
285 // journal_modify_block_abort(hfsmp->jnl, bp);
286 //panic("hfs: releaseblock called for 0x%x but mod_block_start previously called.\n", bp);
287 btree_journal_modify_block_end(hfsmp
, bp
);
288 blockPtr
->isModified
= 0;
290 buf_brelse(bp
); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
301 OSStatus
ExtendBTreeFile(FileReference vp
, FSSize minEOF
, FSSize maxEOF
)
303 #pragma unused (maxEOF)
305 OSStatus retval
= 0, ret
= 0;
306 UInt64 actualBytesAdded
, origSize
;
308 u_int32_t startAllocation
;
309 u_int32_t fileblocks
;
313 struct proc
*p
= NULL
;
317 filePtr
= GetFileControlBlock(vp
);
319 if ( minEOF
> filePtr
->fcbEOF
)
321 bytesToAdd
= minEOF
- filePtr
->fcbEOF
;
323 if (bytesToAdd
< filePtr
->ff_clumpsize
)
324 bytesToAdd
= filePtr
->ff_clumpsize
; //XXX why not always be a mutiple of clump size?
334 * The Extents B-tree can't have overflow extents. ExtendFileC will
335 * return an error if an attempt is made to extend the Extents B-tree
336 * when the resident extents are exhausted.
339 /* Protect allocation bitmap and extents overflow file. */
340 lockflags
= SFL_BITMAP
;
341 if (VTOC(vp
)->c_fileid
!= kHFSExtentsFileID
)
342 lockflags
|= SFL_EXTENTS
;
343 lockflags
= hfs_systemfile_lock(vcb
, lockflags
, HFS_EXCLUSIVE_LOCK
);
345 (void) BTGetInformation(filePtr
, 0, &btInfo
);
349 * The b-tree code expects nodes to be contiguous. So when
350 * the allocation block size is less than the b-tree node
351 * size, we need to force disk allocations to be contiguous.
353 if (vcb
->blockSize
>= btInfo
.nodeSize
) {
356 /* Ensure that all b-tree nodes are contiguous on disk */
357 extendFlags
= kEFContigMask
;
361 origSize
= filePtr
->fcbEOF
;
362 fileblocks
= filePtr
->ff_blocks
;
363 startAllocation
= vcb
->nextAllocation
;
365 // loop trying to get a contiguous chunk that's an integer multiple
366 // of the btree node size. if we can't get a contiguous chunk that
367 // is at least the node size then we break out of the loop and let
368 // the error propagate back up.
370 retval
= ExtendFileC(vcb
, filePtr
, bytesToAdd
, 0,
371 kEFContigMask
| kEFMetadataMask
,
373 if (retval
== dskFulErr
&& actualBytesAdded
== 0) {
375 if (bytesToAdd
== btInfo
.nodeSize
|| bytesToAdd
< (minEOF
- origSize
)) {
376 // if we're here there's nothing else to try, we're out
377 // of space so we break and bail out.
381 if (bytesToAdd
< btInfo
.nodeSize
) {
382 bytesToAdd
= btInfo
.nodeSize
;
383 } else if ((bytesToAdd
% btInfo
.nodeSize
) != 0) {
384 // make sure it's an integer multiple of the nodeSize
385 bytesToAdd
-= (bytesToAdd
% btInfo
.nodeSize
);
389 } while (retval
== dskFulErr
&& actualBytesAdded
== 0);
392 * If a new extent was added then move the roving allocator
393 * reference forward by the current b-tree file size so
394 * there's plenty of room to grow.
397 ((VCBTOHFS(vcb
)->hfs_flags
& HFS_METADATA_ZONE
) == 0) &&
398 (vcb
->nextAllocation
> startAllocation
) &&
399 ((vcb
->nextAllocation
+ fileblocks
) < vcb
->totalBlocks
)) {
400 vcb
->nextAllocation
+= fileblocks
;
403 filePtr
->fcbEOF
= (u_int64_t
)filePtr
->ff_blocks
* (u_int64_t
)vcb
->blockSize
;
405 // XXXdbg ExtendFileC() could have returned an error even though
406 // it grew the file to be big enough for our needs. If this is
407 // the case, we don't care about retval so we blow it away.
409 if (filePtr
->fcbEOF
>= minEOF
&& retval
!= 0) {
413 // XXXdbg if the file grew but isn't large enough or isn't an
414 // even multiple of the nodeSize then trim things back. if
415 // the file isn't large enough we trim back to the original
416 // size. otherwise we trim back to be an even multiple of the
419 if ((filePtr
->fcbEOF
< minEOF
) || (actualBytesAdded
% btInfo
.nodeSize
) != 0) {
421 if (filePtr
->fcbEOF
< minEOF
) {
424 if (filePtr
->fcbEOF
< origSize
) {
425 panic("hfs: btree file eof %lld less than orig size %lld!\n",
426 filePtr
->fcbEOF
, origSize
);
429 trim
= filePtr
->fcbEOF
- origSize
;
430 if (trim
!= actualBytesAdded
) {
431 panic("hfs: trim == %lld but actualBytesAdded == %lld\n",
432 trim
, actualBytesAdded
);
435 trim
= (actualBytesAdded
% btInfo
.nodeSize
);
438 ret
= TruncateFileC(vcb
, filePtr
, filePtr
->fcbEOF
- trim
, 0);
439 filePtr
->fcbEOF
= (u_int64_t
)filePtr
->ff_blocks
* (u_int64_t
)vcb
->blockSize
;
441 // XXXdbg - panic if the file didn't get trimmed back properly
442 if ((filePtr
->fcbEOF
% btInfo
.nodeSize
) != 0) {
443 panic("hfs: truncate file didn't! fcbEOF %lld nsize %d fcb 0x%x\n",
444 filePtr
->fcbEOF
, btInfo
.nodeSize
, filePtr
);
448 // XXXdbg - this probably doesn't need to be a panic()
449 panic("hfs: error truncating btree files (sz 0x%llx, trim %lld, ret %d)\n",
450 filePtr
->fcbEOF
, trim
, ret
);
453 actualBytesAdded
-= trim
;
456 if(VTOC(vp
)->c_fileid
!= kHFSExtentsFileID
) {
458 * Get any extents overflow b-tree changes to disk ASAP!
460 (void) BTFlushPath(VTOF(vcb
->extentsRefNum
));
461 (void) hfs_fsync(vcb
->extentsRefNum
, MNT_WAIT
, 0, p
);
463 hfs_systemfile_unlock(vcb
, lockflags
);
466 if ((filePtr
->fcbEOF
% btInfo
.nodeSize
) != 0) {
467 panic("hfs: extendbtree: fcb 0x%x has eof 0x%llx not a multiple of 0x%x (trim %llx)\n",
468 filePtr
, filePtr
->fcbEOF
, btInfo
.nodeSize
, trim
);
472 * Update the Alternate MDB or Alternate VolumeHeader
474 if ((VTOC(vp
)->c_fileid
== kHFSExtentsFileID
) ||
475 (VTOC(vp
)->c_fileid
== kHFSCatalogFileID
) ||
476 (VTOC(vp
)->c_fileid
== kHFSAttributesFileID
)
478 VTOC(vp
)->c_flag
|= C_MODIFIED
;
480 ret
= hfs_flushvolumeheader(VCBTOHFS(vcb
), MNT_WAIT
, HFS_ALTFLUSH
);
482 VTOC(vp
)->c_touch_chgtime
= TRUE
;
483 VTOC(vp
)->c_touch_modtime
= TRUE
;
484 (void) hfs_update(vp
, TRUE
);
487 ret
= ClearBTNodes(vp
, btInfo
.nodeSize
, filePtr
->fcbEOF
- actualBytesAdded
, actualBytesAdded
);
493 hfs_systemfile_unlock(vcb
, lockflags
);
500 * Clear out (zero) new b-tree nodes on disk.
503 ClearBTNodes(struct vnode
*vp
, long blksize
, off_t offset
, off_t amount
)
505 struct hfsmount
*hfsmp
= VTOHFS(vp
);
506 struct buf
*bp
= NULL
;
510 blk
= offset
/ blksize
;
511 blkcnt
= amount
/ blksize
;
514 bp
= buf_getblk(vp
, blk
, blksize
, 0, 0, BLK_META
);
520 // XXXdbg -- skipping this for now since it makes a transaction
521 // become *way* too large
522 //journal_modify_block_start(hfsmp->jnl, bp);
524 bzero((char *)buf_dataptr(bp
), blksize
);
530 // XXXdbg -- skipping this for now since it makes a transaction
531 // become *way* too large
532 //journal_modify_block_end(hfsmp->jnl, bp);
534 // XXXdbg - remove this once we decide what to do with the
535 // writes to the journal
541 /* wait/yield every 32 blocks so we don't hog all the buffers */
555 extern char hfs_attrname
[];
557 extern int hfs_attrkeycompare(HFSPlusAttrKey
*searchKey
, HFSPlusAttrKey
*trialKey
);
559 int hfs_create_attr_btree(struct hfsmount
*hfsmp
, uint32_t nodesize
, uint32_t nodecnt
);
562 * Create an HFS+ Attribute B-tree File.
564 * A journal transaction must be already started.
567 hfs_create_attr_btree(struct hfsmount
*hfsmp
, uint32_t nodesize
, uint32_t nodecnt
)
569 struct vnode
* vp
= NULL
;
570 struct cat_desc cndesc
;
571 struct cat_attr cnattr
;
572 struct cat_fork cfork
;
573 BlockDescriptor blkdesc
;
574 BTNodeDescriptor
*ndp
;
576 BTreeControlBlockPtr btcb
= NULL
;
577 struct buf
*bp
= NULL
;
583 printf("Creating HFS+ Attribute B-tree File (%d nodes) on %s\n", nodecnt
, hfsmp
->vcbVN
);
586 * Set up Attribute B-tree vnode
588 bzero(&cndesc
, sizeof(cndesc
));
589 cndesc
.cd_parentcnid
= kHFSRootParentID
;
590 cndesc
.cd_flags
|= CD_ISMETA
;
591 cndesc
.cd_nameptr
= hfs_attrname
;
592 cndesc
.cd_namelen
= strlen(hfs_attrname
);
593 cndesc
.cd_cnid
= kHFSAttributesFileID
;
595 bzero(&cnattr
, sizeof(cnattr
));
597 cnattr
.ca_mode
= S_IFREG
;
598 cnattr
.ca_fileid
= cndesc
.cd_cnid
;
600 bzero(&cfork
, sizeof(cfork
));
601 cfork
.cf_clump
= nodesize
* nodecnt
;
603 result
= hfs_getnewvnode(hfsmp
, NULL
, NULL
, &cndesc
, 0, &cnattr
, &cfork
, &vp
);
608 * Set up Attribute B-tree control block
610 MALLOC(btcb
, BTreeControlBlock
*, sizeof(BTreeControlBlock
), M_TEMP
, M_WAITOK
);
611 bzero(btcb
, sizeof(BTreeControlBlock
));
613 btcb
->nodeSize
= nodesize
;
614 btcb
->maxKeyLength
= kHFSPlusAttrKeyMaximumLength
;
615 btcb
->btreeType
= 0xFF;
616 btcb
->attributes
= kBTVariableIndexKeysMask
| kBTBigKeysMask
;
617 btcb
->version
= kBTreeVersion
;
618 btcb
->writeCount
= 1;
619 btcb
->flags
= 0; /* kBTHeaderDirty */
620 btcb
->fileRefNum
= vp
;
621 btcb
->getBlockProc
= GetBTreeBlock
;
622 btcb
->releaseBlockProc
= ReleaseBTreeBlock
;
623 btcb
->setEndOfForkProc
= ExtendBTreeFile
;
624 btcb
->keyCompareProc
= (KeyCompareProcPtr
)hfs_attrkeycompare
;
625 VTOF(vp
)->fcbBTCBPtr
= btcb
;
628 * Allocate some space
630 result
= ExtendBTreeFile(vp
, nodesize
, cfork
.cf_clump
);
634 btcb
->totalNodes
= VTOF(vp
)->ff_size
/ nodesize
;
635 btcb
->freeNodes
= btcb
->totalNodes
- 1;
638 * Initialize the b-tree header on disk
640 bp
= buf_getblk(vp
, 0, nodesize
, 0, 0, BLK_META
);
646 buffer
= (void *)buf_dataptr(bp
);
647 blkdesc
.buffer
= buffer
;
648 blkdesc
.blockHeader
= (void *)bp
;
649 blkdesc
.blockReadFromDisk
= 0;
650 blkdesc
.isModified
= 0;
652 ModifyBlockStart(vp
, &blkdesc
);
654 if (buf_size(bp
) != nodesize
)
655 panic("hfs_create_attr_btree: bad buffer size (%d)\n", buf_size(bp
));
657 bzero(buffer
, nodesize
);
658 index
= (int16_t *)buffer
;
660 /* FILL IN THE NODE DESCRIPTOR: */
661 ndp
= (BTNodeDescriptor
*)buffer
;
662 ndp
->kind
= kBTHeaderNode
;
664 offset
= sizeof(BTNodeDescriptor
);
665 index
[(nodesize
/ 2) - 1] = offset
;
667 /* FILL IN THE HEADER RECORD: */
668 bthp
= (BTHeaderRec
*)((UInt8
*)buffer
+ offset
);
669 bthp
->nodeSize
= nodesize
;
670 bthp
->totalNodes
= btcb
->totalNodes
;
671 bthp
->freeNodes
= btcb
->freeNodes
;
672 bthp
->clumpSize
= cfork
.cf_clump
;
673 bthp
->btreeType
= 0xFF;
674 bthp
->attributes
= kBTVariableIndexKeysMask
| kBTBigKeysMask
;
675 bthp
->maxKeyLength
= kHFSPlusAttrKeyMaximumLength
;
676 bthp
->keyCompareType
= kHFSBinaryCompare
;
677 offset
+= sizeof(BTHeaderRec
);
678 index
[(nodesize
/ 2) - 2] = offset
;
680 /* FILL IN THE USER RECORD: */
681 offset
+= kBTreeHeaderUserBytes
;
682 index
[(nodesize
/ 2) - 3] = offset
;
684 /* FILL IN THE MAP RECORD (only one node in use). */
685 *((u_int8_t
*)buffer
+ offset
) = 0x80;
686 offset
+= nodesize
- sizeof(BTNodeDescriptor
) - sizeof(BTHeaderRec
)
687 - kBTreeHeaderUserBytes
- (4 * sizeof(int16_t));
688 index
[(nodesize
/ 2) - 4] = offset
;
691 result
= btree_journal_modify_block_end(hfsmp
, bp
);
693 result
= VNOP_BWRITE(bp
);
698 /* Publish new btree file */
699 hfsmp
->hfs_attribute_vp
= vp
;
700 (void) hfs_flushvolumeheader(hfsmp
, MNT_WAIT
, HFS_ALTFLUSH
);
703 hfs_unlock(VTOC(vp
));
709 // hfs_truncate(); /* XXX need to give back blocks */