From: Ming Lei <ming.lei@redhat.com>
To: Gao Xiang <gaoxiang25@huawei.com>
Cc: linux-block@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
"linux-erofs@lists.ozlabs.org" <linux-erofs@lists.ozlabs.org>,
Jens Axboe <axboe@kernel.dk>, Chao Yu <yuchao0@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: Some new bio merging behaviors in __bio_try_merge_page
Date: Thu, 11 Apr 2019 15:08:08 +0800 [thread overview]
Message-ID: <20190411070807.GA421@ming.t460p> (raw)
In-Reply-To: <85c5fa1a-a506-e26f-c354-1554d47d8b2b@huawei.com>
Hi Gao Xiang,
On Thu, Apr 11, 2019 at 01:47:49PM +0800, Gao Xiang wrote:
> Hi Ming,
>
> I found a erofs issue after commit 07173c3ec276
> ("block: enable multipage bvecs") is merged. It seems that
> it tries to merge more physical continuous pages in one iovec.
>
> However it breaks the current erofs_read_raw_page logic since it uses
> nr_iovecs of bio_alloc to limit the maximum number of physical
I believe you can do the limit outside easily, such as by checking
how many pages have been added to the bio.
> continuous blocks as well. It was practicable since the old
> __bio_try_merge_page only tries to merge in the same page.
> it is a kAPI behavior change which also affects bio_alloc...
>
> ...
> 231 err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
> 232 if (unlikely(err))
> 233 goto err_out;
> ...
> 284 /* max # of continuous pages */
> 285 if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE))
> 286 nblocks = DIV_ROUND_UP(map.m_plen, PAGE_SIZE);
> 287 if (nblocks > BIO_MAX_PAGES)
> 288 nblocks = BIO_MAX_PAGES;
> 289
> 290 bio = erofs_grab_bio(sb, blknr, nblocks, sb,
> 291 read_endio, false);
Previously this bio is allowed to add at most 'nblocks' pages, however,
now we are allowed to add at most 'nblocks' io vecs, instead of pages.
> 292 if (IS_ERR(bio)) {
> 293 err = PTR_ERR(bio);
> 294 bio = NULL;
> 295 goto err_out;
> 296 }
> 297 }
> 298
> 299 err = bio_add_page(bio, page, PAGE_SIZE, 0);
> 300 /* out of the extent or bio is full */
> 301 if (err < PAGE_SIZE)
> 302 goto submit_bio_retry;
> ...
>
> After commit 07173c3ec276 ("block: enable multipage bvecs"), erofs could
> read more beyond what erofs_map_blocks assigns, and out-of-bound data could
> be read and it breaks tail-end inline determination.
I don't understand why, could you explain a bit why erofs reads more?
The amount depends on how many pages you added to the bio.
>
> I can change the logic in erofs. However, out of curiosity, I have no idea
> if some other places also are designed like this.
>
> IMO, it's better to provide a total count which indicates how many real
> pages have been added in this bio. some thoughts?
As I mentioned, you may count how many pages added to bio, or you still
can get the number via bio_segments(bio).
Thanks,
Ming
WARNING: multiple messages have this Message-ID (diff)
From: ming.lei@redhat.com (Ming Lei)
Subject: Some new bio merging behaviors in __bio_try_merge_page
Date: Thu, 11 Apr 2019 15:08:08 +0800 [thread overview]
Message-ID: <20190411070807.GA421@ming.t460p> (raw)
In-Reply-To: <85c5fa1a-a506-e26f-c354-1554d47d8b2b@huawei.com>
Hi Gao Xiang,
On Thu, Apr 11, 2019@01:47:49PM +0800, Gao Xiang wrote:
> Hi Ming,
>
> I found a erofs issue after commit 07173c3ec276
> ("block: enable multipage bvecs") is merged. It seems that
> it tries to merge more physical continuous pages in one iovec.
>
> However it breaks the current erofs_read_raw_page logic since it uses
> nr_iovecs of bio_alloc to limit the maximum number of physical
I believe you can do the limit outside easily, such as by checking
how many pages have been added to the bio.
> continuous blocks as well. It was practicable since the old
> __bio_try_merge_page only tries to merge in the same page.
> it is a kAPI behavior change which also affects bio_alloc...
>
> ...
> 231 err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
> 232 if (unlikely(err))
> 233 goto err_out;
> ...
> 284 /* max # of continuous pages */
> 285 if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE))
> 286 nblocks = DIV_ROUND_UP(map.m_plen, PAGE_SIZE);
> 287 if (nblocks > BIO_MAX_PAGES)
> 288 nblocks = BIO_MAX_PAGES;
> 289
> 290 bio = erofs_grab_bio(sb, blknr, nblocks, sb,
> 291 read_endio, false);
Previously this bio is allowed to add at most 'nblocks' pages, however,
now we are allowed to add at most 'nblocks' io vecs, instead of pages.
> 292 if (IS_ERR(bio)) {
> 293 err = PTR_ERR(bio);
> 294 bio = NULL;
> 295 goto err_out;
> 296 }
> 297 }
> 298
> 299 err = bio_add_page(bio, page, PAGE_SIZE, 0);
> 300 /* out of the extent or bio is full */
> 301 if (err < PAGE_SIZE)
> 302 goto submit_bio_retry;
> ...
>
> After commit 07173c3ec276 ("block: enable multipage bvecs"), erofs could
> read more beyond what erofs_map_blocks assigns, and out-of-bound data could
> be read and it breaks tail-end inline determination.
I don't understand why, could you explain a bit why erofs reads more?
The amount depends on how many pages you added to the bio.
>
> I can change the logic in erofs. However, out of curiosity, I have no idea
> if some other places also are designed like this.
>
> IMO, it's better to provide a total count which indicates how many real
> pages have been added in this bio. some thoughts?
As I mentioned, you may count how many pages added to bio, or you still
can get the number via bio_segments(bio).
Thanks,
Ming
next prev parent reply other threads:[~2019-04-11 7:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 5:47 Some new bio merging behaviors in __bio_try_merge_page Gao Xiang
2019-04-11 5:47 ` Gao Xiang
2019-04-11 7:08 ` Ming Lei [this message]
2019-04-11 7:08 ` Ming Lei
2019-04-11 7:43 ` Gao Xiang
2019-04-11 7:43 ` Gao Xiang
2019-04-11 8:09 ` Ming Lei
2019-04-11 8:09 ` Ming Lei
2019-04-11 10:20 ` Gao Xiang
2019-04-11 10:20 ` Gao Xiang
2019-04-11 15:34 ` Christoph Hellwig
2019-04-11 15:34 ` Christoph Hellwig
2019-04-11 16:25 ` Gao Xiang
2019-04-11 16:25 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190411070807.GA421@ming.t460p \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=gaoxiang25@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.