More GFP_NOFS cleanups
David Sterba
maintainercover More GFP_NOFS cleanups
David Sterba (4):
btrfs: prepare to drop gfp mask parameter from clear_extent_bit
btrfs: sink gfp parameter to clear_extent_bit
btrfs: sink gfp parameter to clear_extent_uptodate
btrfs: use GFP_KERNEL in btrfs_alloc_inode
fs/btrfs/extent_io.c | 16 ++++++++-------- fs/btrfs/extent_io.h | 24 +++++++++++++----------- fs/btrfs/file.c | 2 +- fs/btrfs/free-space-cache.c | 8 +++----- fs/btrfs/inode.c | 26 ++++++++++++-------------- fs/btrfs/ioctl.c | 2 +- fs/btrfs/qgroup.c | 3 +-- fs/btrfs/tests/inode-tests.c | 12 ++++-------- fs/btrfs/transaction.c | 3 +-- 9 files changed, 44 insertions(+), 52 deletions(-)
Signature · 1 line
2.14.0
David Sterba
maintainerPATCH 1/4 btrfs: prepare to drop gfp mask parameter from clear_extent_bit
Use __clear_extent_bit directly in case we want to pass unknown gfp flags. Otherwise all clear_extent_bit callers use GFP_NOFS, so we can sink them to the function and reduce argument count, at the cost that __clear_extent_bit has to be exported.
--- fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/extent_io.h | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-)
fs/btrfs/extent_io.c +3 -3
@@ -580,7 +580,7 @@ static void extent_io_tree_panic(struct extent_io_tree *tree, int err)* * This takes the tree lock, and returns 0 on success and < 0 on error. */ -static int __clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end, +int __clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,int wake,int delete,struct extent_state **cached_state,gfp_t mask,struct extent_changeset *changeset)
@@ -4244,9 +4244,9 @@ static int try_release_extent_state(struct extent_map_tree *map,* at this point we can safely clear everything except the * locked bit and the nodatasum bit */ - ret =clear_extent_bit (tree, start, end, + ret =__clear_extent_bit (tree, start, end, ~(EXTENT_LOCKED |EXTENT_NODATASUM ), -0 ,0 ,NULL , mask); +0 ,0 ,NULL , mask,NULL );/* if clear_extent_bit failed for enomem reasons, * we can't allow the release to continue.
fs/btrfs/extent_io.h +8 -4
@@ -300,6 +300,10 @@ int clear_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,int clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,int wake,int delete,struct extent_state **cached,gfp_t mask); +int __clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end, +unsigned bits,int wake,int delete, +struct extent_state **cached,gfp_t mask, +struct extent_changeset *changeset);static inline int unlock_extent (struct extent_io_tree *tree,u64 start,u64 end) {
@@ -310,8 +314,8 @@ static inline int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end)static inline int unlock_extent_cached (struct extent_io_tree *tree,u64 start,u64 end,struct extent_state **cached,gfp_t mask) { -return clear_extent_bit (tree, start, end,EXTENT_LOCKED ,1 ,0 , cached, - mask); +return __clear_extent_bit (tree, start, end,EXTENT_LOCKED ,1 ,0 , cached, + mask,NULL ); } static inline int clear_extent_bits(struct extent_io_tree *tree, u64 start,
@@ -341,8 +345,8 @@ static inline int set_extent_bits(struct extent_io_tree *tree, u64 start,static inline int clear_extent_uptodate (struct extent_io_tree *tree,u64 start,u64 end,struct extent_state **cached_state,gfp_t mask) { -return clear_extent_bit (tree, start, end,EXTENT_UPTODATE ,0 ,0 , - cached_state, mask); +return __clear_extent_bit (tree, start, end,EXTENT_UPTODATE ,0 ,0 , + cached_state, mask,NULL ); } static inline int set_extent_dirty(struct extent_io_tree *tree, u64 start,
Signature · 1 line
2.14.0
David Sterba
maintainerPATCH 2/4 btrfs: sink gfp parameter to clear_extent_bit
In reply to David SterbaAll callers use GFP_NOFS, we don't have to pass it as an argument. The built-in tests pass GFP_KERNEL, but they run only at module load time and NOFS works there as well.
--- fs/btrfs/extent_io.c | 10 +++++----- fs/btrfs/extent_io.h | 10 ++++------ fs/btrfs/file.c | 2 +- fs/btrfs/free-space-cache.c | 8 +++----- fs/btrfs/inode.c | 22 ++++++++++------------ fs/btrfs/ioctl.c | 2 +- fs/btrfs/qgroup.c | 3 +-- fs/btrfs/tests/inode-tests.c | 12 ++++-------- fs/btrfs/transaction.c | 3 +-- 9 files changed, 30 insertions(+), 42 deletions(-)
fs/btrfs/extent_io.c +5 -5
@@ -1294,10 +1294,10 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,int clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,int wake,int delete, -struct extent_state **cached,gfp_t mask) +struct extent_state **cached) {return __clear_extent_bit (tree, start, end, bits, wake, delete, - cached, mask,NULL ); + cached,GFP_NOFS ,NULL ); } int clear_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
@@ -1347,7 +1347,7 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end)if (err == -EEXIST ) {if (failed_start > start)clear_extent_bit (tree, start, failed_start -1 , -EXTENT_LOCKED ,1 ,0 ,NULL ,GFP_NOFS ); +EXTENT_LOCKED ,1 ,0 ,NULL );return 0 ; }return 1 ;
@@ -1743,7 +1743,7 @@ void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end, unsigned long page_ops) {clear_extent_bit (&BTRFS_I (inode)->io_tree, start, end, clear_bits,1 ,0 , -NULL ,GFP_NOFS ); +NULL ); __process_pages_contig(inode->i_mapping, locked_page, start >> PAGE_SHIFT, end >> PAGE_SHIFT,
@@ -4219,7 +4219,7 @@ int extent_invalidatepage(struct extent_io_tree *tree,clear_extent_bit (tree, start, end,EXTENT_LOCKED |EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING , -1 ,1 , &cached_state,GFP_NOFS ); +1 ,1 , &cached_state);return 0 ; }
fs/btrfs/extent_io.h +4 -6
@@ -299,7 +299,7 @@ int clear_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, unsigned bits, struct extent_changeset *changeset);int clear_extent_bit (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,int wake,int delete, -struct extent_state **cached,gfp_t mask); +struct extent_state **cached); int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, unsigned bits, int wake, int delete, struct extent_state **cached, gfp_t mask,
@@ -307,8 +307,7 @@ int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,static inline int unlock_extent (struct extent_io_tree *tree,u64 start,u64 end) { -return clear_extent_bit (tree, start, end,EXTENT_LOCKED ,1 ,0 ,NULL , -GFP_NOFS ); +return clear_extent_bit (tree, start, end,EXTENT_LOCKED ,1 ,0 ,NULL ); } static inline int unlock_extent_cached(struct extent_io_tree *tree, u64 start,
@@ -326,8 +325,7 @@ static inline int clear_extent_bits(struct extent_io_tree *tree, u64 start,if (bits &EXTENT_LOCKED ) wake =1 ; -return clear_extent_bit (tree, start, end, bits, wake,0 ,NULL , -GFP_NOFS ); +return clear_extent_bit (tree, start, end, bits, wake,0 ,NULL ); } int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
@@ -361,7 +359,7 @@ static inline int clear_extent_dirty(struct extent_io_tree *tree, u64 start, {return clear_extent_bit (tree, start, end,EXTENT_DIRTY |EXTENT_DELALLOC | -EXTENT_DO_ACCOUNTING ,0 ,0 ,NULL ,GFP_NOFS ); +EXTENT_DO_ACCOUNTING ,0 ,0 ,NULL ); } int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
fs/btrfs/file.c +1 -1
@@ -1508,7 +1508,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,clear_extent_bit (&inode->io_tree, start_pos, last_pos, clear_bits, (clear_bits &EXTENT_LOCKED ) ?1 :0 , -0 , cached_state,GFP_NOFS ); +0 , cached_state);if (ret)return ret; *lockstart = start_pos;
fs/btrfs/free-space-cache.c +3 -5
@@ -993,8 +993,7 @@ update_cache_item(struct btrfs_trans_handle *trans, ret =btrfs_search_slot (trans, root, &key, path,0 ,1 );if (ret <0 ) {clear_extent_bit (&BTRFS_I (inode)->io_tree,0 , inode->i_size -1 , -EXTENT_DIRTY |EXTENT_DELALLOC ,0 ,0 ,NULL , -GFP_NOFS ); +EXTENT_DIRTY |EXTENT_DELALLOC ,0 ,0 ,NULL ); goto fail; } leaf = path->nodes[0 ];
@@ -1008,7 +1007,7 @@ update_cache_item(struct btrfs_trans_handle *trans,clear_extent_bit (&BTRFS_I (inode)->io_tree,0 , inode->i_size -1 ,EXTENT_DIRTY |EXTENT_DELALLOC ,0 ,0 , -NULL ,GFP_NOFS ); +NULL );btrfs_release_path (path); goto fail; }
@@ -1105,8 +1104,7 @@ static int flush_dirty_cache(struct inode *inode) ret =btrfs_wait_ordered_range (inode,0 , (u64)-1 );if (ret)clear_extent_bit (&BTRFS_I (inode)->io_tree,0 , inode->i_size -1 , -EXTENT_DIRTY |EXTENT_DELALLOC ,0 ,0 ,NULL , -GFP_NOFS ); +EXTENT_DIRTY |EXTENT_DELALLOC ,0 ,0 ,NULL );return ret; }
fs/btrfs/inode.c +10 -12
@@ -1203,7 +1203,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,u64 cur_end;clear_extent_bit (&BTRFS_I (inode)->io_tree, start, end,EXTENT_LOCKED , -1 ,0 ,NULL ,GFP_NOFS ); +1 ,0 ,NULL );while (start < end) { async_cow =kmalloc (sizeof (*async_cow),GFP_NOFS );BUG_ON (!async_cow);/* -ENOMEM */
@@ -2985,7 +2985,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)clear_extent_bit (io_tree, ordered_extent->file_offset, ordered_extent->file_offset + ordered_extent->len -1 , -EXTENT_DEFRAG ,0 ,0 , &cached_state,GFP_NOFS ); +EXTENT_DEFRAG ,0 ,0 , &cached_state); }if (nolock)
@@ -3053,7 +3053,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ordered_extent->len -1 , clear_bits, (clear_bits &EXTENT_LOCKED ) ?1 :0 , - 0, &cached_state, GFP_NOFS); + 0, &cached_state); }if (trans)
@@ -4795,7 +4795,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,clear_extent_bit (&BTRFS_I (inode)->io_tree, block_start, block_end,EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , -0 ,0 , &cached_state,GFP_NOFS ); +0 ,0 , &cached_state); ret =btrfs_set_extent_delalloc (inode, block_start, block_end, &cached_state,0 );
@@ -5231,8 +5231,7 @@ static void evict_inode_truncate_pages(struct inode *inode)clear_extent_bit (io_tree, start, end,EXTENT_LOCKED |EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING | -EXTENT_DEFRAG ,1 ,1 , - &cached_state,GFP_NOFS ); +EXTENT_DEFRAG ,1 ,1 , &cached_state);cond_resched ();spin_lock (&io_tree->lock);
@@ -7917,7 +7916,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,if (lockstart < lockend) {clear_extent_bit (&BTRFS_I (inode)->io_tree, lockstart, lockend, unlock_bits,1 ,0 , - &cached_state,GFP_NOFS ); + &cached_state); }else {free_extent_state (cached_state); }
@@ -7928,7 +7927,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, unlock_err:clear_extent_bit (&BTRFS_I (inode)->io_tree, lockstart, lockend, - unlock_bits,1 ,0 , &cached_state,GFP_NOFS ); + unlock_bits,1 ,0 , &cached_state); err:if (dio_data) current->journal_info = dio_data;
@@ -8969,8 +8968,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DELALLOC_NEW |EXTENT_LOCKED |EXTENT_DO_ACCOUNTING | -EXTENT_DEFRAG ,1 ,0 , &cached_state, - GFP_NOFS); + EXTENT_DEFRAG, 1, 0, &cached_state);/* * whoever cleared the private bit is responsible * for the finish_ordered_io
@@ -9027,7 +9025,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,EXTENT_LOCKED |EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DELALLOC_NEW |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG ,1 ,1 , - &cached_state, GFP_NOFS); + &cached_state);__btrfs_releasepage (page,GFP_NOFS ); }
@@ -9155,7 +9153,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)clear_extent_bit (&BTRFS_I (inode)->io_tree, page_start, end,EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , -0 ,0 , &cached_state,GFP_NOFS ); +0 ,0 , &cached_state); ret =btrfs_set_extent_delalloc (inode, page_start, end, &cached_state,0 );
fs/btrfs/ioctl.c +1 -1
@@ -1190,7 +1190,7 @@ static int cluster_pages_for_defrag(struct inode *inode,clear_extent_bit (&BTRFS_I (inode)->io_tree, page_start, page_end -1 ,EXTENT_DIRTY |EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG ,0 ,0 , - &cached_state,GFP_NOFS ); + &cached_state);if (i_done != page_cnt) {spin_lock (&BTRFS_I (inode)->lock);
fs/btrfs/qgroup.c +1 -2
@@ -2883,8 +2883,7 @@ int btrfs_qgroup_reserve_data(struct inode *inode,ULIST_ITER_INIT (&uiter);while ((unode =ulist_next (&reserved->range_changed, &uiter)))clear_extent_bit (&BTRFS_I (inode)->io_tree, unode->val, - unode->aux,EXTENT_QGROUP_RESERVED ,0 ,0 ,NULL , -GFP_NOFS ); + unode->aux,EXTENT_QGROUP_RESERVED ,0 ,0 ,NULL );extent_changeset_release (reserved);return ret; }
fs/btrfs/tests/inode-tests.c +4 -8
@@ -1001,8 +1001,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)BTRFS_MAX_EXTENT_SIZE >>1 , (BTRFS_MAX_EXTENT_SIZE >>1 ) + sectorsize -1 ,EXTENT_DELALLOC |EXTENT_DIRTY | -EXTENT_UPTODATE ,0 ,0 , - NULL, GFP_KERNEL); + EXTENT_UPTODATE, 0, 0, NULL);if (ret) {test_msg ("clear_extent_bit returned %d\n" , ret); goto out;
@@ -1070,8 +1069,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)BTRFS_MAX_EXTENT_SIZE + sectorsize,BTRFS_MAX_EXTENT_SIZE +2 * sectorsize -1 ,EXTENT_DIRTY |EXTENT_DELALLOC | -EXTENT_UPTODATE ,0 ,0 , - NULL, GFP_KERNEL); + EXTENT_UPTODATE, 0, 0, NULL);if (ret) {test_msg ("clear_extent_bit returned %d\n" , ret); goto out;
@@ -1104,8 +1102,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)/* Empty */ ret =clear_extent_bit (&BTRFS_I (inode)->io_tree,0 , (u64)-1 ,EXTENT_DIRTY |EXTENT_DELALLOC | -EXTENT_UPTODATE ,0 ,0 , -NULL ,GFP_KERNEL ); +EXTENT_UPTODATE ,0 ,0 ,NULL );if (ret) {test_msg ("clear_extent_bit returned %d\n" , ret); goto out;
@@ -1121,8 +1118,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)if (ret)clear_extent_bit (&BTRFS_I (inode)->io_tree,0 , (u64)-1 ,EXTENT_DIRTY |EXTENT_DELALLOC | -EXTENT_UPTODATE ,0 ,0 , -NULL ,GFP_KERNEL ); +EXTENT_UPTODATE ,0 ,0 ,NULL );iput (inode);btrfs_free_dummy_root (root);btrfs_free_dummy_fs_info (fs_info);
fs/btrfs/transaction.c +1 -2
@@ -1016,8 +1016,7 @@ static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,* it's safe to do it (through clear_btree_io_tree()). */ err =clear_extent_bit (dirty_pages, start, end, -EXTENT_NEED_WAIT , -0 ,0 , &cached_state,GFP_NOFS ); +EXTENT_NEED_WAIT ,0 ,0 , &cached_state);if (err == -ENOMEM ) err =0 ;if (!err)
Signature · 1 line
2.14.0
David Sterba
maintainerPATCH 3/4 btrfs: sink gfp parameter to clear_extent_uptodate
In reply to David SterbaThere's only one callsite with GFP_NOFS.
--- fs/btrfs/extent_io.h | 4 ++-- fs/btrfs/inode.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/extent_io.h +2 -2
@@ -341,10 +341,10 @@ static inline int set_extent_bits(struct extent_io_tree *tree, u64 start, }static inline int clear_extent_uptodate (struct extent_io_tree *tree,u64 start, -u64 end,struct extent_state **cached_state,gfp_t mask) +u64 end,struct extent_state **cached_state) {return __clear_extent_bit (tree, start, end,EXTENT_UPTODATE ,0 ,0 , - cached_state, mask,NULL ); + cached_state,GFP_NOFS ,NULL ); } static inline int set_extent_dirty(struct extent_io_tree *tree, u64 start,
fs/btrfs/inode.c +1 -1
@@ -3067,7 +3067,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)else start = ordered_extent->file_offset; end = ordered_extent->file_offset + ordered_extent->len -1 ; -clear_extent_uptodate (io_tree, start, end,NULL ,GFP_NOFS ); +clear_extent_uptodate (io_tree, start, end,NULL );/* Drop the cache for the part of the extent we didn't write. */ btrfs_drop_extent_cache (BTRFS_I (inode), start, end,0 );
Signature · 1 line
2.14.0
David Sterba
maintainerPATCH 4/4 btrfs: use GFP_KERNEL in btrfs_alloc_inode
In reply to David SterbaThis callback is called directly from VFS, no locks are held at the allocation time.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -9410,7 +9410,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)struct btrfs_inode *ei;struct inode *inode; - ei =kmem_cache_alloc (btrfs_inode_cachep,GFP_NOFS ); + ei =kmem_cache_alloc (btrfs_inode_cachep,GFP_KERNEL );if (!ei)return NULL ;
Signature · 1 line
2.14.0