filefork_t * filefork;
hotfilelist_t *listp;
enum hfc_stage stage;
+ u_int32_t savedtemp;
int blksmoved;
int filesmoved;
int fileblocks;
int error = 0;
int startedtrans = 0;
+ int bt_op;
if (hfsmp->hfc_stage != HFC_EVICTION) {
return (EBUSY);
hfsmp->hfc_stage = HFC_BUSY;
filesmoved = blksmoved = 0;
+ bt_op = kBTreeFirstRecord;
MALLOC(iterator, BTreeIterator *, sizeof(*iterator), M_TEMP, M_WAITOK);
bzero(iterator, sizeof(*iterator));
/*
* Obtain the first record (ie the coldest one).
*/
- if (BTIterateRecord(filefork, kBTreeFirstRecord, iterator, NULL, NULL) != 0) {
+ if (BTIterateRecord(filefork, bt_op, iterator, NULL, NULL) != 0) {
#if HFC_VERBOSE
printf("hotfiles_evict: no more records\n");
#endif
if (error) {
if (error == ENOENT) {
- (void) BTDeleteRecord(filefork, iterator);
- key->temperature = HFC_LOOKUPTAG;
- (void) BTDeleteRecord(filefork, iterator);
- goto next; /* stale entry, go to next */
+ goto delete; /* stale entry, go to next */
} else {
printf("hotfiles_evict: err %d getting file %d\n",
error, key->fileID);
printf("hotfiles_evict: huh, not a file %d\n", key->fileID);
hfs_unlock(VTOC(vp));
vnode_put(vp);
- (void) BTDeleteRecord(filefork, iterator);
- key->temperature = HFC_LOOKUPTAG;
- (void) BTDeleteRecord(filefork, iterator);
- goto next; /* invalid entry, go to next */
+ goto delete; /* invalid entry, go to next */
}
fileblocks = VTOF(vp)->ff_blocks;
if ((blksmoved > 0) &&
#endif
hfs_unlock(VTOC(vp));
vnode_put(vp);
- (void) BTDeleteRecord(filefork, iterator);
- key->temperature = HFC_LOOKUPTAG;
- (void) BTDeleteRecord(filefork, iterator);
- goto next; /* go to next */
+ goto delete; /* stale entry, go to next */
}
/*
printf("hotfiles_evict: err %d relocating file %d\n", error, key->fileID);
hfs_unlock(VTOC(vp));
vnode_put(vp);
+ bt_op = kBTreeNextRecord;
goto next; /* go to next */
}
listp->hfl_reclaimblks = 0;
blksmoved += fileblocks;
filesmoved++;
-
+delete:
error = BTDeleteRecord(filefork, iterator);
if (error) {
- printf("hotfiles_evict: BTDeleteRecord failed %d (fileid %d)\n", error, key->fileID);
error = MacToVFSError(error);
break;
}
+ savedtemp = key->temperature;
key->temperature = HFC_LOOKUPTAG;
error = BTDeleteRecord(filefork, iterator);
if (error) {
- printf("hotfiles_evict: BTDeleteRecord thread failed %d (fileid %d)\n", error, key->fileID);
error = MacToVFSError(error);
break;
}
+ key->temperature = savedtemp;
next:
(void) BTFlushPath(filefork);