]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hostfs: Convert hostfs_write_end() to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 12 Jul 2024 16:08:54 +0000 (12:08 -0400)
committerChristian Brauner <brauner@kernel.org>
Wed, 7 Aug 2024 09:32:01 +0000 (11:32 +0200)
Convert the passed page to a folio and operate on that.
Replaces four calls to compound_head() with one.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/hostfs/hostfs_kern.c

index 22df574ca99e76937655331176443119f12a8c43..805cfe39c40f4c0b95bd07c9a017314e261ea471 100644 (file)
@@ -479,17 +479,18 @@ static int hostfs_write_end(struct file *file, struct address_space *mapping,
                            loff_t pos, unsigned len, unsigned copied,
                            struct page *page, void *fsdata)
 {
+       struct folio *folio = page_folio(page);
        struct inode *inode = mapping->host;
        void *buffer;
-       unsigned from = pos & (PAGE_SIZE - 1);
+       size_t from = offset_in_folio(folio, pos);
        int err;
 
-       buffer = kmap_local_page(page);
-       err = write_file(FILE_HOSTFS_I(file)->fd, &pos, buffer + from, copied);
+       buffer = kmap_local_folio(folio, from);
+       err = write_file(FILE_HOSTFS_I(file)->fd, &pos, buffer, copied);
        kunmap_local(buffer);
 
-       if (!PageUptodate(page) && err == PAGE_SIZE)
-               SetPageUptodate(page);
+       if (!folio_test_uptodate(folio) && err == folio_size(folio))
+               folio_mark_uptodate(folio);
 
        /*
         * If err > 0, write_file has added err to pos, so we are comparing
@@ -497,8 +498,8 @@ static int hostfs_write_end(struct file *file, struct address_space *mapping,
         */
        if (err > 0 && (pos > inode->i_size))
                inode->i_size = pos;
-       unlock_page(page);
-       put_page(page);
+       folio_unlock(folio);
+       folio_put(folio);
 
        return err;
 }