]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ocfs2: convert ocfs2_page_mkwrite() to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 5 Dec 2024 17:16:30 +0000 (17:16 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 13 Jan 2025 04:21:09 +0000 (20:21 -0800)
Pass the folio into __ocfs2_page_mkwrite() and use it throughout.  Does
not attempt to support large folios.

Link: https://lkml.kernel.org/r/20241205171653.3179945-3-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Mark Tinguely <mark.tinguely@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/mmap.c

index 6ef4cb045ccde5178cd6d397789d92b00e98e529..93b886f16c40f62017dd36d4d6f28f4442366bf4 100644 (file)
@@ -44,13 +44,13 @@ static vm_fault_t ocfs2_fault(struct vm_fault *vmf)
 }
 
 static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
-                       struct buffer_head *di_bh, struct page *page)
+                       struct buffer_head *di_bh, struct folio *folio)
 {
        int err;
        vm_fault_t ret = VM_FAULT_NOPAGE;
        struct inode *inode = file_inode(file);
        struct address_space *mapping = inode->i_mapping;
-       loff_t pos = page_offset(page);
+       loff_t pos = folio_pos(folio);
        unsigned int len = PAGE_SIZE;
        pgoff_t last_index;
        struct folio *locked_folio = NULL;
@@ -72,9 +72,9 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
         *
         * Let VM retry with these cases.
         */
-       if ((page->mapping != inode->i_mapping) ||
-           (!PageUptodate(page)) ||
-           (page_offset(page) >= size))
+       if ((folio->mapping != inode->i_mapping) ||
+           !folio_test_uptodate(folio) ||
+           (pos >= size))
                goto out;
 
        /*
@@ -87,11 +87,11 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
         * worry about ocfs2_write_begin() skipping some buffer reads
         * because the "write" would invalidate their data.
         */
-       if (page->index == last_index)
+       if (folio->index == last_index)
                len = ((size - 1) & ~PAGE_MASK) + 1;
 
        err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP,
-                                      &locked_folio, &fsdata, di_bh, page);
+                                      &locked_folio, &fsdata, di_bh, &folio->page);
        if (err) {
                if (err != -ENOSPC)
                        mlog_errno(err);
@@ -112,7 +112,7 @@ out:
 
 static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf)
 {
-       struct page *page = vmf->page;
+       struct folio *folio = page_folio(vmf->page);
        struct inode *inode = file_inode(vmf->vma->vm_file);
        struct buffer_head *di_bh = NULL;
        sigset_t oldset;
@@ -141,7 +141,7 @@ static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf)
         */
        down_write(&OCFS2_I(inode)->ip_alloc_sem);
 
-       ret = __ocfs2_page_mkwrite(vmf->vma->vm_file, di_bh, page);
+       ret = __ocfs2_page_mkwrite(vmf->vma->vm_file, di_bh, folio);
 
        up_write(&OCFS2_I(inode)->ip_alloc_sem);