summaryrefslogtreecommitdiff
path: root/android-mainline/ANDROID-Revert-io_uring-remove-__io_file_supports_nowait.patch
blob: bacaa08b8efadfea7a84c06cb02b01e881a4c642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <draszik@google.com>
Date: Thu, 13 Jul 2023 10:38:49 +0100
Subject: ANDROID: Revert "io_uring: remove __io_file_supports_nowait"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit b9a6c9459a5aec7bfd9b763554d15148367f1806.

We want to revert caec5ebe77f9 ("io_uring: rely solely on
FMODE_NOWAIT") and doing this revert here will help to do so more
cleanly.

Test: manual boot test, TH
Bug: 290862678
Change-Id: Idcbc3ee68fb976401451cb18c9077bd1bcafe6bd
Signed-off-by: André Draszik <draszik@google.com>
(cherry picked from commit e384f1d61786d5abe114032efa281c1536d75a96)
Signed-off-by: Lee Jones <joneslee@google.com>
---
 io_uring/io_uring.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1753,6 +1753,19 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags)
 	}
 }
 
+/*
+ * If we tracked the file through the SCM inflight mechanism, we could support
+ * any file. For now, just ensure that anything potentially problematic is done
+ * inline.
+ */
+static bool __io_file_supports_nowait(struct file *file, umode_t mode)
+{
+	/* any ->read/write should understand O_NONBLOCK */
+	if (file->f_flags & O_NONBLOCK)
+		return true;
+	return file->f_mode & FMODE_NOWAIT;
+}
+
 unsigned int io_file_get_flags(struct file *file)
 {
 	umode_t mode = file_inode(file)->i_mode;
@@ -1760,7 +1773,7 @@ unsigned int io_file_get_flags(struct file *file)
 
 	if (S_ISREG(mode))
 		res |= REQ_F_ISREG;
-	if ((file->f_flags & O_NONBLOCK) || (file->f_mode & FMODE_NOWAIT))
+	if (__io_file_supports_nowait(file, mode))
 		res |= REQ_F_SUPPORT_NOWAIT;
 	return res;
 }