From: Boaz Harrosh <bharrosh-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
To: Kent Overstreet <koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
neilb-l3A5Bk7waGM@public.gmane.org,
drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org,
vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
mpatocka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
sage-BnTBU8nroG7k1uMJSBkQmQ@public.gmane.org,
yehuda-L5o5AL9CYN0tUFlbccrkMA@public.gmane.org
Subject: Re: [PATCH v4 04/12] pktcdvd: Switch to bio_kmalloc()
Date: Wed, 25 Jul 2012 14:29:59 +0300 [thread overview]
Message-ID: <500FD8B7.9040701@panasas.com> (raw)
In-Reply-To: <1343160689-12378-5-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
On 07/24/2012 11:11 PM, Kent Overstreet wrote:
> This is prep work for killing bi_destructor - previously, pktcdvd had
> its own pkt_bio_alloc which was basically duplication bio_kmalloc(),
> necessitating its own bi_destructor implementation.
>
> Signed-off-by: Kent Overstreet <koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/block/pktcdvd.c | 115 ++++++++++++++++-------------------------------
> 1 files changed, 39 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index ba66e44..6fe693a 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -522,36 +522,38 @@ static void pkt_bio_finished(struct pktcdvd_device *pd)
> }
> }
>
> -static void pkt_bio_destructor(struct bio *bio)
> +static void pkt_end_io_read(struct bio *bio, int err)
> {
> - kfree(bio->bi_io_vec);
> - kfree(bio);
> -}
Again here, you decided to move the pkt_end_io_read && pkt_end_io_packet_write
functions from below, to above here. Which makes it impossible to find
any bugs by just reviewing the patch.
So I have not reviewed it.
I know that you wanted so you can reference them at pkt_alloc_packet_data.
I'd use a forward reference, in this case. And a move in a next patch. But
this is just me. Perhaps the owner of this code can review it?
Cheers
Boaz
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> -static struct bio *pkt_bio_alloc(int nr_iovecs)
> -{
> - struct bio_vec *bvl = NULL;
> - struct bio *bio;
> + VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> + (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
>
> - bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
> - if (!bio)
> - goto no_bio;
> - bio_init(bio);
> + if (err)
> + atomic_inc(&pkt->io_errors);
> + if (atomic_dec_and_test(&pkt->io_wait)) {
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> + }
> + pkt_bio_finished(pd);
> +}
>
> - bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL);
> - if (!bvl)
> - goto no_bvl;
> +static void pkt_end_io_packet_write(struct bio *bio, int err)
> +{
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> - bio->bi_max_vecs = nr_iovecs;
> - bio->bi_io_vec = bvl;
> - bio->bi_destructor = pkt_bio_destructor;
> + VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
>
> - return bio;
> + pd->stats.pkt_ended++;
>
> - no_bvl:
> - kfree(bio);
> - no_bio:
> - return NULL;
> + pkt_bio_finished(pd);
> + atomic_dec(&pkt->io_wait);
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> }
>
> /*
> @@ -567,10 +569,13 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> goto no_pkt;
>
> pkt->frames = frames;
> - pkt->w_bio = pkt_bio_alloc(frames);
> + pkt->w_bio = bio_kmalloc(GFP_KERNEL, frames);
> if (!pkt->w_bio)
> goto no_bio;
>
> + pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> + pkt->w_bio->bi_private = pkt;
> +
> for (i = 0; i < frames / FRAMES_PER_PAGE; i++) {
> pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO);
> if (!pkt->pages[i])
> @@ -581,9 +586,12 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> bio_list_init(&pkt->orig_bios);
>
> for (i = 0; i < frames; i++) {
> - struct bio *bio = pkt_bio_alloc(1);
> + struct bio *bio = bio_kmalloc(GFP_KERNEL, 1);
> if (!bio)
> goto no_rd_bio;
> +
> + bio->bi_end_io = pkt_end_io_read;
> + bio->bi_private = pkt;
> pkt->r_bios[i] = bio;
> }
>
> @@ -1036,40 +1044,6 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec)
> }
> }
>
> -static void pkt_end_io_read(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> - (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
> -
> - if (err)
> - atomic_inc(&pkt->io_errors);
> - if (atomic_dec_and_test(&pkt->io_wait)) {
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> - }
> - pkt_bio_finished(pd);
> -}
> -
> -static void pkt_end_io_packet_write(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
> -
> - pd->stats.pkt_ended++;
> -
> - pkt_bio_finished(pd);
> - atomic_dec(&pkt->io_wait);
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> -}
> -
> /*
> * Schedule reads for the holes in a packet
> */
> @@ -1111,21 +1085,15 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
> * Schedule reads for missing parts of the packet.
> */
> for (f = 0; f < pkt->frames; f++) {
> - struct bio_vec *vec;
> -
> int p, offset;
> +
> if (written[f])
> continue;
> +
> bio = pkt->r_bios[f];
> - vec = bio->bi_io_vec;
> - bio_init(bio);
> - bio->bi_max_vecs = 1;
> - bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> - bio->bi_bdev = pd->bdev;
> - bio->bi_end_io = pkt_end_io_read;
> - bio->bi_private = pkt;
> - bio->bi_io_vec = vec;
> - bio->bi_destructor = pkt_bio_destructor;
> + bio_reset(bio);
> + bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> + bio->bi_bdev = pd->bdev;
>
> p = (f * CD_FRAMESIZE) / PAGE_SIZE;
> offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
> @@ -1418,14 +1386,9 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
> }
>
> /* Start the write request */
> - bio_init(pkt->w_bio);
> - pkt->w_bio->bi_max_vecs = PACKET_MAX_SIZE;
> + bio_reset(pkt->w_bio);
> pkt->w_bio->bi_sector = pkt->sector;
> pkt->w_bio->bi_bdev = pd->bdev;
> - pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> - pkt->w_bio->bi_private = pkt;
> - pkt->w_bio->bi_io_vec = bvec;
> - pkt->w_bio->bi_destructor = pkt_bio_destructor;
> for (f = 0; f < pkt->frames; f++)
> if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
> BUG();
WARNING: multiple messages have this Message-ID (diff)
From: Boaz Harrosh <bharrosh@panasas.com>
To: Kent Overstreet <koverstreet@google.com>
Cc: axboe@kernel.dk, dm-devel@redhat.com, neilb@suse.de,
linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org,
mpatocka@redhat.com, vgoyal@redhat.com, yehuda@hq.newdream.net,
tj@kernel.org, sage@newdream.net, agk@redhat.com,
drbd-dev@lists.linbit.com
Subject: Re: [Drbd-dev] [PATCH v4 04/12] pktcdvd: Switch to bio_kmalloc()
Date: Wed, 25 Jul 2012 14:29:59 +0300 [thread overview]
Message-ID: <500FD8B7.9040701@panasas.com> (raw)
In-Reply-To: <1343160689-12378-5-git-send-email-koverstreet@google.com>
On 07/24/2012 11:11 PM, Kent Overstreet wrote:
> This is prep work for killing bi_destructor - previously, pktcdvd had
> its own pkt_bio_alloc which was basically duplication bio_kmalloc(),
> necessitating its own bi_destructor implementation.
>
> Signed-off-by: Kent Overstreet <koverstreet@google.com>
> ---
> drivers/block/pktcdvd.c | 115 ++++++++++++++++-------------------------------
> 1 files changed, 39 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index ba66e44..6fe693a 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -522,36 +522,38 @@ static void pkt_bio_finished(struct pktcdvd_device *pd)
> }
> }
>
> -static void pkt_bio_destructor(struct bio *bio)
> +static void pkt_end_io_read(struct bio *bio, int err)
> {
> - kfree(bio->bi_io_vec);
> - kfree(bio);
> -}
Again here, you decided to move the pkt_end_io_read && pkt_end_io_packet_write
functions from below, to above here. Which makes it impossible to find
any bugs by just reviewing the patch.
So I have not reviewed it.
I know that you wanted so you can reference them at pkt_alloc_packet_data.
I'd use a forward reference, in this case. And a move in a next patch. But
this is just me. Perhaps the owner of this code can review it?
Cheers
Boaz
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> -static struct bio *pkt_bio_alloc(int nr_iovecs)
> -{
> - struct bio_vec *bvl = NULL;
> - struct bio *bio;
> + VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> + (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
>
> - bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
> - if (!bio)
> - goto no_bio;
> - bio_init(bio);
> + if (err)
> + atomic_inc(&pkt->io_errors);
> + if (atomic_dec_and_test(&pkt->io_wait)) {
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> + }
> + pkt_bio_finished(pd);
> +}
>
> - bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL);
> - if (!bvl)
> - goto no_bvl;
> +static void pkt_end_io_packet_write(struct bio *bio, int err)
> +{
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> - bio->bi_max_vecs = nr_iovecs;
> - bio->bi_io_vec = bvl;
> - bio->bi_destructor = pkt_bio_destructor;
> + VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
>
> - return bio;
> + pd->stats.pkt_ended++;
>
> - no_bvl:
> - kfree(bio);
> - no_bio:
> - return NULL;
> + pkt_bio_finished(pd);
> + atomic_dec(&pkt->io_wait);
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> }
>
> /*
> @@ -567,10 +569,13 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> goto no_pkt;
>
> pkt->frames = frames;
> - pkt->w_bio = pkt_bio_alloc(frames);
> + pkt->w_bio = bio_kmalloc(GFP_KERNEL, frames);
> if (!pkt->w_bio)
> goto no_bio;
>
> + pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> + pkt->w_bio->bi_private = pkt;
> +
> for (i = 0; i < frames / FRAMES_PER_PAGE; i++) {
> pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO);
> if (!pkt->pages[i])
> @@ -581,9 +586,12 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> bio_list_init(&pkt->orig_bios);
>
> for (i = 0; i < frames; i++) {
> - struct bio *bio = pkt_bio_alloc(1);
> + struct bio *bio = bio_kmalloc(GFP_KERNEL, 1);
> if (!bio)
> goto no_rd_bio;
> +
> + bio->bi_end_io = pkt_end_io_read;
> + bio->bi_private = pkt;
> pkt->r_bios[i] = bio;
> }
>
> @@ -1036,40 +1044,6 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec)
> }
> }
>
> -static void pkt_end_io_read(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> - (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
> -
> - if (err)
> - atomic_inc(&pkt->io_errors);
> - if (atomic_dec_and_test(&pkt->io_wait)) {
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> - }
> - pkt_bio_finished(pd);
> -}
> -
> -static void pkt_end_io_packet_write(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
> -
> - pd->stats.pkt_ended++;
> -
> - pkt_bio_finished(pd);
> - atomic_dec(&pkt->io_wait);
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> -}
> -
> /*
> * Schedule reads for the holes in a packet
> */
> @@ -1111,21 +1085,15 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
> * Schedule reads for missing parts of the packet.
> */
> for (f = 0; f < pkt->frames; f++) {
> - struct bio_vec *vec;
> -
> int p, offset;
> +
> if (written[f])
> continue;
> +
> bio = pkt->r_bios[f];
> - vec = bio->bi_io_vec;
> - bio_init(bio);
> - bio->bi_max_vecs = 1;
> - bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> - bio->bi_bdev = pd->bdev;
> - bio->bi_end_io = pkt_end_io_read;
> - bio->bi_private = pkt;
> - bio->bi_io_vec = vec;
> - bio->bi_destructor = pkt_bio_destructor;
> + bio_reset(bio);
> + bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> + bio->bi_bdev = pd->bdev;
>
> p = (f * CD_FRAMESIZE) / PAGE_SIZE;
> offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
> @@ -1418,14 +1386,9 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
> }
>
> /* Start the write request */
> - bio_init(pkt->w_bio);
> - pkt->w_bio->bi_max_vecs = PACKET_MAX_SIZE;
> + bio_reset(pkt->w_bio);
> pkt->w_bio->bi_sector = pkt->sector;
> pkt->w_bio->bi_bdev = pd->bdev;
> - pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> - pkt->w_bio->bi_private = pkt;
> - pkt->w_bio->bi_io_vec = bvec;
> - pkt->w_bio->bi_destructor = pkt_bio_destructor;
> for (f = 0; f < pkt->frames; f++)
> if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
> BUG();
WARNING: multiple messages have this Message-ID (diff)
From: Boaz Harrosh <bharrosh@panasas.com>
To: Kent Overstreet <koverstreet@google.com>
Cc: <linux-bcache@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<dm-devel@redhat.com>, <tj@kernel.org>, <axboe@kernel.dk>,
<agk@redhat.com>, <neilb@suse.de>, <drbd-dev@lists.linbit.com>,
<vgoyal@redhat.com>, <mpatocka@redhat.com>, <sage@newdream.net>,
<yehuda@hq.newdream.net>
Subject: Re: [PATCH v4 04/12] pktcdvd: Switch to bio_kmalloc()
Date: Wed, 25 Jul 2012 14:29:59 +0300 [thread overview]
Message-ID: <500FD8B7.9040701@panasas.com> (raw)
In-Reply-To: <1343160689-12378-5-git-send-email-koverstreet@google.com>
On 07/24/2012 11:11 PM, Kent Overstreet wrote:
> This is prep work for killing bi_destructor - previously, pktcdvd had
> its own pkt_bio_alloc which was basically duplication bio_kmalloc(),
> necessitating its own bi_destructor implementation.
>
> Signed-off-by: Kent Overstreet <koverstreet@google.com>
> ---
> drivers/block/pktcdvd.c | 115 ++++++++++++++++-------------------------------
> 1 files changed, 39 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index ba66e44..6fe693a 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -522,36 +522,38 @@ static void pkt_bio_finished(struct pktcdvd_device *pd)
> }
> }
>
> -static void pkt_bio_destructor(struct bio *bio)
> +static void pkt_end_io_read(struct bio *bio, int err)
> {
> - kfree(bio->bi_io_vec);
> - kfree(bio);
> -}
Again here, you decided to move the pkt_end_io_read && pkt_end_io_packet_write
functions from below, to above here. Which makes it impossible to find
any bugs by just reviewing the patch.
So I have not reviewed it.
I know that you wanted so you can reference them at pkt_alloc_packet_data.
I'd use a forward reference, in this case. And a move in a next patch. But
this is just me. Perhaps the owner of this code can review it?
Cheers
Boaz
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> -static struct bio *pkt_bio_alloc(int nr_iovecs)
> -{
> - struct bio_vec *bvl = NULL;
> - struct bio *bio;
> + VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> + (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
>
> - bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
> - if (!bio)
> - goto no_bio;
> - bio_init(bio);
> + if (err)
> + atomic_inc(&pkt->io_errors);
> + if (atomic_dec_and_test(&pkt->io_wait)) {
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> + }
> + pkt_bio_finished(pd);
> +}
>
> - bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL);
> - if (!bvl)
> - goto no_bvl;
> +static void pkt_end_io_packet_write(struct bio *bio, int err)
> +{
> + struct packet_data *pkt = bio->bi_private;
> + struct pktcdvd_device *pd = pkt->pd;
> + BUG_ON(!pd);
>
> - bio->bi_max_vecs = nr_iovecs;
> - bio->bi_io_vec = bvl;
> - bio->bi_destructor = pkt_bio_destructor;
> + VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
>
> - return bio;
> + pd->stats.pkt_ended++;
>
> - no_bvl:
> - kfree(bio);
> - no_bio:
> - return NULL;
> + pkt_bio_finished(pd);
> + atomic_dec(&pkt->io_wait);
> + atomic_inc(&pkt->run_sm);
> + wake_up(&pd->wqueue);
> }
>
> /*
> @@ -567,10 +569,13 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> goto no_pkt;
>
> pkt->frames = frames;
> - pkt->w_bio = pkt_bio_alloc(frames);
> + pkt->w_bio = bio_kmalloc(GFP_KERNEL, frames);
> if (!pkt->w_bio)
> goto no_bio;
>
> + pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> + pkt->w_bio->bi_private = pkt;
> +
> for (i = 0; i < frames / FRAMES_PER_PAGE; i++) {
> pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO);
> if (!pkt->pages[i])
> @@ -581,9 +586,12 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
> bio_list_init(&pkt->orig_bios);
>
> for (i = 0; i < frames; i++) {
> - struct bio *bio = pkt_bio_alloc(1);
> + struct bio *bio = bio_kmalloc(GFP_KERNEL, 1);
> if (!bio)
> goto no_rd_bio;
> +
> + bio->bi_end_io = pkt_end_io_read;
> + bio->bi_private = pkt;
> pkt->r_bios[i] = bio;
> }
>
> @@ -1036,40 +1044,6 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec)
> }
> }
>
> -static void pkt_end_io_read(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
> - (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
> -
> - if (err)
> - atomic_inc(&pkt->io_errors);
> - if (atomic_dec_and_test(&pkt->io_wait)) {
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> - }
> - pkt_bio_finished(pd);
> -}
> -
> -static void pkt_end_io_packet_write(struct bio *bio, int err)
> -{
> - struct packet_data *pkt = bio->bi_private;
> - struct pktcdvd_device *pd = pkt->pd;
> - BUG_ON(!pd);
> -
> - VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
> -
> - pd->stats.pkt_ended++;
> -
> - pkt_bio_finished(pd);
> - atomic_dec(&pkt->io_wait);
> - atomic_inc(&pkt->run_sm);
> - wake_up(&pd->wqueue);
> -}
> -
> /*
> * Schedule reads for the holes in a packet
> */
> @@ -1111,21 +1085,15 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
> * Schedule reads for missing parts of the packet.
> */
> for (f = 0; f < pkt->frames; f++) {
> - struct bio_vec *vec;
> -
> int p, offset;
> +
> if (written[f])
> continue;
> +
> bio = pkt->r_bios[f];
> - vec = bio->bi_io_vec;
> - bio_init(bio);
> - bio->bi_max_vecs = 1;
> - bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> - bio->bi_bdev = pd->bdev;
> - bio->bi_end_io = pkt_end_io_read;
> - bio->bi_private = pkt;
> - bio->bi_io_vec = vec;
> - bio->bi_destructor = pkt_bio_destructor;
> + bio_reset(bio);
> + bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
> + bio->bi_bdev = pd->bdev;
>
> p = (f * CD_FRAMESIZE) / PAGE_SIZE;
> offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
> @@ -1418,14 +1386,9 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
> }
>
> /* Start the write request */
> - bio_init(pkt->w_bio);
> - pkt->w_bio->bi_max_vecs = PACKET_MAX_SIZE;
> + bio_reset(pkt->w_bio);
> pkt->w_bio->bi_sector = pkt->sector;
> pkt->w_bio->bi_bdev = pd->bdev;
> - pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
> - pkt->w_bio->bi_private = pkt;
> - pkt->w_bio->bi_io_vec = bvec;
> - pkt->w_bio->bi_destructor = pkt_bio_destructor;
> for (f = 0; f < pkt->frames; f++)
> if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
> BUG();
next prev parent reply other threads:[~2012-07-25 11:29 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-24 20:11 [PATCH v4 00/12] Block cleanups Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 01/12] block: Generalized bio pool freeing Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-2-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 11:06 ` Boaz Harrosh
2012-07-25 11:06 ` Boaz Harrosh
2012-07-25 11:06 ` [Drbd-dev] " Boaz Harrosh
[not found] ` <500FD32F.2010809-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2012-07-25 23:38 ` Kent Overstreet
2012-07-25 23:38 ` Kent Overstreet
2012-07-25 23:38 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 02/12] dm: Use bioset's front_pad for dm_rq_clone_bio_info Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 03/12] block: Add bio_reset() Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-4-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 11:19 ` Boaz Harrosh
2012-07-25 11:19 ` Boaz Harrosh
2012-07-25 11:19 ` [Drbd-dev] " Boaz Harrosh
[not found] ` <500FD63F.7050501-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2012-07-25 22:56 ` Kent Overstreet
2012-07-25 22:56 ` Kent Overstreet
2012-07-25 22:56 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 04/12] pktcdvd: Switch to bio_kmalloc() Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-5-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 11:29 ` Boaz Harrosh [this message]
2012-07-25 11:29 ` Boaz Harrosh
2012-07-25 11:29 ` [Drbd-dev] " Boaz Harrosh
[not found] ` <500FD8B7.9040701-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2012-07-25 23:01 ` Kent Overstreet
2012-07-25 23:01 ` Kent Overstreet
2012-07-25 23:01 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 05/12] block: Kill bi_destructor Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-6-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 11:39 ` Boaz Harrosh
2012-07-25 11:39 ` Boaz Harrosh
2012-07-25 11:39 ` [Drbd-dev] " Boaz Harrosh
[not found] ` <500FDB0D.4070605-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2012-07-25 23:15 ` Kent Overstreet
2012-07-25 23:15 ` Kent Overstreet
2012-07-25 23:15 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 06/12] block: Add an explicit bio flag for bios that own their bvec Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 08/12] block: Introduce new bio_split() Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-25 11:55 ` Boaz Harrosh
2012-07-25 11:55 ` Boaz Harrosh
2012-07-25 11:55 ` [Drbd-dev] " Boaz Harrosh
2012-07-25 23:26 ` Kent Overstreet
2012-07-25 23:26 ` [Drbd-dev] " Kent Overstreet
2012-07-27 0:50 ` [PATCH] A possible deadlock with stacked devices (was: [PATCH v4 08/12] block: Introduce new bio_split()) Mikulas Patocka
2012-07-27 0:50 ` [Drbd-dev] " Mikulas Patocka
2012-08-15 23:07 ` Kent Overstreet
2012-08-15 23:07 ` [Drbd-dev] " Kent Overstreet
[not found] ` <20120815230715.GD2758-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-29 16:08 ` Mikulas Patocka
2012-08-29 16:08 ` Mikulas Patocka
[not found] ` <1343160689-12378-1-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-24 20:11 ` [PATCH v4 07/12] block: Rename bio_split() -> bio_pair_split() Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 09/12] block: Rework bio_pair_split() Kent Overstreet
2012-07-24 20:11 ` Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-10-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 12:03 ` Boaz Harrosh
2012-07-25 12:03 ` Boaz Harrosh
2012-07-25 12:03 ` [Drbd-dev] " Boaz Harrosh
2012-07-24 20:11 ` [PATCH v4 10/12] block: Add bio_clone_kmalloc() Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-11-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-07-25 12:05 ` Boaz Harrosh
2012-07-25 12:05 ` Boaz Harrosh
2012-07-25 12:05 ` [Drbd-dev] " Boaz Harrosh
2012-07-24 20:11 ` [PATCH v4 11/12] block: Add bio_clone_bioset() Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
2012-07-24 20:11 ` [PATCH v4 12/12] block: Only clone bio vecs that are in use Kent Overstreet
2012-07-24 20:11 ` [Drbd-dev] " Kent Overstreet
[not found] ` <1343160689-12378-13-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-07 3:17 ` Muthu Kumar
2012-08-07 3:17 ` Muthu Kumar
2012-08-07 3:17 ` [Drbd-dev] " Muthu Kumar
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=500FD8B7.9040701@panasas.com \
--to=bharrosh-c4p08nqkorlbdgjk7y7tuq@public.gmane.org \
--cc=agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org \
--cc=koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mpatocka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=neilb-l3A5Bk7waGM@public.gmane.org \
--cc=sage-BnTBU8nroG7k1uMJSBkQmQ@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=yehuda-L5o5AL9CYN0tUFlbccrkMA@public.gmane.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.