Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Commit b4f42e2

Browse files
committed
block: remove struct request buffer member
This was used in the olden days, back when onions were proper yellow. Basically it mapped to the current buffer to be transferred. With highmem being added more than a decade ago, most drivers map pages out of a bio, and rq->buffer isn't pointing at anything valid. Convert old style drivers to just use bio_data(). For the discard payload use case, just reference the page in the bio. Signed-off-by: Jens Axboe <[email protected]>
1 parent f89e0dd commit b4f42e2

23 files changed

Lines changed: 55 additions & 75 deletions

File tree

block/blk-core.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ void blk_dump_rq_flags(struct request *rq, char *msg)
146146
printk(KERN_INFO " sector %llu, nr/cnr %u/%u\n",
147147
(unsigned long long)blk_rq_pos(rq),
148148
blk_rq_sectors(rq), blk_rq_cur_sectors(rq));
149-
printk(KERN_INFO " bio %p, biotail %p, buffer %p, len %u\n",
150-
rq->bio, rq->biotail, rq->buffer, blk_rq_bytes(rq));
149+
printk(KERN_INFO " bio %p, biotail %p, len %u\n",
150+
rq->bio, rq->biotail, blk_rq_bytes(rq));
151151

152152
if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
153153
printk(KERN_INFO " cdb: ");
@@ -1360,7 +1360,6 @@ void blk_add_request_payload(struct request *rq, struct page *page,
13601360

13611361
rq->__data_len = rq->resid_len = len;
13621362
rq->nr_phys_segments = 1;
1363-
rq->buffer = bio_data(bio);
13641363
}
13651364
EXPORT_SYMBOL_GPL(blk_add_request_payload);
13661365

@@ -1402,12 +1401,6 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
14021401
bio->bi_next = req->bio;
14031402
req->bio = bio;
14041403

1405-
/*
1406-
* may not be valid. if the low level driver said
1407-
* it didn't need a bounce buffer then it better
1408-
* not touch req->buffer either...
1409-
*/
1410-
req->buffer = bio_data(bio);
14111404
req->__sector = bio->bi_iter.bi_sector;
14121405
req->__data_len += bio->bi_iter.bi_size;
14131406
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
@@ -2434,7 +2427,6 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
24342427
}
24352428

24362429
req->__data_len -= total_bytes;
2437-
req->buffer = bio_data(req->bio);
24382430

24392431
/* update sector only for requests with clear definition of sector */
24402432
if (req->cmd_type == REQ_TYPE_FS)
@@ -2752,10 +2744,9 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
27522744
/* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw */
27532745
rq->cmd_flags |= bio->bi_rw & REQ_WRITE;
27542746

2755-
if (bio_has_data(bio)) {
2747+
if (bio_has_data(bio))
27562748
rq->nr_phys_segments = bio_phys_segments(q, bio);
2757-
rq->buffer = bio_data(bio);
2758-
}
2749+
27592750
rq->__data_len = bio->bi_iter.bi_size;
27602751
rq->bio = rq->biotail = bio;
27612752

@@ -2831,7 +2822,7 @@ EXPORT_SYMBOL_GPL(blk_rq_unprep_clone);
28312822

28322823
/*
28332824
* Copy attributes of the original request to the clone request.
2834-
* The actual data parts (e.g. ->cmd, ->buffer, ->sense) are not copied.
2825+
* The actual data parts (e.g. ->cmd, ->sense) are not copied.
28352826
*/
28362827
static void __blk_rq_prep_clone(struct request *dst, struct request *src)
28372828
{
@@ -2857,7 +2848,7 @@ static void __blk_rq_prep_clone(struct request *dst, struct request *src)
28572848
*
28582849
* Description:
28592850
* Clones bios in @rq_src to @rq, and copies attributes of @rq_src to @rq.
2860-
* The actual data parts of @rq_src (e.g. ->cmd, ->buffer, ->sense)
2851+
* The actual data parts of @rq_src (e.g. ->cmd, ->sense)
28612852
* are not copied, and copying such parts is the caller's responsibility.
28622853
* Also, pages which the original bios are pointing to are not copied
28632854
* and the cloned bios just point same pages.

block/blk-map.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
155155
if (!bio_flagged(bio, BIO_USER_MAPPED))
156156
rq->cmd_flags |= REQ_COPY_USER;
157157

158-
rq->buffer = NULL;
159158
return 0;
160159
unmap_rq:
161160
blk_rq_unmap_user(bio);
@@ -238,7 +237,6 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
238237
blk_queue_bounce(q, &bio);
239238
bio_get(bio);
240239
blk_rq_bio_prep(q, rq, bio);
241-
rq->buffer = NULL;
242240
return 0;
243241
}
244242
EXPORT_SYMBOL(blk_rq_map_user_iov);
@@ -325,7 +323,6 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
325323
}
326324

327325
blk_queue_bounce(q, &rq->bio);
328-
rq->buffer = NULL;
329326
return 0;
330327
}
331328
EXPORT_SYMBOL(blk_rq_map_kern);

drivers/block/amiflop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ static void redo_fd_request(void)
14061406

14071407
track = block / (floppy->dtype->sects * floppy->type->sect_mult);
14081408
sector = block % (floppy->dtype->sects * floppy->type->sect_mult);
1409-
data = rq->buffer + 512 * cnt;
1409+
data = bio_data(rq->bio) + 512 * cnt;
14101410
#ifdef DEBUG
14111411
printk("access to track %d, sector %d, with buffer at "
14121412
"0x%08lx\n", track, sector, data);

drivers/block/ataflop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ static void redo_fd_request(void)
14841484
ReqCnt = 0;
14851485
ReqCmd = rq_data_dir(fd_request);
14861486
ReqBlock = blk_rq_pos(fd_request);
1487-
ReqBuffer = fd_request->buffer;
1487+
ReqBuffer = bio_data(fd_request->bio);
14881488
setup_req_params( drive );
14891489
do_fd_action( drive );
14901490

drivers/block/floppy.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ static void rw_interrupt(void)
23512351
}
23522352

23532353
if (CT(COMMAND) != FD_READ ||
2354-
raw_cmd->kernel_data == current_req->buffer) {
2354+
raw_cmd->kernel_data == bio_data(current_req->bio)) {
23552355
/* transfer directly from buffer */
23562356
cont->done(1);
23572357
} else if (CT(COMMAND) == FD_READ) {
@@ -2640,7 +2640,7 @@ static int make_raw_rw_request(void)
26402640
raw_cmd->flags &= ~FD_RAW_WRITE;
26412641
raw_cmd->flags |= FD_RAW_READ;
26422642
COMMAND = FM_MODE(_floppy, FD_READ);
2643-
} else if ((unsigned long)current_req->buffer < MAX_DMA_ADDRESS) {
2643+
} else if ((unsigned long)bio_data(current_req->bio) < MAX_DMA_ADDRESS) {
26442644
unsigned long dma_limit;
26452645
int direct, indirect;
26462646

@@ -2654,13 +2654,13 @@ static int make_raw_rw_request(void)
26542654
*/
26552655
max_size = buffer_chain_size();
26562656
dma_limit = (MAX_DMA_ADDRESS -
2657-
((unsigned long)current_req->buffer)) >> 9;
2657+
((unsigned long)bio_data(current_req->bio))) >> 9;
26582658
if ((unsigned long)max_size > dma_limit)
26592659
max_size = dma_limit;
26602660
/* 64 kb boundaries */
2661-
if (CROSS_64KB(current_req->buffer, max_size << 9))
2661+
if (CROSS_64KB(bio_data(current_req->bio), max_size << 9))
26622662
max_size = (K_64 -
2663-
((unsigned long)current_req->buffer) %
2663+
((unsigned long)bio_data(current_req->bio)) %
26642664
K_64) >> 9;
26652665
direct = transfer_size(ssize, max_sector, max_size) - fsector_t;
26662666
/*
@@ -2677,7 +2677,7 @@ static int make_raw_rw_request(void)
26772677
(DP->read_track & (1 << DRS->probed_format)))))) {
26782678
max_size = blk_rq_sectors(current_req);
26792679
} else {
2680-
raw_cmd->kernel_data = current_req->buffer;
2680+
raw_cmd->kernel_data = bio_data(current_req->bio);
26812681
raw_cmd->length = current_count_sectors << 9;
26822682
if (raw_cmd->length == 0) {
26832683
DPRINT("%s: zero dma transfer attempted\n", __func__);
@@ -2731,15 +2731,15 @@ static int make_raw_rw_request(void)
27312731
raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1;
27322732
raw_cmd->length <<= 9;
27332733
if ((raw_cmd->length < current_count_sectors << 9) ||
2734-
(raw_cmd->kernel_data != current_req->buffer &&
2734+
(raw_cmd->kernel_data != bio_data(current_req->bio) &&
27352735
CT(COMMAND) == FD_WRITE &&
27362736
(aligned_sector_t + (raw_cmd->length >> 9) > buffer_max ||
27372737
aligned_sector_t < buffer_min)) ||
27382738
raw_cmd->length % (128 << SIZECODE) ||
27392739
raw_cmd->length <= 0 || current_count_sectors <= 0) {
27402740
DPRINT("fractionary current count b=%lx s=%lx\n",
27412741
raw_cmd->length, current_count_sectors);
2742-
if (raw_cmd->kernel_data != current_req->buffer)
2742+
if (raw_cmd->kernel_data != bio_data(current_req->bio))
27432743
pr_info("addr=%d, length=%ld\n",
27442744
(int)((raw_cmd->kernel_data -
27452745
floppy_track_buffer) >> 9),
@@ -2756,7 +2756,7 @@ static int make_raw_rw_request(void)
27562756
return 0;
27572757
}
27582758

2759-
if (raw_cmd->kernel_data != current_req->buffer) {
2759+
if (raw_cmd->kernel_data != bio_data(current_req->bio)) {
27602760
if (raw_cmd->kernel_data < floppy_track_buffer ||
27612761
current_count_sectors < 0 ||
27622762
raw_cmd->length < 0 ||

drivers/block/hd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,11 @@ static void read_intr(void)
464464

465465
ok_to_read:
466466
req = hd_req;
467-
insw(HD_DATA, req->buffer, 256);
467+
insw(HD_DATA, bio_data(req->bio), 256);
468468
#ifdef DEBUG
469469
printk("%s: read: sector %ld, remaining = %u, buffer=%p\n",
470470
req->rq_disk->disk_name, blk_rq_pos(req) + 1,
471-
blk_rq_sectors(req) - 1, req->buffer+512);
471+
blk_rq_sectors(req) - 1, bio_data(req->bio)+512);
472472
#endif
473473
if (hd_end_request(0, 512)) {
474474
SET_HANDLER(&read_intr);
@@ -505,7 +505,7 @@ static void write_intr(void)
505505
ok_to_write:
506506
if (hd_end_request(0, 512)) {
507507
SET_HANDLER(&write_intr);
508-
outsw(HD_DATA, req->buffer, 256);
508+
outsw(HD_DATA, bio_data(req->bio), 256);
509509
return;
510510
}
511511

@@ -624,7 +624,7 @@ static void hd_request(void)
624624
printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n",
625625
req->rq_disk->disk_name,
626626
req_data_dir(req) == READ ? "read" : "writ",
627-
cyl, head, sec, nsect, req->buffer);
627+
cyl, head, sec, nsect, bio_data(req->bio));
628628
#endif
629629
if (req->cmd_type == REQ_TYPE_FS) {
630630
switch (rq_data_dir(req)) {
@@ -643,7 +643,7 @@ static void hd_request(void)
643643
bad_rw_intr();
644644
goto repeat;
645645
}
646-
outsw(HD_DATA, req->buffer, 256);
646+
outsw(HD_DATA, bio_data(req->bio), 256);
647647
break;
648648
default:
649649
printk("unknown hd-command\n");

drivers/block/mg_disk.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static unsigned int mg_out(struct mg_host *host,
479479

480480
static void mg_read_one(struct mg_host *host, struct request *req)
481481
{
482-
u16 *buff = (u16 *)req->buffer;
482+
u16 *buff = (u16 *)bio_data(req->bio);
483483
u32 i;
484484

485485
for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
@@ -496,7 +496,7 @@ static void mg_read(struct request *req)
496496
mg_bad_rw_intr(host);
497497

498498
MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
499-
blk_rq_sectors(req), blk_rq_pos(req), req->buffer);
499+
blk_rq_sectors(req), blk_rq_pos(req), bio_data(req->bio));
500500

501501
do {
502502
if (mg_wait(host, ATA_DRQ,
@@ -514,7 +514,7 @@ static void mg_read(struct request *req)
514514

515515
static void mg_write_one(struct mg_host *host, struct request *req)
516516
{
517-
u16 *buff = (u16 *)req->buffer;
517+
u16 *buff = (u16 *)bio_data(req->bio);
518518
u32 i;
519519

520520
for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
@@ -534,7 +534,7 @@ static void mg_write(struct request *req)
534534
}
535535

536536
MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
537-
rem, blk_rq_pos(req), req->buffer);
537+
rem, blk_rq_pos(req), bio_data(req->bio));
538538

539539
if (mg_wait(host, ATA_DRQ,
540540
MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
@@ -585,7 +585,7 @@ static void mg_read_intr(struct mg_host *host)
585585
mg_read_one(host, req);
586586

587587
MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
588-
blk_rq_pos(req), blk_rq_sectors(req) - 1, req->buffer);
588+
blk_rq_pos(req), blk_rq_sectors(req) - 1, bio_data(req->bio));
589589

590590
/* send read confirm */
591591
outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND);
@@ -624,7 +624,7 @@ static void mg_write_intr(struct mg_host *host)
624624
/* write 1 sector and set handler if remains */
625625
mg_write_one(host, req);
626626
MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
627-
blk_rq_pos(req), blk_rq_sectors(req), req->buffer);
627+
blk_rq_pos(req), blk_rq_sectors(req), bio_data(req->bio));
628628
host->mg_do_intr = mg_write_intr;
629629
mod_timer(&host->timer, jiffies + 3 * HZ);
630630
}

drivers/block/paride/pcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static void do_pcd_request(struct request_queue * q)
747747
pcd_current = cd;
748748
pcd_sector = blk_rq_pos(pcd_req);
749749
pcd_count = blk_rq_cur_sectors(pcd_req);
750-
pcd_buf = pcd_req->buffer;
750+
pcd_buf = bio_data(pcd_req->bio);
751751
pcd_busy = 1;
752752
ps_set_intr(do_pcd_read, NULL, 0, nice);
753753
return;

drivers/block/paride/pd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static enum action do_pd_io_start(void)
454454
if (pd_block + pd_count > get_capacity(pd_req->rq_disk))
455455
return Fail;
456456
pd_run = blk_rq_sectors(pd_req);
457-
pd_buf = pd_req->buffer;
457+
pd_buf = bio_data(pd_req->bio);
458458
pd_retries = 0;
459459
if (pd_cmd == READ)
460460
return do_pd_read_start();
@@ -485,7 +485,7 @@ static int pd_next_buf(void)
485485
spin_lock_irqsave(&pd_lock, saved_flags);
486486
__blk_end_request_cur(pd_req, 0);
487487
pd_count = blk_rq_cur_sectors(pd_req);
488-
pd_buf = pd_req->buffer;
488+
pd_buf = bio_data(pd_req->bio);
489489
spin_unlock_irqrestore(&pd_lock, saved_flags);
490490
return 0;
491491
}

drivers/block/paride/pf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static void do_pf_request(struct request_queue * q)
795795
}
796796

797797
pf_cmd = rq_data_dir(pf_req);
798-
pf_buf = pf_req->buffer;
798+
pf_buf = bio_data(pf_req->bio);
799799
pf_retries = 0;
800800

801801
pf_busy = 1;
@@ -827,7 +827,7 @@ static int pf_next_buf(void)
827827
if (!pf_req)
828828
return 1;
829829
pf_count = blk_rq_cur_sectors(pf_req);
830-
pf_buf = pf_req->buffer;
830+
pf_buf = bio_data(pf_req->bio);
831831
}
832832
return 0;
833833
}

0 commit comments

Comments
 (0)