mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
vboxsf: Use a folio in vboxsf_write_end()
Because we have to kmap() the page before calling vboxsf_write(), we can't entirely remove the use of struct page. But we can eliminate some uses of old APIs and remove some unnecessary calls to compound_head(). Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
4c7e13850f
commit
3e5d37c5f9
@ -302,16 +302,17 @@ static int vboxsf_write_end(struct file *file, struct address_space *mapping,
|
|||||||
loff_t pos, unsigned int len, unsigned int copied,
|
loff_t pos, unsigned int len, unsigned int copied,
|
||||||
struct page *page, void *fsdata)
|
struct page *page, void *fsdata)
|
||||||
{
|
{
|
||||||
|
struct folio *folio = page_folio(page);
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
struct vboxsf_handle *sf_handle = file->private_data;
|
struct vboxsf_handle *sf_handle = file->private_data;
|
||||||
unsigned int from = pos & ~PAGE_MASK;
|
size_t from = offset_in_folio(folio, pos);
|
||||||
u32 nwritten = len;
|
u32 nwritten = len;
|
||||||
u8 *buf;
|
u8 *buf;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* zero the stale part of the page if we did a short copy */
|
/* zero the stale part of the folio if we did a short copy */
|
||||||
if (!PageUptodate(page) && copied < len)
|
if (!folio_test_uptodate(folio) && copied < len)
|
||||||
zero_user(page, from + copied, len - copied);
|
folio_zero_range(folio, from + copied, len - copied);
|
||||||
|
|
||||||
buf = kmap(page);
|
buf = kmap(page);
|
||||||
err = vboxsf_write(sf_handle->root, sf_handle->handle,
|
err = vboxsf_write(sf_handle->root, sf_handle->handle,
|
||||||
@ -326,16 +327,16 @@ static int vboxsf_write_end(struct file *file, struct address_space *mapping,
|
|||||||
/* mtime changed */
|
/* mtime changed */
|
||||||
VBOXSF_I(inode)->force_restat = 1;
|
VBOXSF_I(inode)->force_restat = 1;
|
||||||
|
|
||||||
if (!PageUptodate(page) && nwritten == PAGE_SIZE)
|
if (!folio_test_uptodate(folio) && nwritten == folio_size(folio))
|
||||||
SetPageUptodate(page);
|
folio_mark_uptodate(folio);
|
||||||
|
|
||||||
pos += nwritten;
|
pos += nwritten;
|
||||||
if (pos > inode->i_size)
|
if (pos > inode->i_size)
|
||||||
i_size_write(inode, pos);
|
i_size_write(inode, pos);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
put_page(page);
|
folio_put(folio);
|
||||||
|
|
||||||
return nwritten;
|
return nwritten;
|
||||||
}
|
}
|
||||||
@ -343,7 +344,7 @@ out:
|
|||||||
/*
|
/*
|
||||||
* Note simple_write_begin does not read the page from disk on partial writes
|
* Note simple_write_begin does not read the page from disk on partial writes
|
||||||
* this is ok since vboxsf_write_end only writes the written parts of the
|
* this is ok since vboxsf_write_end only writes the written parts of the
|
||||||
* page and it does not call SetPageUptodate for partial writes.
|
* page and it does not call folio_mark_uptodate for partial writes.
|
||||||
*/
|
*/
|
||||||
const struct address_space_operations vboxsf_reg_aops = {
|
const struct address_space_operations vboxsf_reg_aops = {
|
||||||
.read_folio = vboxsf_read_folio,
|
.read_folio = vboxsf_read_folio,
|
||||||
|
Loading…
Reference in New Issue
Block a user