diff options
author | David Sterba <dsterba@suse.com> | 2024-08-27 04:10:11 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-09-10 16:51:19 +0200 |
commit | 91c9f2855ead841b27eefb8968079290725d4f2e (patch) | |
tree | 288f8fd3fa4946a7bf741da042af9e94132b7e55 /fs/btrfs | |
parent | 276940915f232f8569124811fd8a9524f27f5748 (diff) |
btrfs: return void from btrfs_add_inode_defrag()
The potential memory allocation failure is not a fatal error, skipping
autodefrag is fine and the caller inode_should_defrag() does not care
about the errors. Further writes can attempt to add the inode back to
the defragmentation list again.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/defrag.c | 14 | ||||
-rw-r--r-- | fs/btrfs/defrag.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index 89f51252d25c..6af593a0313d 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -117,10 +117,11 @@ static inline int need_auto_defrag(struct btrfs_fs_info *fs_info) } /* - * Insert a defrag record for this inode if auto defrag is enabled. + * Insert a defrag record for this inode if auto defrag is enabled. No errors + * returned as they're not considered fatal. */ -int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, - struct btrfs_inode *inode, u32 extent_thresh) +void btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, + struct btrfs_inode *inode, u32 extent_thresh) { struct btrfs_root *root = inode->root; struct btrfs_fs_info *fs_info = root->fs_info; @@ -129,10 +130,10 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, int ret; if (!need_auto_defrag(fs_info)) - return 0; + return; if (test_bit(BTRFS_INODE_IN_DEFRAG, &inode->runtime_flags)) - return 0; + return; if (trans) transid = trans->transid; @@ -141,7 +142,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, defrag = kmem_cache_zalloc(btrfs_inode_defrag_cachep, GFP_NOFS); if (!defrag) - return -ENOMEM; + return; defrag->ino = btrfs_ino(inode); defrag->transid = transid; @@ -162,7 +163,6 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, kmem_cache_free(btrfs_inode_defrag_cachep, defrag); } spin_unlock(&fs_info->defrag_inodes_lock); - return 0; } /* diff --git a/fs/btrfs/defrag.h b/fs/btrfs/defrag.h index 878528e086fb..97f36ab3f24d 100644 --- a/fs/btrfs/defrag.h +++ b/fs/btrfs/defrag.h @@ -18,8 +18,8 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra, u64 newer_than, unsigned long max_to_defrag); int __init btrfs_auto_defrag_init(void); void __cold btrfs_auto_defrag_exit(void); -int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, - struct btrfs_inode *inode, u32 extent_thresh); +void btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, + struct btrfs_inode *inode, u32 extent_thresh); int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info); void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info); int btrfs_defrag_root(struct btrfs_root *root); |