ufs: Convert ufs_make_empty() to use a folio
Removes a few hidden calls to compound_head() and uses kmap_local instead of kmap. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
767bd0af25
commit
f4a20e53ab
25
fs/ufs/dir.c
25
fs/ufs/dir.c
@ -540,26 +540,25 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
|
||||
{
|
||||
struct super_block * sb = dir->i_sb;
|
||||
struct address_space *mapping = inode->i_mapping;
|
||||
struct page *page = grab_cache_page(mapping, 0);
|
||||
struct folio *folio = filemap_grab_folio(mapping, 0);
|
||||
const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
|
||||
struct ufs_dir_entry * de;
|
||||
char *base;
|
||||
int err;
|
||||
char *kaddr;
|
||||
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
if (IS_ERR(folio))
|
||||
return PTR_ERR(folio);
|
||||
|
||||
err = ufs_prepare_chunk(page, 0, chunk_size);
|
||||
err = ufs_prepare_chunk(&folio->page, 0, chunk_size);
|
||||
if (err) {
|
||||
unlock_page(page);
|
||||
folio_unlock(folio);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
kmap(page);
|
||||
base = (char*)page_address(page);
|
||||
memset(base, 0, PAGE_SIZE);
|
||||
kaddr = kmap_local_folio(folio, 0);
|
||||
memset(kaddr, 0, folio_size(folio));
|
||||
|
||||
de = (struct ufs_dir_entry *) base;
|
||||
de = (struct ufs_dir_entry *)kaddr;
|
||||
|
||||
de->d_ino = cpu_to_fs32(sb, inode->i_ino);
|
||||
ufs_set_de_type(sb, de, inode->i_mode);
|
||||
@ -573,12 +572,12 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
|
||||
de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1));
|
||||
ufs_set_de_namlen(sb, de, 2);
|
||||
strcpy (de->d_name, "..");
|
||||
kunmap(page);
|
||||
kunmap_local(kaddr);
|
||||
|
||||
ufs_commit_chunk(page, 0, chunk_size);
|
||||
ufs_commit_chunk(&folio->page, 0, chunk_size);
|
||||
err = ufs_handle_dirsync(inode);
|
||||
fail:
|
||||
put_page(page);
|
||||
folio_put(folio);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user