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

btrfs: declare free_ipath() via DEFINE_FREE()

The free_ipath() function was being used as a cleanup function
everywhere. Declare it via DEFINE_FREE() so we can use this function
with the __free() helper.

The name has also been adjusted so it's closer to the type's name.

Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Miquel Sabaté Solà and committed by
David Sterba
285c3ab2 937f99c7

+10 -18
+1 -9
fs/btrfs/backref.c
··· 2785 2785 * allocates space to return multiple file system paths for an inode. 2786 2786 * total_bytes to allocate are passed, note that space usable for actual path 2787 2787 * information will be total_bytes - sizeof(struct inode_fs_paths). 2788 - * the returned pointer must be freed with free_ipath() in the end. 2788 + * the returned pointer must be freed with __free_inode_fs_paths() in the end. 2789 2789 */ 2790 2790 struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 2791 2791 struct btrfs_path *path) ··· 2808 2808 ifp->fs_root = fs_root; 2809 2809 2810 2810 return ifp; 2811 - } 2812 - 2813 - void free_ipath(struct inode_fs_paths *ipath) 2814 - { 2815 - if (!ipath) 2816 - return; 2817 - kvfree(ipath->fspath); 2818 - kfree(ipath); 2819 2811 } 2820 2812 2821 2813 struct btrfs_backref_iter *btrfs_backref_iter_alloc(struct btrfs_fs_info *fs_info)
+6 -1
fs/btrfs/backref.h
··· 241 241 struct btrfs_data_container *init_data_container(u32 total_bytes); 242 242 struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 243 243 struct btrfs_path *path); 244 - void free_ipath(struct inode_fs_paths *ipath); 244 + 245 + DEFINE_FREE(inode_fs_paths, struct inode_fs_paths *, 246 + if (_T) { 247 + kvfree(_T->fspath); 248 + kfree(_T); 249 + }) 245 250 246 251 int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid, 247 252 u64 start_off, struct btrfs_path *path,
+1 -3
fs/btrfs/inode.c
··· 130 130 struct btrfs_fs_info *fs_info = warn->fs_info; 131 131 struct extent_buffer *eb; 132 132 struct btrfs_inode_item *inode_item; 133 - struct inode_fs_paths *ipath = NULL; 133 + struct inode_fs_paths *ipath __free(inode_fs_paths) = NULL; 134 134 struct btrfs_root *local_root; 135 135 struct btrfs_key key; 136 136 unsigned int nofs_flag; ··· 195 195 } 196 196 197 197 btrfs_put_root(local_root); 198 - free_ipath(ipath); 199 198 return 0; 200 199 201 200 err: ··· 202 203 "checksum error at logical %llu mirror %u root %llu inode %llu offset %llu, path resolving failed with ret=%d", 203 204 warn->logical, warn->mirror_num, root, inum, offset, ret); 204 205 205 - free_ipath(ipath); 206 206 return ret; 207 207 } 208 208
+1 -2
fs/btrfs/ioctl.c
··· 3298 3298 u64 rel_ptr; 3299 3299 int size; 3300 3300 struct btrfs_ioctl_ino_path_args *ipa = NULL; 3301 - struct inode_fs_paths *ipath = NULL; 3301 + struct inode_fs_paths *ipath __free(inode_fs_paths) = NULL; 3302 3302 struct btrfs_path *path; 3303 3303 3304 3304 if (!capable(CAP_DAC_READ_SEARCH)) ··· 3346 3346 3347 3347 out: 3348 3348 btrfs_free_path(path); 3349 - free_ipath(ipath); 3350 3349 kfree(ipa); 3351 3350 3352 3351 return ret;
+1 -3
fs/btrfs/scrub.c
··· 505 505 struct btrfs_inode_item *inode_item; 506 506 struct scrub_warning *swarn = warn_ctx; 507 507 struct btrfs_fs_info *fs_info = swarn->dev->fs_info; 508 - struct inode_fs_paths *ipath = NULL; 508 + struct inode_fs_paths *ipath __free(inode_fs_paths) = NULL; 509 509 struct btrfs_root *local_root; 510 510 struct btrfs_key key; 511 511 ··· 569 569 (char *)(unsigned long)ipath->fspath->val[i]); 570 570 571 571 btrfs_put_root(local_root); 572 - free_ipath(ipath); 573 572 return 0; 574 573 575 574 err: ··· 579 580 swarn->physical, 580 581 root, inum, offset, ret); 581 582 582 - free_ipath(ipath); 583 583 return 0; 584 584 } 585 585