Skip to content

Commit 5fb7bd5

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
ufs: add ufs_get_locked_folio and ufs_put_locked_folio
Convert the _page variants to call them. Saves a few hidden calls to compound_head(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Andreas Gruenbacher <[email protected]> Cc: Pankaj Raghav <[email protected]> Cc: Ryusuke Konishi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 44f6857 commit 5fb7bd5

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

fs/ufs/util.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,43 +229,50 @@ ufs_set_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi, dev_t dev
229229
ufsi->i_u1.i_data[0] = cpu_to_fs32(sb, fs32);
230230
}
231231

232+
struct page *ufs_get_locked_page(struct address_space *mapping, pgoff_t index)
233+
{
234+
struct folio *folio = ufs_get_locked_folio(mapping, index);
235+
236+
if (folio)
237+
return folio_file_page(folio, index);
238+
return NULL;
239+
}
240+
232241
/**
233-
* ufs_get_locked_page() - locate, pin and lock a pagecache page, if not exist
242+
* ufs_get_locked_folio() - locate, pin and lock a pagecache folio, if not exist
234243
* read it from disk.
235244
* @mapping: the address_space to search
236245
* @index: the page index
237246
*
238-
* Locates the desired pagecache page, if not exist we'll read it,
247+
* Locates the desired pagecache folio, if not exist we'll read it,
239248
* locks it, increments its reference
240249
* count and returns its address.
241250
*
242251
*/
243-
244-
struct page *ufs_get_locked_page(struct address_space *mapping,
252+
struct folio *ufs_get_locked_folio(struct address_space *mapping,
245253
pgoff_t index)
246254
{
247255
struct inode *inode = mapping->host;
248-
struct page *page = find_lock_page(mapping, index);
249-
if (!page) {
250-
page = read_mapping_page(mapping, index, NULL);
256+
struct folio *folio = filemap_lock_folio(mapping, index);
257+
if (!folio) {
258+
folio = read_mapping_folio(mapping, index, NULL);
251259

252-
if (IS_ERR(page)) {
253-
printk(KERN_ERR "ufs_change_blocknr: "
254-
"read_mapping_page error: ino %lu, index: %lu\n",
260+
if (IS_ERR(folio)) {
261+
printk(KERN_ERR "ufs_change_blocknr: read_mapping_folio error: ino %lu, index: %lu\n",
255262
mapping->host->i_ino, index);
256-
return page;
263+
return folio;
257264
}
258265

259-
lock_page(page);
266+
folio_lock(folio);
260267

261-
if (unlikely(page->mapping == NULL)) {
268+
if (unlikely(folio->mapping == NULL)) {
262269
/* Truncate got there first */
263-
unlock_page(page);
264-
put_page(page);
270+
folio_unlock(folio);
271+
folio_put(folio);
265272
return NULL;
266273
}
267274
}
268-
if (!page_has_buffers(page))
269-
create_empty_buffers(page, 1 << inode->i_blkbits, 0);
270-
return page;
275+
if (!folio_buffers(folio))
276+
folio_create_empty_buffers(folio, 1 << inode->i_blkbits, 0);
277+
return folio;
271278
}

fs/ufs/util.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,17 @@ extern void _ubh_ubhcpymem_(struct ufs_sb_private_info *, unsigned char *, struc
273273
extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head *, unsigned char *, unsigned);
274274

275275
/* This functions works with cache pages*/
276-
extern struct page *ufs_get_locked_page(struct address_space *mapping,
277-
pgoff_t index);
276+
struct page *ufs_get_locked_page(struct address_space *mapping, pgoff_t index);
277+
struct folio *ufs_get_locked_folio(struct address_space *mapping, pgoff_t index);
278+
static inline void ufs_put_locked_folio(struct folio *folio)
279+
{
280+
folio_unlock(folio);
281+
folio_put(folio);
282+
}
283+
278284
static inline void ufs_put_locked_page(struct page *page)
279285
{
280-
unlock_page(page);
281-
put_page(page);
286+
ufs_put_locked_folio(page_folio(page));
282287
}
283288

284289

0 commit comments

Comments
 (0)