linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp()
@ 2013-06-20  8:08 Dan Carpenter
  2013-06-20 14:13 ` Theodore Ts'o
  2013-06-20 15:21 ` Zheng Liu
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-06-20  8:08 UTC (permalink / raw)
  To: Theodore Ts'o, Zheng Liu; +Cc: Andreas Dilger, linux-ext4, kernel-janitors

"diff" is unsigned so this doesn't sort the LRU list correctly.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This was introduced in 6480bad916be "ext4: improve extent cache shrink
mechanism to avoid to burn CPU time"

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index e0190f6..79e097d 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -880,7 +880,7 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
 				     struct list_head *b)
 {
 	struct ext4_inode_info *eia, *eib;
-	unsigned long diff;
+	long diff;
 
 	eia = list_entry(a, struct ext4_inode_info, i_es_lru);
 	eib = list_entry(b, struct ext4_inode_info, i_es_lru);

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

* Re: [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp()
  2013-06-20  8:08 [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp() Dan Carpenter
@ 2013-06-20 14:13 ` Theodore Ts'o
  2013-06-20 15:24   ` Zheng Liu
  2013-06-20 15:21 ` Zheng Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Theodore Ts'o @ 2013-06-20 14:13 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Zheng Liu, Andreas Dilger, linux-ext4, kernel-janitors

On Thu, Jun 20, 2013 at 11:08:58AM +0300, Dan Carpenter wrote:
> "diff" is unsigned so this doesn't sort the LRU list correctly.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This was introduced in 6480bad916be "ext4: improve extent cache shrink
> mechanism to avoid to burn CPU time"

Thanks for pointing this out!  The following patch is better I think
because it uses the time_after() abstraction.  I will be folding the
following into Zheng's "ext4: improve extent cache shrink > mechanism
to avoid to burn CPU time".

I've desk checked this but we may want to do some explicit testing to
make sure we are in fact ejecting the appropriate inode from the list.

     	     	    	 	      - Ted

 fs/ext4/extents_status.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 80dcc59..ee018d5 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -880,17 +880,15 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
 				     struct list_head *b)
 {
 	struct ext4_inode_info *eia, *eib;
-	unsigned long diff;
-
 	eia = list_entry(a, struct ext4_inode_info, i_es_lru);
 	eib = list_entry(b, struct ext4_inode_info, i_es_lru);
 
-	diff = eia->i_touch_when - eib->i_touch_when;
-	if (diff < 0)
-		return -1;
-	if (diff > 0)
+	if (eia->i_touch_when == eib->i_touch_when)
+		return 0;
+	if (time_after(eia->i_touch_when, eib->i_touch_when))
 		return 1;
-	return 0;
+	else
+		return -1;
 }
 
 static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)

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

* Re: [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp()
  2013-06-20  8:08 [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp() Dan Carpenter
  2013-06-20 14:13 ` Theodore Ts'o
@ 2013-06-20 15:21 ` Zheng Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Zheng Liu @ 2013-06-20 15:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Theodore Ts'o, Zheng Liu, Andreas Dilger, linux-ext4,
	kernel-janitors

On Thu, Jun 20, 2013 at 11:08:58AM +0300, Dan Carpenter wrote:
> "diff" is unsigned so this doesn't sort the LRU list correctly.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for fixing it.

Regards,
                                                - Zheng

> ---
> This was introduced in 6480bad916be "ext4: improve extent cache shrink
> mechanism to avoid to burn CPU time"
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index e0190f6..79e097d 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -880,7 +880,7 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
>  				     struct list_head *b)
>  {
>  	struct ext4_inode_info *eia, *eib;
> -	unsigned long diff;
> +	long diff;
>  
>  	eia = list_entry(a, struct ext4_inode_info, i_es_lru);
>  	eib = list_entry(b, struct ext4_inode_info, i_es_lru);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp()
  2013-06-20 14:13 ` Theodore Ts'o
@ 2013-06-20 15:24   ` Zheng Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Zheng Liu @ 2013-06-20 15:24 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Dan Carpenter, Zheng Liu, Andreas Dilger, linux-ext4,
	kernel-janitors

On Thu, Jun 20, 2013 at 10:13:10AM -0400, Theodore Ts'o wrote:
> On Thu, Jun 20, 2013 at 11:08:58AM +0300, Dan Carpenter wrote:
> > "diff" is unsigned so this doesn't sort the LRU list correctly.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > This was introduced in 6480bad916be "ext4: improve extent cache shrink
> > mechanism to avoid to burn CPU time"
> 
> Thanks for pointing this out!  The following patch is better I think
> because it uses the time_after() abstraction.  I will be folding the
> following into Zheng's "ext4: improve extent cache shrink > mechanism
> to avoid to burn CPU time".

Thanks for fixing it.  The patch looks good to me.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>

> 
> I've desk checked this but we may want to do some explicit testing to
> make sure we are in fact ejecting the appropriate inode from the list.

I will check it tomorrow.  If there still has a problem, I will try to
fix it.

                                                - Zheng

> 
>      	     	    	 	      - Ted
> 
>  fs/ext4/extents_status.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 80dcc59..ee018d5 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -880,17 +880,15 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
>  				     struct list_head *b)
>  {
>  	struct ext4_inode_info *eia, *eib;
> -	unsigned long diff;
> -
>  	eia = list_entry(a, struct ext4_inode_info, i_es_lru);
>  	eib = list_entry(b, struct ext4_inode_info, i_es_lru);
>  
> -	diff = eia->i_touch_when - eib->i_touch_when;
> -	if (diff < 0)
> -		return -1;
> -	if (diff > 0)
> +	if (eia->i_touch_when == eib->i_touch_when)
> +		return 0;
> +	if (time_after(eia->i_touch_when, eib->i_touch_when))
>  		return 1;
> -	return 0;
> +	else
> +		return -1;
>  }
>  
>  static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2013-06-20 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-20  8:08 [patch] ext4: signedness bug breaks ext4_inode_touch_time_cmp() Dan Carpenter
2013-06-20 14:13 ` Theodore Ts'o
2013-06-20 15:24   ` Zheng Liu
2013-06-20 15:21 ` Zheng Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).