diff mbox

[3/5] block: Provide blk_status_t decoding for retryable errors

Message ID 20180104224623.8944-4-keith.busch@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Keith Busch Jan. 4, 2018, 10:46 p.m. UTC
This patch provides a common decoder for block status that may be retried
so various entities wishing to consult this do not have to duplicate
this decision.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 include/linux/blk_types.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Mike Snitzer Jan. 4, 2018, 11:43 p.m. UTC | #1
On Thu, Jan 04 2018 at  5:46pm -0500,
Keith Busch <keith.busch@intel.com> wrote:

> This patch provides a common decoder for block status that may be retried
> so various entities wishing to consult this do not have to duplicate
> this decision.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>

Acked-by: Mike Snitzer <snitzer@redhat.com>
Hannes Reinecke Jan. 8, 2018, 8:58 a.m. UTC | #2
On 01/04/2018 11:46 PM, Keith Busch wrote:
> This patch provides a common decoder for block status that may be retried
> so various entities wishing to consult this do not have to duplicate
> this decision.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
>  include/linux/blk_types.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index a1e628e032da..b6a8723b493c 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -39,6 +39,22 @@ typedef u8 __bitwise blk_status_t;
>  
>  #define BLK_STS_AGAIN		((__force blk_status_t)12)
>  
> +static inline bool blk_retryable(blk_status_t error)
> +{
> +	switch (error) {
> +	case BLK_STS_NOTSUPP:
> +	case BLK_STS_NOSPC:
> +	case BLK_STS_TARGET:
> +	case BLK_STS_NEXUS:
> +	case BLK_STS_MEDIUM:
> +	case BLK_STS_PROTECTION:
> +		return false;
> +	}
> +
> +	/* Anything else could be a path failure, so should be retried */
> +	return true;
> +}
> +
>  struct blk_issue_stat {
>  	u64 stat;
>  };
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Christoph Hellwig Jan. 8, 2018, 9:58 a.m. UTC | #3
> +static inline bool blk_retryable(blk_status_t error)

The naming isn't really useful - it is about the fact that it's
worth retrying on another path.  So please chose a better name,
and add a kerneldoc comment describing it.
diff mbox

Patch

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index a1e628e032da..b6a8723b493c 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -39,6 +39,22 @@  typedef u8 __bitwise blk_status_t;
 
 #define BLK_STS_AGAIN		((__force blk_status_t)12)
 
+static inline bool blk_retryable(blk_status_t error)
+{
+	switch (error) {
+	case BLK_STS_NOTSUPP:
+	case BLK_STS_NOSPC:
+	case BLK_STS_TARGET:
+	case BLK_STS_NEXUS:
+	case BLK_STS_MEDIUM:
+	case BLK_STS_PROTECTION:
+		return false;
+	}
+
+	/* Anything else could be a path failure, so should be retried */
+	return true;
+}
+
 struct blk_issue_stat {
 	u64 stat;
 };