Skip to content

Commit 7b73c12

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
shmem: Add shmem_writeout()
This will be the replacement for shmem_writepage(). Signed-off-by: "Matthew Wilcox (Oracle)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8e5ae38 commit 7b73c12

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

include/linux/shmem_fs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ static inline bool shmem_mapping(struct address_space *mapping)
104104
return false;
105105
}
106106
#endif /* CONFIG_SHMEM */
107-
extern void shmem_unlock_mapping(struct address_space *mapping);
108-
extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
107+
void shmem_unlock_mapping(struct address_space *mapping);
108+
struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
109109
pgoff_t index, gfp_t gfp_mask);
110-
extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
110+
int shmem_writeout(struct folio *folio, struct writeback_control *wbc);
111+
void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
111112
int shmem_unuse(unsigned int type);
112113

113114
#ifdef CONFIG_TRANSPARENT_HUGEPAGE

mm/shmem.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,12 +1536,20 @@ int shmem_unuse(unsigned int type)
15361536
return error;
15371537
}
15381538

1539-
/*
1540-
* Move the page from the page cache to the swap cache.
1541-
*/
15421539
static int shmem_writepage(struct page *page, struct writeback_control *wbc)
15431540
{
1544-
struct folio *folio = page_folio(page);
1541+
return shmem_writeout(page_folio(page), wbc);
1542+
}
1543+
1544+
/**
1545+
* shmem_writeout - Write the folio to swap
1546+
* @folio: The folio to write
1547+
* @wbc: How writeback is to be done
1548+
*
1549+
* Move the folio from the page cache to the swap cache.
1550+
*/
1551+
int shmem_writeout(struct folio *folio, struct writeback_control *wbc)
1552+
{
15451553
struct address_space *mapping = folio->mapping;
15461554
struct inode *inode = mapping->host;
15471555
struct shmem_inode_info *info = SHMEM_I(inode);
@@ -1586,9 +1594,8 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
15861594
try_split:
15871595
/* Ensure the subpages are still dirty */
15881596
folio_test_set_dirty(folio);
1589-
if (split_huge_page_to_list_to_order(page, wbc->list, 0))
1597+
if (split_folio_to_list(folio, wbc->list))
15901598
goto redirty;
1591-
folio = page_folio(page);
15921599
folio_clear_dirty(folio);
15931600
}
15941601

@@ -1660,6 +1667,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
16601667
folio_unlock(folio);
16611668
return 0;
16621669
}
1670+
EXPORT_SYMBOL_GPL(shmem_writeout);
16631671

16641672
#if defined(CONFIG_NUMA) && defined(CONFIG_TMPFS)
16651673
static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)

0 commit comments

Comments
 (0)