This patch along with any one uses sector/node size in
btrfs_parse_options() should only use them after it get initialized.
Unfortunately at this point, nodesize is not initialized in open_ctree().
So unfortunately, this patch needs extra work to move
btrfs_parse_options() after basic fs_info initialization, and please
ignore this version.
Thanks,
Qu
On 2018年03月02日 10:09, Qu Wenruo wrote:
> We have extra sector size check in cow_file_range_inline(), but doesn't
> implement it in BTRFS_MAX_INLINE_DATA_SIZE().
>
> The biggest reason is that btrfs_symlink() also uses this macro to check
> name length.
>
> In fact such behavior makes max_inline calculation quite confusing, and
> cause unexpected large extent for symbol link.
>
> Here we embed sector size check into BTRFS_MAX_INLINE_DATA_SIZE() so
> that it will never exceed sector size.
>
> The downside is, for symbol link, we will reduce max symbol link length
> from 16K- to 4095, but it won't affect current system using that long
> name, but only prevent later creation.
>
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
> ---
> fs/btrfs/ctree.h | 5 +++--
> fs/btrfs/inode.c | 1 -
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 13c260b525a1..90948096c00f 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1297,8 +1297,9 @@ static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info)
> (offsetof(struct btrfs_file_extent_item, disk_bytenr))
> static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info)
> {
> - return BTRFS_MAX_ITEM_SIZE(info) -
> - BTRFS_FILE_EXTENT_INLINE_DATA_START;
> + return min_t(u32, info->sectorsize - 1,
> + BTRFS_MAX_ITEM_SIZE(info) -
> + BTRFS_FILE_EXTENT_INLINE_DATA_START);
> }
>
> static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e1a7f3cb5be9..0f7041e10c67 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -299,7 +299,6 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
>
> if (start > 0 ||
> actual_end > fs_info->sectorsize ||
> - data_len > BTRFS_MAX_INLINE_DATA_SIZE(fs_info) ||
> (!compressed_size &&
> (actual_end & (fs_info->sectorsize - 1)) == 0) ||
> end + 1 < isize ||
>
Attachment:
signature.asc
Description: OpenPGP digital signature
