From mboxrd@z Thu Jan 1 00:00:00 1970 From: "hch@infradead.org" Subject: Re: [PATCH] hfsplus: fix cross-page bio requests Date: Tue, 9 Jun 2015 22:05:08 -0700 Message-ID: <20150610050508.GB11894@infradead.org> References: <1428656543-6790-1-git-send-email-saproj@gmail.com> <03D2C0C2-2A16-4018-B24C-28D9011C4446@tuxera.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Anton Altaparmakov , "linux-fsdevel@vger.kernel.org" , Anton Altaparmakov , Al Viro , "hch@infradead.org" , Andrew Morton , Vyacheslav Dubeyko , Hin-Tak Leung , Sougata Santra To: Sergei Antonov Return-path: Received: from bombadil.infradead.org ([198.137.202.9]:60979 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbbFJFFM (ORCPT ); Wed, 10 Jun 2015 01:05:12 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Jun 10, 2015 at 01:53:47AM +0200, Sergei Antonov wrote: > >> + bio = bio_alloc(GFP_NOIO, 1); > >> + if (!bio) > >> + return -ENOMEM; > >> + bio->bi_iter.bi_sector = sector; > >> + bio->bi_bdev = sb->s_bdev; > >> + bio->bi_vcnt = 1; > >> + bio->bi_iter.bi_size = io_size; > >> + bio->bi_io_vec[0].bv_page = virt_to_page(buf); > >> + bio->bi_io_vec[0].bv_offset = offset_in_page(buf); > >> + bio->bi_io_vec[0].bv_len = io_size; > >> ret = submit_bio_wait(rw, bio); > > > > I think you need to rethink this. Think of what you are doing: You are adding a single page to the bio but then submitting io that exceeds the page... > > I'm not adding a single page, I'm adding a single vector. > This "bio->bi_vcnt = 1; bio->bi_io_vec[0].bv_page = ...; etc." > approach can be found in a number of places in the kernel. Just > followed other people's example. And I tested the code too :). And we're getting right of it because it's problematic. Please allocate an optimistic numbero of vectors in bio_alloc and use bio_add_page as only that takes care of the block driver limits properly.