diff --git a/libntfs-3g/lcnalloc.c b/libntfs-3g/lcnalloc.c index 073141d0..75f8b6ab 100644 --- a/libntfs-3g/lcnalloc.c +++ b/libntfs-3g/lcnalloc.c @@ -51,7 +51,7 @@ * the update of the mapping pairs which converges to the cubic Faulhaber's * formula as the function of the number of extents (fragments, runs). */ -#define NTFS_LCNALLOC_BSIZE 8192 +#define NTFS_LCNALLOC_BSIZE 4096 #define NTFS_LCNALLOC_SKIP NTFS_LCNALLOC_BSIZE static void ntfs_cluster_set_zone_pos(LCN start, LCN end, LCN *pos, LCN tc) @@ -89,6 +89,11 @@ static s64 max_empty_bit_range(unsigned char *buf, int size) for (i = 0; i < size; i++, buf++) { + if (*buf == 0) { + run += 8; + continue; + } + for (j = 0; j < 8; j++) { int bit = *buf & (1 << j); diff --git a/libntfs-3g/mft.c b/libntfs-3g/mft.c index 7171cf6f..251a667f 100644 --- a/libntfs-3g/mft.c +++ b/libntfs-3g/mft.c @@ -797,6 +797,7 @@ static int ntfs_mft_bitmap_extend_initialized(ntfs_volume *vol) ll = ntfs_attr_pwrite(mftbmp_na, old_initialized_size, 8, &ll); if (ll == 8) { ntfs_log_debug("Wrote eight initialized bytes to mft bitmap.\n"); + vol->free_mft_records += (8 * 8); return 0; } ntfs_log_error("Failed to write to mft bitmap.\n"); @@ -1440,6 +1441,7 @@ found_free_rec: /* Return the opened, allocated inode of the allocated mft record. */ ntfs_log_debug("Returning opened, allocated %sinode 0x%llx.\n", base_ni ? "extent " : "", (long long)bit); + vol->free_mft_records--; return ni; undo_mftbmp_alloc: @@ -1508,8 +1510,10 @@ int ntfs_mft_record_free(ntfs_volume *vol, ntfs_inode *ni) } /* Throw away the now freed inode. */ - if (!ntfs_inode_close(ni)) + if (!ntfs_inode_close(ni)) { + vol->free_mft_records++; return 0; + } err = errno; /* Rollback what we did... */ diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index 1a147dbb..030640da 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -681,7 +681,7 @@ static int ntfs_volume_check_hiberfile(ntfs_volume *vol) { ntfs_inode *ni; ntfs_attr *na = NULL; - int i, bytes_read, err; + int bytes_read, err; char *buf = NULL; ni = ntfs_hiberfile_open(vol);