|
Filipe Manana |
c127de |
From: Nikolay Borisov <nborisov@suse.com>
|
|
Filipe Manana |
c127de |
Date: Tue, 7 May 2019 10:19:22 +0300
|
|
Filipe Manana |
c127de |
Git-commit: ffa87214c1100c7ea38e85a3cf981d0d47b1c744
|
|
Filipe Manana |
c127de |
Patch-mainline: 5.3
|
|
Filipe Manana |
c127de |
References: bsc#1174438
|
|
Filipe Manana |
c127de |
Subject: [PATCH] btrfs: add new helper
|
|
Filipe Manana |
c127de |
btrfs_lock_and_flush_ordered_range
|
|
Filipe Manana |
c127de |
|
|
Filipe Manana |
c127de |
There is a certain idiom used in multiple places in btrfs' codebase,
|
|
Filipe Manana |
c127de |
dealing with flushing an ordered range. Factor this in a separate
|
|
Filipe Manana |
c127de |
function that can be reused. Future patches will replace the existing
|
|
Filipe Manana |
c127de |
code with that function.
|
|
Filipe Manana |
c127de |
|
|
Filipe Manana |
c127de |
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
|
|
Filipe Manana |
c127de |
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
|
|
Filipe Manana |
c127de |
Reviewed-by: David Sterba <dsterba@suse.com>
|
|
Filipe Manana |
c127de |
Signed-off-by: David Sterba <dsterba@suse.com>
|
|
Filipe Manana |
c127de |
Signed-off-by: Filipe Manana <fdmanana@suse.com>
|
|
Filipe Manana |
c127de |
---
|
|
Filipe Manana |
c127de |
fs/btrfs/ordered-data.c | 33 +++++++++++++++++++++++++++++++++
|
|
Filipe Manana |
c127de |
fs/btrfs/ordered-data.h | 4 ++++
|
|
Filipe Manana |
c127de |
2 files changed, 37 insertions(+)
|
|
Filipe Manana |
c127de |
|
|
Filipe Manana |
c127de |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
|
|
Filipe Manana |
c127de |
index 4f51e634f22d..f8324f63571d 100644
|
|
Filipe Manana |
c127de |
--- a/fs/btrfs/ordered-data.c
|
|
Filipe Manana |
c127de |
+++ b/fs/btrfs/ordered-data.c
|
|
Filipe Manana |
c127de |
@@ -1146,6 +1146,39 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
|
|
Filipe Manana |
c127de |
return index;
|
|
Filipe Manana |
c127de |
}
|
|
Filipe Manana |
c127de |
|
|
Filipe Manana |
c127de |
+/*
|
|
Filipe Manana |
c127de |
+ * btrfs_flush_ordered_range - Lock the passed range and ensures all pending
|
|
Filipe Manana |
c127de |
+ * ordered extents in it are run to completion.
|
|
Filipe Manana |
c127de |
+ *
|
|
Filipe Manana |
c127de |
+ * @tree: IO tree used for locking out other users of the range
|
|
Filipe Manana |
c127de |
+ * @inode: Inode whose ordered tree is to be searched
|
|
Filipe Manana |
c127de |
+ * @start: Beginning of range to flush
|
|
Filipe Manana |
c127de |
+ * @end: Last byte of range to lock
|
|
Filipe Manana |
c127de |
+ * @cached_state: If passed, will return the extent state responsible for the
|
|
Filipe Manana |
c127de |
+ * locked range. It's the caller's responsibility to free the cached state.
|
|
Filipe Manana |
c127de |
+ *
|
|
Filipe Manana |
c127de |
+ * This function always returns with the given range locked, ensuring after it's
|
|
Filipe Manana |
c127de |
+ * called no order extent can be pending.
|
|
Filipe Manana |
c127de |
+ */
|
|
Filipe Manana |
c127de |
+void btrfs_lock_and_flush_ordered_range(struct extent_io_tree *tree,
|
|
Filipe Manana |
c127de |
+ struct btrfs_inode *inode, u64 start,
|
|
Filipe Manana |
c127de |
+ u64 end,
|
|
Filipe Manana |
c127de |
+ struct extent_state **cached_state)
|
|
Filipe Manana |
c127de |
+{
|
|
Filipe Manana |
c127de |
+ struct btrfs_ordered_extent *ordered;
|
|
Filipe Manana |
c127de |
+
|
|
Filipe Manana |
c127de |
+ while (1) {
|
|
Filipe Manana |
c127de |
+ lock_extent_bits(tree, start, end, cached_state);
|
|
Filipe Manana |
c127de |
+ ordered = btrfs_lookup_ordered_range(inode, start,
|
|
Filipe Manana |
c127de |
+ end - start + 1);
|
|
Filipe Manana |
c127de |
+ if (!ordered)
|
|
Filipe Manana |
c127de |
+ break;
|
|
Filipe Manana |
c127de |
+ unlock_extent_cached(tree, start, end, cached_state, GFP_NOFS);
|
|
Filipe Manana |
c127de |
+ btrfs_start_ordered_extent(&inode->vfs_inode, ordered, 1);
|
|
Filipe Manana |
c127de |
+ btrfs_put_ordered_extent(ordered);
|
|
Filipe Manana |
c127de |
+ }
|
|
Filipe Manana |
c127de |
+}
|
|
Filipe Manana |
c127de |
+
|
|
Filipe Manana |
c127de |
int __init ordered_data_init(void)
|
|
Filipe Manana |
c127de |
{
|
|
Filipe Manana |
c127de |
btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent",
|
|
Filipe Manana |
c127de |
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
|
|
Filipe Manana |
c127de |
index bc08fb1250de..12bd38ce68b0 100644
|
|
Filipe Manana |
c127de |
--- a/fs/btrfs/ordered-data.h
|
|
Filipe Manana |
c127de |
+++ b/fs/btrfs/ordered-data.h
|
|
Denis Kirjanov |
5a44c0 |
@@ -197,6 +197,10 @@ u64 btrfs_wait_ordered_extents(struct bt
|
|
Denis Kirjanov |
5a44c0 |
const u64 range_start, const u64 range_len);
|
|
Denis Kirjanov |
5a44c0 |
u64 btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
|
|
Denis Kirjanov |
5a44c0 |
const u64 range_start, const u64 range_len);
|
|
Filipe Manana |
c127de |
+void btrfs_lock_and_flush_ordered_range(struct extent_io_tree *tree,
|
|
Denis Kirjanov |
5a44c0 |
+ struct btrfs_inode *inode, u64 start,
|
|
Denis Kirjanov |
5a44c0 |
+ u64 end,
|
|
Denis Kirjanov |
5a44c0 |
+ struct extent_state **cached_state);
|
|
Filipe Manana |
c127de |
int __init ordered_data_init(void);
|
|
Filipe Manana |
c127de |
void ordered_data_exit(void);
|
|
Filipe Manana |
c127de |
#endif
|
|
Filipe Manana |
c127de |
--
|
|
Filipe Manana |
c127de |
2.26.2
|
|
Filipe Manana |
c127de |
|