Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Btrfs: use find_or_create_page instead of grab_cache_page

grab_cache_page will use mapping_gfp_mask(), which for all inodes is set to
GFP_HIGHUSER_MOVABLE. So instead use find_or_create_page in all cases where we
need GFP_NOFS so we don't deadlock. Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>

authored by

Josef Bacik and committed by
Chris Mason
a94733d0 bab39bf9

+9 -7
+2 -1
fs/btrfs/file.c
··· 1081 1081 1082 1082 again: 1083 1083 for (i = 0; i < num_pages; i++) { 1084 - pages[i] = grab_cache_page(inode->i_mapping, index + i); 1084 + pages[i] = find_or_create_page(inode->i_mapping, index + i, 1085 + GFP_NOFS); 1085 1086 if (!pages[i]) { 1086 1087 faili = i - 1; 1087 1088 err = -ENOMEM;
+2 -2
fs/btrfs/free-space-cache.c
··· 307 307 if (!num_entries && !num_bitmaps) 308 308 break; 309 309 310 - page = grab_cache_page(inode->i_mapping, index); 310 + page = find_or_create_page(inode->i_mapping, index, GFP_NOFS); 311 311 if (!page) 312 312 goto free_cache; 313 313 ··· 594 594 * know and don't freak out. 595 595 */ 596 596 while (index < num_pages) { 597 - page = grab_cache_page(inode->i_mapping, index); 597 + page = find_or_create_page(inode->i_mapping, index, GFP_NOFS); 598 598 if (!page) { 599 599 int i; 600 600
+1 -1
fs/btrfs/inode.c
··· 3398 3398 3399 3399 ret = -ENOMEM; 3400 3400 again: 3401 - page = grab_cache_page(mapping, index); 3401 + page = find_or_create_page(mapping, index, GFP_NOFS); 3402 3402 if (!page) { 3403 3403 btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); 3404 3404 goto out;
+2 -2
fs/btrfs/ioctl.c
··· 867 867 /* step one, lock all the pages */ 868 868 for (i = 0; i < num_pages; i++) { 869 869 struct page *page; 870 - page = grab_cache_page(inode->i_mapping, 871 - start_index + i); 870 + page = find_or_create_page(inode->i_mapping, 871 + start_index + i, GFP_NOFS); 872 872 if (!page) 873 873 break; 874 874
+2 -1
fs/btrfs/relocation.c
··· 2955 2955 page_cache_sync_readahead(inode->i_mapping, 2956 2956 ra, NULL, index, 2957 2957 last_index + 1 - index); 2958 - page = grab_cache_page(inode->i_mapping, index); 2958 + page = find_or_create_page(inode->i_mapping, index, 2959 + GFP_NOFS); 2959 2960 if (!page) { 2960 2961 btrfs_delalloc_release_metadata(inode, 2961 2962 PAGE_CACHE_SIZE);