if (!PageDirty(cc->rpages[i]))
                        goto continue_unlock;
 
-               if (PageWriteback(cc->rpages[i])) {
+               if (folio_test_writeback(page_folio(cc->rpages[i]))) {
                        if (wbc->sync_mode == WB_SYNC_NONE)
                                goto continue_unlock;
                        f2fs_wait_on_page_writeback(cc->rpages[i], DATA, true, true);
 
                if (err) {
                        if (fscrypt_inode_uses_fs_layer_crypto(inode))
                                fscrypt_finalize_bounce_page(&fio->encrypted_page);
-                       if (PageWriteback(page))
-                               end_page_writeback(page);
+                       end_page_writeback(page);
                } else {
                        set_inode_flag(inode, FI_UPDATE_WRITE);
                }
 
        mutex_unlock(&curseg->curseg_mutex);
        f2fs_up_read(&SM_I(sbi)->curseg_lock);
        return 0;
+
 out_err:
        *new_blkaddr = NULL_ADDR;
        up_write(&sit_i->sentry_lock);
        mutex_unlock(&curseg->curseg_mutex);
        f2fs_up_read(&SM_I(sbi)->curseg_lock);
        return ret;
-
 }
 
 void f2fs_update_device_state(struct f2fs_sb_info *sbi, nid_t ino,
                        &fio->new_blkaddr, sum, type, fio)) {
                if (fscrypt_inode_uses_fs_layer_crypto(fio->page->mapping->host))
                        fscrypt_finalize_bounce_page(&fio->encrypted_page);
-               if (PageWriteback(fio->page))
-                       end_page_writeback(fio->page);
+               end_page_writeback(fio->page);
                if (f2fs_in_warm_node_list(fio->sbi, fio->page))
                        f2fs_del_fsync_node_entry(fio->sbi, fio->page);
                goto out;
 void f2fs_wait_on_page_writeback(struct page *page,
                                enum page_type type, bool ordered, bool locked)
 {
-       if (PageWriteback(page)) {
+       if (folio_test_writeback(page_folio(page))) {
                struct f2fs_sb_info *sbi = F2FS_P_SB(page);
 
                /* submit cached LFS IO */
                f2fs_submit_merged_ipu_write(sbi, NULL, page);
                if (ordered) {
                        wait_on_page_writeback(page);
-                       f2fs_bug_on(sbi, locked && PageWriteback(page));
+                       f2fs_bug_on(sbi, locked &&
+                               folio_test_writeback(page_folio(page)));
                } else {
                        wait_for_stable_page(page);
                }