diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2024-04-22 21:31:53 +0200 |
---|---|---|
committer | Konstantin Komarov <almaz.alexandrovich@paragon-software.com> | 2024-06-26 14:48:55 +0200 |
commit | ab055cf9db2027f7cb59c80663578c053fb0afde (patch) | |
tree | 411701a7e411fee52494d3519336b0f8e398c315 /fs/ntfs3 | |
parent | ntfs3: Convert ntfs_write_begin to use a folio (diff) | |
download | linux-ab055cf9db2027f7cb59c80663578c053fb0afde.tar.xz linux-ab055cf9db2027f7cb59c80663578c053fb0afde.zip |
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: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r-- | fs/ntfs3/attrib.c | 27 | ||||
-rw-r--r-- | fs/ntfs3/inode.c | 6 | ||||
-rw-r--r-- | fs/ntfs3/ntfs_fs.h | 2 |
3 files changed, 13 insertions, 22 deletions
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 68d1c61fe3b5..73c22c518697 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1239,11 +1239,12 @@ undo1: 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; struct ATTRIB *attr; u32 data_size; + size_t len; attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL); if (!attr) @@ -1252,25 +1253,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page) if (attr->non_res) return E_NTFS_NONRESIDENT; - vbo = page->index << PAGE_SHIFT; + vbo = folio->index << PAGE_SHIFT; data_size = le32_to_cpu(attr->res.data_size); - if (vbo < data_size) { - const char *data = resident_data(attr); - char *kaddr = kmap_atomic(page); - u32 use = data_size - vbo; - - if (use > PAGE_SIZE) - use = PAGE_SIZE; + if (vbo > data_size) + len = 0; + else + len = min(data_size - vbo, folio_size(folio)); - memcpy(kaddr, data + vbo, use); - memset(kaddr + use, 0, PAGE_SIZE - use); - kunmap_atomic(kaddr); - flush_dcache_page(page); - SetPageUptodate(page); - } else if (!PageUptodate(page)) { - zero_user_segment(page, 0, PAGE_SIZE); - SetPageUptodate(page); - } + folio_fill_tail(folio, 0, resident_data(attr) + vbo, len); + folio_mark_uptodate(folio); return 0; } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 7288787b7ff2..fd544e710ed1 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, err = 0; } else { ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (!err) @@ -717,7 +717,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio) if (is_resident(ni)) { ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (err != E_NTFS_NONRESIDENT) { folio_unlock(folio); @@ -923,7 +923,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping, } ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (!err) { diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 3583d47b95da..d2feb3de6502 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, struct ATTRIB **ret); int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, 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_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name, u8 name_len, struct runs_tree *run, |