All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: btrfs: extent_map: removed unneeded variable
@ 2021-06-29  8:50 lijian_8010a29
  2021-06-29  9:04 ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: lijian_8010a29 @ 2021-06-29  8:50 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, lijian

From: lijian <lijian@yulong.com>

removed unneeded variable 'ret'.

Signed-off-by: lijian <lijian@yulong.com>
---
 fs/btrfs/extent_map.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 4a8e02f7b6c7..70d3e76e30c5 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -296,7 +296,6 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
 int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
 		       u64 gen)
 {
-	int ret = 0;
 	struct extent_map *em;
 	bool prealloc = false;
 
@@ -328,8 +327,7 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
 	free_extent_map(em);
 out:
 	write_unlock(&tree->lock);
-	return ret;
-
+	return 0;
 }
 
 void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: btrfs: extent_map: removed unneeded variable
  2021-06-29  8:50 [PATCH] fs: btrfs: extent_map: removed unneeded variable lijian_8010a29
@ 2021-06-29  9:04 ` Johannes Thumshirn
  2021-06-30  9:59   ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Thumshirn @ 2021-06-29  9:04 UTC (permalink / raw)
  To: lijian_8010a29, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, lijian

On 29/06/2021 10:51, lijian_8010a29@163.com wrote:
> From: lijian <lijian@yulong.com>
> 
> removed unneeded variable 'ret'.

Wouldn't it make more sense to return an error (-ENOENT??) in case
the em lookup fails and handle the error in btrfs_finish_ordered_io()
as this is the only caller of unpin_extent_cache()?

I've actually tripped over this a couple of times already when 
investigating extent map and ordered extent splitting problems
on zoned filesystems:

	em = lookup_extent_mapping(tree, start, len);
	WARN_ON(!em || em->start != start);

Maybe even turn this WARN_ON() into an ASSERT() when introducing proper
error handling, as we shouldn't really get there unless we have a logical
error.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: btrfs: extent_map: removed unneeded variable
  2021-06-29  9:04 ` Johannes Thumshirn
@ 2021-06-30  9:59   ` David Sterba
  2021-06-30 11:17     ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2021-06-30  9:59 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: lijian_8010a29, clm, josef, dsterba, linux-btrfs, linux-kernel, lijian

On Tue, Jun 29, 2021 at 09:04:40AM +0000, Johannes Thumshirn wrote:
> On 29/06/2021 10:51, lijian_8010a29@163.com wrote:
> > From: lijian <lijian@yulong.com>
> > 
> > removed unneeded variable 'ret'.
> 
> Wouldn't it make more sense to return an error (-ENOENT??) in case
> the em lookup fails and handle the error in btrfs_finish_ordered_io()
> as this is the only caller of unpin_extent_cache()?
> 
> I've actually tripped over this a couple of times already when 
> investigating extent map and ordered extent splitting problems
> on zoned filesystems:
> 
> 	em = lookup_extent_mapping(tree, start, len);
> 	WARN_ON(!em || em->start != start);
> 
> Maybe even turn this WARN_ON() into an ASSERT() when introducing proper
> error handling, as we shouldn't really get there unless we have a logical
> error.

If you have real workloads hitting the warning then it really should be
proper error handling, not even an assert.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: btrfs: extent_map: removed unneeded variable
  2021-06-30  9:59   ` David Sterba
@ 2021-06-30 11:17     ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2021-06-30 11:17 UTC (permalink / raw)
  To: dsterba
  Cc: lijian_8010a29, clm, josef, dsterba, linux-btrfs, linux-kernel, lijian

On 30/06/2021 12:01, David Sterba wrote:
> On Tue, Jun 29, 2021 at 09:04:40AM +0000, Johannes Thumshirn wrote:
>> On 29/06/2021 10:51, lijian_8010a29@163.com wrote:
>>> From: lijian <lijian@yulong.com>
>>>
>>> removed unneeded variable 'ret'.
>>
>> Wouldn't it make more sense to return an error (-ENOENT??) in case
>> the em lookup fails and handle the error in btrfs_finish_ordered_io()
>> as this is the only caller of unpin_extent_cache()?
>>
>> I've actually tripped over this a couple of times already when 
>> investigating extent map and ordered extent splitting problems
>> on zoned filesystems:
>>
>> 	em = lookup_extent_mapping(tree, start, len);
>> 	WARN_ON(!em || em->start != start);
>>
>> Maybe even turn this WARN_ON() into an ASSERT() when introducing proper
>> error handling, as we shouldn't really get there unless we have a logical
>> error.
> 
> If you have real workloads hitting the warning then it really should be
> proper error handling, not even an assert.
> 

Up to now it's been coding errors from my side so I think it warrants an
ASSERT().

But still we should handle the error in the caller.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-30 11:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29  8:50 [PATCH] fs: btrfs: extent_map: removed unneeded variable lijian_8010a29
2021-06-29  9:04 ` Johannes Thumshirn
2021-06-30  9:59   ` David Sterba
2021-06-30 11:17     ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.