Skip to contentSkip to conversation

io_uring: correct O_NONBLOCK check for splice punt

PATCH In review Jens Axboe 2 participants 2 messages Apr 13, 2020

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring: correct O_NONBLOCK check for splice punt

The splice file punt check uses file->f_mode to check for O_NONBLOCK, but it should be checking file->f_flags. This leads to punting even for files that have O_NONBLOCK set, which isn't necessary. This equates to checking for FMODE_PATH, which will never be set on the fd in question.

Fixes 7d67af2c0134 ("io_uring: add splice(2) support")

---

fs/io_uring.c +1 -1
index 68a678a0056b..0d1b5d5f1251 100644
@@ -2763,7 +2763,7 @@ static bool io_splice_punt(struct file *file)
 		return false;
 	if (!io_file_supports_async(file))
 		return true;
-	return !(file->f_mode & O_NONBLOCK);
+	return !(file->f_flags & O_NONBLOCK);
 }
 
 static int io_splice(struct io_kiocb *req, bool force_nonblock)
Signature · 1 line
Jens Axboe
#1 lore raw
Quoted 5 lines · Jens Axboe

The splice file punt check uses file->f_mode to check for O_NONBLOCK, but it should be checking file->f_flags. This leads to punting even for files that have O_NONBLOCK set, which isn't necessary. This equates to checking for FMODE_PATH, which will never be set on the fd in question.

My bad, thanks

Quoted 19 lines
Fixes 7d67af2c0134 ("io_uring: add splice(2) support")

---

fs/io_uring.c +1 -1
index 68a678a0056b..0d1b5d5f1251 100644
@@ -2763,7 +2763,7 @@ static bool io_splice_punt(struct file *file)
 		return false;
 	if (!io_file_supports_async(file))
 		return true;
-	return !(file->f_mode & O_NONBLOCK);
+	return !(file->f_flags & O_NONBLOCK);
 }
 
 static int io_splice(struct io_kiocb *req, bool force_nonblock)
Signature · 1 line
Pavel Begunkov