vfs: clear to the end of the buffer on reads
Subsystems (2)
PATCH 1/1 vfs: clear to the end of the buffer on reads
READ is zero so this test is always false. (rw = READ) was intended.
fs/buffer.c +1 -1
@@ -2931,7 +2931,7 @@ static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh) bio->bi_io_vec[0 ].bv_len = bytes;/* ..and clear the end of the buffer for reads */ -if (rw &READ ) { +if (rw =READ ) {void *kaddr =kmap_atomic (bh->b_page);memset (kaddr +bh_offset (bh) + bytes,0 , bh->b_size - bytes);kunmap_atomic (kaddr);
Quoted 1 line · Dan Carpenter
READ is zero so this test is always false. (rw = READ) was intended.
Actually, that really *is* a bitmask, but yeah, the test is wrong.
The correct test is
((rw & RW_MASK) = READ)
because the field can have other bits set too (REQ_SYNC or REQ_META or whatever - read-ahead, other bits)
Alternatively, just "!(rw & WRITE)" I guess.
But thanks for noticing.
Linus
Quoted 9 lines · Linus Torvalds
Quoted 1 line · Dan Carpenter
READ is zero so this test is always false. (rw = READ) was intended.
Actually, that really *is* a bitmask, but yeah, the test is wrong.
The correct test is
((rw &
RW_MASK) = READ)
Ah. Of course. I'll send a v2.
regards,
dan carpenter
PATCH v2 1/1 vfs: clear to the end of the buffer on reads
In reply to Linus TorvaldsREAD is zero so this test is always false. If ((rw & RW_MASK) = READ) was intended.
---
v2: I didn't mask out the other flags in the first version
fs/buffer.c +1 -1
@@ -2931,7 +2931,7 @@ static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh) bio->bi_io_vec[0 ].bv_len = bytes;/* ..and clear the end of the buffer for reads */ -if (rw &READ ) { +if ((rw &RW_MASK ) =READ ) {void *kaddr =kmap_atomic (bh->b_page);memset (kaddr +bh_offset (bh) + bytes,0 , bh->b_size - bytes);kunmap_atomic (kaddr);