diff mbox series

[20/23] ocfs2: Use a folio in ocfs2_fast_symlink_read_folio()

Message ID 20241205171653.3179945-21-willy@infradead.org (mailing list archive)
State New
Headers show
Series Convert ocfs2 to use folios | expand

Commit Message

Matthew Wilcox (Oracle) Dec. 5, 2024, 5:16 p.m. UTC
Use folio_end_read() instead of SetPageUptodate() and unlock_page().
Use memcpy_to_folio() instead of open-coding a kmap_atomic() sequence.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/symlink.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Joseph Qi Dec. 14, 2024, 2:43 p.m. UTC | #1
On 2024/12/6 01:16, Matthew Wilcox (Oracle) wrote:
> Use folio_end_read() instead of SetPageUptodate() and unlock_page().
> Use memcpy_to_folio() instead of open-coding a kmap_atomic() sequence.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/symlink.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
> index f5cf2255dc09..ad8be3300b49 100644
> --- a/fs/ocfs2/symlink.c
> +++ b/fs/ocfs2/symlink.c
> @@ -54,13 +54,11 @@
>  
>  static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
>  {
> -	struct page *page = &folio->page;
> -	struct inode *inode = page->mapping->host;
> +	struct inode *inode = folio->mapping->host;
>  	struct buffer_head *bh = NULL;
>  	int status = ocfs2_read_inode_block(inode, &bh);
>  	struct ocfs2_dinode *fe;
>  	const char *link;
> -	void *kaddr;
>  	size_t len;
>  
>  	if (status < 0) {
> @@ -72,12 +70,9 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
>  	link = (char *) fe->id2.i_symlink;
>  	/* will be less than a page size */
>  	len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
> -	kaddr = kmap_atomic(page);
> -	memcpy(kaddr, link, len + 1);
> -	kunmap_atomic(kaddr);
> -	SetPageUptodate(page);
> +	memcpy_to_folio(folio, 0, link, len + 1);
>  out:
> -	unlock_page(page);
> +	folio_end_read(folio, status == 0);
>  	brelse(bh);
>  	return status;
>  }
diff mbox series

Patch

diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index f5cf2255dc09..ad8be3300b49 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -54,13 +54,11 @@ 
 
 static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
 {
-	struct page *page = &folio->page;
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	struct buffer_head *bh = NULL;
 	int status = ocfs2_read_inode_block(inode, &bh);
 	struct ocfs2_dinode *fe;
 	const char *link;
-	void *kaddr;
 	size_t len;
 
 	if (status < 0) {
@@ -72,12 +70,9 @@  static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
 	link = (char *) fe->id2.i_symlink;
 	/* will be less than a page size */
 	len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
-	kaddr = kmap_atomic(page);
-	memcpy(kaddr, link, len + 1);
-	kunmap_atomic(kaddr);
-	SetPageUptodate(page);
+	memcpy_to_folio(folio, 0, link, len + 1);
 out:
-	unlock_page(page);
+	folio_end_read(folio, status == 0);
 	brelse(bh);
 	return status;
 }