Skip to contentSkip to conversation

linux-next: hdparm -B <value> broken

PATCH In review Sabrina Dubroca 3 participants 5 messages Aug 26, 2014 Block layer

lore
Share & tools
lore
#0 lore raw

Hello,

Since next-20140823:

# hdparm -B 200 /dev/sda

/dev/sda:
setting Advanced Power Management level to 0xc8 (200) HDIO_DRIVE_CMD failed: Bad address
APM_level = 128

It looks like before commit 2cada584b200 ("block: cleanup error handling in sg_io"), we had ret = 0 before entering the last big if block of sg_io, and now ret = -EFAULT.

The following patch seems to fix the problem:

block/scsi_ioctl.c +1 -0
index 5dd477bfb4bc..9b8eaeca6a79 100644
@@ -330,6 +330,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
 	if (blk_fill_sghdr_rq(q, rq, hdr, mode))
 		goto out_free_cdb;
 
+	ret = 0;
 	if (hdr->iovec_count) {
 		size_t iov_data_len;
 		struct iovec *iov = NULL;

Thanks,

Signature · 1 line
Sabrina
#1 lore raw
Quoted 1 line · Sabrina Dubroca

The following patch seems to fix the problem:

Thanks for the fix! Can you turn this into a patch with a proper subject and a signoff?

#2 lore raw

PATCH 1/1 block: fix error handling in sg_io

Before commit 2cada584b200 ("block: cleanup error handling in sg_io"), we had ret = 0 before entering the last big if block of sg_io.

Since 2cada584b200, ret = -EFAULT, which breaks hdparm:

/dev/sda:
setting Advanced Power Management level to 0xc8 (200) HDIO_DRIVE_CMD failed: Bad address
APM_level = 128

Fixes 2cada584b200 ("block: cleanup error handling in sg_io")
---
 block/scsi_ioctl.c | 1 +
 1 file changed, 1 insertion(+)
block/scsi_ioctl.c +1 -0
index 5dd477bfb4bc..9b8eaeca6a79 100644
@@ -330,6 +330,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
 	if (blk_fill_sghdr_rq(q, rq, hdr, mode))
 		goto out_free_cdb;
 
+	ret = 0;
 	if (hdr->iovec_count) {
 		size_t iov_data_len;
 		struct iovec *iov = NULL;
Signature · 1 line
2.1.0
maintainer
#3 lore raw

Re: [PATCH] block: fix error handling in sg_io

Quoted 5 lines · Sabrina Dubroca

Before commit 2cada584b200 ("block: cleanup error handling in sg_io"), we had ret = 0 before entering the last big if block of sg_io.

Since 2cada584b200, ret = -EFAULT, which breaks hdparm:

Quoted 7 lines

/dev/sda:
setting Advanced Power Management level to 0xc8 (200) HDIO_DRIVE_CMD failed: Bad address
APM_level = 128

Fixes 2cada584b200 ("block: cleanup error handling in sg_io")

Thanks, good catch. Someone else reported a regression with identical symptoms to me yesterday, but did not follow up, so I'm glad you both found and fixed it.

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH] block: fix error handling in sg_io

In reply to Sabrina Dubroca
Quoted 5 lines · Sabrina Dubroca

Before commit 2cada584b200 ("block: cleanup error handling in sg_io"), we had ret = 0 before entering the last big if block of sg_io.

Since 2cada584b200, ret = -EFAULT, which breaks hdparm:

Quoted 7 lines

/dev/sda:
setting Advanced Power Management level to 0xc8 (200) HDIO_DRIVE_CMD failed: Bad address
APM_level = 128

Fixes 2cada584b200 ("block: cleanup error handling in sg_io")

Looks good,