On 15.04.20 г. 18:41 ч., David Sterba wrote:
> On Wed, Apr 15, 2020 at 03:53:46PM +0300, Nikolay Borisov wrote:
>> - if (btrfs_super_bytenr(*disk_super) != bytenr ||
>> - btrfs_super_magic(*disk_super) != BTRFS_MAGIC) {
>> + if (btrfs_super_bytenr(disk_super) != bytenr ||
>> + btrfs_super_magic(disk_super) != BTRFS_MAGIC) {
>> btrfs_release_disk_super(p);
>> - return 1;
>> + return ERR_PTR(-EUCLEAN);
>
> One more question: what's the reason for -EUCLEAN? The condition fails
> if the superblock offset is wrong or there's no magic number. Clearly
> not a btrfs superblock, this could be returned to the scanning ioctl, or
> is called during mount.
>
> At this point the decision is 'is this potentially a btrfs device?' and
> the lightest check we do is the offset and magic number. Only after that
> the checksum is verified and all the superblock items and from that
> point on it's all EUCLEAN, but before that it's EINVAL.
>
Good point, even though EINVAL was always returned if
btrfs_read_disk_super returned an error. But I will incorporate this and
the previous suggested change - forward error from btrfs_read_disk_super
to the caller.