mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
nilfs2: convert nilfs_prepare_chunk() and nilfs_commit_chunk() to folios
All callers now have a folio, so convert these two functions. Saves one call to compound_head() in unlock_page(). [konishi.ryusuke: resolved conflicts in nilfs_{set_link,delete_entry}] Link: https://lkml.kernel.org/r/20231127143036.2425-17-konishi.ryusuke@gmail.com Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
0743230fff
commit
9bff5f980e
@ -78,33 +78,32 @@ static unsigned int nilfs_last_byte(struct inode *inode, unsigned long page_nr)
|
|||||||
return last_byte;
|
return last_byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nilfs_prepare_chunk(struct page *page, unsigned int from,
|
static int nilfs_prepare_chunk(struct folio *folio, unsigned int from,
|
||||||
unsigned int to)
|
unsigned int to)
|
||||||
{
|
{
|
||||||
loff_t pos = page_offset(page) + from;
|
loff_t pos = folio_pos(folio) + from;
|
||||||
|
|
||||||
return __block_write_begin(page, pos, to - from, nilfs_get_block);
|
return __block_write_begin(&folio->page, pos, to - from, nilfs_get_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nilfs_commit_chunk(struct page *page,
|
static void nilfs_commit_chunk(struct folio *folio,
|
||||||
struct address_space *mapping,
|
struct address_space *mapping, size_t from, size_t to)
|
||||||
unsigned int from, unsigned int to)
|
|
||||||
{
|
{
|
||||||
struct inode *dir = mapping->host;
|
struct inode *dir = mapping->host;
|
||||||
loff_t pos = page_offset(page) + from;
|
loff_t pos = folio_pos(folio) + from;
|
||||||
unsigned int len = to - from;
|
size_t copied, len = to - from;
|
||||||
unsigned int nr_dirty, copied;
|
unsigned int nr_dirty;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
nr_dirty = nilfs_page_count_clean_buffers(page, from, to);
|
nr_dirty = nilfs_page_count_clean_buffers(&folio->page, from, to);
|
||||||
copied = block_write_end(NULL, mapping, pos, len, len, page, NULL);
|
copied = block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL);
|
||||||
if (pos + copied > dir->i_size)
|
if (pos + copied > dir->i_size)
|
||||||
i_size_write(dir, pos + copied);
|
i_size_write(dir, pos + copied);
|
||||||
if (IS_DIRSYNC(dir))
|
if (IS_DIRSYNC(dir))
|
||||||
nilfs_set_transaction_flag(NILFS_TI_SYNC);
|
nilfs_set_transaction_flag(NILFS_TI_SYNC);
|
||||||
err = nilfs_set_file_dirty(dir, nr_dirty);
|
err = nilfs_set_file_dirty(dir, nr_dirty);
|
||||||
WARN_ON(err); /* do not happen */
|
WARN_ON(err); /* do not happen */
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nilfs_check_folio(struct folio *folio, char *kaddr)
|
static bool nilfs_check_folio(struct folio *folio, char *kaddr)
|
||||||
@ -409,11 +408,11 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
folio_lock(folio);
|
folio_lock(folio);
|
||||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
err = nilfs_prepare_chunk(folio, from, to);
|
||||||
BUG_ON(err);
|
BUG_ON(err);
|
||||||
de->inode = cpu_to_le64(inode->i_ino);
|
de->inode = cpu_to_le64(inode->i_ino);
|
||||||
nilfs_set_de_type(de, inode);
|
nilfs_set_de_type(de, inode);
|
||||||
nilfs_commit_chunk(&folio->page, mapping, from, to);
|
nilfs_commit_chunk(folio, mapping, from, to);
|
||||||
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +484,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
|
|||||||
got_it:
|
got_it:
|
||||||
from = offset_in_folio(folio, de);
|
from = offset_in_folio(folio, de);
|
||||||
to = from + rec_len;
|
to = from + rec_len;
|
||||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
err = nilfs_prepare_chunk(folio, from, to);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
if (de->inode) {
|
if (de->inode) {
|
||||||
@ -500,7 +499,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
|
|||||||
memcpy(de->name, name, namelen);
|
memcpy(de->name, name, namelen);
|
||||||
de->inode = cpu_to_le64(inode->i_ino);
|
de->inode = cpu_to_le64(inode->i_ino);
|
||||||
nilfs_set_de_type(de, inode);
|
nilfs_set_de_type(de, inode);
|
||||||
nilfs_commit_chunk(&folio->page, folio->mapping, from, to);
|
nilfs_commit_chunk(folio, folio->mapping, from, to);
|
||||||
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
||||||
nilfs_mark_inode_dirty(dir);
|
nilfs_mark_inode_dirty(dir);
|
||||||
/* OFFSET_CACHE */
|
/* OFFSET_CACHE */
|
||||||
@ -542,12 +541,12 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio)
|
|||||||
if (pde)
|
if (pde)
|
||||||
from = (char *)pde - kaddr;
|
from = (char *)pde - kaddr;
|
||||||
folio_lock(folio);
|
folio_lock(folio);
|
||||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
err = nilfs_prepare_chunk(folio, from, to);
|
||||||
BUG_ON(err);
|
BUG_ON(err);
|
||||||
if (pde)
|
if (pde)
|
||||||
pde->rec_len = nilfs_rec_len_to_disk(to - from);
|
pde->rec_len = nilfs_rec_len_to_disk(to - from);
|
||||||
dir->inode = 0;
|
dir->inode = 0;
|
||||||
nilfs_commit_chunk(&folio->page, mapping, from, to);
|
nilfs_commit_chunk(folio, mapping, from, to);
|
||||||
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
@ -568,7 +567,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
|
|||||||
if (IS_ERR(folio))
|
if (IS_ERR(folio))
|
||||||
return PTR_ERR(folio);
|
return PTR_ERR(folio);
|
||||||
|
|
||||||
err = nilfs_prepare_chunk(&folio->page, 0, chunk_size);
|
err = nilfs_prepare_chunk(folio, 0, chunk_size);
|
||||||
if (unlikely(err)) {
|
if (unlikely(err)) {
|
||||||
folio_unlock(folio);
|
folio_unlock(folio);
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -589,7 +588,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
|
|||||||
memcpy(de->name, "..\0", 4);
|
memcpy(de->name, "..\0", 4);
|
||||||
nilfs_set_de_type(de, inode);
|
nilfs_set_de_type(de, inode);
|
||||||
kunmap_local(kaddr);
|
kunmap_local(kaddr);
|
||||||
nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size);
|
nilfs_commit_chunk(folio, mapping, 0, chunk_size);
|
||||||
fail:
|
fail:
|
||||||
folio_put(folio);
|
folio_put(folio);
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user