All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] drbd: cleanup: change "<= 0" to "== 0"
@ 2010-08-11 22:38 Dan Carpenter
  2010-08-23 10:34 ` Jens Axboe
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Dan Carpenter @ 2010-08-11 22:38 UTC (permalink / raw)
  To: kernel-janitors

dt is unsigned so it's never less than zero.  We are calculating the
elapsed time, and that's never less than zero (unless there is a bug or
we invent time travel).  The comparison here is just to guard against
divide by zero bugs.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index be3374b..4c0c4aa 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
 	/* mean speed since syncer started
 	 * we do account for PausedSync periods */
 	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
-	if (dt <= 0)
+	if (dt = 0)
 		dt = 1;
 	db = mdev->rs_total - rs_left;
 	dbdt = Bit2KB(db/dt);

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

* Re: [patch] drbd: cleanup: change "<= 0" to "== 0"
  2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
@ 2010-08-23 10:34 ` Jens Axboe
  2010-08-23 16:03 ` Philipp Reisner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2010-08-23 10:34 UTC (permalink / raw)
  To: kernel-janitors

On 2010-08-12 00:38, Dan Carpenter wrote:
> dt is unsigned so it's never less than zero.  We are calculating the
> elapsed time, and that's never less than zero (unless there is a bug or
> we invent time travel).  The comparison here is just to guard against
> divide by zero bugs.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
> index be3374b..4c0c4aa 100644
> --- a/drivers/block/drbd/drbd_proc.c
> +++ b/drivers/block/drbd/drbd_proc.c
> @@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
>  	/* mean speed since syncer started
>  	 * we do account for PausedSync periods */
>  	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
> -	if (dt <= 0)
> +	if (dt = 0)
>  		dt = 1;
>  	db = mdev->rs_total - rs_left;
>  	dbdt = Bit2KB(db/dt);

Lars et al, I'll let you pick this up.

-- 
Jens Axboe


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

* Re: [patch] drbd: cleanup: change "<= 0" to "== 0"
  2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
  2010-08-23 10:34 ` Jens Axboe
@ 2010-08-23 16:03 ` Philipp Reisner
  2010-08-24  8:38 ` Philipp Reisner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Reisner @ 2010-08-23 16:03 UTC (permalink / raw)
  To: kernel-janitors

Am Montag, 23. August 2010, um 12:34:29 schrieb Jens Axboe:
> On 2010-08-12 00:38, Dan Carpenter wrote:
> > dt is unsigned so it's never less than zero.  We are calculating the
> > elapsed time, and that's never less than zero (unless there is a bug or
> > we invent time travel).  The comparison here is just to guard against
> > divide by zero bugs.
> > 
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > 
> > diff --git a/drivers/block/drbd/drbd_proc.c
> > b/drivers/block/drbd/drbd_proc.c index be3374b..4c0c4aa 100644
> > --- a/drivers/block/drbd/drbd_proc.c
> > +++ b/drivers/block/drbd/drbd_proc.c
> > @@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf
> > *mdev, struct seq_file *seq)
> > 
> >  	/* mean speed since syncer started
> >  	
> >  	 * we do account for PausedSync periods */
> >  	
> >  	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
> > 
> > -	if (dt <= 0)
> > +	if (dt = 0)
> > 
> >  		dt = 1;
> >  	
> >  	db = mdev->rs_total - rs_left;
> >  	dbdt = Bit2KB(db/dt);
> 
> Lars et al, I'll let you pick this up.

Jens, we (LINBIT) feel responsible for picking this up. I work on that
tomorrow.

Best,
 Phil
-- 
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.

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

* Re: [patch] drbd: cleanup: change "<= 0" to "== 0"
  2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
  2010-08-23 10:34 ` Jens Axboe
  2010-08-23 16:03 ` Philipp Reisner
@ 2010-08-24  8:38 ` Philipp Reisner
  2010-08-24  8:41 ` Jens Axboe
  2010-08-24  9:10 ` Philipp Reisner
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Reisner @ 2010-08-24  8:38 UTC (permalink / raw)
  To: kernel-janitors

Am Donnerstag, 12. August 2010, um 00:38:45 schrieb Dan Carpenter:
> dt is unsigned so it's never less than zero.  We are calculating the
> elapsed time, and that's never less than zero (unless there is a bug or
> we invent time travel).  The comparison here is just to guard against
> divide by zero bugs.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/block/drbd/drbd_proc.c
> b/drivers/block/drbd/drbd_proc.c index be3374b..4c0c4aa 100644
> --- a/drivers/block/drbd/drbd_proc.c
> +++ b/drivers/block/drbd/drbd_proc.c
> @@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf
> *mdev, struct seq_file *seq) /* mean speed since syncer started
>  	 * we do account for PausedSync periods */
>  	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
> -	if (dt <= 0)
> +	if (dt = 0)
>  		dt = 1;
>  	db = mdev->rs_total - rs_left;
>  	dbdt = Bit2KB(db/dt);

Hi Dan,

Please elaborate the improvement this patch brings.
dt can actually get negative, on jiffie wrap. I see
little value in displaying then a negative resync speed...

Best,
 Phil
-- 
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.

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

* Re: [patch] drbd: cleanup: change "<= 0" to "== 0"
  2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
                   ` (2 preceding siblings ...)
  2010-08-24  8:38 ` Philipp Reisner
@ 2010-08-24  8:41 ` Jens Axboe
  2010-08-24  9:10 ` Philipp Reisner
  4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2010-08-24  8:41 UTC (permalink / raw)
  To: kernel-janitors

On 2010-08-24 10:38, Philipp Reisner wrote:
> Am Donnerstag, 12. August 2010, um 00:38:45 schrieb Dan Carpenter:
>> dt is unsigned so it's never less than zero.  We are calculating the
>> elapsed time, and that's never less than zero (unless there is a bug or
>> we invent time travel).  The comparison here is just to guard against
>> divide by zero bugs.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>>
>> diff --git a/drivers/block/drbd/drbd_proc.c
>> b/drivers/block/drbd/drbd_proc.c index be3374b..4c0c4aa 100644
>> --- a/drivers/block/drbd/drbd_proc.c
>> +++ b/drivers/block/drbd/drbd_proc.c
>> @@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf
>> *mdev, struct seq_file *seq) /* mean speed since syncer started
>>  	 * we do account for PausedSync periods */
>>  	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
>> -	if (dt <= 0)
>> +	if (dt = 0)
>>  		dt = 1;
>>  	db = mdev->rs_total - rs_left;
>>  	dbdt = Bit2KB(db/dt);
> 
> Hi Dan,
> 
> Please elaborate the improvement this patch brings.
> dt can actually get negative, on jiffie wrap. I see
> little value in displaying then a negative resync speed...

Aren't all members unsigned long? If not, then you have
another bug.

-- 
Jens Axboe


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

* Re: [patch] drbd: cleanup: change "<= 0" to "== 0"
  2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
                   ` (3 preceding siblings ...)
  2010-08-24  8:41 ` Jens Axboe
@ 2010-08-24  9:10 ` Philipp Reisner
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Reisner @ 2010-08-24  9:10 UTC (permalink / raw)
  To: kernel-janitors

Am Dienstag, 24. August 2010, um 10:41:31 schrieb Jens Axboe:
> On 2010-08-24 10:38, Philipp Reisner wrote:
> > Am Donnerstag, 12. August 2010, um 00:38:45 schrieb Dan Carpenter:
> >> dt is unsigned so it's never less than zero.  We are calculating the
> >> elapsed time, and that's never less than zero (unless there is a bug or
> >> we invent time travel).  The comparison here is just to guard against
> >> divide by zero bugs.
> >> 
> >> Signed-off-by: Dan Carpenter <error27@gmail.com>
> >> 
> >> diff --git a/drivers/block/drbd/drbd_proc.c
> >> b/drivers/block/drbd/drbd_proc.c index be3374b..4c0c4aa 100644
> >> --- a/drivers/block/drbd/drbd_proc.c
> >> +++ b/drivers/block/drbd/drbd_proc.c
> >> @@ -118,7 +118,7 @@ static void drbd_syncer_progress(struct drbd_conf
> >> *mdev, struct seq_file *seq) /* mean speed since syncer started
> >> 
> >>  	 * we do account for PausedSync periods */
> >>  	
> >>  	dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
> >> 
> >> -	if (dt <= 0)
> >> +	if (dt = 0)
> >> 
> >>  		dt = 1;
> >>  	
> >>  	db = mdev->rs_total - rs_left;
> >>  	dbdt = Bit2KB(db/dt);
> > 
> > Hi Dan,
> > 
> > Please elaborate the improvement this patch brings.
> > dt can actually get negative, on jiffie wrap. I see
> > little value in displaying then a negative resync speed...
> 
> Aren't all members unsigned long? If not, then you have
> another bug.

Um, well that is right. Ok, patch goes in.

Best,
 Phil
-- 
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.

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

end of thread, other threads:[~2010-08-24  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 22:38 [patch] drbd: cleanup: change "<= 0" to "== 0" Dan Carpenter
2010-08-23 10:34 ` Jens Axboe
2010-08-23 16:03 ` Philipp Reisner
2010-08-24  8:38 ` Philipp Reisner
2010-08-24  8:41 ` Jens Axboe
2010-08-24  9:10 ` Philipp Reisner

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.