diff mbox series

mm, netfs: Fix readahead bits

Message ID 1234933.1617886271@warthog.procyon.org.uk (mailing list archive)
State New, archived
Headers show
Series mm, netfs: Fix readahead bits | expand

Commit Message

David Howells April 8, 2021, 12:51 p.m. UTC
Hi Willy, Jeff,

I think we need the attached change to readahead_expand() to fix the oops seen
when it tries to dereference ractl->ra when called indirectly from
netfs_write_begin().

netfs_write_begin() should also be using DEFINE_READAHEAD() rather than
manually initialising the ractl variable so that Willy can find it;-).

David
---
commit 9c0931285131c3b65ab4b58b614c30c7feb1dbd4
Author: David Howells <dhowells@redhat.com>
Date:   Thu Apr 8 13:39:54 2021 +0100

    netfs: readahead fixes

Comments

Matthew Wilcox April 8, 2021, 1:09 p.m. UTC | #1
On Thu, Apr 08, 2021 at 01:51:11PM +0100, David Howells wrote:
> Hi Willy, Jeff,
> 
> I think we need the attached change to readahead_expand() to fix the oops seen
> when it tries to dereference ractl->ra when called indirectly from
> netfs_write_begin().
> 
> netfs_write_begin() should also be using DEFINE_READAHEAD() rather than
> manually initialising the ractl variable so that Willy can find it;-).

ACK.  Please fold into the appropriate patches.
diff mbox series

Patch

diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index 762a15350242..1d3b50c5db6d 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -1065,12 +1065,7 @@  int netfs_write_begin(struct file *file, struct address_space *mapping,
 	loff_t size;
 	int ret;
 
-	struct readahead_control ractl = {
-		.file		= file,
-		.mapping	= mapping,
-		._index		= index,
-		._nr_pages	= 0,
-	};
+	DEFINE_READAHEAD(ractl, file, NULL, mapping, index);
 
 retry:
 	page = grab_cache_page_write_begin(mapping, index, 0);
diff --git a/mm/readahead.c b/mm/readahead.c
index 65215c48f25c..f02dbebf1cef 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -706,8 +706,10 @@  void readahead_expand(struct readahead_control *ractl,
 			return;
 		}
 		ractl->_nr_pages++;
-		ra->size++;
-		ra->async_size++;
+		if (ra) {
+			ra->size++;
+			ra->async_size++;
+		}
 	}
 }
 EXPORT_SYMBOL(readahead_expand);