diff mbox series

[13/15] ubifs: Pass a folio into ubifs_bulk_read() and ubifs_do_bulk_read()

Message ID 20240120230824.2619716-14-willy@infradead.org
State Superseded
Headers show
Series ubifs folio conversion | expand

Commit Message

Matthew Wilcox Jan. 20, 2024, 11:08 p.m. UTC
This saves a single call to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ubifs/file.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

Comments

Zhihao Cheng Jan. 22, 2024, 12:15 p.m. UTC | #1
在 2024/1/21 7:08, Matthew Wilcox (Oracle) 写道:
> This saves a single call to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/ubifs/file.c | 28 +++++++++++++---------------
>   1 file changed, 13 insertions(+), 15 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index f34371436a84..8cad1fe9c50f 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -705,15 +705,15 @@ static int populate_page(struct ubifs_info *c, struct page *page,
>    * ubifs_do_bulk_read - do bulk-read.
>    * @c: UBIFS file-system description object
>    * @bu: bulk-read information
> - * @page1: first page to read
> + * @folio1: first folio to read
>    *
>    * Returns: %1 if the bulk-read is done, otherwise %0 is returned.
>    */
>   static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
> -			      struct page *page1)
> +			      struct folio *folio1)
>   {
> -	pgoff_t offset = page1->index, end_index;
> -	struct address_space *mapping = page1->mapping;
> +	pgoff_t offset = folio1->index, end_index;
> +	struct address_space *mapping = folio1->mapping;
>   	struct inode *inode = mapping->host;
>   	struct ubifs_inode *ui = ubifs_inode(inode);
>   	int err, page_idx, page_cnt, ret = 0, n = 0;
> @@ -763,11 +763,11 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
>   			goto out_warn;
>   	}
>   
> -	err = populate_page(c, page1, bu, &n);
> +	err = populate_page(c, &folio1->page, bu, &n);
>   	if (err)
>   		goto out_warn;
>   
> -	unlock_page(page1);
> +	folio_unlock(folio1);
>   	ret = 1;
>   
>   	isize = i_size_read(inode);
> @@ -812,7 +812,7 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
>   
>   /**
>    * ubifs_bulk_read - determine whether to bulk-read and, if so, do it.
> - * @page: page from which to start bulk-read.
> + * @folio: folio from which to start bulk-read.
>    *
>    * Some flash media are capable of reading sequentially at faster rates. UBIFS
>    * bulk-read facility is designed to take advantage of that, by reading in one
> @@ -821,12 +821,12 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
>    *
>    * Returns: %1 if a bulk-read is done and %0 otherwise.
>    */
> -static int ubifs_bulk_read(struct page *page)
> +static int ubifs_bulk_read(struct folio *folio)
>   {
> -	struct inode *inode = page->mapping->host;
> +	struct inode *inode = folio->mapping->host;
>   	struct ubifs_info *c = inode->i_sb->s_fs_info;
>   	struct ubifs_inode *ui = ubifs_inode(inode);
> -	pgoff_t index = page->index, last_page_read = ui->last_page_read;
> +	pgoff_t index = folio->index, last_page_read = ui->last_page_read;
>   	struct bu_info *bu;
>   	int err = 0, allocated = 0;
>   
> @@ -874,8 +874,8 @@ static int ubifs_bulk_read(struct page *page)
>   
>   	bu->buf_len = c->max_bu_buf_len;
>   	data_key_init(c, &bu->key, inode->i_ino,
> -		      page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT);
> -	err = ubifs_do_bulk_read(c, bu, page);
> +		      folio->index << UBIFS_BLOCKS_PER_PAGE_SHIFT);
> +	err = ubifs_do_bulk_read(c, bu, folio);
>   
>   	if (!allocated)
>   		mutex_unlock(&c->bu_mutex);
> @@ -889,9 +889,7 @@ static int ubifs_bulk_read(struct page *page)
>   
>   static int ubifs_read_folio(struct file *file, struct folio *folio)
>   {
> -	struct page *page = &folio->page;
> -
> -	if (ubifs_bulk_read(page))
> +	if (ubifs_bulk_read(folio))
>   		return 0;
>   	do_readpage(folio);
>   	folio_unlock(folio);
>
diff mbox series

Patch

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index f34371436a84..8cad1fe9c50f 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -705,15 +705,15 @@  static int populate_page(struct ubifs_info *c, struct page *page,
  * ubifs_do_bulk_read - do bulk-read.
  * @c: UBIFS file-system description object
  * @bu: bulk-read information
- * @page1: first page to read
+ * @folio1: first folio to read
  *
  * Returns: %1 if the bulk-read is done, otherwise %0 is returned.
  */
 static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
-			      struct page *page1)
+			      struct folio *folio1)
 {
-	pgoff_t offset = page1->index, end_index;
-	struct address_space *mapping = page1->mapping;
+	pgoff_t offset = folio1->index, end_index;
+	struct address_space *mapping = folio1->mapping;
 	struct inode *inode = mapping->host;
 	struct ubifs_inode *ui = ubifs_inode(inode);
 	int err, page_idx, page_cnt, ret = 0, n = 0;
@@ -763,11 +763,11 @@  static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
 			goto out_warn;
 	}
 
-	err = populate_page(c, page1, bu, &n);
+	err = populate_page(c, &folio1->page, bu, &n);
 	if (err)
 		goto out_warn;
 
-	unlock_page(page1);
+	folio_unlock(folio1);
 	ret = 1;
 
 	isize = i_size_read(inode);
@@ -812,7 +812,7 @@  static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
 
 /**
  * ubifs_bulk_read - determine whether to bulk-read and, if so, do it.
- * @page: page from which to start bulk-read.
+ * @folio: folio from which to start bulk-read.
  *
  * Some flash media are capable of reading sequentially at faster rates. UBIFS
  * bulk-read facility is designed to take advantage of that, by reading in one
@@ -821,12 +821,12 @@  static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu,
  *
  * Returns: %1 if a bulk-read is done and %0 otherwise.
  */
-static int ubifs_bulk_read(struct page *page)
+static int ubifs_bulk_read(struct folio *folio)
 {
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	struct ubifs_info *c = inode->i_sb->s_fs_info;
 	struct ubifs_inode *ui = ubifs_inode(inode);
-	pgoff_t index = page->index, last_page_read = ui->last_page_read;
+	pgoff_t index = folio->index, last_page_read = ui->last_page_read;
 	struct bu_info *bu;
 	int err = 0, allocated = 0;
 
@@ -874,8 +874,8 @@  static int ubifs_bulk_read(struct page *page)
 
 	bu->buf_len = c->max_bu_buf_len;
 	data_key_init(c, &bu->key, inode->i_ino,
-		      page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT);
-	err = ubifs_do_bulk_read(c, bu, page);
+		      folio->index << UBIFS_BLOCKS_PER_PAGE_SHIFT);
+	err = ubifs_do_bulk_read(c, bu, folio);
 
 	if (!allocated)
 		mutex_unlock(&c->bu_mutex);
@@ -889,9 +889,7 @@  static int ubifs_bulk_read(struct page *page)
 
 static int ubifs_read_folio(struct file *file, struct folio *folio)
 {
-	struct page *page = &folio->page;
-
-	if (ubifs_bulk_read(page))
+	if (ubifs_bulk_read(folio))
 		return 0;
 	do_readpage(folio);
 	folio_unlock(folio);