Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b93629b authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe
Browse files

block: implement blk_rq_pos/[cur_]sectors() and convert obvious ones



Implement accessors - blk_rq_pos(), blk_rq_sectors() and
blk_rq_cur_sectors() which return rq->hard_sector, rq->hard_nr_sectors
and rq->hard_cur_sectors respectively and convert direct references of
the said fields to the accessors.

This is in preparation of request data length handling cleanup.

Geert	: suggested adding const to struct request * parameter to accessors
Sergei	: spotted error in patch description

[ Impact: cleanup ]

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Acked-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Tested-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Ackec-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent c3a4d78c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ static inline bool start_ordered(struct request_queue *q, struct request **rqp)
	 * For an empty barrier, there's no actual BAR request, which
	 * in turn makes POSTFLUSH unnecessary.  Mask them off.
	 */
	if (!rq->hard_nr_sectors) {
	if (!blk_rq_sectors(rq)) {
		q->ordered &= ~(QUEUE_ORDERED_DO_BAR |
				QUEUE_ORDERED_DO_POSTFLUSH);
		/*
+1 −1
Original line number Diff line number Diff line
@@ -1683,7 +1683,7 @@ static void blk_account_io_done(struct request *req)
unsigned int blk_rq_bytes(struct request *rq)
{
	if (blk_fs_request(rq))
		return rq->hard_nr_sectors << 9;
		return blk_rq_sectors(rq) << 9;

	return rq->data_len;
}
+1 −1
Original line number Diff line number Diff line
@@ -760,7 +760,7 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq)
	cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "activate rq, drv=%d",
						cfqd->rq_in_driver);

	cfqd->last_position = rq->hard_sector + rq->hard_nr_sectors;
	cfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq);
}

static void cfq_deactivate_request(struct request_queue *q, struct request *rq)
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
	dev_dbg(&dev->sbd.core,
		"%s:%u: %s req has %u bvecs for %lu sectors %lu hard sectors\n",
		__func__, __LINE__, op, n, req->nr_sectors,
		req->hard_nr_sectors);
		blk_rq_sectors(req));
#endif

	start_sector = req->sector * priv->blocking_factor;
+3 −3
Original line number Diff line number Diff line
@@ -368,12 +368,12 @@ static void do_viodasd_request(struct request_queue *q)
		blkdev_dequeue_request(req);
		/* check that request contains a valid command */
		if (!blk_fs_request(req)) {
			viodasd_end_request(req, -EIO, req->hard_nr_sectors);
			viodasd_end_request(req, -EIO, blk_rq_sectors(req));
			continue;
		}
		/* Try sending the request */
		if (send_request(req) != 0)
			viodasd_end_request(req, -EIO, req->hard_nr_sectors);
			viodasd_end_request(req, -EIO, blk_rq_sectors(req));
	}
}

@@ -590,7 +590,7 @@ static int viodasd_handle_read_write(struct vioblocklpevent *bevent)
		err = vio_lookup_rc(viodasd_err_table, bevent->sub_result);
		printk(VIOD_KERN_WARNING "read/write error %d:0x%04x (%s)\n",
				event->xRc, bevent->sub_result, err->msg);
		num_sect = req->hard_nr_sectors;
		num_sect = blk_rq_sectors(req);
	}
	qlock = req->q->queue_lock;
	spin_lock_irqsave(qlock, irq_flags);
Loading