All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Neil Brown <neilb@suse.de>, Christoph Hellwig <hch@infradead.org>
Cc: Jiri Slaby <jirislaby@gmail.com>,
	James Bottomley <James.Bottomley@suse.de>,
	linux-scsi@vger.kernel.org, hch@lst.de, jaxboe@fusionio.com,
	LKML <linux-kernel@vger.kernel.org>,
	linux-raid@vger.kernel.org
Subject: [PATCH] md: bitwise operations might not fit in a "bool"
Date: Thu, 22 Jul 2010 14:44:53 +0300	[thread overview]
Message-ID: <4C482F35.6000004@panasas.com> (raw)
In-Reply-To: <4C481FD5.4070509@gmail.com>


when taking a resolute of a bit-wise AND as true false. Better / faster
to make it a boolean operation.

This fixes a bug and a crash because the flags field did not fit into
the bool operands.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
git diff --stat -p -M drivers/md/raid1.c
 drivers/md/raid1.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 73cc74f..67a9159 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -787,7 +787,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
 	struct bio_list bl;
 	struct page **behind_pages = NULL;
 	const int rw = bio_data_dir(bio);
-	const bool do_sync = (bio->bi_rw & REQ_SYNC);
+	const bool do_sync = (bio->bi_rw & REQ_SYNC) != 0;
 	bool do_barriers;
 	mdk_rdev_t *blocked_rdev;
 
@@ -959,7 +959,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
 	atomic_set(&r1_bio->remaining, 0);
 	atomic_set(&r1_bio->behind_remaining, 0);
 
-	do_barriers = bio->bi_rw & REQ_HARDBARRIER;
+	do_barriers = (bio->bi_rw & REQ_HARDBARRIER) != 0;
 	if (do_barriers)
 		set_bit(R1BIO_Barrier, &r1_bio->state);
 
@@ -1640,7 +1640,8 @@ static void raid1d(mddev_t *mddev)
 			 * We already have a nr_pending reference on these rdevs.
 			 */
 			int i;
-			const bool do_sync = (r1_bio->master_bio->bi_rw & REQ_SYNC);
+			const bool do_sync =
+				(r1_bio->master_bio->bi_rw & REQ_SYNC) != 0;
 			clear_bit(R1BIO_BarrierRetry, &r1_bio->state);
 			clear_bit(R1BIO_Barrier, &r1_bio->state);
 			for (i=0; i < conf->raid_disks; i++)
@@ -1696,7 +1697,9 @@ static void raid1d(mddev_t *mddev)
 				       (unsigned long long)r1_bio->sector);
 				raid_end_bio_io(r1_bio);
 			} else {
-				const bool do_sync = r1_bio->master_bio->bi_rw & REQ_SYNC;
+				const bool do_sync =
+					(r1_bio->master_bio->bi_rw & REQ_SYNC)
+					!= 0;
 				r1_bio->bios[r1_bio->read_disk] =
 					mddev->ro ? IO_BLOCKED : NULL;
 				r1_bio->read_disk = disk;

  reply	other threads:[~2010-07-22 11:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22  7:04 BUG at drivers/scsi/scsi_lib.c:1113 Jiri Slaby
2010-07-22  7:37 ` Neil Brown
2010-07-22  8:06   ` Jiri Slaby
2010-07-22  8:36   ` Christoph Hellwig
2010-07-22  8:39     ` Jiri Slaby
2010-07-22 10:39   ` Boaz Harrosh
2010-07-22 11:44     ` Boaz Harrosh [this message]
2010-07-22 11:55       ` [PATCH] md: bitwise operations might not fit in a "bool" Neil Brown
2010-07-22 12:20         ` Boaz Harrosh
2010-07-22 12:37           ` Neil Brown
2010-07-27 22:27         ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C482F35.6000004@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@suse.de \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jaxboe@fusionio.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=neilb@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.