Just a little convenience macro - main reason to add it now is preparing
for immutable bio vecs, it'll reduce the size of the patch that puts
bi_sector/bi_size/bi_idx into a struct bvec_iter.
return NULL;
}
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 599b12e..ef19d5f 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -132,7 +132,7 @@ deadline_merge(struct request_queue *q, struct request **req, struct bio *bio)
* check for front merge
*/
if (dd->front_merges) {
- sector_t sector = bio->bi_sector + bio_sectors(bio);
+ sector_t sector = bio_end_sector(bio);
__rq = elv_rb_find(&dd->sort_list[bio_data_dir(bio)], sector);
if (__rq) {
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 01b2ac6..d90a1fd 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -1144,7 +1144,7 @@ void drbd_make_request(struct request_queue *q, struct bio *bio)
/* to make some things easier, force alignment of requests within the
* granularity of our hash tables */
s_enr = bio->bi_sector >> HT_SHIFT;
- e_enr = bio->bi_size ? (bio->bi_sector+(bio->bi_size>>9)-1) >> HT_SHIFT : s_enr;
+ e_enr = (bio_end_sector(bio) - 1) >> HT_SHIFT;
if (likely(s_enr == e_enr)) {
do {
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 2e7de7a..26938e8 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -901,7 +901,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
pd->iosched.successive_reads += bio->bi_size >> 10;
else {
pd->iosched.successive_reads = 0;
- pd->iosched.last_write = bio->bi_sector + bio_sectors(bio);
+ pd->iosched.last_write = bio_end_sector(bio);
}
if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) {
if (pd->read_speed == pd->write_speed) {
@@ -2454,7 +2454,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
zone = ZONE(bio->bi_sector, pd);
VPRINTK("pkt_make_request: start = %6llx stop = %6llx
",
(unsigned long long)bio->bi_sector,
- (unsigned long long)(bio->bi_sector + bio_sectors(bio)));
+ (unsigned long long)bio_end_sector(bio));
/* Check if we have to split the bio */
{
@@ -2462,7 +2462,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
sector_t last_zone;
int first_sectors;
static inline unsigned int bio_cur_bytes(struct bio *bio)
{
--
1.7.12
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-26-2012, 03:16 PM
Lars Ellenberg
block: Add bio_end_sector()
On Tue, Sep 25, 2012 at 03:06:24PM -0700, Kent Overstreet wrote:
> On Tue, Sep 25, 2012 at 01:54:52PM +0200, Lars Ellenberg wrote:
> > On Mon, Sep 24, 2012 at 03:34:46PM -0700, Kent Overstreet wrote:
> > > Just a little convenience macro - main reason to add it now is preparing
> > > for immutable bio vecs, it'll reduce the size of the patch that puts
> > > bi_sector/bi_size/bi_idx into a struct bvec_iter.
> >
> >
> > For the DRBD part:
> Version below look good?
>
> diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
> index 01b2ac6..47f55db 100644
> --- a/drivers/block/drbd/drbd_req.c
> +++ b/drivers/block/drbd/drbd_req.c
> @@ -1144,7 +1144,7 @@ void drbd_make_request(struct request_queue *q, struct bio *bio)
> /* to make some things easier, force alignment of requests within the
> * granularity of our hash tables */
> s_enr = bio->bi_sector >> HT_SHIFT;
> - e_enr = bio->bi_size ? (bio->bi_sector+(bio->bi_size>>9)-1) >> HT_SHIFT : s_enr;
> + e_enr = bio->bi_size ? (bio_end_sector(bio) - 1) >> HT_SHIFT : s_enr;
>
> if (likely(s_enr == e_enr)) {
> do {
Sure.
Cheers,
Lars
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
10-02-2012, 06:10 PM
Vivek Goyal
block: Add bio_end_sector()
On Mon, Sep 24, 2012 at 03:34:46PM -0700, Kent Overstreet wrote:
May be it is just me. But bio_end_sector() kind of sounds that it will
calculate to the last sector of bio. So I thought of it more as
bio_last_sector() and not the sector which is next to the last sector.
Will it make sense to introduce bio_last_sector() and use +1 everywhere.
Or may be we need a better name. Can't think of one though.
Thanks
Vivek
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
10-02-2012, 08:20 PM
Kent Overstreet
block: Add bio_end_sector()
On Tue, Oct 02, 2012 at 02:10:01PM -0400, Vivek Goyal wrote:
> On Mon, Sep 24, 2012 at 03:34:46PM -0700, Kent Overstreet wrote:
>
> [..]
> > diff --git a/include/linux/bio.h b/include/linux/bio.h
> > index 4e32be1..d985e90 100644
> > --- a/include/linux/bio.h
> > +++ b/include/linux/bio.h
> > @@ -67,6 +67,7 @@
> > #define bio_offset(bio) bio_iovec((bio))->bv_offset
> > #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
> > #define bio_sectors(bio) ((bio)->bi_size >> 9)
> > +#define bio_end_sector(bio) ((bio)->bi_sector + bio_sectors(bio))
>
> May be it is just me. But bio_end_sector() kind of sounds that it will
> calculate to the last sector of bio. So I thought of it more as
> bio_last_sector() and not the sector which is next to the last sector.
>
> Will it make sense to introduce bio_last_sector() and use +1 everywhere.
> Or may be we need a better name. Can't think of one though.
Ugh, that sounds like it'd be just begging for fencepost errors. I've
never ran into a situation where I needed bio->bi_sector +
bio_sectors(bio) - 1, either.
I kind of see your point... it seems like there should be a name for
this concept (same as a pointer to the end of an array), but I can't
think of one.
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel