Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c091354

Browse files
Matthew Wilcox (Oracle)aalexandrovich
authored andcommitted
ntfs3: Convert attr_wof_frame_info() to use a folio
This involves converting all users of offs_page to offs_folio, but it's worth it because we get rid of a lot of hidden calls to compound_head(). We continue to use order-0 folios here, and convert back to a struct page to call ntfs_bio_pages(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 4d89b67 commit c091354

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

fs/ntfs3/attrib.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
13801380
u32 voff;
13811381
u8 bytes_per_off;
13821382
char *addr;
1383-
struct page *page;
1383+
struct folio *folio;
13841384
int i, err;
13851385
__le32 *off32;
13861386
__le64 *off64;
@@ -1425,18 +1425,18 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
14251425

14261426
wof_size = le64_to_cpu(attr->nres.data_size);
14271427
down_write(&ni->file.run_lock);
1428-
page = ni->file.offs_page;
1429-
if (!page) {
1430-
page = alloc_page(GFP_KERNEL);
1431-
if (!page) {
1428+
folio = ni->file.offs_folio;
1429+
if (!folio) {
1430+
folio = folio_alloc(GFP_KERNEL, 0);
1431+
if (!folio) {
14321432
err = -ENOMEM;
14331433
goto out;
14341434
}
1435-
page->index = -1;
1436-
ni->file.offs_page = page;
1435+
folio->index = -1;
1436+
ni->file.offs_folio = folio;
14371437
}
1438-
lock_page(page);
1439-
addr = page_address(page);
1438+
folio_lock(folio);
1439+
addr = folio_address(folio);
14401440

14411441
if (vbo[1]) {
14421442
voff = vbo[1] & (PAGE_SIZE - 1);
@@ -1452,7 +1452,8 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
14521452
do {
14531453
pgoff_t index = vbo[i] >> PAGE_SHIFT;
14541454

1455-
if (index != page->index) {
1455+
if (index != folio->index) {
1456+
struct page *page = &folio->page;
14561457
u64 from = vbo[i] & ~(u64)(PAGE_SIZE - 1);
14571458
u64 to = min(from + PAGE_SIZE, wof_size);
14581459

@@ -1465,10 +1466,10 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
14651466
err = ntfs_bio_pages(sbi, run, &page, 1, from,
14661467
to - from, REQ_OP_READ);
14671468
if (err) {
1468-
page->index = -1;
1469+
folio->index = -1;
14691470
goto out1;
14701471
}
1471-
page->index = index;
1472+
folio->index = index;
14721473
}
14731474

14741475
if (i) {
@@ -1506,7 +1507,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
15061507
*ondisk_size = off[1] - off[0];
15071508

15081509
out1:
1509-
unlock_page(page);
1510+
folio_unlock(folio);
15101511
out:
15111512
up_write(&ni->file.run_lock);
15121513
return err;

fs/ntfs3/frecord.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ void ni_clear(struct ntfs_inode *ni)
122122
else {
123123
run_close(&ni->file.run);
124124
#ifdef CONFIG_NTFS3_LZX_XPRESS
125-
if (ni->file.offs_page) {
125+
if (ni->file.offs_folio) {
126126
/* On-demand allocated page for offsets. */
127-
put_page(ni->file.offs_page);
128-
ni->file.offs_page = NULL;
127+
folio_put(ni->file.offs_folio);
128+
ni->file.offs_folio = NULL;
129129
}
130130
#endif
131131
}
@@ -2362,9 +2362,9 @@ int ni_decompress_file(struct ntfs_inode *ni)
23622362

23632363
/* Clear cached flag. */
23642364
ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK;
2365-
if (ni->file.offs_page) {
2366-
put_page(ni->file.offs_page);
2367-
ni->file.offs_page = NULL;
2365+
if (ni->file.offs_folio) {
2366+
folio_put(ni->file.offs_folio);
2367+
ni->file.offs_folio = NULL;
23682368
}
23692369
mapping->a_ops = &ntfs_aops;
23702370

fs/ntfs3/ntfs_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ struct ntfs_inode {
383383
struct rw_semaphore run_lock;
384384
struct runs_tree run;
385385
#ifdef CONFIG_NTFS3_LZX_XPRESS
386-
struct page *offs_page;
386+
struct folio *offs_folio;
387387
#endif
388388
} file;
389389
};

0 commit comments

Comments
 (0)