Commit ab055cf9 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Konstantin Komarov

ntfs3: Convert attr_data_read_resident() to take a folio

Now that all three callers have a folio, pass it in and use
folio_fill_tail() to do the hard work of filling the folio.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent 00c91073
...@@ -1239,11 +1239,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, ...@@ -1239,11 +1239,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
goto out; goto out;
} }
int attr_data_read_resident(struct ntfs_inode *ni, struct page *page) int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
{ {
u64 vbo; u64 vbo;
struct ATTRIB *attr; struct ATTRIB *attr;
u32 data_size; u32 data_size;
size_t len;
attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL); attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL);
if (!attr) if (!attr)
...@@ -1252,25 +1253,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page) ...@@ -1252,25 +1253,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
if (attr->non_res) if (attr->non_res)
return E_NTFS_NONRESIDENT; return E_NTFS_NONRESIDENT;
vbo = page->index << PAGE_SHIFT; vbo = folio->index << PAGE_SHIFT;
data_size = le32_to_cpu(attr->res.data_size); data_size = le32_to_cpu(attr->res.data_size);
if (vbo < data_size) { if (vbo > data_size)
const char *data = resident_data(attr); len = 0;
char *kaddr = kmap_atomic(page); else
u32 use = data_size - vbo; len = min(data_size - vbo, folio_size(folio));
if (use > PAGE_SIZE)
use = PAGE_SIZE;
memcpy(kaddr, data + vbo, use); folio_fill_tail(folio, 0, resident_data(attr) + vbo, len);
memset(kaddr + use, 0, PAGE_SIZE - use); folio_mark_uptodate(folio);
kunmap_atomic(kaddr);
flush_dcache_page(page);
SetPageUptodate(page);
} else if (!PageUptodate(page)) {
zero_user_segment(page, 0, PAGE_SIZE);
SetPageUptodate(page);
}
return 0; return 0;
} }
......
...@@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, ...@@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
err = 0; err = 0;
} else { } else {
ni_lock(ni); ni_lock(ni);
err = attr_data_read_resident(ni, &folio->page); err = attr_data_read_resident(ni, folio);
ni_unlock(ni); ni_unlock(ni);
if (!err) if (!err)
...@@ -717,7 +717,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio) ...@@ -717,7 +717,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
if (is_resident(ni)) { if (is_resident(ni)) {
ni_lock(ni); ni_lock(ni);
err = attr_data_read_resident(ni, &folio->page); err = attr_data_read_resident(ni, folio);
ni_unlock(ni); ni_unlock(ni);
if (err != E_NTFS_NONRESIDENT) { if (err != E_NTFS_NONRESIDENT) {
folio_unlock(folio); folio_unlock(folio);
...@@ -923,7 +923,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping, ...@@ -923,7 +923,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
} }
ni_lock(ni); ni_lock(ni);
err = attr_data_read_resident(ni, &folio->page); err = attr_data_read_resident(ni, folio);
ni_unlock(ni); ni_unlock(ni);
if (!err) { if (!err) {
......
...@@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, ...@@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
struct ATTRIB **ret); struct ATTRIB **ret);
int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
CLST *len, bool *new, bool zero); CLST *len, bool *new, bool zero);
int attr_data_read_resident(struct ntfs_inode *ni, struct page *page); int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio);
int attr_data_write_resident(struct ntfs_inode *ni, struct page *page); int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type, int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
const __le16 *name, u8 name_len, struct runs_tree *run, const __le16 *name, u8 name_len, struct runs_tree *run,
......
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