]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ntfs3: Convert attr_wof_frame_info() to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 22 Apr 2024 19:31:59 +0000 (20:31 +0100)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Wed, 26 Jun 2024 12:48:58 +0000 (15:48 +0300)
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) <willy@infradead.org>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/attrib.c
fs/ntfs3/frecord.c
fs/ntfs3/ntfs_fs.h

index 3a4b81bbc5d98f78601b20627951ec5bdc1a7091..e62a8fee525058c1613710f1ea39b29017a973ac 100644 (file)
@@ -1380,7 +1380,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
        u32 voff;
        u8 bytes_per_off;
        char *addr;
-       struct page *page;
+       struct folio *folio;
        int i, err;
        __le32 *off32;
        __le64 *off64;
@@ -1425,18 +1425,18 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
 
        wof_size = le64_to_cpu(attr->nres.data_size);
        down_write(&ni->file.run_lock);
-       page = ni->file.offs_page;
-       if (!page) {
-               page = alloc_page(GFP_KERNEL);
-               if (!page) {
+       folio = ni->file.offs_folio;
+       if (!folio) {
+               folio = folio_alloc(GFP_KERNEL, 0);
+               if (!folio) {
                        err = -ENOMEM;
                        goto out;
                }
-               page->index = -1;
-               ni->file.offs_page = page;
+               folio->index = -1;
+               ni->file.offs_folio = folio;
        }
-       lock_page(page);
-       addr = page_address(page);
+       folio_lock(folio);
+       addr = folio_address(folio);
 
        if (vbo[1]) {
                voff = vbo[1] & (PAGE_SIZE - 1);
@@ -1452,7 +1452,8 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
        do {
                pgoff_t index = vbo[i] >> PAGE_SHIFT;
 
-               if (index != page->index) {
+               if (index != folio->index) {
+                       struct page *page = &folio->page;
                        u64 from = vbo[i] & ~(u64)(PAGE_SIZE - 1);
                        u64 to = min(from + PAGE_SIZE, wof_size);
 
@@ -1465,10 +1466,10 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
                        err = ntfs_bio_pages(sbi, run, &page, 1, from,
                                             to - from, REQ_OP_READ);
                        if (err) {
-                               page->index = -1;
+                               folio->index = -1;
                                goto out1;
                        }
-                       page->index = index;
+                       folio->index = index;
                }
 
                if (i) {
@@ -1506,7 +1507,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
        *ondisk_size = off[1] - off[0];
 
 out1:
-       unlock_page(page);
+       folio_unlock(folio);
 out:
        up_write(&ni->file.run_lock);
        return err;
index 7962471692e65b6f40f0e8d8e520444e7bcc4315..d792908c85f493f521f8f7e10dda1aa4f9f6e27b 100644 (file)
@@ -122,10 +122,10 @@ void ni_clear(struct ntfs_inode *ni)
        else {
                run_close(&ni->file.run);
 #ifdef CONFIG_NTFS3_LZX_XPRESS
-               if (ni->file.offs_page) {
+               if (ni->file.offs_folio) {
                        /* On-demand allocated page for offsets. */
-                       put_page(ni->file.offs_page);
-                       ni->file.offs_page = NULL;
+                       folio_put(ni->file.offs_folio);
+                       ni->file.offs_folio = NULL;
                }
 #endif
        }
@@ -2362,9 +2362,9 @@ remove_wof:
 
        /* Clear cached flag. */
        ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK;
-       if (ni->file.offs_page) {
-               put_page(ni->file.offs_page);
-               ni->file.offs_page = NULL;
+       if (ni->file.offs_folio) {
+               folio_put(ni->file.offs_folio);
+               ni->file.offs_folio = NULL;
        }
        mapping->a_ops = &ntfs_aops;
 
index e2a3ecc1224789d05813bf0cc2fa3f52c0813c64..8074fc53a145e0f63c013aac59702f52af8d65d8 100644 (file)
@@ -383,7 +383,7 @@ struct ntfs_inode {
                        struct rw_semaphore run_lock;
                        struct runs_tree run;
 #ifdef CONFIG_NTFS3_LZX_XPRESS
-                       struct page *offs_page;
+                       struct folio *offs_folio;
 #endif
                } file;
        };