Skip to content

Commit 2d68317

Browse files
Christoph HellwigAl Viro
authored andcommitted
mm,jfs: move write_one_page/folio_write_one to jfs
The last remaining user of folio_write_one through the write_one_page wrapper is jfs, so move the functionality there and hard code the call to metapage_writepage. Note that the use of the pagecache by the JFS 'metapage' buffer cache is a bit odd, and we could probably do without VM-level dirty tracking at all, but that's a change for another time. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 8e4bfd1 commit 2d68317

3 files changed

Lines changed: 34 additions & 51 deletions

File tree

fs/jfs/jfs_metapage.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,35 @@ void grab_metapage(struct metapage * mp)
691691
unlock_page(mp->page);
692692
}
693693

694+
static int metapage_write_one(struct page *page)
695+
{
696+
struct folio *folio = page_folio(page);
697+
struct address_space *mapping = folio->mapping;
698+
struct writeback_control wbc = {
699+
.sync_mode = WB_SYNC_ALL,
700+
.nr_to_write = folio_nr_pages(folio),
701+
};
702+
int ret = 0;
703+
704+
BUG_ON(!folio_test_locked(folio));
705+
706+
folio_wait_writeback(folio);
707+
708+
if (folio_clear_dirty_for_io(folio)) {
709+
folio_get(folio);
710+
ret = metapage_writepage(page, &wbc);
711+
if (ret == 0)
712+
folio_wait_writeback(folio);
713+
folio_put(folio);
714+
} else {
715+
folio_unlock(folio);
716+
}
717+
718+
if (!ret)
719+
ret = filemap_check_errors(mapping);
720+
return ret;
721+
}
722+
694723
void force_metapage(struct metapage *mp)
695724
{
696725
struct page *page = mp->page;
@@ -700,8 +729,8 @@ void force_metapage(struct metapage *mp)
700729
get_page(page);
701730
lock_page(page);
702731
set_page_dirty(page);
703-
if (write_one_page(page))
704-
jfs_error(mp->sb, "write_one_page() failed\n");
732+
if (metapage_write_one(page))
733+
jfs_error(mp->sb, "metapage_write_one() failed\n");
705734
clear_bit(META_forcewrite, &mp->flag);
706735
put_page(page);
707736
}
@@ -746,9 +775,9 @@ void release_metapage(struct metapage * mp)
746775
set_page_dirty(page);
747776
if (test_bit(META_sync, &mp->flag)) {
748777
clear_bit(META_sync, &mp->flag);
749-
if (write_one_page(page))
750-
jfs_error(mp->sb, "write_one_page() failed\n");
751-
lock_page(page); /* write_one_page unlocks the page */
778+
if (metapage_write_one(page))
779+
jfs_error(mp->sb, "metapage_write_one() failed\n");
780+
lock_page(page);
752781
}
753782
} else if (mp->lsn) /* discard_metapage doesn't remove it */
754783
remove_from_logsync(mp);

include/linux/pagemap.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,12 +1066,6 @@ static inline void folio_cancel_dirty(struct folio *folio)
10661066
bool folio_clear_dirty_for_io(struct folio *folio);
10671067
bool clear_page_dirty_for_io(struct page *page);
10681068
void folio_invalidate(struct folio *folio, size_t offset, size_t length);
1069-
int __must_check folio_write_one(struct folio *folio);
1070-
static inline int __must_check write_one_page(struct page *page)
1071-
{
1072-
return folio_write_one(page_folio(page));
1073-
}
1074-
10751069
int __set_page_dirty_nobuffers(struct page *page);
10761070
bool noop_dirty_folio(struct address_space *mapping, struct folio *folio);
10771071

mm/page-writeback.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,46 +2583,6 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
25832583
return ret;
25842584
}
25852585

2586-
/**
2587-
* folio_write_one - write out a single folio and wait on I/O.
2588-
* @folio: The folio to write.
2589-
*
2590-
* The folio must be locked by the caller and will be unlocked upon return.
2591-
*
2592-
* Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this
2593-
* function returns.
2594-
*
2595-
* Return: %0 on success, negative error code otherwise
2596-
*/
2597-
int folio_write_one(struct folio *folio)
2598-
{
2599-
struct address_space *mapping = folio->mapping;
2600-
int ret = 0;
2601-
struct writeback_control wbc = {
2602-
.sync_mode = WB_SYNC_ALL,
2603-
.nr_to_write = folio_nr_pages(folio),
2604-
};
2605-
2606-
BUG_ON(!folio_test_locked(folio));
2607-
2608-
folio_wait_writeback(folio);
2609-
2610-
if (folio_clear_dirty_for_io(folio)) {
2611-
folio_get(folio);
2612-
ret = mapping->a_ops->writepage(&folio->page, &wbc);
2613-
if (ret == 0)
2614-
folio_wait_writeback(folio);
2615-
folio_put(folio);
2616-
} else {
2617-
folio_unlock(folio);
2618-
}
2619-
2620-
if (!ret)
2621-
ret = filemap_check_errors(mapping);
2622-
return ret;
2623-
}
2624-
EXPORT_SYMBOL(folio_write_one);
2625-
26262586
/*
26272587
* For address_spaces which do not use buffers nor write back.
26282588
*/

0 commit comments

Comments
 (0)