aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 20:04:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 20:04:23 -0400
commitce40be7a820bb393ac4ac69865f018d2f4038cf0 (patch)
treeb1fe5a93346eb06f22b1c303d63ec5456d7212ab /drivers/block
parentba0a5a36f60e4c1152af3a2ae2813251974405bf (diff)
parent02f3939e1a9357b7c370a4a69717cf9c02452737 (diff)
Merge branch 'for-3.7/core' of git://git.kernel.dk/linux-block
Pull block IO update from Jens Axboe: "Core block IO bits for 3.7. Not a huge round this time, it contains: - First series from Kent cleaning up and generalizing bio allocation and freeing. - WRITE_SAME support from Martin. - Mikulas patches to prevent O_DIRECT crashes when someone changes the block size of a device. - Make bio_split() work on data-less bio's (like trim/discards). - A few other minor fixups." Fixed up silent semantic mis-merge as per Mikulas Patocka and Andrew Morton. It is due to the VM no longer using a prio-tree (see commit 6b2dbba8b6ac: "mm: replace vma prio_tree with an interval tree"). So make set_blocksize() use mapping_mapped() instead of open-coding the internal VM knowledge that has changed. * 'for-3.7/core' of git://git.kernel.dk/linux-block: (26 commits) block: makes bio_split support bio without data scatterlist: refactor the sg_nents scatterlist: add sg_nents fs: fix include/percpu-rwsem.h export error percpu-rw-semaphore: fix documentation typos fs/block_dev.c:1644:5: sparse: symbol 'blkdev_mmap' was not declared blockdev: turn a rw semaphore into a percpu rw semaphore Fix a crash when block device is read and block size is changed at the same time block: fix request_queue->flags initialization block: lift the initial queue bypass mode on blk_register_queue() instead of blk_init_allocated_queue() block: ioctl to zero block ranges block: Make blkdev_issue_zeroout use WRITE SAME block: Implement support for WRITE SAME block: Consolidate command flag and queue limit checks for merges block: Clean up special command handling logic block/blk-tag.c: Remove useless kfree block: remove the duplicated setting for congestion_threshold block: reject invalid queue attribute values block: Add bio_clone_bioset(), bio_clone_kmalloc() block: Consolidate bio_alloc_bioset(), bio_kmalloc() ...
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_main.c13
-rw-r--r--drivers/block/osdblk.c3
-rw-r--r--drivers/block/pktcdvd.c52
3 files changed, 9 insertions, 59 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index f93a0320e952..f55683ad4ffa 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -162,23 +162,12 @@ static const struct block_device_operations drbd_ops = {
162 .release = drbd_release, 162 .release = drbd_release,
163}; 163};
164 164
165static void bio_destructor_drbd(struct bio *bio)
166{
167 bio_free(bio, drbd_md_io_bio_set);
168}
169
170struct bio *bio_alloc_drbd(gfp_t gfp_mask) 165struct bio *bio_alloc_drbd(gfp_t gfp_mask)
171{ 166{
172 struct bio *bio;
173
174 if (!drbd_md_io_bio_set) 167 if (!drbd_md_io_bio_set)
175 return bio_alloc(gfp_mask, 1); 168 return bio_alloc(gfp_mask, 1);
176 169
177 bio = bio_alloc_bioset(gfp_mask, 1, drbd_md_io_bio_set); 170 return bio_alloc_bioset(gfp_mask, 1, drbd_md_io_bio_set);
178 if (!bio)
179 return NULL;
180 bio->bi_destructor = bio_destructor_drbd;
181 return bio;
182} 171}
183 172
184#ifdef __CHECKER__ 173#ifdef __CHECKER__
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c
index 87311ebac0db..1bbc681688e4 100644
--- a/drivers/block/osdblk.c
+++ b/drivers/block/osdblk.c
@@ -266,11 +266,10 @@ static struct bio *bio_chain_clone(struct bio *old_chain, gfp_t gfpmask)
266 struct bio *tmp, *new_chain = NULL, *tail = NULL; 266 struct bio *tmp, *new_chain = NULL, *tail = NULL;
267 267
268 while (old_chain) { 268 while (old_chain) {
269 tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs); 269 tmp = bio_clone_kmalloc(old_chain, gfpmask);
270 if (!tmp) 270 if (!tmp)
271 goto err_out; 271 goto err_out;
272 272
273 __bio_clone(tmp, old_chain);
274 tmp->bi_bdev = NULL; 273 tmp->bi_bdev = NULL;
275 gfpmask &= ~__GFP_WAIT; 274 gfpmask &= ~__GFP_WAIT;
276 tmp->bi_next = NULL; 275 tmp->bi_next = NULL;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index ba66e4445f41..2e7de7a59bfc 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -522,38 +522,6 @@ static void pkt_bio_finished(struct pktcdvd_device *pd)
522 } 522 }
523} 523}
524 524
525static void pkt_bio_destructor(struct bio *bio)
526{
527 kfree(bio->bi_io_vec);
528 kfree(bio);
529}
530
531static struct bio *pkt_bio_alloc(int nr_iovecs)
532{
533 struct bio_vec *bvl = NULL;
534 struct bio *bio;
535
536 bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
537 if (!bio)
538 goto no_bio;
539 bio_init(bio);
540
541 bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL);
542 if (!bvl)
543 goto no_bvl;
544
545 bio->bi_max_vecs = nr_iovecs;
546 bio->bi_io_vec = bvl;
547 bio->bi_destructor = pkt_bio_destructor;
548
549 return bio;
550
551 no_bvl:
552 kfree(bio);
553 no_bio:
554 return NULL;
555}
556
557/* 525/*
558 * Allocate a packet_data struct 526 * Allocate a packet_data struct
559 */ 527 */
@@ -567,7 +535,7 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
567 goto no_pkt; 535 goto no_pkt;
568 536
569 pkt->frames = frames; 537 pkt->frames = frames;
570 pkt->w_bio = pkt_bio_alloc(frames); 538 pkt->w_bio = bio_kmalloc(GFP_KERNEL, frames);
571 if (!pkt->w_bio) 539 if (!pkt->w_bio)
572 goto no_bio; 540 goto no_bio;
573 541
@@ -581,9 +549,10 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
581 bio_list_init(&pkt->orig_bios); 549 bio_list_init(&pkt->orig_bios);
582 550
583 for (i = 0; i < frames; i++) { 551 for (i = 0; i < frames; i++) {
584 struct bio *bio = pkt_bio_alloc(1); 552 struct bio *bio = bio_kmalloc(GFP_KERNEL, 1);
585 if (!bio) 553 if (!bio)
586 goto no_rd_bio; 554 goto no_rd_bio;
555
587 pkt->r_bios[i] = bio; 556 pkt->r_bios[i] = bio;
588 } 557 }
589 558
@@ -1111,21 +1080,17 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
1111 * Schedule reads for missing parts of the packet. 1080 * Schedule reads for missing parts of the packet.
1112 */ 1081 */
1113 for (f = 0; f < pkt->frames; f++) { 1082 for (f = 0; f < pkt->frames; f++) {
1114 struct bio_vec *vec;
1115
1116 int p, offset; 1083 int p, offset;
1084
1117 if (written[f]) 1085 if (written[f])
1118 continue; 1086 continue;
1087
1119 bio = pkt->r_bios[f]; 1088 bio = pkt->r_bios[f];
1120 vec = bio->bi_io_vec; 1089 bio_reset(bio);
1121 bio_init(bio);
1122 bio->bi_max_vecs = 1;
1123 bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9); 1090 bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
1124 bio->bi_bdev = pd->bdev; 1091 bio->bi_bdev = pd->bdev;
1125 bio->bi_end_io = pkt_end_io_read; 1092 bio->bi_end_io = pkt_end_io_read;
1126 bio->bi_private = pkt; 1093 bio->bi_private = pkt;
1127 bio->bi_io_vec = vec;
1128 bio->bi_destructor = pkt_bio_destructor;
1129 1094
1130 p = (f * CD_FRAMESIZE) / PAGE_SIZE; 1095 p = (f * CD_FRAMESIZE) / PAGE_SIZE;
1131 offset = (f * CD_FRAMESIZE) % PAGE_SIZE; 1096 offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
@@ -1418,14 +1383,11 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
1418 } 1383 }
1419 1384
1420 /* Start the write request */ 1385 /* Start the write request */
1421 bio_init(pkt->w_bio); 1386 bio_reset(pkt->w_bio);
1422 pkt->w_bio->bi_max_vecs = PACKET_MAX_SIZE;
1423 pkt->w_bio->bi_sector = pkt->sector; 1387 pkt->w_bio->bi_sector = pkt->sector;
1424 pkt->w_bio->bi_bdev = pd->bdev; 1388 pkt->w_bio->bi_bdev = pd->bdev;
1425 pkt->w_bio->bi_end_io = pkt_end_io_packet_write; 1389 pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
1426 pkt->w_bio->bi_private = pkt; 1390 pkt->w_bio->bi_private = pkt;
1427 pkt->w_bio->bi_io_vec = bvec;
1428 pkt->w_bio->bi_destructor = pkt_bio_destructor;
1429 for (f = 0; f < pkt->frames; f++) 1391 for (f = 0; f < pkt->frames; f++)
1430 if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset)) 1392 if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
1431 BUG(); 1393 BUG();