summaryrefslogtreecommitdiff
path: root/android-mainline/ANDROID-Revert-io_uring-rely-solely-on-FMODE_NOWAIT.patch
blob: 62d2b7e9c7bcf1ff6d7147bbd35f92ed6db8d694 (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
57
58
59
60
61
62
63
64
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:39:13 +0100
Subject: ANDROID: Revert "io_uring: rely solely on FMODE_NOWAIT"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit caec5ebe77f97d948dcf46f07d622bda7f1f6dfd.

This commit is the reason for two (related?) issues on Pixel6:
* TH can't flash devices in fastbootd
* not all drivers are being bound to devices

Revert while we further investigate the issue.

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

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
@@ -1763,6 +1763,11 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags)
 	}
 }
 
+static bool io_bdev_nowait(struct block_device *bdev)
+{
+	return !bdev || bdev_nowait(bdev);
+}
+
 /*
  * 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
@@ -1770,6 +1775,22 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags)
  */
 static bool __io_file_supports_nowait(struct file *file, umode_t mode)
 {
+	if (S_ISBLK(mode)) {
+		if (IS_ENABLED(CONFIG_BLOCK) &&
+		    io_bdev_nowait(I_BDEV(file->f_mapping->host)))
+			return true;
+		return false;
+	}
+	if (S_ISSOCK(mode))
+		return true;
+	if (S_ISREG(mode)) {
+		if (IS_ENABLED(CONFIG_BLOCK) &&
+		    io_bdev_nowait(file->f_inode->i_sb->s_bdev) &&
+		    !io_is_uring_fops(file))
+			return true;
+		return false;
+	}
+
 	/* any ->read/write should understand O_NONBLOCK */
 	if (file->f_flags & O_NONBLOCK)
 		return true;