From: Omar Sandoval <osandov@osandov.com>
To: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Cc: hch@lst.de, Shaohua Li <shli@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, caspar@linux.alibaba.com,
Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH 2/4] block: bio_check_eod() needs to consider partition
Date: Mon, 26 Feb 2018 13:03:08 -0800 [thread overview]
Message-ID: <20180226210308.GB9157@vader.DHCP.thefacebook.com> (raw)
In-Reply-To: <9827cd58-0044-19a2-6bc1-bc4357ed846d@linux.alibaba.com>
On Mon, Feb 26, 2018 at 08:04:38PM +0800, Jiufei Xue wrote:
> bio_check_eod() should get the capacity of partiton, not the whole
> disk.
>
> Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
> ---
> block/blk-core.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 6d82c4f..ef6677d 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -2023,7 +2023,7 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
> return BLK_QC_T_NONE;
> }
>
> -static void handle_bad_sector(struct bio *bio)
> +static void handle_bad_sector(struct bio *bio, sector_t maxsector)
> {
> char b[BDEVNAME_SIZE];
>
> @@ -2031,7 +2031,7 @@ static void handle_bad_sector(struct bio *bio)
> printk(KERN_INFO "%s: rw=%d, want=%Lu, limit=%Lu\n",
> bio_devname(bio, b), bio->bi_opf,
> (unsigned long long)bio_end_sector(bio),
> - (long long)get_capacity(bio->bi_disk));
> + (long long)maxsector);
> }
>
> #ifdef CONFIG_FAIL_MAKE_REQUEST
> @@ -2131,12 +2131,20 @@ static inline int blk_partition_remap(struct bio *bio)
> static inline int bio_check_eod(struct bio *bio, unsigned int nr_sectors)
> {
> sector_t maxsector;
> + struct hd_struct *part;
>
> if (!nr_sectors)
> return 0;
>
> /* Test device or partition size, when known. */
> - maxsector = get_capacity(bio->bi_disk);
> + rcu_read_lock();
> + part = __disk_get_part(bio->bi_disk, bio->bi_partno);
> + if (part)
> + maxsector = part_nr_sects_read(part);
> + else
> + maxsector = get_capacity(bio->bi_disk);
This case means that bio->bi_partno was invalid, right? Shouldn't this
be an error? I see that this is copied from guard_bio_eod(), but that
serves a slightly different purpose.
> + rcu_read_unlock();
> +
> if (maxsector) {
> sector_t sector = bio->bi_iter.bi_sector;
>
> @@ -2146,7 +2154,7 @@ static inline int bio_check_eod(struct bio *bio, unsigned int nr_sectors)
> * without checking the size of the device, e.g., when
> * mounting a device.
> */
> - handle_bad_sector(bio);
> + handle_bad_sector(bio, maxsector);
> return 1;
> }
> }
> --
> 1.9.4
>
>
next prev parent reply other threads:[~2018-02-26 21:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 12:01 [PATCH 0/4] fix a few problems in block layer Jiufei Xue
2018-02-26 12:04 ` [PATCH 1/4] block: fix the count of PGPGOUT for WRITE_SAME Jiufei Xue
2018-02-26 20:52 ` Omar Sandoval
2018-02-26 23:43 ` Bart Van Assche
2018-02-27 0:10 ` Christoph Hellwig
2018-02-26 12:04 ` [PATCH 2/4] block: bio_check_eod() needs to consider partition Jiufei Xue
2018-02-26 21:03 ` Omar Sandoval [this message]
2018-02-27 0:11 ` Christoph Hellwig
2018-02-27 4:51 ` Jiufei Xue
2018-02-26 12:04 ` [PATCH 3/4] block: display the correct diskname for bio Jiufei Xue
2018-02-26 21:07 ` Omar Sandoval
2018-02-26 12:04 ` [PATCH 4/4] block: fix a typo Jiufei Xue
2018-02-26 16:03 ` [PATCH 0/4] fix a few problems in block layer Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2018-02-27 12:07 [PATCH V2 " Jiufei Xue
2018-02-27 12:11 ` [PATCH 2/4] block: bio_check_eod() needs to consider partition Jiufei Xue
2018-02-28 17:48 ` Christoph Hellwig
2018-03-01 1:23 ` Jiufei Xue
2018-03-08 7:44 ` Christoph Hellwig
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=20180226210308.GB9157@vader.DHCP.thefacebook.com \
--to=osandov@osandov.com \
--cc=axboe@kernel.dk \
--cc=caspar@linux.alibaba.com \
--cc=hch@lst.de \
--cc=jiufei.xue@linux.alibaba.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-block@vger.kernel.org \
--cc=shli@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox