diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c index 92d5c521..0b0c40af 100644 --- a/kernel-shared/extent-tree.c +++ b/kernel-shared/extent-tree.c @@ -3529,6 +3529,12 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, u64 extent_offset; u64 num_bytes = *ret_num_bytes; + /* + * @objectid should be an inode number, thus it must not be smaller + * than BTRFS_FIRST_FREE_OBJECTID. + */ + ASSERT(objectid >= BTRFS_FIRST_FREE_OBJECTID); + /* * All supported file system should not use its 0 extent. * As it's for hole diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index 6b67a9b9..2cf6eef9 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -530,7 +530,13 @@ static int traverse_directory(struct btrfs_trans_handle *trans, goto fail; } - cur_inum = st.st_ino; + /* + * We can not directly use the source ino number, + * as there is a chance that the ino is smaller than + * BTRFS_FIRST_FREE_OBJECTID, which will screw up + * backref code. + */ + cur_inum = st.st_ino + BTRFS_FIRST_FREE_OBJECTID; ret = add_directory_items(trans, root, cur_inum, parent_inum, cur_file->d_name,