From: Boaz Harrosh <bharrosh@panasas.com>
To: Tejun Heo <tj@kernel.org>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
linux-scsi <linux-scsi@vger.kernel.org>
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org,
fujita.tomonori@lab.ntt.co.jp
Subject: Re: [PATCH 14/17] scsi: replace custom rq mapping with blk_rq_map_kern_sgl()
Date: Wed, 01 Apr 2009 20:00:44 +0300 [thread overview]
Message-ID: <49D39DBC.3000206@panasas.com> (raw)
In-Reply-To: <1238593472-30360-15-git-send-email-tj@kernel.org>
On 04/01/2009 04:44 PM, Tejun Heo wrote:
> Impact: hack removal
>
> SCSI needs to map sgl into rq for kernel PC requests; however, block
> API didn't have such feature so it used its own rq mapping function
> which hooked into block/bio internals and is generally considered an
> ugly hack. The private function may also produce requests which are
> bigger than queue per-rq limits.
>
> Block blk_rq_map_kern_sgl(). Kill the private implementation and use
> it.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
James, TOMO
what happened to Tomo's patches that removes all this after fixing up
all users (sg.c)?
I thought that was agreed and done? What is left to do for that to go
in.
Thanks Boaz
> ---
> drivers/scsi/scsi_lib.c | 108 +----------------------------------------------
> 1 files changed, 1 insertions(+), 107 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 3196c83..3fa5589 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -296,112 +296,6 @@ static void scsi_end_async(struct request *req, int uptodate)
> __blk_put_request(req->q, req);
> }
>
> -static int scsi_merge_bio(struct request *rq, struct bio *bio)
> -{
> - struct request_queue *q = rq->q;
> -
> - bio->bi_flags &= ~(1 << BIO_SEG_VALID);
> - if (rq_data_dir(rq) == WRITE)
> - bio->bi_rw |= (1 << BIO_RW);
> - blk_queue_bounce(q, &bio);
> -
> - return blk_rq_append_bio(q, rq, bio);
> -}
> -
> -static void scsi_bi_endio(struct bio *bio, int error)
> -{
> - bio_put(bio);
> -}
> -
> -/**
> - * scsi_req_map_sg - map a scatterlist into a request
> - * @rq: request to fill
> - * @sgl: scatterlist
> - * @nsegs: number of elements
> - * @bufflen: len of buffer
> - * @gfp: memory allocation flags
> - *
> - * scsi_req_map_sg maps a scatterlist into a request so that the
> - * request can be sent to the block layer. We do not trust the scatterlist
> - * sent to use, as some ULDs use that struct to only organize the pages.
> - */
> -static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
> - int nsegs, unsigned bufflen, gfp_t gfp)
> -{
> - struct request_queue *q = rq->q;
> - int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
> - unsigned int data_len = bufflen, len, bytes, off;
> - struct scatterlist *sg;
> - struct page *page;
> - struct bio *bio = NULL;
> - int i, err, nr_vecs = 0;
> -
> - for_each_sg(sgl, sg, nsegs, i) {
> - page = sg_page(sg);
> - off = sg->offset;
> - len = sg->length;
> -
> - while (len > 0 && data_len > 0) {
> - /*
> - * sg sends a scatterlist that is larger than
> - * the data_len it wants transferred for certain
> - * IO sizes
> - */
> - bytes = min_t(unsigned int, len, PAGE_SIZE - off);
> - bytes = min(bytes, data_len);
> -
> - if (!bio) {
> - nr_vecs = min_t(int, BIO_GUARANTEED_PAGES,
> - nr_pages);
> - nr_pages -= nr_vecs;
> -
> - bio = bio_alloc(gfp, nr_vecs);
> - if (!bio) {
> - err = -ENOMEM;
> - goto free_bios;
> - }
> - bio->bi_end_io = scsi_bi_endio;
> - }
> -
> - if (bio_add_pc_page(q, bio, page, bytes, off) !=
> - bytes) {
> - bio_put(bio);
> - err = -EINVAL;
> - goto free_bios;
> - }
> -
> - if (bio->bi_vcnt >= nr_vecs) {
> - err = scsi_merge_bio(rq, bio);
> - if (err) {
> - bio_endio(bio, 0);
> - goto free_bios;
> - }
> - bio = NULL;
> - }
> -
> - page++;
> - len -= bytes;
> - data_len -=bytes;
> - off = 0;
> - }
> - }
> -
> - rq->buffer = rq->data = NULL;
> - rq->data_len = bufflen;
> - return 0;
> -
> -free_bios:
> - while ((bio = rq->bio) != NULL) {
> - rq->bio = bio->bi_next;
> - /*
> - * call endio instead of bio_put incase it was bounced
> - */
> - bio_endio(bio, 0);
> - }
> -
> - return err;
> -}
> -
> /**
> * scsi_execute_async - insert request
> * @sdev: scsi device
> @@ -438,7 +332,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
> req->cmd_flags |= REQ_QUIET;
>
> if (use_sg)
> - err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp);
> + err = blk_rq_map_kern_sg(req->q, req, buffer, use_sg, gfp);
> else if (bufflen)
> err = blk_rq_map_kern(req->q, req, buffer, bufflen, gfp);
>
next prev parent reply other threads:[~2009-04-01 17:02 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-01 13:44 [RFC PATCHSET block] block: blk-map updates and API cleanup Tejun Heo
2009-04-01 13:44 ` [PATCH 01/17] blk-map: move blk_rq_map_user() below blk_rq_map_user_iov() Tejun Heo
2009-04-01 13:44 ` [PATCH 02/17] scatterlist: improve atomic mapping handling in mapping iterator Tejun Heo
2009-04-01 13:44 ` [PATCH 03/17] blk-map: improve alignment checking for blk_rq_map_user_iov() Tejun Heo
2009-04-01 13:44 ` [PATCH 04/17] bio: bio.h cleanup Tejun Heo
2009-04-01 13:44 ` [PATCH 05/17] bio: cleanup rw usage Tejun Heo
2009-04-02 8:36 ` Boaz Harrosh
2009-04-02 9:02 ` Tejun Heo
2009-04-02 9:07 ` Boaz Harrosh
2009-04-02 9:13 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 06/17] blk-map/bio: use struct iovec instead of sg_iovec Tejun Heo
2009-04-01 14:50 ` Boaz Harrosh
2009-04-01 15:32 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 07/17] blk-map/bio: rename stuff Tejun Heo
2009-04-01 13:44 ` [PATCH 08/17] bio: reimplement bio_copy_user_iov() Tejun Heo
2009-04-01 15:50 ` Boaz Harrosh
2009-04-01 23:57 ` Tejun Heo
2009-04-02 8:24 ` Boaz Harrosh
2009-04-02 8:59 ` Tejun Heo
2009-04-02 9:54 ` Boaz Harrosh
2009-04-02 1:38 ` Tejun Heo
2009-04-02 7:34 ` Boaz Harrosh
2009-04-02 7:51 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 09/17] bio: collapse __bio_map_user_iov(), __bio_unmap_user() and __bio_map_kern() Tejun Heo
2009-04-01 13:44 ` [PATCH 10/17] bio: use bio_create_from_sgl() in bio_map_user_iov() Tejun Heo
2009-04-01 16:33 ` Boaz Harrosh
2009-04-01 22:20 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 11/17] bio: add sgl source support to bci and implement bio_memcpy_sgl_sgl() Tejun Heo
2009-04-01 13:44 ` [PATCH 12/17] bio: implement bio_{map|copy}_kern_sgl() Tejun Heo
2009-04-01 13:44 ` [PATCH 13/17] blk-map: implement blk_rq_map_kern_sgl() Tejun Heo
2009-04-01 16:50 ` Boaz Harrosh
2009-04-01 22:25 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 14/17] scsi: replace custom rq mapping with blk_rq_map_kern_sgl() Tejun Heo
2009-04-01 17:00 ` Boaz Harrosh [this message]
2009-04-01 17:05 ` James Bottomley
2009-04-01 17:17 ` Boaz Harrosh
2009-04-13 7:42 ` FUJITA Tomonori
2009-04-13 9:38 ` Tejun Heo
2009-04-13 10:07 ` FUJITA Tomonori
2009-04-13 12:59 ` Borislav Petkov
2009-04-14 0:44 ` FUJITA Tomonori
2009-04-14 10:01 ` Borislav Petkov
2009-04-14 23:44 ` FUJITA Tomonori
2009-04-15 4:25 ` Tejun Heo
2009-04-15 7:26 ` Borislav Petkov
2009-04-15 7:48 ` FUJITA Tomonori
2009-04-15 8:13 ` Borislav Petkov
2009-04-16 3:06 ` Tejun Heo
2009-04-16 3:06 ` Tejun Heo
2009-04-16 5:44 ` Borislav Petkov
2009-04-16 6:07 ` Tejun Heo
2009-04-16 6:07 ` Tejun Heo
2009-04-16 6:29 ` Borislav Petkov
2009-04-16 6:30 ` Tejun Heo
2009-04-16 6:30 ` Tejun Heo
2009-04-16 5:53 ` [PATCH 1/3] ide: add helpers for preparing sense requests Borislav Petkov
2009-04-16 5:53 ` [PATCH 2/3] ide-cd: convert to using generic sense request Borislav Petkov
2009-04-16 5:54 ` [PATCH 3/3] ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer Borislav Petkov
2009-04-01 13:44 ` [PATCH 15/17] bio/blk-map: kill unused stuff and un-export internal functions Tejun Heo
2009-04-01 13:54 ` Boaz Harrosh
2009-04-01 14:06 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 16/17] blk-map/bio: remove superflous @len parameter from blk_rq_map_user_iov() Tejun Heo
2009-04-01 17:12 ` Boaz Harrosh
2009-04-01 22:17 ` Tejun Heo
2009-04-01 13:44 ` [PATCH 17/17] blk-map/bio: remove superflous @q from blk_rq_map_{user|kern}*() Tejun Heo
2009-04-01 17:05 ` Boaz Harrosh
2009-04-01 14:08 ` [RFC PATCHSET block] block: blk-map updates and API cleanup Tejun Heo
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=49D39DBC.3000206@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=axboe@kernel.dk \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=tj@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 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.