block: scsi: introduce and use BLK_STS_OFFLINE
Subsystems (2)
cover block: scsi: introduce and use BLK_STS_OFFLINE
We have a use case where HDDs are regularly power on/off to perserve power. When a drive is being removed, we often see errors like
[ 172.803279] I/O error, dev sda, sector 3137184
These messages are confusing for automations that grep dmesg, as they look very similar to real HDD error.
Solve this issue with a new block state BLK_STS_OFFLINE. After the change, the error message looks like
[ 172.803279] device offline error, dev sda, sector 3137184
so that the automations won't confuse them with real I/O error.
Song Liu (2):
block: introduce BLK_STS_OFFLINE
scsi: use BLK_STS_OFFLINE for not fully online devices
block/blk-core.c | 1 + drivers/scsi/scsi_lib.c | 2 +- include/linux/blk_types.h | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
--
2.30.2
PATCH 1/2 block: introduce BLK_STS_OFFLINE
Currently, drivers reports BLK_STS_IOERR for devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.
Solve this issue with a new state BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".
--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)
block/blk-core.c +1 -0
@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },
include/linux/blk_types.h +7 -0
@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16) +/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related * @error: status the request was completed with
Signature · 1 line
2.30.2
Re: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
CC linux-block (it was a typo in the original email)
Quoted 47 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +7
-1@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16) +/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related * @error: status the request was completed with -- 2.30.2
Re: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
Quoted 37 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 34 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +0
-0@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16)
Quoted 13 lines
Quoted 11 lines
include/linux/blk_types.h +7
-1+/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related * @error: status the request was completed with -- Quoted 2 lines
2.30.2
Please do not overload EIO here.
EIO already is a catch-all error if we don't know any better, but for the 'device offline' case we do (or rather should). Please map it onto 'ENODEV' or 'ENXIO'.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Jens Axboe
maintainerRe: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
Quoted 47 lines · Hannes Reinecke
Quoted 46 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 43 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +7
-0@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16) +/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
include/linux/blk_types.h +0
-1* @error: status the request was completed with --2.30.2
Please do not overload EIO here.
EIO already is a catch-all error if we don't know any better, but for the 'device offline' case we do (or rather should).
Please map it onto 'ENODEV' or 'ENXIO'.
It's deliberately EIO as not to force a change in behavior. I don't mind using something else, but that should be a separate change then.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
Hi Hannes and Jens,
Quoted 59 lines · Jens Axboe
Quoted 47 lines · Hannes Reinecke
Quoted 46 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 43 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +7
-0@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16) +/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
include/linux/blk_types.h +0
-1* @error: status the request was completed with --2.30.2
Please do not overload EIO here.
EIO already is a catch-all error if we don't know any better, but for the 'device offline' case we do (or rather should).
Please map it onto 'ENODEV' or 'ENXIO'.
Quoted 2 lines
It's deliberately EIO as not to force a change in behavior. I don't mind using something else, but that should be a separate change then.
Thanks for these feedbacks. Shall I send v2 with an extra patch that changes EIO to ENODEV/ENXIO? Or shall we do that in a follow up patch? Also, any preference between ENODEV and ENXIO?
Thanks,
Song
Jens Axboe
maintainerRe: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
Quoted 61 lines · Song Liu
Hi Hannes and Jens,
Quoted 59 lines · Jens Axboe
Quoted 55 lines · Hannes Reinecke
Quoted 37 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 34 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +0
-0@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16)Quoted 13 lines
Quoted 11 lines
include/linux/blk_types.h +7
-1+/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related * @error: status the request was completed with -- Quoted 2 lines
2.30.2
Please do not overload EIO here.
EIO already is a catch-all error if we don't know any better, but for the 'device offline' case we do (or rather should).
Please map it onto 'ENODEV' or 'ENXIO'.
Quoted 6 lines
Quoted 2 lines
It's deliberately EIO as not to force a change in behavior. I don't mind using something else, but that should be a separate change then.
Thanks for these feedbacks. Shall I send v2 with an extra patch that changes EIO to ENODEV/ENXIO? Or shall we do that in a follow up patch? Also, any preference between ENODEV and ENXIO?
Yeah I think so, and perhaps put a mention in this patch on why EIO is chosen to not change the user visible return value.
Signature · 1 line
Jens Axboe
Hannes Reinecke
Reviewed-byRe: [PATCH 1/2] block: introduce BLK_STS_OFFLINE
In reply to Song LiuQuoted 61 lines · Song Liu
Hi Hannes and Jens,
Quoted 59 lines · Jens Axboe
Quoted 55 lines · Hannes Reinecke
Quoted 37 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 34 lines · Song Liu
Currently, drivers reports
BLK_STS_IOERRfor devices that are not full online or being removed. This behavior could cause confusion for users, as they are not really I/O errors from the device.Solve this issue with a new state
BLK_STS_OFFLINE, which reports "device offline error" in dmesg instead of "I/O error".Signed-off-by Song Liu <[email protected]>--- block/blk-core.c | 1 + include/linux/blk_types.h | 7 +++++++ 2 files changed, 8 insertions(+)block/blk-core.c +1
-0@@ -164,6 +164,7 @@ static const struct { [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" }, [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" }, [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" }, + [BLK_STS_OFFLINE] = { -EIO, "device offline" }, /* device mapper special case, should not leak out: */ [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },include/linux/blk_types.h +0
-0@@ -153,6 +153,13 @@ typedef u8 __bitwise blk_status_t;*/ #define BLK_STS_ZONE_ACTIVE_RESOURCE ((__force blk_status_t)16)Quoted 13 lines
Quoted 11 lines
include/linux/blk_types.h +7
-1+/* +* BLK_STS_OFFLINE is returned from the driver when the target device is offline +* or is being taken offline. This could help differentiate the case where a +* device is intentionally being shut down from a real I/O error. +*/ +#define BLK_STS_OFFLINE ((__force blk_status_t)17) +/** * blk_path_error - returns true if error may be path related * @error: status the request was completed with -- Quoted 2 lines
2.30.2
Please do not overload EIO here.
EIO already is a catch-all error if we don't know any better, but for the 'device offline' case we do (or rather should).
Please map it onto 'ENODEV' or 'ENXIO'.
Quoted 7 lines
Quoted 2 lines
It's deliberately EIO as not to force a change in behavior. I don't mind using something else, but that should be a separate change then.
Thanks for these feedbacks. Shall I send v2 with an extra patch that changes EIO to ENODEV/ENXIO? Or shall we do that in a follow up patch? Also, any preference between ENODEV and ENXIO?
Please make it an addtional patch, and use ENODEV as a return value. For this patch you can add:
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH 2/2 scsi: use BLK_STS_OFFLINE for not fully online devices
In reply to Song LiuThe new error message for such case looks like
[ 172.809565] device offline error, dev sda, sector 3138208 ...
which will not be confused with regular I/O error (BLK_STS_IOERR).
--- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -1276,7 +1276,7 @@ scsi_device_state_check(struct scsi_device *sdev, struct request *req)* power management commands. */ if (req && !(req->rq_flags &RQF_PM )) -return BLK_STS_IOERR ; +return BLK_STS_OFFLINE ;return BLK_STS_OK ; } }
Signature · 1 line
2.30.2
Re: [PATCH 2/2] scsi: use BLK_STS_OFFLINE for not fully online devices
CC linux-block (it was a typo in the original email)
Quoted 28 lines · Song Liu
The new error message for such case looks like
[ 172.809565] device offline error, dev sda, sector 3138208 ...which will not be confused with regular I/O error (
BLK_STS_IOERR).Signed-off-by Song Liu <[email protected]>--- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/scsi_lib.c +1
-2@@ -1276,7 +1276,7 @@ scsi_device_state_check(struct scsi_device *sdev, struct request *req)* power management commands. */ if (req && !(req->rq_flags &RQF_PM )) -return BLK_STS_IOERR ; +return BLK_STS_OFFLINE ;return BLK_STS_OK ; } } --2.30.2
Hannes Reinecke
Reviewed-byRe: [PATCH 2/2] scsi: use BLK_STS_OFFLINE for not fully online devices
Quoted 15 lines · Song Liu
CC linux-block (it was a typo in the original email)
Quoted 12 lines · Song Liu
The new error message for such case looks like
[ 172.809565] device offline error, dev sda, sector 3138208 ...which will not be confused with regular I/O error (
BLK_STS_IOERR).Signed-off-by Song Liu <[email protected]>--- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 14 lines
drivers/scsi/scsi_lib.c +1
-2@@ -1276,7 +1276,7 @@ scsi_device_state_check(struct scsi_device *sdev, struct request *req)* power management commands. */ if (req && !(req->rq_flags &RQF_PM )) -return BLK_STS_IOERR ; +return BLK_STS_OFFLINE ;return BLK_STS_OK ; } } --Quoted 2 lines
2.30.2
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
CC linux-block (it was a typo in the original email)
Quoted 27 lines · Song Liu
We have a use case where HDDs are regularly power on/off to perserve power. When a drive is being removed, we often see errors like
[ 172.803279] I/O error, dev sda, sector 3137184These messages are confusing for automations that grep dmesg, as they look very similar to real HDD error.
Solve this issue with a new block state
BLK_STS_OFFLINE. After the change, the error message looks like[ 172.803279] device offline error, dev sda, sector 3137184so that the automations won't confuse them with real I/O error.
Song Liu (2):
block: introduceBLK_STS_OFFLINE
scsi: useBLK_STS_OFFLINEfor not fully online devicesblock/blk-core.c | 1 + drivers/scsi/scsi_lib.c | 2 +- include/linux/blk_types.h | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)--
2.30.2