Skip to content

Commit 8c8ebed

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: add a macro to initialize the status table
Prepare for adding a new value to the error table by adding a macro to fill it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Md Haris Iqbal <haris.iqbal@linux.dev> Link: https://patch.msgid.link/20260611140703.2401204-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 64e3357 commit 8c8ebed

1 file changed

Lines changed: 25 additions & 20 deletions

File tree

block/blk-core.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,39 +132,44 @@ inline const char *blk_op_str(enum req_op op)
132132
}
133133
EXPORT_SYMBOL_GPL(blk_op_str);
134134

135+
#define ENT(_tag, _errno, _desc) \
136+
[BLK_STS_##_tag] = { \
137+
.errno = _errno, \
138+
.name = _desc, \
139+
}
135140
static const struct {
136141
int errno;
137142
const char *name;
138143
} blk_errors[] = {
139-
[BLK_STS_OK] = { 0, "" },
140-
[BLK_STS_NOTSUPP] = { -EOPNOTSUPP, "operation not supported" },
141-
[BLK_STS_TIMEOUT] = { -ETIMEDOUT, "timeout" },
142-
[BLK_STS_NOSPC] = { -ENOSPC, "critical space allocation" },
143-
[BLK_STS_TRANSPORT] = { -ENOLINK, "recoverable transport" },
144-
[BLK_STS_TARGET] = { -EREMOTEIO, "critical target" },
145-
[BLK_STS_RESV_CONFLICT] = { -EBADE, "reservation conflict" },
146-
[BLK_STS_MEDIUM] = { -ENODATA, "critical medium" },
147-
[BLK_STS_PROTECTION] = { -EILSEQ, "protection" },
148-
[BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" },
149-
[BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" },
150-
[BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" },
151-
[BLK_STS_OFFLINE] = { -ENODEV, "device offline" },
144+
ENT(OK, 0, ""),
145+
ENT(NOTSUPP, -EOPNOTSUPP, "operation not supported"),
146+
ENT(TIMEOUT, -ETIMEDOUT, "timeout"),
147+
ENT(NOSPC, -ENOSPC, "critical space allocation"),
148+
ENT(TRANSPORT, -ENOLINK, "recoverable transport"),
149+
ENT(TARGET, -EREMOTEIO, "critical target"),
150+
ENT(RESV_CONFLICT, -EBADE, "reservation conflict"),
151+
ENT(MEDIUM, -ENODATA, "critical medium"),
152+
ENT(PROTECTION, -EILSEQ, "protection"),
153+
ENT(RESOURCE, -ENOMEM, "kernel resource"),
154+
ENT(DEV_RESOURCE, -EBUSY, "device resource"),
155+
ENT(AGAIN, -EAGAIN, "nonblocking retry"),
156+
ENT(OFFLINE, -ENODEV, "device offline"),
152157

153158
/* device mapper special case, should not leak out: */
154-
[BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },
159+
ENT(DM_REQUEUE, -EREMCHG, "dm internal retry"),
155160

156161
/* zone device specific errors */
157-
[BLK_STS_ZONE_OPEN_RESOURCE] = { -ETOOMANYREFS, "open zones exceeded" },
158-
[BLK_STS_ZONE_ACTIVE_RESOURCE] = { -EOVERFLOW, "active zones exceeded" },
162+
ENT(ZONE_OPEN_RESOURCE, -ETOOMANYREFS, "open zones exceeded"),
163+
ENT(ZONE_ACTIVE_RESOURCE, -EOVERFLOW, "active zones exceeded"),
159164

160165
/* Command duration limit device-side timeout */
161-
[BLK_STS_DURATION_LIMIT] = { -ETIME, "duration limit exceeded" },
162-
163-
[BLK_STS_INVAL] = { -EINVAL, "invalid" },
166+
ENT(DURATION_LIMIT, -ETIME, "duration limit exceeded"),
167+
ENT(INVAL, -EINVAL, "invalid"),
164168

165169
/* everything else not covered above: */
166-
[BLK_STS_IOERR] = { -EIO, "I/O" },
170+
ENT(IOERR, -EIO, "I/O"),
167171
};
172+
#undef ENT
168173

169174
blk_status_t errno_to_blk_status(int errno)
170175
{

0 commit comments

Comments
 (0)