Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-24 Thread Peter Zijlstra
On Tue, Jul 18, 2017 at 03:19:00PM -0700, Bart Van Assche wrote: > Hello Peter, Sorry for being late, I'm trying to recover from a few weeks of leave and the inbox is in shambles. > In a test I ran myself with kernel v4.12-rc1 I also noticed that a > WARN_ON_ONCE() statement triggered an oops in

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-18 Thread Bart Van Assche
On 07/14/17 13:54, Liu Bo wrote: > On Fri, Jul 14, 2017 at 08:22:31AM -0600, Jens Axboe wrote: >> On 07/14/2017 07:47 AM, Ming Lei wrote: @@ -156,6 +156,9 @@ static inline void *bio_data(struct bio *bio) /* * drivers should _never_ use the all version - the bio may have been

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread David Sterba
On Fri, Jul 14, 2017 at 08:22:31AM -0600, Jens Axboe wrote: > /* > * drivers should _never_ use the all version - the bio may have been split > - * before it got to the driver and the driver won't own all of it > + * before it got to the driver and the driver won't own all of it. > + * > + *

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Jens Axboe
On 07/14/2017 04:35 PM, Ming Lei wrote: > On Sat, Jul 15, 2017 at 4:54 AM, Liu Bo wrote: >> On Fri, Jul 14, 2017 at 08:22:31AM -0600, Jens Axboe wrote: >>> On 07/14/2017 07:47 AM, Ming Lei wrote: > @@ -156,6 +156,9 @@ static inline void *bio_data(struct bio *bio) >

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Ming Lei
On Sat, Jul 15, 2017 at 4:54 AM, Liu Bo wrote: > On Fri, Jul 14, 2017 at 08:22:31AM -0600, Jens Axboe wrote: >> On 07/14/2017 07:47 AM, Ming Lei wrote: >> >> @@ -156,6 +156,9 @@ static inline void *bio_data(struct bio *bio) >> >> /* >> >> * drivers should _never_ use the

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Liu Bo
On Fri, Jul 14, 2017 at 08:22:31AM -0600, Jens Axboe wrote: > On 07/14/2017 07:47 AM, Ming Lei wrote: > >> @@ -156,6 +156,9 @@ static inline void *bio_data(struct bio *bio) > >> /* > >> * drivers should _never_ use the all version - the bio may have been > >> split > >> * before it got to

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Jens Axboe
On 07/14/2017 11:56 AM, Filipe Manana wrote: > > > On 07/14/2017 04:03 PM, David Sterba wrote: >> On Fri, Jul 14, 2017 at 09:47:30PM +0800, Ming Lei wrote: >>> On Fri, Jul 14, 2017 at 9:40 PM, David Sterba wrote: We've switched to cloned bios in btrfs and hit a nasty bug

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Filipe Manana
On 07/14/2017 04:03 PM, David Sterba wrote: > On Fri, Jul 14, 2017 at 09:47:30PM +0800, Ming Lei wrote: >> On Fri, Jul 14, 2017 at 9:40 PM, David Sterba wrote: >>> We've switched to cloned bios in btrfs and hit a nasty bug leading to >>> corruptions, when cloned bios are

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread David Sterba
On Fri, Jul 14, 2017 at 09:47:30PM +0800, Ming Lei wrote: > On Fri, Jul 14, 2017 at 9:40 PM, David Sterba wrote: > > We've switched to cloned bios in btrfs and hit a nasty bug leading to > > corruptions, when cloned bios are iterated by bio_for_each_segment_all. > > No, you

Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread Ming Lei
On Fri, Jul 14, 2017 at 9:40 PM, David Sterba wrote: > We've switched to cloned bios in btrfs and hit a nasty bug leading to > corruptions, when cloned bios are iterated by bio_for_each_segment_all. No, you simply can't use bio_for_each_segment_all on cloned bio, and the reason

[PATCH] block: note about cloned bios and bio_for_each_segment_all

2017-07-14 Thread David Sterba
We've switched to cloned bios in btrfs and hit a nasty bug leading to corruptions, when cloned bios are iterated by bio_for_each_segment_all. Report and fix: https://patchwork.kernel.org/patch/9838535/ As a matter of precaution, we've added assertions to btrfs code to catch the bad usage