* [patch] vfs: clear to the end of the buffer on reads
@ 2012-12-05 12:44 Dan Carpenter
2012-12-05 15:17 ` Linus Torvalds
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2012-12-05 12:44 UTC (permalink / raw)
To: Alexander Viro, Linus Torvalds
Cc: linux-fsdevel, kernel-janitors, Romain Francoise, Meelis Roos,
Tony Luck
READ is zero so this test is always false. (rw == READ) was intended.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/buffer.c b/fs/buffer.c
index 70ed4d8..e0a59c6 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] vfs: clear to the end of the buffer on reads
2012-12-05 12:44 [patch] vfs: clear to the end of the buffer on reads Dan Carpenter
@ 2012-12-05 15:17 ` Linus Torvalds
2012-12-05 16:59 ` Dan Carpenter
2012-12-05 17:01 ` [patch v2] " Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: Linus Torvalds @ 2012-12-05 15:17 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alexander Viro, linux-fsdevel, kernel-janitors, Romain Francoise,
Meelis Roos, Tony Luck
On Wed, Dec 5, 2012 at 4:44 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] vfs: clear to the end of the buffer on reads
2012-12-05 15:17 ` Linus Torvalds
@ 2012-12-05 16:59 ` Dan Carpenter
2012-12-05 17:01 ` [patch v2] " Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-12-05 16:59 UTC (permalink / raw)
To: Linus Torvalds
Cc: Alexander Viro, linux-fsdevel, kernel-janitors, Romain Francoise,
Meelis Roos, Tony Luck
On Wed, Dec 05, 2012 at 07:17:16AM -0800, Linus Torvalds wrote:
> On Wed, Dec 5, 2012 at 4:44 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch v2] vfs: clear to the end of the buffer on reads
2012-12-05 15:17 ` Linus Torvalds
2012-12-05 16:59 ` Dan Carpenter
@ 2012-12-05 17:01 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-12-05 17:01 UTC (permalink / raw)
To: Alexander Viro, Linus Torvalds
Cc: linux-fsdevel, kernel-janitors, Romain Francoise, Meelis Roos,
Tony Luck
READ is zero so this test is always false. If ((rw & RW_MASK) == READ)
was intended.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: I didn't mask out the other flags in the first version
diff --git a/fs/buffer.c b/fs/buffer.c
index 70ed4d8..e0a59c6 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-05 17:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 12:44 [patch] vfs: clear to the end of the buffer on reads Dan Carpenter
2012-12-05 15:17 ` Linus Torvalds
2012-12-05 16:59 ` Dan Carpenter
2012-12-05 17:01 ` [patch v2] " Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).