diff options
author | Filipe Manana <fdmanana@suse.com> | 2022-10-11 13:17:02 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-12-05 18:00:39 +0100 |
commit | 61dbb952f0a5f587c983d88853212e969d2d4ede (patch) | |
tree | 0e28d1d2e8a16d2c72afaedb04c595f475d0e854 /fs/btrfs/extent_io.c | |
parent | ceb707da9ad92ad3a5251dc13844034ded06cb3d (diff) | |
download | lwn-61dbb952f0a5f587c983d88853212e969d2d4ede.tar.gz lwn-61dbb952f0a5f587c983d88853212e969d2d4ede.zip |
btrfs: turn the backref sharedness check cache into a context object
Right now we are using a struct btrfs_backref_shared_cache to pass state
across multiple btrfs_is_data_extent_shared() calls. The structure's name
closely follows its current purpose, which is to cache previous checks
for the sharedness of metadata extents. However we will start using the
structure for more things other than caching sharedness checks, so rename
it to struct btrfs_backref_share_check_ctx.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 83be7e85ba91..365ad00a5942 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3705,7 +3705,7 @@ static int fiemap_search_slot(struct btrfs_inode *inode, struct btrfs_path *path static int fiemap_process_hole(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, struct fiemap_cache *cache, - struct btrfs_backref_shared_cache *backref_cache, + struct btrfs_backref_share_check_ctx *backref_ctx, u64 disk_bytenr, u64 extent_offset, u64 extent_gen, struct ulist *roots, struct ulist *tmp_ulist, @@ -3755,7 +3755,7 @@ static int fiemap_process_hole(struct btrfs_inode *inode, disk_bytenr, extent_gen, roots, tmp_ulist, - backref_cache); + backref_ctx); if (ret < 0) return ret; else if (ret > 0) @@ -3805,7 +3805,7 @@ static int fiemap_process_hole(struct btrfs_inode *inode, disk_bytenr, extent_gen, roots, tmp_ulist, - backref_cache); + backref_ctx); if (ret < 0) return ret; else if (ret > 0) @@ -3904,7 +3904,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, struct extent_state *cached_state = NULL; struct btrfs_path *path; struct fiemap_cache cache = { 0 }; - struct btrfs_backref_shared_cache *backref_cache; + struct btrfs_backref_share_check_ctx *backref_ctx; struct ulist *roots; struct ulist *tmp_ulist; u64 last_extent_end; @@ -3914,11 +3914,11 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, bool stopped = false; int ret; - backref_cache = kzalloc(sizeof(*backref_cache), GFP_KERNEL); + backref_ctx = kzalloc(sizeof(*backref_ctx), GFP_KERNEL); path = btrfs_alloc_path(); roots = ulist_alloc(GFP_KERNEL); tmp_ulist = ulist_alloc(GFP_KERNEL); - if (!backref_cache || !path || !roots || !tmp_ulist) { + if (!backref_ctx || !path || !roots || !tmp_ulist) { ret = -ENOMEM; goto out; } @@ -3978,7 +3978,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, const u64 range_end = min(key.offset, lockend) - 1; ret = fiemap_process_hole(inode, fieinfo, &cache, - backref_cache, 0, 0, 0, + backref_ctx, 0, 0, 0, roots, tmp_ulist, prev_extent_end, range_end); if (ret < 0) { @@ -4019,14 +4019,14 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, extent_len, flags); } else if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) { ret = fiemap_process_hole(inode, fieinfo, &cache, - backref_cache, + backref_ctx, disk_bytenr, extent_offset, extent_gen, roots, tmp_ulist, key.offset, extent_end - 1); } else if (disk_bytenr == 0) { /* We have an explicit hole. */ ret = fiemap_process_hole(inode, fieinfo, &cache, - backref_cache, 0, 0, 0, + backref_ctx, 0, 0, 0, roots, tmp_ulist, key.offset, extent_end - 1); } else { @@ -4037,7 +4037,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, extent_gen, roots, tmp_ulist, - backref_cache); + backref_ctx); if (ret < 0) goto out_unlock; else if (ret > 0) @@ -4086,7 +4086,7 @@ check_eof_delalloc: path = NULL; if (!stopped && prev_extent_end < lockend) { - ret = fiemap_process_hole(inode, fieinfo, &cache, backref_cache, + ret = fiemap_process_hole(inode, fieinfo, &cache, backref_ctx, 0, 0, 0, roots, tmp_ulist, prev_extent_end, lockend - 1); if (ret < 0) @@ -4119,7 +4119,7 @@ check_eof_delalloc: out_unlock: unlock_extent(&inode->io_tree, lockstart, lockend, &cached_state); out: - kfree(backref_cache); + kfree(backref_ctx); btrfs_free_path(path); ulist_free(roots); ulist_free(tmp_ulist); |