mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08: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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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,
|
||||
struct address_space *mapping,
|
||||
unsigned int from, unsigned int to)
|
||||
static void nilfs_commit_chunk(struct folio *folio,
|
||||
struct address_space *mapping, size_t from, size_t to)
|
||||
{
|
||||
struct inode *dir = mapping->host;
|
||||
loff_t pos = page_offset(page) + from;
|
||||
unsigned int len = to - from;
|
||||
unsigned int nr_dirty, copied;
|
||||
loff_t pos = folio_pos(folio) + from;
|
||||
size_t copied, len = to - from;
|
||||
unsigned int nr_dirty;
|
||||
int err;
|
||||
|
||||
nr_dirty = nilfs_page_count_clean_buffers(page, from, to);
|
||||
copied = block_write_end(NULL, mapping, pos, len, len, page, NULL);
|
||||
nr_dirty = nilfs_page_count_clean_buffers(&folio->page, from, to);
|
||||
copied = block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL);
|
||||
if (pos + copied > dir->i_size)
|
||||
i_size_write(dir, pos + copied);
|
||||
if (IS_DIRSYNC(dir))
|
||||
nilfs_set_transaction_flag(NILFS_TI_SYNC);
|
||||
err = nilfs_set_file_dirty(dir, nr_dirty);
|
||||
WARN_ON(err); /* do not happen */
|
||||
unlock_page(page);
|
||||
folio_unlock(folio);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
folio_lock(folio);
|
||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
||||
err = nilfs_prepare_chunk(folio, from, to);
|
||||
BUG_ON(err);
|
||||
de->inode = cpu_to_le64(inode->i_ino);
|
||||
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));
|
||||
}
|
||||
|
||||
@ -485,7 +484,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
|
||||
got_it:
|
||||
from = offset_in_folio(folio, de);
|
||||
to = from + rec_len;
|
||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
||||
err = nilfs_prepare_chunk(folio, from, to);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
if (de->inode) {
|
||||
@ -500,7 +499,7 @@ got_it:
|
||||
memcpy(de->name, name, namelen);
|
||||
de->inode = cpu_to_le64(inode->i_ino);
|
||||
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));
|
||||
nilfs_mark_inode_dirty(dir);
|
||||
/* OFFSET_CACHE */
|
||||
@ -542,12 +541,12 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio)
|
||||
if (pde)
|
||||
from = (char *)pde - kaddr;
|
||||
folio_lock(folio);
|
||||
err = nilfs_prepare_chunk(&folio->page, from, to);
|
||||
err = nilfs_prepare_chunk(folio, from, to);
|
||||
BUG_ON(err);
|
||||
if (pde)
|
||||
pde->rec_len = nilfs_rec_len_to_disk(to - from);
|
||||
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));
|
||||
out:
|
||||
return err;
|
||||
@ -568,7 +567,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
|
||||
if (IS_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)) {
|
||||
folio_unlock(folio);
|
||||
goto fail;
|
||||
@ -589,7 +588,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
|
||||
memcpy(de->name, "..\0", 4);
|
||||
nilfs_set_de_type(de, inode);
|
||||
kunmap_local(kaddr);
|
||||
nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size);
|
||||
nilfs_commit_chunk(folio, mapping, 0, chunk_size);
|
||||
fail:
|
||||
folio_put(folio);
|
||||
return err;
|
||||
|
Loading…
Reference in New Issue
Block a user