int extents = 0;
int depth;
int i;
- int newblocks = 0;
+ int dirty_groups = 0;
int rc = 0;
int credits = 0;
long long quota_space = 0;
}
/* count only unmapped changes */
- newblocks++;
if (lnb[i].lnb_file_offset != extent.end || extent.end == 0) {
if (extent.end != 0)
extents += (extent.end - extent.start +
* overwrite case, no need to modify tree and
* allocate blocks.
*/
- if (!newblocks)
+ if (!extent.end)
goto out_declare;
extents += (extent.end - extent.start +
if (extents > MAX_EXTENTS_PER_WRITE)
extents = MAX_EXTENTS_PER_WRITE;
+ dirty_groups = extents;
/*
* each extent can go into new leaf causing a split
* 5 is max tree depth: inode + 4 index blocks
*/
depth = ext_depth(inode);
depth = max(depth, 1) + 1;
- newblocks += depth;
+ dirty_groups += depth;
credits += depth * 2 * extents;
} else {
depth = 3;
- newblocks += depth;
+ dirty_groups += depth;
credits += depth * extents;
}
/* each new block can go in different group (bitmap + gd) */
/* we can't dirty more bitmap blocks than exist */
- if (extents > LDISKFS_SB(osd_sb(osd))->s_groups_count)
+ if (dirty_groups > LDISKFS_SB(osd_sb(osd))->s_groups_count)
credits += LDISKFS_SB(osd_sb(osd))->s_groups_count;
else
- credits += extents;
+ credits += dirty_groups;
/* we can't dirty more gd blocks than exist */
if (extents > LDISKFS_SB(osd_sb(osd))->s_gdb_count)
credits += LDISKFS_SB(osd_sb(osd))->s_gdb_count;
else
- credits += extents;
+ credits += dirty_groups;
CDEBUG(D_INODE,
"%s: inode #%lu extent_bytes %u extents %d credits %d\n",