Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752881AbcCLOkH (ORCPT ); Sat, 12 Mar 2016 09:40:07 -0500 Received: from mail-yw0-f173.google.com ([209.85.161.173]:36758 "EHLO mail-yw0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752116AbcCLOkA (ORCPT ); Sat, 12 Mar 2016 09:40:00 -0500 MIME-Version: 1.0 In-Reply-To: <20160312143612.GA30418@kmo-pixel> References: <20160312074329.GA19066@kmo-pixel> <20160312092421.GA20839@kmo-pixel> <20160312121236.GA25403@kmo-pixel> <20160312134843.GA27821@kmo-pixel> <20160312140256.GA29313@kmo-pixel> <20160312222548.6a81d13b@tom-T450> <20160312143612.GA30418@kmo-pixel> Date: Sat, 12 Mar 2016 22:39:59 +0800 Message-ID: Subject: Re: e827091cb1 "block: merge: get the 1st and last bvec via helpers" broken From: Ming Lei To: Kent Overstreet Cc: Ming Lin , Jens Axboe , Linux Kernel Mailing List , Linus Torvalds Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1964 Lines: 60 On Sat, Mar 12, 2016 at 10:36 PM, Kent Overstreet wrote: > On Sat, Mar 12, 2016 at 10:25:48PM +0800, Ming Lei wrote: >> On Sat, 12 Mar 2016 05:02:56 -0900 >> Kent Overstreet wrote: >> >> > Here's the output of the patch below: >> > >> > generic/036 11s ...run fstests generic/036 at 2016-03-12 13:58:21 >> > end 4096 0 ffffea0001d611c0 end2 1024 0 ffffea0001d611c0 >> > len 1024 offset 0 page ffffea0001d611c0 >> > KGDB: Waiting for remote debugger >> > >> > Your code gives a biovec with bv_len of 4096, the old code gives a biovec with >> > bv_len of 1024 (and then we dump every biovec, we see that the bio had only a >> > single biovec that did indeed have bv_len == 1024). >> >> I guess we shouldn't have optimized for the case of non-cloned bio, could you >> try the following patch? >> >> -- >> diff --git a/include/linux/bio.h b/include/linux/bio.h >> index 1e7248f..4abc129 100644 >> --- a/include/linux/bio.h >> +++ b/include/linux/bio.h >> @@ -267,11 +267,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) >> struct bvec_iter iter = bio->bi_iter; >> int idx; >> >> - if (!bio_flagged(bio, BIO_CLONED)) { >> - *bv = bio->bi_io_vec[bio->bi_vcnt - 1]; >> - return; >> - } >> - >> if (unlikely(!bio_multiple_segments(bio))) { >> *bv = bio_iovec(bio); >> return; >> >> Thanks, >> Ming > > Yes, that's it. > > !BIO_CLONED is _not_ a guarantee that bi_size doesn't straddle the middle of a > bvec - bcachefs was hitting this by bouncing a bio that had already been split > (which can happen elsewhere in the kernel...) but there's other (perfectly > legal) ways it can happen. Exactly! > > I would still strongly suggest reverting the patch for 4.5 and resubmitting > during the next merge window. I am fine with either way, and I will prepare one patch and let Jens decide. thanks, Ming Lei