bh->b_dev_id & bh->b_kiobuf

From: Manfred Spraul (manfreds@colorfullife.com)
Date: Sat May 13 2000 - 04:28:45 EST


Hi Ingo,

A few months ago I noticed that each buffer_head contains 2 pointers for
the callback function, and that they are mutually exclusive: the kiobuf
functions use b_kiobuf, raid1 & highmem bounce use b_dev_id.
raid1 & highmem bounce operate on copies of the original buffer_head, so
there are no problems in a bounced raw-io write to a raid array.

It seems the patch got lost, so I updated it to 2.3.99-pre8. Could you
include it in your next raid update? It compiles, but I couldn't stress
test it [no highmem/raid test setup]

--
	Manfred

<<<<<<<<<<< patch-bh // $Header$ // Kernel Version: // VERSION = 2 // PATCHLEVEL = 3 // SUBLEVEL = 99 // EXTRAVERSION = -pre8 --- 2.3/drivers/block/raid1.c Sat May 13 11:20:53 2000 +++ build-2.3/drivers/block/raid1.c Sat May 13 10:56:21 2000 @@ -109,7 +109,7 @@ static void raid1_reschedule_retry (struct buffer_head *bh) { unsigned long flags; - struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_dev_id); + struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_private); mddev_t *mddev = r1_bh->mddev; raid1_conf_t *conf = mddev_to_conf(mddev); @@ -170,7 +170,7 @@ } void raid1_end_request (struct buffer_head *bh, int uptodate) { - struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_dev_id); + struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_private); /* * this branch is our 'one mirror IO has finished' event handler: @@ -341,7 +341,7 @@ bh_req = &r1_bh->bh_req; memcpy(bh_req, bh, sizeof(*bh)); bh_req->b_end_io = raid1_end_request; - bh_req->b_dev_id = r1_bh; + bh_req->b_private = r1_bh; q = blk_get_queue(bh_req->b_rdev); generic_make_request (q, rw, bh_req); return 0; @@ -391,7 +391,7 @@ mirror_bh[i]->b_data = bh->b_data; mirror_bh[i]->b_list = BUF_LOCKED; mirror_bh[i]->b_end_io = raid1_end_request; - mirror_bh[i]->b_dev_id = r1_bh; + mirror_bh[i]->b_private = r1_bh; r1_bh->mirror_bh[i] = mirror_bh[i]; sum_bhs++; @@ -839,7 +839,7 @@ bh = raid1_retry_list; if (!bh) break; - r1_bh = (struct raid1_bh *)(bh->b_dev_id); + r1_bh = (struct raid1_bh *)(bh->b_private); raid1_retry_list = r1_bh->next_retry; md_spin_unlock_irqrestore(&retry_list_lock, flags); @@ -897,7 +897,7 @@ mirror_bh[i]->b_data = bh->b_data; mirror_bh[i]->b_list = BUF_LOCKED; mirror_bh[i]->b_end_io = end_sync_write; - mirror_bh[i]->b_dev_id = r1_bh; + mirror_bh[i]->b_private = r1_bh; r1_bh->mirror_bh[i] = mirror_bh[i]; sum_bhs++; @@ -1097,7 +1097,7 @@ bh->b_page = raid1_gfp(); bh->b_data = (char *) page_address(bh->b_page); bh->b_end_io = end_sync_read; - bh->b_dev_id = (void *) r1_bh; + bh->b_private = (void *) r1_bh; bh->b_rsector = block_nr<<1; init_waitqueue_head(&bh->b_wait); @@ -1110,7 +1110,7 @@ static void end_sync_read(struct buffer_head *bh, int uptodate) { - struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_dev_id); + struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_private); /* we have read a block, now it needs to be re-written, * or re-read if the read failed. @@ -1125,7 +1125,7 @@ static void end_sync_write(struct buffer_head *bh, int uptodate) { - struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_dev_id); + struct raid1_bh * r1_bh = (struct raid1_bh *)(bh->b_private); if (!uptodate) md_error (bh->b_dev, bh->b_rdev); --- 2.3/drivers/block/raid5.c Sat May 13 11:20:53 2000 +++ build-2.3/drivers/block/raid5.c Sat May 13 10:57:23 2000 @@ -591,7 +591,7 @@ static void raid5_end_request (struct buffer_head * bh, int uptodate) { - struct stripe_head *sh = bh->b_dev_id; + struct stripe_head *sh = bh->b_private; raid5_conf_t *conf = sh->raid_conf; int disks = conf->raid_disks, i; unsigned long flags; --- 2.3/fs/buffer.c Sat May 13 11:20:57 2000 +++ build-2.3/fs/buffer.c Sat May 13 11:14:47 2000 @@ -719,11 +719,11 @@ } } -void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *dev_id) +void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private) { bh->b_list = BUF_CLEAN; bh->b_end_io = handler; - bh->b_dev_id = dev_id; + bh->b_private = private; } static void end_buffer_io_sync(struct buffer_head *bh, int uptodate) @@ -1753,7 +1753,7 @@ mark_buffer_uptodate(bh, uptodate); - kiobuf = bh->b_kiobuf; + kiobuf = bh->b_private; unlock_buffer(bh); end_kio_request(kiobuf, uptodate); } @@ -1876,11 +1876,10 @@ set_bh_page(tmp, map, offset); tmp->b_this_page = tmp; - init_buffer(tmp, end_buffer_io_kiobuf, NULL); + init_buffer(tmp, end_buffer_io_kiobuf, iobuf); tmp->b_dev = dev; tmp->b_blocknr = blocknr; tmp->b_state = 1 << BH_Mapped; - tmp->b_kiobuf = iobuf; if (rw == WRITE) { set_bit(BH_Uptodate, &tmp->b_state); --- 2.3/include/linux/fs.h Fri May 12 08:52:24 2000 +++ build-2.3/include/linux/fs.h Sat May 13 10:55:24 2000 @@ -231,11 +231,10 @@ char * b_data; /* pointer to data block (512 byte) */ struct page *b_page; /* the page this bh is mapped to */ void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */ - void *b_dev_id; + void *b_private; /* reserved for b_end_io */ unsigned long b_rsector; /* Real buffer location on disk */ wait_queue_head_t b_wait; - struct kiobuf * b_kiobuf; /* kiobuf which owns this IO */ }; typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate); --- 2.3/mm/highmem.c Sat May 13 11:21:00 2000 +++ build-2.3/mm/highmem.c Sat May 13 10:55:24 2000 @@ -281,7 +281,7 @@ static inline void bounce_end_io (struct buffer_head *bh, int uptodate) { - struct buffer_head *bh_orig = (struct buffer_head *)(bh->b_dev_id); + struct buffer_head *bh_orig = (struct buffer_head *)(bh->b_private); bh_orig->b_end_io(bh_orig, uptodate); __free_page(bh->b_page); @@ -295,7 +295,7 @@ static void bounce_end_io_read (struct buffer_head *bh, int uptodate) { - struct buffer_head *bh_orig = (struct buffer_head *)(bh->b_dev_id); + struct buffer_head *bh_orig = (struct buffer_head *)(bh->b_private); if (uptodate) copy_to_high_bh_irq(bh_orig, bh); @@ -354,10 +354,9 @@ copy_from_high_bh(bh, bh_orig); } else bh->b_end_io = bounce_end_io_read; - bh->b_dev_id = (void *)bh_orig; + bh->b_private = (void *)bh_orig; bh->b_rsector = bh_orig->b_rsector; memset(&bh->b_wait, -1, sizeof(bh->b_wait)); - bh->b_kiobuf = NULL; return bh; } >>>>>>>>>>>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:22 EST