[PATCH 1/2] jffs2: Convert jffs2_do_readpage_nolock to take a folio

Zhihao Cheng chengzhihao1 at huawei.com
Fri Aug 16 05:59:28 PDT 2024


在 2024/8/15 3:59, Matthew Wilcox (Oracle) 写道:
> Both callers now have a folio, so pass it in.  No effort is made
> here to support large folios.  Removes several hidden calls to
> compound_head(), two references to page->index and a use of kmap.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy at infradead.org>
> ---
>   fs/jffs2/file.c | 24 +++++++++++-------------
>   1 file changed, 11 insertions(+), 13 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
> diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
> index ada572c466f8..13c18ccc13b0 100644
> --- a/fs/jffs2/file.c
> +++ b/fs/jffs2/file.c
> @@ -77,29 +77,27 @@ const struct address_space_operations jffs2_file_address_operations =
>   	.write_end =	jffs2_write_end,
>   };
>   
> -static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
> +static int jffs2_do_readpage_nolock(struct inode *inode, struct folio *folio)
>   {
>   	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
>   	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
> -	unsigned char *pg_buf;
> +	unsigned char *kaddr;
>   	int ret;
>   
>   	jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
> -		  __func__, inode->i_ino, pg->index << PAGE_SHIFT);
> +		  __func__, inode->i_ino, folio->index << PAGE_SHIFT);
>   
> -	BUG_ON(!PageLocked(pg));
> +	BUG_ON(!folio_test_locked(folio));
>   
> -	pg_buf = kmap(pg);
> -	/* FIXME: Can kmap fail? */
> -
> -	ret = jffs2_read_inode_range(c, f, pg_buf, pg->index << PAGE_SHIFT,
> +	kaddr = kmap_local_folio(folio, 0);
> +	ret = jffs2_read_inode_range(c, f, kaddr, folio->index << PAGE_SHIFT,
>   				     PAGE_SIZE);
> +	kunmap_local(kaddr);
>   
>   	if (!ret)
> -		SetPageUptodate(pg);
> +		folio_mark_uptodate(folio);
>   
> -	flush_dcache_page(pg);
> -	kunmap(pg);
> +	flush_dcache_folio(folio);
>   
>   	jffs2_dbg(2, "readpage finished\n");
>   	return ret;
> @@ -107,7 +105,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
>   
>   int __jffs2_read_folio(struct file *file, struct folio *folio)
>   {
> -	int ret = jffs2_do_readpage_nolock(folio->mapping->host, &folio->page);
> +	int ret = jffs2_do_readpage_nolock(folio->mapping->host, folio);
>   	folio_unlock(folio);
>   	return ret;
>   }
> @@ -221,7 +219,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
>   	 */
>   	if (!folio_test_uptodate(folio)) {
>   		mutex_lock(&f->sem);
> -		ret = jffs2_do_readpage_nolock(inode, &folio->page);
> +		ret = jffs2_do_readpage_nolock(inode, folio);
>   		mutex_unlock(&f->sem);
>   		if (ret) {
>   			folio_unlock(folio);
> 




More information about the linux-mtd mailing list