diff mbox series

[1/4] btrfs: Document __etree_search

Message ID 20190603100602.19362-2-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series Further FITRIM improvements | expand

Commit Message

Nikolay Borisov June 3, 2019, 10:05 a.m. UTC
The function has a lot of return values and specific conventions making
it cumbersome to understand what's returned. Have a go at documenting
its parameters and return values.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent_io.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Johannes Thumshirn June 5, 2019, 8:04 a.m. UTC | #1
On Mon, Jun 03, 2019 at 01:05:59PM +0300, Nikolay Borisov wrote:
> The function has a lot of return values and specific conventions making
> it cumbersome to understand what's returned. Have a go at documenting
> its parameters and return values.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/extent_io.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index e56afb826517..d5979558c96f 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -359,6 +359,22 @@ static struct rb_node *tree_insert(struct rb_root *root,
>  	return NULL;
>  }
>  
> +/**
> + * __etree_search - searches @tree for an entry that contains @offset. Such
> + * entry would have entry->start <= offset && entry->end >= offset.
> + *

This is missing @tree, make W=1 should warn about this.

> + * @offset - offset that should fall within an entry in @tree
> + * @next_ret - pointer to the first entry whose range ends after @offset
> + * @prev - pointer to the first entry whose range begins before @offset
> + * @p_ret - pointer where new node should be anchored (used when inserting an
> + *	    entry in the tree)
> + * @parent_ret - points to entry which would have been the parent of the entry,
> + * containing @offset
> + *
> + * This function returns a pointer to the entry that contains @offset byte
> + * address. If no such entry exists, then NULL is returned and the other
> + * pointer arguments to the function are filled.
> + */
>  static struct rb_node *__etree_search(struct extent_io_tree *tree, u64 offset,
>  				      struct rb_node **next_ret,
>  				      struct rb_node **prev_ret,
> -- 
> 2.17.1
>
Qu Wenruo June 5, 2019, 9:13 a.m. UTC | #2
On 2019/6/3 下午6:05, Nikolay Borisov wrote:
> The function has a lot of return values and specific conventions making
> it cumbersome to understand what's returned. Have a go at documenting
> its parameters and return values.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

The idea is pretty good, will help later readers.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Just a small nitpick inlined below.

> ---
>  fs/btrfs/extent_io.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index e56afb826517..d5979558c96f 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -359,6 +359,22 @@ static struct rb_node *tree_insert(struct rb_root *root,
>  	return NULL;
>  }
>
> +/**
> + * __etree_search - searches @tree for an entry that contains @offset. Such
> + * entry would have entry->start <= offset && entry->end >= offset.
> + *
> + * @offset - offset that should fall within an entry in @tree
> + * @next_ret - pointer to the first entry whose range ends after @offset
> + * @prev - pointer to the first entry whose range begins before @offset
> + * @p_ret - pointer where new node should be anchored (used when inserting an
> + *	    entry in the tree)
> + * @parent_ret - points to entry which would have been the parent of the entry,
> + * containing @offset
> + *
> + * This function returns a pointer to the entry that contains @offset byte
> + * address.

it would be better to mention when found, the remaining pointers are
untouched.

> If no such entry exists, then NULL is returned and the other
> + * pointer arguments to the function are filled.
> + */
>  static struct rb_node *__etree_search(struct extent_io_tree *tree, u64 offset,
>  				      struct rb_node **next_ret,
>  				      struct rb_node **prev_ret,
>
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e56afb826517..d5979558c96f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -359,6 +359,22 @@  static struct rb_node *tree_insert(struct rb_root *root,
 	return NULL;
 }
 
+/**
+ * __etree_search - searches @tree for an entry that contains @offset. Such
+ * entry would have entry->start <= offset && entry->end >= offset.
+ *
+ * @offset - offset that should fall within an entry in @tree
+ * @next_ret - pointer to the first entry whose range ends after @offset
+ * @prev - pointer to the first entry whose range begins before @offset
+ * @p_ret - pointer where new node should be anchored (used when inserting an
+ *	    entry in the tree)
+ * @parent_ret - points to entry which would have been the parent of the entry,
+ * containing @offset
+ *
+ * This function returns a pointer to the entry that contains @offset byte
+ * address. If no such entry exists, then NULL is returned and the other
+ * pointer arguments to the function are filled.
+ */
 static struct rb_node *__etree_search(struct extent_io_tree *tree, u64 offset,
 				      struct rb_node **next_ret,
 				      struct rb_node **prev_ret,