shmem: convert shmem_symlink() to use a folio
While symlinks will always be < PAGE_SIZE, using the folio APIs gets rid of unnecessary calls to compound_head(). Link: https://lkml.kernel.org/r/20220902194653.1739778-30-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
b0802b22a9
commit
7ad0414bde
14
mm/shmem.c
14
mm/shmem.c
@ -3093,7 +3093,7 @@ static int shmem_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
int error;
|
int error;
|
||||||
int len;
|
int len;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct page *page;
|
struct folio *folio;
|
||||||
|
|
||||||
len = strlen(symname) + 1;
|
len = strlen(symname) + 1;
|
||||||
if (len > PAGE_SIZE)
|
if (len > PAGE_SIZE)
|
||||||
@ -3121,18 +3121,18 @@ static int shmem_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
inode->i_op = &shmem_short_symlink_operations;
|
inode->i_op = &shmem_short_symlink_operations;
|
||||||
} else {
|
} else {
|
||||||
inode_nohighmem(inode);
|
inode_nohighmem(inode);
|
||||||
error = shmem_getpage(inode, 0, &page, SGP_WRITE);
|
error = shmem_get_folio(inode, 0, &folio, SGP_WRITE);
|
||||||
if (error) {
|
if (error) {
|
||||||
iput(inode);
|
iput(inode);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
inode->i_mapping->a_ops = &shmem_aops;
|
inode->i_mapping->a_ops = &shmem_aops;
|
||||||
inode->i_op = &shmem_symlink_inode_operations;
|
inode->i_op = &shmem_symlink_inode_operations;
|
||||||
memcpy(page_address(page), symname, len);
|
memcpy(folio_address(folio), symname, len);
|
||||||
SetPageUptodate(page);
|
folio_mark_uptodate(folio);
|
||||||
set_page_dirty(page);
|
folio_mark_dirty(folio);
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
put_page(page);
|
folio_put(folio);
|
||||||
}
|
}
|
||||||
dir->i_size += BOGO_DIRENT_SIZE;
|
dir->i_size += BOGO_DIRENT_SIZE;
|
||||||
dir->i_ctime = dir->i_mtime = current_time(dir);
|
dir->i_ctime = dir->i_mtime = current_time(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user