io_uring: add req flag invariant build assertion
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 31 Mar 2025 07:54:00 +0000 (08:54 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 31 Mar 2025 13:07:34 +0000 (07:07 -0600)
We're caching some of file related request flags in a tricky way, put
a build check to make sure flags don't get reshuffled.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9877577b83c25dd78224a8274f799187e7ec7639.1743407551.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index e4484a03e033e0a7cee6e37ad796657aca40e22e..a4065e3d13d0695fea0f24b340886344b82a652d 100644 (file)
@@ -1643,6 +1643,8 @@ io_req_flags_t io_file_get_flags(struct file *file)
 {
        io_req_flags_t res = 0;
 
+       BUILD_BUG_ON(REQ_F_ISREG_BIT != REQ_F_SUPPORT_NOWAIT_BIT + 1);
+
        if (S_ISREG(file_inode(file)->i_mode))
                res |= REQ_F_ISREG;
        if ((file->f_flags & O_NONBLOCK) || (file->f_mode & FMODE_NOWAIT))