Merge branch 'for-4.16/block' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / include / linux / blk_types.h
index 9e7d8bd776d227d2ba92b137af7230300f5b1d4a..c5d3db0d83f8ac1adf177f0f92c7bf3ed0e2c261 100644 (file)
@@ -39,6 +39,34 @@ typedef u8 __bitwise blk_status_t;
 
 #define BLK_STS_AGAIN          ((__force blk_status_t)12)
 
+/**
+ * blk_path_error - returns true if error may be path related
+ * @error: status the request was completed with
+ *
+ * Description:
+ *     This classifies block error status into non-retryable errors and ones
+ *     that may be successful if retried on a failover path.
+ *
+ * Return:
+ *     %false - retrying failover path will not help
+ *     %true  - may succeed if retried
+ */
+static inline bool blk_path_error(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;
 };