Skip to content

Commit ab055cf

Browse files
Matthew Wilcox (Oracle)aalexandrovich
authored andcommitted
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) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 00c9107 commit ab055cf

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

fs/ntfs3/attrib.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,11 +1239,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
12391239
goto out;
12401240
}
12411241

1242-
int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
1242+
int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
12431243
{
12441244
u64 vbo;
12451245
struct ATTRIB *attr;
12461246
u32 data_size;
1247+
size_t len;
12471248

12481249
attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL);
12491250
if (!attr)
@@ -1252,25 +1253,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
12521253
if (attr->non_res)
12531254
return E_NTFS_NONRESIDENT;
12541255

1255-
vbo = page->index << PAGE_SHIFT;
1256+
vbo = folio->index << PAGE_SHIFT;
12561257
data_size = le32_to_cpu(attr->res.data_size);
1257-
if (vbo < data_size) {
1258-
const char *data = resident_data(attr);
1259-
char *kaddr = kmap_atomic(page);
1260-
u32 use = data_size - vbo;
1261-
1262-
if (use > PAGE_SIZE)
1263-
use = PAGE_SIZE;
1258+
if (vbo > data_size)
1259+
len = 0;
1260+
else
1261+
len = min(data_size - vbo, folio_size(folio));
12641262

1265-
memcpy(kaddr, data + vbo, use);
1266-
memset(kaddr + use, 0, PAGE_SIZE - use);
1267-
kunmap_atomic(kaddr);
1268-
flush_dcache_page(page);
1269-
SetPageUptodate(page);
1270-
} else if (!PageUptodate(page)) {
1271-
zero_user_segment(page, 0, PAGE_SIZE);
1272-
SetPageUptodate(page);
1273-
}
1263+
folio_fill_tail(folio, 0, resident_data(attr) + vbo, len);
1264+
folio_mark_uptodate(folio);
12741265

12751266
return 0;
12761267
}

fs/ntfs3/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
583583
err = 0;
584584
} else {
585585
ni_lock(ni);
586-
err = attr_data_read_resident(ni, &folio->page);
586+
err = attr_data_read_resident(ni, folio);
587587
ni_unlock(ni);
588588

589589
if (!err)
@@ -717,7 +717,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
717717

718718
if (is_resident(ni)) {
719719
ni_lock(ni);
720-
err = attr_data_read_resident(ni, &folio->page);
720+
err = attr_data_read_resident(ni, folio);
721721
ni_unlock(ni);
722722
if (err != E_NTFS_NONRESIDENT) {
723723
folio_unlock(folio);
@@ -923,7 +923,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
923923
}
924924

925925
ni_lock(ni);
926-
err = attr_data_read_resident(ni, &folio->page);
926+
err = attr_data_read_resident(ni, folio);
927927
ni_unlock(ni);
928928

929929
if (!err) {

fs/ntfs3/ntfs_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
434434
struct ATTRIB **ret);
435435
int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
436436
CLST *len, bool *new, bool zero);
437-
int attr_data_read_resident(struct ntfs_inode *ni, struct page *page);
437+
int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio);
438438
int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
439439
int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
440440
const __le16 *name, u8 name_len, struct runs_tree *run,

0 commit comments

Comments
 (0)