mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
jfs: Convert insert_metapage() to take a folio
Both of its callers now have a folio, so convert this function. Use folio_attach_private() instead of manually setting folio->private. This also gets the expected refcount of the folio correct. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
This commit is contained in:
parent
2dcd9630d9
commit
9346476d21
@ -87,25 +87,23 @@ static inline struct metapage *page_to_mp(struct page *page, int offset)
|
||||
return mp_anchor(page)->mp[offset >> L2PSIZE];
|
||||
}
|
||||
|
||||
static inline int insert_metapage(struct page *page, struct metapage *mp)
|
||||
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
|
||||
{
|
||||
struct meta_anchor *a;
|
||||
int index;
|
||||
int l2mp_blocks; /* log2 blocks per metapage */
|
||||
|
||||
if (PagePrivate(page))
|
||||
a = mp_anchor(page);
|
||||
else {
|
||||
a = folio->private;
|
||||
if (!a) {
|
||||
a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS);
|
||||
if (!a)
|
||||
return -ENOMEM;
|
||||
set_page_private(page, (unsigned long)a);
|
||||
SetPagePrivate(page);
|
||||
kmap(page);
|
||||
folio_attach_private(folio, a);
|
||||
kmap(&folio->page);
|
||||
}
|
||||
|
||||
if (mp) {
|
||||
l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
|
||||
l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
|
||||
index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
|
||||
a->mp_count++;
|
||||
a->mp[index] = mp;
|
||||
@ -127,8 +125,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
|
||||
a->mp[index] = NULL;
|
||||
if (--a->mp_count == 0) {
|
||||
kfree(a);
|
||||
set_page_private(page, 0);
|
||||
ClearPagePrivate(page);
|
||||
detach_page_private(page);
|
||||
kunmap(page);
|
||||
}
|
||||
}
|
||||
@ -150,20 +147,18 @@ static inline struct metapage *page_to_mp(struct page *page, int offset)
|
||||
return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
|
||||
}
|
||||
|
||||
static inline int insert_metapage(struct page *page, struct metapage *mp)
|
||||
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
|
||||
{
|
||||
if (mp) {
|
||||
set_page_private(page, (unsigned long)mp);
|
||||
SetPagePrivate(page);
|
||||
kmap(page);
|
||||
folio_attach_private(folio, mp);
|
||||
kmap(&folio->page);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void remove_metapage(struct page *page, struct metapage *mp)
|
||||
{
|
||||
set_page_private(page, 0);
|
||||
ClearPagePrivate(page);
|
||||
detach_page_private(page);
|
||||
kunmap(page);
|
||||
}
|
||||
|
||||
@ -496,7 +491,7 @@ static int metapage_read_folio(struct file *fp, struct folio *folio)
|
||||
&xlen);
|
||||
if (pblock) {
|
||||
if (!folio->private)
|
||||
insert_metapage(&folio->page, NULL);
|
||||
insert_metapage(folio, NULL);
|
||||
inc_io(&folio->page);
|
||||
if (bio)
|
||||
submit_bio(bio);
|
||||
@ -658,7 +653,7 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
|
||||
mp->logical_size = size;
|
||||
mp->data = folio_address(folio) + page_offset;
|
||||
mp->index = lblock;
|
||||
if (unlikely(insert_metapage(&folio->page, mp))) {
|
||||
if (unlikely(insert_metapage(folio, mp))) {
|
||||
free_metapage(mp);
|
||||
goto unlock;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user