diff mbox series

[04/29] lustre: osc: simplify list manipulation

Message ID 154701504121.26726.13780223132597872019.stgit@noble (mailing list archive)
State New, archived
Headers show
Series assorted osc cleanups. | expand

Commit Message

NeilBrown Jan. 9, 2019, 6:24 a.m. UTC
when A is empty,
 list_move_tail(&A, &B);
is identical to
 list_add_tail(&A, &B);

so always use list_move_tail() - it is easier to understand.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/osc/osc_cache.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Andreas Dilger Jan. 10, 2019, 1:58 a.m. UTC | #1
> On Jan 8, 2019, at 23:24, NeilBrown <neilb@suse.com> wrote:
> 
> when A is empty,
> list_move_tail(&A, &B);
> is identical to
> list_add_tail(&A, &B);
> 
> so always use list_move_tail() - it is easier to understand.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

> ---
> drivers/staging/lustre/lustre/osc/osc_cache.c |    5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
> index 00056dffceb9..6771675dd520 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
> @@ -2885,10 +2885,7 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj,
> 		}
> 		/* This extent could be on the full extents list, that's OK */
> 		EASSERT(!ext->oe_hp && !ext->oe_urgent, ext);
> -		if (!list_empty(&ext->oe_link))
> -			list_move_tail(&ext->oe_link, &list);
> -		else
> -			list_add_tail(&ext->oe_link, &list);
> +		list_move_tail(&ext->oe_link, &list);
> 
> 		ext = next_extent(ext);
> 	}
> 
> 

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
diff mbox series

Patch

diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 00056dffceb9..6771675dd520 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -2885,10 +2885,7 @@  int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj,
 		}
 		/* This extent could be on the full extents list, that's OK */
 		EASSERT(!ext->oe_hp && !ext->oe_urgent, ext);
-		if (!list_empty(&ext->oe_link))
-			list_move_tail(&ext->oe_link, &list);
-		else
-			list_add_tail(&ext->oe_link, &list);
+		list_move_tail(&ext->oe_link, &list);
 
 		ext = next_extent(ext);
 	}