@@ -194,6 +194,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
blk64_t blk;
errcode_t retval;
__u32 count;
+ __u32 blocks;
if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode)))
return 0;
@@ -238,8 +239,10 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode));
if (blk) {
- retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1,
- &count, ino);
+ retval = ext2fs_adjust_ea_refcount4(fs, blk, block_buf, -1,
+ &count, ino, &blocks);
+ if (retval == 0)
+ ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode), blocks);
if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
retval = 0;
count = 1;
@@ -1289,6 +1289,11 @@ extern errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
char *block_buf,
int adjust, __u32 *newcount,
ext2_ino_t inum);
+extern errcode_t ext2fs_adjust_ea_refcount4(ext2_filsys fs, blk64_t blk,
+ char *block_buf,
+ int adjust, __u32 *newcount,
+ ext2_ino_t inum,
+ __u32 *blocks);
errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle);
errcode_t ext2fs_xattrs_read(struct ext2_xattr_handle *handle);
errcode_t ext2fs_xattrs_read_inode(struct ext2_xattr_handle *handle,
@@ -237,9 +237,10 @@ errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
/*
* This function adjusts the reference count of the EA block.
*/
-errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
+errcode_t ext2fs_adjust_ea_refcount4(ext2_filsys fs, blk64_t blk,
char *block_buf, int adjust,
- __u32 *newcount, ext2_ino_t inum)
+ __u32 *newcount, ext2_ino_t inum,
+ __u32 *blocks)
{
errcode_t retval;
struct ext2_ext_attr_header *header;
@@ -264,6 +265,8 @@ errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
header->h_refcount += adjust;
if (newcount)
*newcount = header->h_refcount;
+ if (blocks)
+ *blocks = header->h_blocks;
retval = ext2fs_write_ext_attr3(fs, blk, block_buf, inum);
if (retval)
@@ -275,6 +278,14 @@ errout:
return retval;
}
+errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
+ char *block_buf, int adjust,
+ __u32 *newcount, ext2_ino_t inum)
+{
+ return ext2fs_adjust_ea_refcount4(fs, blk, block_buf, adjust,
+ newcount, 0, NULL);
+}
+
errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
char *block_buf, int adjust,
__u32 *newcount)