Commit 111c7d27 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Use mapping->gfp_mask for metadata inodes

Set mapping->gfp mask to GFP_NOFS for all metadata inodes so that
allocating pages in the address space of those inodes won't call back
into the filesystem.  This allows to switch back from
find_or_create_page() to grab_cache_page() in two places.

Partially reverts commit 220cca2a ("GFS2: Change truncate page
allocation to be GFP_NOFS").

Thanks to Dan Carpenter <dan.carpenter@linaro.org> for pointing out a
Smatch static checker warning.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent 5f02d168
...@@ -276,10 +276,16 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) ...@@ -276,10 +276,16 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
* gfs2_lookup_simple callers expect ENOENT * gfs2_lookup_simple callers expect ENOENT
* and do not check for NULL. * and do not check for NULL.
*/ */
if (inode == NULL) if (IS_ERR_OR_NULL(inode))
return ERR_PTR(-ENOENT); return inode ? inode : ERR_PTR(-ENOENT);
else
return inode; /*
* Must not call back into the filesystem when allocating
* pages in the metadata inode's address space.
*/
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
return inode;
} }
......
...@@ -456,7 +456,7 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd, ...@@ -456,7 +456,7 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd,
* Find the folio with 'index' in the journal's mapping. Search the folio for * Find the folio with 'index' in the journal's mapping. Search the folio for
* the journal head if requested (cleanup == false). Release refs on the * the journal head if requested (cleanup == false). Release refs on the
* folio so the page cache can reclaim it. We grabbed a * folio so the page cache can reclaim it. We grabbed a
* reference on this folio twice, first when we did a find_or_create_page() * reference on this folio twice, first when we did a grab_cache_page()
* to obtain the folio to add it to the bio and second when we do a * to obtain the folio to add it to the bio and second when we do a
* filemap_get_folio() here to get the folio to wait on while I/O on it is being * filemap_get_folio() here to get the folio to wait on while I/O on it is being
* completed. * completed.
...@@ -481,7 +481,7 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index, ...@@ -481,7 +481,7 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
if (!*done) if (!*done)
*done = gfs2_jhead_pg_srch(jd, head, &folio->page); *done = gfs2_jhead_pg_srch(jd, head, &folio->page);
/* filemap_get_folio() and the earlier find_or_create_page() */ /* filemap_get_folio() and the earlier grab_cache_page() */
folio_put_refs(folio, 2); folio_put_refs(folio, 2);
} }
...@@ -535,8 +535,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head, ...@@ -535,8 +535,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
for (; block < je->lblock + je->blocks; block++, dblock++) { for (; block < je->lblock + je->blocks; block++, dblock++) {
if (!page) { if (!page) {
page = find_or_create_page(mapping, page = grab_cache_page(mapping, block >> shift);
block >> shift, GFP_NOFS);
if (!page) { if (!page) {
ret = -ENOMEM; ret = -ENOMEM;
done = true; done = true;
......
...@@ -724,7 +724,7 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, ...@@ -724,7 +724,7 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
blk = index << (PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift); blk = index << (PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift);
boff = off % bsize; boff = off % bsize;
page = find_or_create_page(mapping, index, GFP_NOFS); page = grab_cache_page(mapping, index);
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
if (!page_has_buffers(page)) if (!page_has_buffers(page))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment