Skip to contentSkip to conversation

dm log: fix unitialized i/o operations flags

PATCH In review [email protected] 2 participants 2 messages Aug 23, 2016 – Aug 24, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm log: fix unitialized i/o operations flags

From: Heinz Mauelshagen <[email protected]>

During the port to bio_set_op_attrs() of dm-io.c, a dm-log.c caller was missing to initialize lc->io_req.bi_op_flags in the rw_header() caller of dm_io() which lead to respective unitialized bio->bi_op_flags in do_region().

Symptom was hitting the BUG() in sd_init_command() for SCSI devices.

Whilst on it, adjust rw_header() and its callers to use REQ_OP_{READ|WRITE}.

---
 drivers/md/dm-log.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/md/dm-log.c +6 -5
index 4ca2d1d..07fc1ad 100644
@@ -291,9 +291,10 @@ static void header_from_disk(struct log_header_core *core, struct log_header_dis
 	core->nr_regions = le64_to_cpu(disk->nr_regions);
 }
 
-static int rw_header(struct log_c *lc, int rw)
+static int rw_header(struct log_c *lc, int op)
 {
-	lc->io_req.bi_op = rw;
+	lc->io_req.bi_op = op;
+	lc->io_req.bi_op_flags = 0;
 
 	return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
 }
@@ -316,7 +317,7 @@ static int read_header(struct log_c *log)
 {
 	int r;
 
-	r = rw_header(log, READ);
+	r = rw_header(log, REQ_OP_READ);
 	if (r)
 		return r;
 
@@ -630,7 +631,7 @@ static int disk_resume(struct dm_dirty_log *log)
 	header_to_disk(&lc->header, lc->disk_header);
 
 	/* write the new header */
-	r = rw_header(lc, WRITE);
+	r = rw_header(lc, REQ_OP_WRITE);
 	if (!r) {
 		r = flush_header(lc);
 		if (r)
@@ -698,7 +699,7 @@ static int disk_flush(struct dm_dirty_log *log)
 			log_clear_bit(lc, lc->clean_bits, i);
 	}
 
-	r = rw_header(lc, WRITE);
+	r = rw_header(lc, REQ_OP_WRITE);
 	if (r)
 		fail_log_device(lc);
 	else {
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 61 lines · On Tue, Aug 23, 2016 at 2:17 PM, <[email protected]> wrote:

From: Heinz Mauelshagen <[email protected]>

During the port to bio_set_op_attrs() of dm-io.c, a dm-log.c caller was missing to initialize lc->io_req.bi_op_flags in the rw_header() caller of dm_io() which lead to respective unitialized bio->bi_op_flags in do_region().

Symptom was hitting the BUG() in sd_init_command() for SCSI devices.

Whilst on it, adjust rw_header() and its callers to use REQ_OP_{READ|WRITE}.

---
 drivers/md/dm-log.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/md/dm-log.c +6 -6
index 4ca2d1d..07fc1ad 100644
@@ -291,9 +291,10 @@ static void header_from_disk(struct log_header_core *core, struct log_header_dis
        core->nr_regions = le64_to_cpu(disk->nr_regions);
 }
 
-static int rw_header(struct log_c *lc, int rw)
+static int rw_header(struct log_c *lc, int op)
 {
-       lc->io_req.bi_op = rw;
+       lc->io_req.bi_op = op;
+       lc->io_req.bi_op_flags = 0;
 
        return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
 }
@@ -316,7 +317,7 @@ static int read_header(struct log_c *log)
 {
        int r;
 
-       r = rw_header(log, READ);
+       r = rw_header(log, REQ_OP_READ);
        if (r)
                return r;
 
@@ -630,7 +631,7 @@ static int disk_resume(struct dm_dirty_log *log)
        header_to_disk(&lc->header, lc->disk_header);
 
        /* write the new header */
-       r = rw_header(lc, WRITE);
+       r = rw_header(lc, REQ_OP_WRITE);
        if (!r) {
                r = flush_header(lc);
                if (r)
@@ -698,7 +699,7 @@ static int disk_flush(struct dm_dirty_log *log)
                        log_clear_bit(lc, lc->clean_bits, i);
        }
 
-       r = rw_header(lc, WRITE);
+       r = rw_header(lc, REQ_OP_WRITE);
        if (r)
                fail_log_device(lc);
        else {
--
Quoted 1 line

2.7.4

Looks fine to me.

Quoted 4 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Signature · 2 lines
Regards,
Shaun Tancheff