md/raid5: fix raid5_set_bi_hw_segments
PATCH 1/3 md/raid5: fix raid5_set_bi_hw_segments
The @bio->bi_phys_segments consists of active stripes count in the lower 16 bits and processed stripes count in the upper 16 bits. So logical-OR operator should be bitwise one.
--- drivers/md/raid5.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/md/raid5.c +1 -1
@@ -129,7 +129,7 @@ static inline int raid5_dec_bi_hw_segments(struct bio *bio)static inline void raid5_set_bi_hw_segments (struct bio *bio,unsigned int cnt) { - bio->bi_phys_segments =raid5_bi_phys_segments (bio) || (cnt <<16 ); + bio->bi_phys_segments =raid5_bi_phys_segments (bio) | (cnt <<16 ); }/* Find first data disk in a raid6 stripe */
Signature · 1 line
1.7.5.2
PATCH 2/3 md/raid5: fix FUA request handling in ops_run_io()
Commit e9c7469bb4f5 ("md: implment REQ_FLUSH/FUA support") introduced R5_WantFUA flag and set rw to WRITE_FUA in that case. However remaining code still checks whether rw is exactly same as WRITE or not, so FUAed-write ends up with being treated as READ. Fix it.
--- drivers/md/raid5.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/md/raid5.c +3 -3
@@ -514,7 +514,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) bi = &sh->dev[i].req; bi->bi_rw = rw; -if (rw ==WRITE ) +if (rw &WRITE ) bi->bi_end_io = raid5_end_write_request;else bi->bi_end_io = raid5_end_read_request;
@@ -548,13 +548,13 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) bi->bi_io_vec[0 ].bv_offset =0 ; bi->bi_size =STRIPE_SIZE ; bi->bi_next =NULL ; -if (rw ==WRITE && +if (rw &WRITE &&test_bit (R5_ReWrite, &sh->dev[i].flags))atomic_add (STRIPE_SECTORS , &rdev->corrected_errors);generic_make_request (bi); }else { -if (rw ==WRITE ) +if (rw &WRITE )set_bit (STRIPE_DEGRADED , &sh->state);pr_debug ("skip op %ld on disc %d for sector %llu\n" , bi->bi_rw, i, (unsigned long long )sh->sector);
Signature · 1 line
1.7.5.2
PATCH 3/3 md/raid5: remove unusual use of bio_iovec_idx()
In reply to Namhyung KimIn the bio_for_each_segment loop, bvl always points current bio_vec, so the same as bio_iovec_idx(, i). Let's get rid of it.
--- drivers/md/raid5.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/md/raid5.c +3 -3
@@ -585,7 +585,7 @@ async_copy_data(int frombio, struct bio *bio, struct page *page,init_async_submit (&submit, flags, tx,NULL ,NULL ,NULL );bio_for_each_segment (bvl, bio, i) { -int len =bio_iovec_idx (bio, i)->bv_len; +int len = bvl->bv_len;int clen;int b_offset =0 ;
@@ -601,8 +601,8 @@ async_copy_data(int frombio, struct bio *bio, struct page *page, clen = len;if (clen >0 ) { - b_offset +=bio_iovec_idx (bio, i)->bv_offset; - bio_page =bio_iovec_idx (bio, i)->bv_page; + b_offset += bvl->bv_offset; + bio_page = bvl->bv_page;if (frombio) tx =async_memcpy (page, bio_page, page_offset, b_offset, clen, &submit);
Signature · 1 line
1.7.5.2
Quoted 14 lines · On Mon, 13 Jun 2011 23:48:22 +0900 Namhyung Kim <[email protected]> wrote:
The @bio->bi_phys_segments consists of active stripes count in the lower 16 bits and processed stripes count in the upper 16 bits. So logical-OR operator should be bitwise one.
Signed-off-by Namhyung Kim <[email protected]>--- drivers/md/raid5.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/md/raid5.c +0
-0
drivers/md/raid5.c static inline int raid5_dec_bi_hw_segments(struct bio *bio) · line 135
Quoted 8 lines
drivers/md/raid5.c +1
-1@@ -129,7 +129,7 @@ static inline int raid5_dec_bi_hw_segments(struct bio *bio)static inline void raid5_set_bi_hw_segments (struct bio *bio,unsigned int cnt) { - bio->bi_phys_segments =raid5_bi_phys_segments (bio) || (cnt <<16 ); + bio->bi_phys_segments =raid5_bi_phys_segments (bio) | (cnt <<16 ); }/* Find first data disk in a raid6 stripe */
Thanks for this and the other 2!!
I have added "Cc: [email protected]" to the first two and applied them. I expect to send them off to Linus later today.
Thanks,
NeilBrown