Commit eff1f906 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

shmem: convert shmem_write_begin() to use shmem_get_folio()

Use a folio throughout this function, saving a couple of calls to
compound_head().

Link: https://lkml.kernel.org/r/20220902194653.1739778-27-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent a7f5862c
...@@ -2498,6 +2498,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping, ...@@ -2498,6 +2498,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_inode_info *info = SHMEM_I(inode);
pgoff_t index = pos >> PAGE_SHIFT; pgoff_t index = pos >> PAGE_SHIFT;
struct folio *folio;
int ret = 0; int ret = 0;
/* i_rwsem is held by caller */ /* i_rwsem is held by caller */
...@@ -2509,14 +2510,15 @@ shmem_write_begin(struct file *file, struct address_space *mapping, ...@@ -2509,14 +2510,15 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
return -EPERM; return -EPERM;
} }
ret = shmem_getpage(inode, index, pagep, SGP_WRITE); ret = shmem_get_folio(inode, index, &folio, SGP_WRITE);
if (ret) if (ret)
return ret; return ret;
*pagep = folio_file_page(folio, index);
if (PageHWPoison(*pagep)) { if (PageHWPoison(*pagep)) {
unlock_page(*pagep); folio_unlock(folio);
put_page(*pagep); folio_put(folio);
*pagep = NULL; *pagep = NULL;
return -EIO; return -EIO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment