ntfs3: Convert attr_make_nonresident to use a folio

Fetch a folio from the page cache instead of a page and operate on it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
[almaz.alexandrovich@paragon-software.com: skip using folio_end_read]
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Matthew Wilcox (Oracle) 2024-04-22 20:31:56 +01:00 committed by Konstantin Komarov
parent d0c3df6277
commit 562d060bed
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -288,22 +288,21 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
if (err)
goto out2;
} else if (!page) {
char *kaddr;
struct address_space *mapping = ni->vfs_inode.i_mapping;
struct folio *folio;
page = grab_cache_page(ni->vfs_inode.i_mapping, 0);
if (!page) {
err = -ENOMEM;
folio = __filemap_get_folio(mapping, 0,
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
mapping_gfp_mask(mapping));
if (IS_ERR(folio)) {
err = PTR_ERR(folio);
goto out2;
}
kaddr = kmap_atomic(page);
memcpy(kaddr, data, rsize);
memset(kaddr + rsize, 0, PAGE_SIZE - rsize);
kunmap_atomic(kaddr);
flush_dcache_page(page);
SetPageUptodate(page);
set_page_dirty(page);
unlock_page(page);
put_page(page);
folio_fill_tail(folio, 0, data, rsize);
folio_mark_uptodate(folio);
folio_mark_dirty(folio);
folio_unlock(folio);
folio_put(folio);
}
}