summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-03-20 14:42:25 +0800
committerDavid Sterba <dsterba@suse.com>2018-03-30 22:15:54 +0200
commit51667947e435444d9e125189b2a07e3966ac145c (patch)
treeb7db4ef47ca32847f2be8d92766e05e6cdb0fd1d /mkfs
parente02049d964e77d22348bf940a7027a1aff558f18 (diff)
btrfs-progs: mkfs/rootdir: Fix inline extent creation check
Just like convert, we need extra check against sector size for creating inline extent. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/rootdir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c
index e06b65ac..a1d223a2 100644
--- a/mkfs/rootdir.c
+++ b/mkfs/rootdir.c
@@ -139,7 +139,8 @@ static int fill_inode_item(struct btrfs_trans_handle *trans,
}
if (S_ISREG(src->st_mode)) {
btrfs_set_stack_inode_size(dst, (u64)src->st_size);
- if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info))
+ if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+ src->st_size < sectorsize)
btrfs_set_stack_inode_nbytes(dst, src->st_size);
else {
blocks = src->st_size / sectorsize;
@@ -327,7 +328,8 @@ static int add_file_items(struct btrfs_trans_handle *trans,
if (st->st_size % sectorsize)
blocks += 1;
- if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) {
+ if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+ st->st_size < sectorsize) {
char *buffer = malloc(st->st_size);
if (!buffer) {