Whamcloud - gitweb
AOSP: libext2fs: increment i_blocks for shared blocks
authorJin Qian <jinqian@google.com>
Thu, 1 Feb 2018 01:46:46 +0000 (17:46 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 21 Jun 2018 13:43:28 +0000 (09:43 -0400)
This fixes an incorrect i_blocks count when using shared blocks.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Google-Bug-Id: 64109868
Change-Id: I44a4997f6a93f2a3fc9aa362fd39d72e7cc9ff84
From AOSP commit: 632cc1f02d47ce54d9f17ca5d80c2d7ba2851020

lib/ext2fs/fileio.c

index 5bc02d0..a5d90a7 100644 (file)
@@ -475,6 +475,11 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
                                ext2fs_hashmap_add(fs->block_sha_map, new_block,
                                        new_block->sha, sizeof(new_block->sha));
                        }
+
+                       if (bmap_flags & BMAP_SET) {
+                               ext2fs_iblk_add_blocks(fs, &file->inode, 1);
+                               ext2fs_write_inode(fs, file->ino, &file->inode);
+                       }
                }
 
                file->pos += c;