Message ID | 20200915053532.63279-7-wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: add read-only support for subpage sector size | expand |
On 15.09.20 г. 8:35 ч., Qu Wenruo wrote: > As a preparation for subpage sector size support (allowing filesystem > with sector size smaller than page size to be mounted) if the sector > size is smaller than page size, we don't allow tree block to be read if > it cross 64K(*) boundary. > > The 64K is selected because: > - We are only going to support 64K page size for subpage What does "only support 64k page size for subpage" ? > - 64K is also the max node size btrfs supports > > This ensures that, tree blocks are always contained in one page for a > system with 64K page size, which can greatly simplify the handling. > > Or we need to do complex multi-page handling for tree blocks. > > Currently the only way to create such tree blocks crossing 64K boundary > is by btrfs-convert, which will get fixed soon and doesn't get > wide-spread usage. > > Signed-off-by: Qu Wenruo <wqu@suse.com> > --- > fs/btrfs/extent_io.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index e56aa68cd9fe..9af972999a09 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -5232,6 +5232,13 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, > btrfs_err(fs_info, "bad tree block start %llu", start); > return ERR_PTR(-EINVAL); > } > + if (fs_info->sectorsize < PAGE_SIZE && round_down(start, PAGE_SIZE) != > + round_down(start + len - 1, PAGE_SIZE)) { > + btrfs_err(fs_info, > + "tree block crosses page boundary, start %llu nodesize %lu", > + start, len); > + return ERR_PTR(-EINVAL); > + } > > eb = find_extent_buffer(fs_info, start); > if (eb) >
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 2020/9/15 下午4:37, Nikolay Borisov wrote: > > > On 15.09.20 г. 8:35 ч., Qu Wenruo wrote: >> As a preparation for subpage sector size support (allowing filesystem >> with sector size smaller than page size to be mounted) if the sector >> size is smaller than page size, we don't allow tree block to be read if >> it cross 64K(*) boundary. >> >> The 64K is selected because: >> - We are only going to support 64K page size for subpage > > What does "only support 64k page size for subpage" ? That means, we only support 64K page size system to mount sector size smaller than page size. Or to be more specific, we only support 64K page size system to mount 4K sector size fs. Thanks, Qu > >> - 64K is also the max node size btrfs supports >> >> This ensures that, tree blocks are always contained in one page for a >> system with 64K page size, which can greatly simplify the handling. >> >> Or we need to do complex multi-page handling for tree blocks. >> >> Currently the only way to create such tree blocks crossing 64K boundary >> is by btrfs-convert, which will get fixed soon and doesn't get >> wide-spread usage. >> >> Signed-off-by: Qu Wenruo <wqu@suse.com> >> --- >> fs/btrfs/extent_io.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c >> index e56aa68cd9fe..9af972999a09 100644 >> --- a/fs/btrfs/extent_io.c >> +++ b/fs/btrfs/extent_io.c >> @@ -5232,6 +5232,13 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, >> btrfs_err(fs_info, "bad tree block start %llu", start); >> return ERR_PTR(-EINVAL); >> } >> + if (fs_info->sectorsize < PAGE_SIZE && round_down(start, PAGE_SIZE) != >> + round_down(start + len - 1, PAGE_SIZE)) { >> + btrfs_err(fs_info, >> + "tree block crosses page boundary, start %llu nodesize %lu", >> + start, len); >> + return ERR_PTR(-EINVAL); >> + } >> >> eb = find_extent_buffer(fs_info, start); >> if (eb) >>
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e56aa68cd9fe..9af972999a09 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5232,6 +5232,13 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, btrfs_err(fs_info, "bad tree block start %llu", start); return ERR_PTR(-EINVAL); } + if (fs_info->sectorsize < PAGE_SIZE && round_down(start, PAGE_SIZE) != + round_down(start + len - 1, PAGE_SIZE)) { + btrfs_err(fs_info, + "tree block crosses page boundary, start %llu nodesize %lu", + start, len); + return ERR_PTR(-EINVAL); + } eb = find_extent_buffer(fs_info, start); if (eb)
As a preparation for subpage sector size support (allowing filesystem with sector size smaller than page size to be mounted) if the sector size is smaller than page size, we don't allow tree block to be read if it cross 64K(*) boundary. The 64K is selected because: - We are only going to support 64K page size for subpage - 64K is also the max node size btrfs supports This ensures that, tree blocks are always contained in one page for a system with 64K page size, which can greatly simplify the handling. Or we need to do complex multi-page handling for tree blocks. Currently the only way to create such tree blocks crossing 64K boundary is by btrfs-convert, which will get fixed soon and doesn't get wide-spread usage. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/extent_io.c | 7 +++++++ 1 file changed, 7 insertions(+)