Skip to content

Commit 9346476

Browse files
Matthew Wilcox (Oracle)kleikamp
authored andcommitted
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) <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent 2dcd963 commit 9346476

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

fs/jfs/jfs_metapage.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,23 @@ static inline struct metapage *page_to_mp(struct page *page, int offset)
8787
return mp_anchor(page)->mp[offset >> L2PSIZE];
8888
}
8989

90-
static inline int insert_metapage(struct page *page, struct metapage *mp)
90+
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
9191
{
9292
struct meta_anchor *a;
9393
int index;
9494
int l2mp_blocks; /* log2 blocks per metapage */
9595

96-
if (PagePrivate(page))
97-
a = mp_anchor(page);
98-
else {
96+
a = folio->private;
97+
if (!a) {
9998
a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS);
10099
if (!a)
101100
return -ENOMEM;
102-
set_page_private(page, (unsigned long)a);
103-
SetPagePrivate(page);
104-
kmap(page);
101+
folio_attach_private(folio, a);
102+
kmap(&folio->page);
105103
}
106104

107105
if (mp) {
108-
l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
106+
l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
109107
index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
110108
a->mp_count++;
111109
a->mp[index] = mp;
@@ -127,8 +125,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
127125
a->mp[index] = NULL;
128126
if (--a->mp_count == 0) {
129127
kfree(a);
130-
set_page_private(page, 0);
131-
ClearPagePrivate(page);
128+
detach_page_private(page);
132129
kunmap(page);
133130
}
134131
}
@@ -150,20 +147,18 @@ static inline struct metapage *page_to_mp(struct page *page, int offset)
150147
return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
151148
}
152149

153-
static inline int insert_metapage(struct page *page, struct metapage *mp)
150+
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
154151
{
155152
if (mp) {
156-
set_page_private(page, (unsigned long)mp);
157-
SetPagePrivate(page);
158-
kmap(page);
153+
folio_attach_private(folio, mp);
154+
kmap(&folio->page);
159155
}
160156
return 0;
161157
}
162158

163159
static inline void remove_metapage(struct page *page, struct metapage *mp)
164160
{
165-
set_page_private(page, 0);
166-
ClearPagePrivate(page);
161+
detach_page_private(page);
167162
kunmap(page);
168163
}
169164

@@ -496,7 +491,7 @@ static int metapage_read_folio(struct file *fp, struct folio *folio)
496491
&xlen);
497492
if (pblock) {
498493
if (!folio->private)
499-
insert_metapage(&folio->page, NULL);
494+
insert_metapage(folio, NULL);
500495
inc_io(&folio->page);
501496
if (bio)
502497
submit_bio(bio);
@@ -658,7 +653,7 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
658653
mp->logical_size = size;
659654
mp->data = folio_address(folio) + page_offset;
660655
mp->index = lblock;
661-
if (unlikely(insert_metapage(&folio->page, mp))) {
656+
if (unlikely(insert_metapage(folio, mp))) {
662657
free_metapage(mp);
663658
goto unlock;
664659
}

0 commit comments

Comments
 (0)