mirror of
https://github.com/torvalds/linux.git
synced 2025-11-02 17:49:03 +02:00
ocfs2: pass mmap_folio around instead of mmap_page
Saves a few hidden calls to compound_head() and accesses to page->mapping. Link: https://lkml.kernel.org/r/20241205171653.3179945-7-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jun Piao <piaojun@huawei.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Mark Tinguely <mark.tinguely@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
e981f18e6d
commit
b4f3b496dc
3 changed files with 22 additions and 23 deletions
|
|
@ -1023,7 +1023,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
|
||||||
struct ocfs2_write_ctxt *wc,
|
struct ocfs2_write_ctxt *wc,
|
||||||
u32 cpos, loff_t user_pos,
|
u32 cpos, loff_t user_pos,
|
||||||
unsigned user_len, int new,
|
unsigned user_len, int new,
|
||||||
struct page *mmap_page)
|
struct folio *mmap_folio)
|
||||||
{
|
{
|
||||||
int ret = 0, i;
|
int ret = 0, i;
|
||||||
unsigned long start, target_index, end_index, index;
|
unsigned long start, target_index, end_index, index;
|
||||||
|
|
@ -1068,18 +1068,18 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
|
||||||
* and wants us to directly use the page
|
* and wants us to directly use the page
|
||||||
* passed in.
|
* passed in.
|
||||||
*/
|
*/
|
||||||
lock_page(mmap_page);
|
folio_lock(mmap_folio);
|
||||||
|
|
||||||
/* Exit and let the caller retry */
|
/* Exit and let the caller retry */
|
||||||
if (mmap_page->mapping != mapping) {
|
if (mmap_folio->mapping != mapping) {
|
||||||
WARN_ON(mmap_page->mapping);
|
WARN_ON(mmap_folio->mapping);
|
||||||
unlock_page(mmap_page);
|
folio_unlock(mmap_folio);
|
||||||
ret = -EAGAIN;
|
ret = -EAGAIN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_page(mmap_page);
|
folio_get(mmap_folio);
|
||||||
wc->w_pages[i] = mmap_page;
|
wc->w_pages[i] = &mmap_folio->page;
|
||||||
wc->w_target_locked = true;
|
wc->w_target_locked = true;
|
||||||
} else if (index >= target_index && index <= end_index &&
|
} else if (index >= target_index && index <= end_index &&
|
||||||
wc->w_type == OCFS2_WRITE_DIRECT) {
|
wc->w_type == OCFS2_WRITE_DIRECT) {
|
||||||
|
|
@ -1536,9 +1536,8 @@ int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
|
static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
|
||||||
struct inode *inode, loff_t pos,
|
struct inode *inode, loff_t pos, size_t len,
|
||||||
unsigned len, struct page *mmap_page,
|
struct folio *mmap_folio, struct ocfs2_write_ctxt *wc)
|
||||||
struct ocfs2_write_ctxt *wc)
|
|
||||||
{
|
{
|
||||||
int ret, written = 0;
|
int ret, written = 0;
|
||||||
loff_t end = pos + len;
|
loff_t end = pos + len;
|
||||||
|
|
@ -1553,7 +1552,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
|
||||||
* Handle inodes which already have inline data 1st.
|
* Handle inodes which already have inline data 1st.
|
||||||
*/
|
*/
|
||||||
if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
|
if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
|
||||||
if (mmap_page == NULL &&
|
if (mmap_folio == NULL &&
|
||||||
ocfs2_size_fits_inline_data(wc->w_di_bh, end))
|
ocfs2_size_fits_inline_data(wc->w_di_bh, end))
|
||||||
goto do_inline_write;
|
goto do_inline_write;
|
||||||
|
|
||||||
|
|
@ -1577,7 +1576,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping,
|
||||||
* Check whether the write can fit.
|
* Check whether the write can fit.
|
||||||
*/
|
*/
|
||||||
di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
|
di = (struct ocfs2_dinode *)wc->w_di_bh->b_data;
|
||||||
if (mmap_page ||
|
if (mmap_folio ||
|
||||||
end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
|
end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -1644,9 +1643,9 @@ static int ocfs2_zero_tail(struct inode *inode, struct buffer_head *di_bh,
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocfs2_write_begin_nolock(struct address_space *mapping,
|
int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
loff_t pos, unsigned len, ocfs2_write_type_t type,
|
loff_t pos, unsigned len, ocfs2_write_type_t type,
|
||||||
struct folio **foliop, void **fsdata,
|
struct folio **foliop, void **fsdata,
|
||||||
struct buffer_head *di_bh, struct page *mmap_page)
|
struct buffer_head *di_bh, struct folio *mmap_folio)
|
||||||
{
|
{
|
||||||
int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS;
|
int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS;
|
||||||
unsigned int clusters_to_alloc, extents_to_split, clusters_need = 0;
|
unsigned int clusters_to_alloc, extents_to_split, clusters_need = 0;
|
||||||
|
|
@ -1669,7 +1668,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
|
|
||||||
if (ocfs2_supports_inline_data(osb)) {
|
if (ocfs2_supports_inline_data(osb)) {
|
||||||
ret = ocfs2_try_to_write_inline_data(mapping, inode, pos, len,
|
ret = ocfs2_try_to_write_inline_data(mapping, inode, pos, len,
|
||||||
mmap_page, wc);
|
mmap_folio, wc);
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto success;
|
goto success;
|
||||||
|
|
@ -1721,7 +1720,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
(unsigned long long)OCFS2_I(inode)->ip_blkno,
|
(unsigned long long)OCFS2_I(inode)->ip_blkno,
|
||||||
(long long)i_size_read(inode),
|
(long long)i_size_read(inode),
|
||||||
le32_to_cpu(di->i_clusters),
|
le32_to_cpu(di->i_clusters),
|
||||||
pos, len, type, mmap_page,
|
pos, len, type, mmap_folio,
|
||||||
clusters_to_alloc, extents_to_split);
|
clusters_to_alloc, extents_to_split);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1797,7 +1796,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
* extent.
|
* extent.
|
||||||
*/
|
*/
|
||||||
ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len,
|
ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len,
|
||||||
cluster_of_pages, mmap_page);
|
cluster_of_pages, mmap_folio);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/*
|
/*
|
||||||
* ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock
|
* ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock
|
||||||
|
|
@ -1848,7 +1847,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
* to VM code.
|
* to VM code.
|
||||||
*/
|
*/
|
||||||
if (wc->w_target_locked)
|
if (wc->w_target_locked)
|
||||||
unlock_page(mmap_page);
|
folio_unlock(mmap_folio);
|
||||||
|
|
||||||
ocfs2_free_write_ctxt(inode, wc);
|
ocfs2_free_write_ctxt(inode, wc);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ typedef enum {
|
||||||
} ocfs2_write_type_t;
|
} ocfs2_write_type_t;
|
||||||
|
|
||||||
int ocfs2_write_begin_nolock(struct address_space *mapping,
|
int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||||
loff_t pos, unsigned len, ocfs2_write_type_t type,
|
loff_t pos, unsigned len, ocfs2_write_type_t type,
|
||||||
struct folio **foliop, void **fsdata,
|
struct folio **foliop, void **fsdata,
|
||||||
struct buffer_head *di_bh, struct page *mmap_page);
|
struct buffer_head *di_bh, struct folio *mmap_folio);
|
||||||
|
|
||||||
int ocfs2_read_inline_data(struct inode *inode, struct page *page,
|
int ocfs2_read_inline_data(struct inode *inode, struct page *page,
|
||||||
struct buffer_head *di_bh);
|
struct buffer_head *di_bh);
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
|
||||||
len = ((size - 1) & ~PAGE_MASK) + 1;
|
len = ((size - 1) & ~PAGE_MASK) + 1;
|
||||||
|
|
||||||
err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP,
|
err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP,
|
||||||
&locked_folio, &fsdata, di_bh, &folio->page);
|
&locked_folio, &fsdata, di_bh, folio);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err != -ENOSPC)
|
if (err != -ENOSPC)
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue