Skip to contentSkip to conversation

netfs: Fix missing xas_retry() calls in xarray iteration

PATCH Superseded Anthony Brennan 2 participants 2 messages Dec 22, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfs: Fix missing xas_retry() calls in xarray iteration

commit 59d0d52c30d4991ac4b329f049cc37118e00f5b0 upstream

Stops kernel from crashing when encountering an XAS retry entry. Patch modified from upstream to work with pages instead of folios, and omits fixes to "dodgy maths" as unrelated to fixing the crash.

---
 fs/netfs/read_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/netfs/read_helper.c +6 -0
index 242f8bcb34a4..4de15555bceb 100644
@@ -248,6 +248,9 @@ static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq,
 		XA_STATE(xas, &rreq->mapping->i_pages, subreq->start / PAGE_SIZE);
 
 		xas_for_each(&xas, page, (subreq->start + subreq->len - 1) / PAGE_SIZE) {
+			if(xas_retry(&xas, page))
+				continue;
+
 			/* We might have multiple writes from the same huge
 			 * page, but we mustn't unlock a page more than once.
 			 */
@@ -403,6 +406,9 @@ static void netfs_rreq_unlock(struct netfs_read_request *rreq)
 		unsigned int pgend = pgpos + thp_size(page);
 		bool pg_failed = false;
 
+		if(xas_retry(&xas, page))
+			continue;
+
 		for (;;) {
 			if (!subreq) {
 				pg_failed = true;
Signature · 1 line
2.30.2
#1 lore raw

From: Anthony Brennan

Quoted 18 lines

Sent: 22 December 2023 00:15

commit 59d0d52c30d4991ac4b329f049cc37118e00f5b0 upstream

Stops kernel from crashing when encountering an XAS retry entry. Patch modified from upstream to work with pages instead of folios, and omits fixes to "dodgy maths" as unrelated to fixing the crash.

---
 fs/netfs/read_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/netfs/read_helper.c +0 -0
index 242f8bcb34a4..4de15555bceb 100644

fs/netfs/read_helper.c static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq, · line 251

Quoted 4 lines
fs/netfs/read_helper.c +1 -0
@@ -248,6 +248,9 @@ static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq,
 		XA_STATE(xas, &rreq->mapping->i_pages, subreq->start / PAGE_SIZE);
 
 		xas_for_each(&xas, page, (subreq->start + subreq->len - 1) / PAGE_SIZE) {
+			if(xas_retry(&xas, page))

'if' is not a function.

Quoted 16 lines
fs/netfs/read_helper.c +5 -1
+				continue;
+
 			/* We might have multiple writes from the same huge
 			 * page, but we mustn't unlock a page more than once.
 			 */
@@ -403,6 +406,9 @@ static void netfs_rreq_unlock(struct netfs_read_request *rreq)
 		unsigned int pgend = pgpos + thp_size(page);
 		bool pg_failed = false;
 
+		if(xas_retry(&xas, page))
+			continue;
+
 		for (;;) {
 			if (!subreq) {
 				pg_failed = true;
--
Quoted 1 line

2.30.2

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)