Message ID | 20190516084803.9774-9-jthumshirn@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support for SHA-256 checksums | expand |
On 16.05.19 г. 11:47 ч., Johannes Thumshirn wrote: > Now that we have factorerd out the superblock checksum type validation, we > can check for supported superblock checksum types before doing the actual > validation of the superblock read from disk. > > This leads the path to further simplifications of btrfs_check_super_csum() > later on. > > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Nikolay Borisov <nborisov@suse.com> > --- > fs/btrfs/disk-io.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index ab13282d91d2..74937effaed4 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -2822,6 +2822,14 @@ int open_ctree(struct super_block *sb, > goto fail_alloc; > } > > + if (!btrfs_supported_super_csum((struct btrfs_super_block *) > + bh->b_data)) { > + btrfs_err(fs_info, "unsupported checksum algorithm"); > + err = -EINVAL; > + brelse(bh); > + goto fail_alloc; > + } > + > /* > * We want to check superblock checksum, the type is stored inside. > * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). >
On Thu, May 16, 2019 at 10:47:58AM +0200, Johannes Thumshirn wrote: > Now that we have factorerd out the superblock checksum type validation, we > can check for supported superblock checksum types before doing the actual > validation of the superblock read from disk. > > This leads the path to further simplifications of btrfs_check_super_csum() > later on. > > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> > --- > fs/btrfs/disk-io.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index ab13282d91d2..74937effaed4 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -2822,6 +2822,14 @@ int open_ctree(struct super_block *sb, > goto fail_alloc; > } > > + if (!btrfs_supported_super_csum((struct btrfs_super_block *) > + bh->b_data)) { > + btrfs_err(fs_info, "unsupported checksum algorithm"); The other error message printed the value and I think we should print also the maximum. That's future proof once we have more algos.
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ab13282d91d2..74937effaed4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2822,6 +2822,14 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } + if (!btrfs_supported_super_csum((struct btrfs_super_block *) + bh->b_data)) { + btrfs_err(fs_info, "unsupported checksum algorithm"); + err = -EINVAL; + brelse(bh); + goto fail_alloc; + } + /* * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).
Now that we have factorerd out the superblock checksum type validation, we can check for supported superblock checksum types before doing the actual validation of the superblock read from disk. This leads the path to further simplifications of btrfs_check_super_csum() later on. Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+)