On Wed, Nov 28, 2018 at 06:51:59PM +0200, Nikolay Borisov wrote: > > Got me curious if we could get rid of the size parameter, it's 2x > > PAGE_SIZE and could be something else in one case but it's not obvious > > if it really happens. > > > > Another thing I noticed is lack of proper error handling in all callers, > > as its' 0, 1, and negative errno. The error would be interpreted as true > > ie. add page to bio and continue. > > Actually anything other than 0 is returned then the current bio is > actually submitted (I presume you refer to the code in compression.c). > As a matter of fact I think btrfs_bio_fits_in_stripe could even be > turned to return a bool value. > > THe only time this function could return an error is if the mapping > logic goes haywire which could happen 'if (offset < stripe_offset) {' or > we don't find a chunk for the given offset, which is unlikely.
Unlikely yes, but if it's possible to trigger the mapping failure eg. by a crafted image, it should be handled. Besides the mapping errors, there are EIO or ENOMEM in __btrfs_map_block or its callees. I see all other callers of map block handle the errors.