linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Use readahead_batch_length
@ 2021-03-21 21:03 Matthew Wilcox (Oracle)
  2021-03-30 17:38 ` Matthew Wilcox
  2021-04-06 19:42 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-03-21 21:03 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, linux-fsdevel
  Cc: Matthew Wilcox (Oracle)

Implement readahead_batch_length() to determine the number of bytes in
the current batch of readahead pages and use it in btrfs.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/btrfs/extent_io.c    | 6 ++----
 include/linux/pagemap.h | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e9837562f7d6..97ac4ddb2857 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4875,10 +4875,8 @@ void extent_readahead(struct readahead_control *rac)
 	int nr;
 
 	while ((nr = readahead_page_batch(rac, pagepool))) {
-		u64 contig_start = page_offset(pagepool[0]);
-		u64 contig_end = page_offset(pagepool[nr - 1]) + PAGE_SIZE - 1;
-
-		ASSERT(contig_start + nr * PAGE_SIZE - 1 == contig_end);
+		u64 contig_start = readahead_pos(rac);
+		u64 contig_end = contig_start + readahead_batch_length(rac) - 1;
 
 		contiguous_readpages(pagepool, nr, contig_start, contig_end,
 				&em_cached, &bio, &bio_flags, &prev_em_start);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 2cbfd4c36026..92939afd4944 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1174,6 +1174,15 @@ static inline unsigned int readahead_count(struct readahead_control *rac)
 	return rac->_nr_pages;
 }
 
+/**
+ * readahead_batch_length - The number of bytes in the current batch.
+ * @rac: The readahead request.
+ */
+static inline loff_t readahead_batch_length(struct readahead_control *rac)
+{
+	return rac->_batch_count * PAGE_SIZE;
+}
+
 static inline unsigned long dir_pages(struct inode *inode)
 {
 	return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: Use readahead_batch_length
  2021-03-21 21:03 [PATCH] btrfs: Use readahead_batch_length Matthew Wilcox (Oracle)
@ 2021-03-30 17:38 ` Matthew Wilcox
  2021-04-06 19:42 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2021-03-30 17:38 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, linux-fsdevel

ping?

On Sun, Mar 21, 2021 at 09:03:11PM +0000, Matthew Wilcox (Oracle) wrote:
> Implement readahead_batch_length() to determine the number of bytes in
> the current batch of readahead pages and use it in btrfs.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  fs/btrfs/extent_io.c    | 6 ++----
>  include/linux/pagemap.h | 9 +++++++++
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index e9837562f7d6..97ac4ddb2857 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -4875,10 +4875,8 @@ void extent_readahead(struct readahead_control *rac)
>  	int nr;
>  
>  	while ((nr = readahead_page_batch(rac, pagepool))) {
> -		u64 contig_start = page_offset(pagepool[0]);
> -		u64 contig_end = page_offset(pagepool[nr - 1]) + PAGE_SIZE - 1;
> -
> -		ASSERT(contig_start + nr * PAGE_SIZE - 1 == contig_end);
> +		u64 contig_start = readahead_pos(rac);
> +		u64 contig_end = contig_start + readahead_batch_length(rac) - 1;
>  
>  		contiguous_readpages(pagepool, nr, contig_start, contig_end,
>  				&em_cached, &bio, &bio_flags, &prev_em_start);
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 2cbfd4c36026..92939afd4944 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -1174,6 +1174,15 @@ static inline unsigned int readahead_count(struct readahead_control *rac)
>  	return rac->_nr_pages;
>  }
>  
> +/**
> + * readahead_batch_length - The number of bytes in the current batch.
> + * @rac: The readahead request.
> + */
> +static inline loff_t readahead_batch_length(struct readahead_control *rac)
> +{
> +	return rac->_batch_count * PAGE_SIZE;
> +}
> +
>  static inline unsigned long dir_pages(struct inode *inode)
>  {
>  	return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: Use readahead_batch_length
  2021-03-21 21:03 [PATCH] btrfs: Use readahead_batch_length Matthew Wilcox (Oracle)
  2021-03-30 17:38 ` Matthew Wilcox
@ 2021-04-06 19:42 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-04-06 19:42 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, linux-fsdevel, linux-mm

On Sun, Mar 21, 2021 at 09:03:11PM +0000, Matthew Wilcox (Oracle) wrote:
> Implement readahead_batch_length() to determine the number of bytes in
> the current batch of readahead pages and use it in btrfs.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Thanks, I'll take it through my tree as btrfs is probably the only user
of the new helper. The MM list hasn't been CCed, I've added it now but I
think the patch is trivial enough and does not need another ack, so it's
just for the record.

> ---
>  fs/btrfs/extent_io.c    | 6 ++----
>  include/linux/pagemap.h | 9 +++++++++
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index e9837562f7d6..97ac4ddb2857 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -4875,10 +4875,8 @@ void extent_readahead(struct readahead_control *rac)
>  	int nr;
>  
>  	while ((nr = readahead_page_batch(rac, pagepool))) {
> -		u64 contig_start = page_offset(pagepool[0]);
> -		u64 contig_end = page_offset(pagepool[nr - 1]) + PAGE_SIZE - 1;
> -
> -		ASSERT(contig_start + nr * PAGE_SIZE - 1 == contig_end);
> +		u64 contig_start = readahead_pos(rac);
> +		u64 contig_end = contig_start + readahead_batch_length(rac) - 1;
>  
>  		contiguous_readpages(pagepool, nr, contig_start, contig_end,
>  				&em_cached, &bio, &bio_flags, &prev_em_start);
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 2cbfd4c36026..92939afd4944 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -1174,6 +1174,15 @@ static inline unsigned int readahead_count(struct readahead_control *rac)
>  	return rac->_nr_pages;
>  }
>  
> +/**
> + * readahead_batch_length - The number of bytes in the current batch.
> + * @rac: The readahead request.
> + */
> +static inline loff_t readahead_batch_length(struct readahead_control *rac)
> +{
> +	return rac->_batch_count * PAGE_SIZE;
> +}
> +
>  static inline unsigned long dir_pages(struct inode *inode)
>  {
>  	return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>

--

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-06 19:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 21:03 [PATCH] btrfs: Use readahead_batch_length Matthew Wilcox (Oracle)
2021-03-30 17:38 ` Matthew Wilcox
2021-04-06 19:42 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).