mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
mm: stop passing a writeback_control structure to swap_writeout
swap_writeout only needs the swap_iocb cookie from the writeback_control structure, so pass it explicitly. Link: https://lkml.kernel.org/r/20250610054959.2057526-6-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Chengming Zhou <chengming.zhou@linux.dev> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2ba8ffcefe
commit
624043dbd5
@ -72,13 +72,6 @@ struct writeback_control {
|
|||||||
*/
|
*/
|
||||||
unsigned no_cgroup_owner:1;
|
unsigned no_cgroup_owner:1;
|
||||||
|
|
||||||
/* To enable batching of swap writes to non-block-device backends,
|
|
||||||
* "plug" can be set point to a 'struct swap_iocb *'. When all swap
|
|
||||||
* writes have been submitted, if with swap_iocb is not NULL,
|
|
||||||
* swap_write_unplug() should be called.
|
|
||||||
*/
|
|
||||||
struct swap_iocb **swap_plug;
|
|
||||||
|
|
||||||
/* internal fields used by the ->writepages implementation: */
|
/* internal fields used by the ->writepages implementation: */
|
||||||
struct folio_batch fbatch;
|
struct folio_batch fbatch;
|
||||||
pgoff_t index;
|
pgoff_t index;
|
||||||
|
@ -237,7 +237,7 @@ static void swap_zeromap_folio_clear(struct folio *folio)
|
|||||||
* We may have stale swap cache pages in memory: notice
|
* We may have stale swap cache pages in memory: notice
|
||||||
* them here and get rid of the unnecessary final write.
|
* them here and get rid of the unnecessary final write.
|
||||||
*/
|
*/
|
||||||
int swap_writeout(struct folio *folio, struct writeback_control *wbc)
|
int swap_writeout(struct folio *folio, struct swap_iocb **swap_plug)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ int swap_writeout(struct folio *folio, struct writeback_control *wbc)
|
|||||||
return AOP_WRITEPAGE_ACTIVATE;
|
return AOP_WRITEPAGE_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
__swap_writepage(folio, wbc->swap_plug);
|
__swap_writepage(folio, swap_plug);
|
||||||
return 0;
|
return 0;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
folio_unlock(folio);
|
folio_unlock(folio);
|
||||||
|
10
mm/shmem.c
10
mm/shmem.c
@ -1635,21 +1635,13 @@ try_split:
|
|||||||
list_add(&info->swaplist, &shmem_swaplist);
|
list_add(&info->swaplist, &shmem_swaplist);
|
||||||
|
|
||||||
if (!folio_alloc_swap(folio, __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
|
if (!folio_alloc_swap(folio, __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
|
||||||
struct writeback_control wbc = {
|
|
||||||
.sync_mode = WB_SYNC_NONE,
|
|
||||||
.nr_to_write = SWAP_CLUSTER_MAX,
|
|
||||||
.range_start = 0,
|
|
||||||
.range_end = LLONG_MAX,
|
|
||||||
.for_reclaim = 1,
|
|
||||||
.swap_plug = plug,
|
|
||||||
};
|
|
||||||
shmem_recalc_inode(inode, 0, nr_pages);
|
shmem_recalc_inode(inode, 0, nr_pages);
|
||||||
swap_shmem_alloc(folio->swap, nr_pages);
|
swap_shmem_alloc(folio->swap, nr_pages);
|
||||||
shmem_delete_from_page_cache(folio, swp_to_radix_entry(folio->swap));
|
shmem_delete_from_page_cache(folio, swp_to_radix_entry(folio->swap));
|
||||||
|
|
||||||
mutex_unlock(&shmem_swaplist_mutex);
|
mutex_unlock(&shmem_swaplist_mutex);
|
||||||
BUG_ON(folio_mapped(folio));
|
BUG_ON(folio_mapped(folio));
|
||||||
return swap_writeout(folio, &wbc);
|
return swap_writeout(folio, plug);
|
||||||
}
|
}
|
||||||
if (!info->swapped)
|
if (!info->swapped)
|
||||||
list_del_init(&info->swaplist);
|
list_del_init(&info->swaplist);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#define _MM_SWAP_H
|
#define _MM_SWAP_H
|
||||||
|
|
||||||
struct mempolicy;
|
struct mempolicy;
|
||||||
|
struct swap_iocb;
|
||||||
|
|
||||||
extern int page_cluster;
|
extern int page_cluster;
|
||||||
|
|
||||||
#ifdef CONFIG_SWAP
|
#ifdef CONFIG_SWAP
|
||||||
@ -20,7 +22,7 @@ static inline void swap_read_unplug(struct swap_iocb *plug)
|
|||||||
__swap_read_unplug(plug);
|
__swap_read_unplug(plug);
|
||||||
}
|
}
|
||||||
void swap_write_unplug(struct swap_iocb *sio);
|
void swap_write_unplug(struct swap_iocb *sio);
|
||||||
int swap_writeout(struct folio *folio, struct writeback_control *wbc);
|
int swap_writeout(struct folio *folio, struct swap_iocb **swap_plug);
|
||||||
void __swap_writepage(struct folio *folio, struct swap_iocb **swap_plug);
|
void __swap_writepage(struct folio *folio, struct swap_iocb **swap_plug);
|
||||||
|
|
||||||
/* linux/mm/swap_state.c */
|
/* linux/mm/swap_state.c */
|
||||||
@ -160,7 +162,8 @@ static inline struct folio *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int swap_writeout(struct folio *f, struct writeback_control *wbc)
|
static inline int swap_writeout(struct folio *folio,
|
||||||
|
struct swap_iocb **swap_plug)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
10
mm/vmscan.c
10
mm/vmscan.c
@ -655,14 +655,6 @@ typedef enum {
|
|||||||
static pageout_t writeout(struct folio *folio, struct address_space *mapping,
|
static pageout_t writeout(struct folio *folio, struct address_space *mapping,
|
||||||
struct swap_iocb **plug, struct list_head *folio_list)
|
struct swap_iocb **plug, struct list_head *folio_list)
|
||||||
{
|
{
|
||||||
struct writeback_control wbc = {
|
|
||||||
.sync_mode = WB_SYNC_NONE,
|
|
||||||
.nr_to_write = SWAP_CLUSTER_MAX,
|
|
||||||
.range_start = 0,
|
|
||||||
.range_end = LLONG_MAX,
|
|
||||||
.for_reclaim = 1,
|
|
||||||
.swap_plug = plug,
|
|
||||||
};
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
folio_set_reclaim(folio);
|
folio_set_reclaim(folio);
|
||||||
@ -675,7 +667,7 @@ static pageout_t writeout(struct folio *folio, struct address_space *mapping,
|
|||||||
if (shmem_mapping(mapping))
|
if (shmem_mapping(mapping))
|
||||||
res = shmem_writeout(folio, plug, folio_list);
|
res = shmem_writeout(folio, plug, folio_list);
|
||||||
else
|
else
|
||||||
res = swap_writeout(folio, &wbc);
|
res = swap_writeout(folio, plug);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
handle_write_error(mapping, folio, res);
|
handle_write_error(mapping, folio, res);
|
||||||
|
Loading…
Reference in New Issue
Block a user