Skip to contentSkip to conversation

mtd: blkdevs: Fix mtd block write failure

PATCH In review Abhishek Sahu 3 participants 4 messages Aug 2, 2017 – Aug 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: blkdevs: Fix mtd block write failure

All the MTD block write requests are failing with
following error messages

mkfs.ext4 /dev/mtdblock0

print_req_error: I/O error, dev mtdblock0, sector 0 Buffer I/O error on dev mtdblock0, logical block 0, lost async page write

The control is going to default case after block write request because of missing return.

Fixes commit 2a842acab109 ("block: introduce new block status code type")
---
 drivers/mtd/mtd_blkdevs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/mtd_blkdevs.c +1 -0
index f336a9b..9ec8f03 100644
@@ -113,6 +113,7 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
 		for (; nsect > 0; nsect--, block++, buf += tr->blksize)
 			if (tr->writesect(dev, block, buf))
 				return BLK_STS_IOERR;
+		return BLK_STS_OK;
 	default:
 		return BLK_STS_IOERR;
 	}
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Wed, 2 Aug 2017 18:03:05 +0530 Abhishek Sahu <[email protected]> wrote:

All the MTD block write requests are failing with
following error messages

mkfs.ext4 /dev/mtdblock0

print_req_error: I/O error, dev mtdblock0, sector 0 Buffer I/O error on dev mtdblock0, logical block 0, lost async page write

Quoted 5 lines

The control is going to default case after block write request because of missing return.

Fixes commit 2a842acab109 ("block: introduce new block status code type")
Quoted 16 lines
---
 drivers/mtd/mtd_blkdevs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/mtd_blkdevs.c +1 -0
index f336a9b..9ec8f03 100644
@@ -113,6 +113,7 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
 		for (; nsect > 0; nsect--, block++, buf += tr->blksize)
 			if (tr->writesect(dev, block, buf))
 				return BLK_STS_IOERR;
+		return BLK_STS_OK;
 	default:
 		return BLK_STS_IOERR;
 	}
#2 lore raw
Quoted 12 lines · Boris Brezillon
Quoted 9 lines · On Wed, 2 Aug 2017 18:03:05 +0530 Abhishek Sahu <[email protected]> wrote:

All the MTD block write requests are failing with
following error messages

mkfs.ext4 /dev/mtdblock0

print_req_error: I/O error, dev mtdblock0, sector 0 Buffer I/O error on dev mtdblock0, logical block 0, lost async page write

Quoted 8 lines
Quoted 5 lines

The control is going to default case after block write request because of missing return.

Fixes commit 2a842acab109 ("block: introduce new block status code type")

Shall this patch be included for next RC since the MTD block write is broken in 4.13 and without this, all the writes to MTD block device will return failure.

Quoted 17 lines
Quoted 17 lines
---
 drivers/mtd/mtd_blkdevs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/mtd_blkdevs.c +1 -0
index f336a9b..9ec8f03 100644
@@ -113,6 +113,7 @@ static blk_status_t do_blktrans_request(struct 
 mtd_blktrans_ops *tr,
 		for (; nsect > 0; nsect--, block++, buf += tr->blksize)
 			if (tr->writesect(dev, block, buf))
 				return BLK_STS_IOERR;
+		return BLK_STS_OK;
 	default:
 		return BLK_STS_IOERR;

}

#3 lore raw

Hi,

Quoted 13 lines · Abhishek Sahu
Quoted 12 lines · Boris Brezillon
Quoted 9 lines · On Wed, 2 Aug 2017 18:03:05 +0530 Abhishek Sahu <[email protected]> wrote:

All the MTD block write requests are failing with
following error messages

mkfs.ext4 /dev/mtdblock0

print_req_error: I/O error, dev mtdblock0, sector 0 Buffer I/O error on dev mtdblock0, logical block 0, lost async page write

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The control is going to default case after block write request because of missing return.

Fixes commit 2a842acab109 ("block: introduce new block status

code type")

Looks like that never even went to the MTD list. Oh well, I still likely wouldn't have reviewed it this closely :)

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Shall this patch be included for next RC since the MTD block write is broken in 4.13 and without this, all the writes to MTD block device will return failure.

Yes, applied to linux-mtd.git, and I'll try to get this out for 4.13.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

---
drivers/mtd/mtd_blkdevs.c | 1 +

1 file changed, 1 insertion(+)
Quoted 10 lines
Quoted 10 lines

drivers/mtd/mtd_blkdevs.c static blk_status_t · line 117

Quoted 10 lines
drivers/mtd/mtd_blkdevs.c +1 -0
index f336a9b..9ec8f03 100644
@@ -113,6 +113,7 @@ static blk_status_t
 do_blktrans_request(struct mtd_blktrans_ops *tr,
 		for (; nsect > 0; nsect--, block++, buf += tr->blksize)
 			if (tr->writesect(dev, block, buf))
 				return BLK_STS_IOERR;
+		return BLK_STS_OK;

Ooh, that's a nasty one. No compiler warning, because it just falls back to the 'default' case :(

Brian

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mtd/mtd_blkdevs.c +0 -0
 	default:
 		return BLK_STS_IOERR;
	}