Linux NILFS development
 help / color / mirror / Atom feed
From: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
To: Ryusuke Konishi
	<konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v4 6/6] nilfs-utils: add a no_timeout flag to enable faster loop
Date: Thu, 06 Feb 2014 15:37:20 +0100	[thread overview]
Message-ID: <52F39E20.8000803@gmx.net> (raw)
In-Reply-To: <20140206.101641.184822830.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>

On 2014-02-06 02:16, Ryusuke Konishi wrote:
> On Wed,  5 Feb 2014 03:16:39 +0100, Andreas Rohner wrote:
>> This patch adds a flag, that enables the GC to skip the timeout in
>> certain situations. For example if the cleaning of some segments
>> was deferred to a later time, then no real progress has been
>> made. Apart from reading a few summary blocks, no data was read or
>> written to disk. In this situation it makes sense to skip the
>> normal timeout once and immediately try to clean the next set of
>> segments.
>>
>> Unfortunately it is not possible, to directly continue the cleaning
>> loop, because this would lead to an unresponsive GC process.
>> Therefore the timeout is simply set to 0 seconds.
>>
>> Signed-off-by: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
>> ---
>>  sbin/cleanerd/cleanerd.c | 27 ++++++++++++++++-----------
>>  1 file changed, 16 insertions(+), 11 deletions(-)
>>
>> diff --git a/sbin/cleanerd/cleanerd.c b/sbin/cleanerd/cleanerd.c
>> index 1374e38..e1bd558 100644
>> --- a/sbin/cleanerd/cleanerd.c
>> +++ b/sbin/cleanerd/cleanerd.c
>> @@ -167,6 +167,7 @@ struct nilfs_cleanerd {
>>  	int running;
>>  	int fallback;
>>  	int retry_cleaning;
>> +	int no_timeout;
> 
> Corresponding comment is missing for this one, too.
> 
>>  	int shutdown;
>>  	long ncleansegs;
>>  	struct timeval cleaning_interval;
>> @@ -894,7 +895,7 @@ static int nilfs_cleanerd_recalc_interval(struct nilfs_cleanerd *cleanerd,
>>  	interval = nilfs_cleanerd_cleaning_interval(cleanerd);
>>  	/* timercmp() does not work for '>=' or '<='. */
>>  	/* curr >= target */
>> -	if (!timercmp(&curr, &cleanerd->target, <)) {
>> +	if (!timercmp(&curr, &cleanerd->target, <) || cleanerd->no_timeout) {
>>  		cleanerd->timeout.tv_sec = 0;
>>  		cleanerd->timeout.tv_usec = 0;
>>  		timeradd(&curr, interval, &cleanerd->target);
>> @@ -1395,6 +1396,7 @@ static int nilfs_cleanerd_clean_segments(struct nilfs_cleanerd *cleanerd,
>>  		       "number: %m");
>>  		goto out;
>>  	}
>> +	cleanerd->no_timeout = 0;
> 
> This one is needed for the else case of nilfs_cleanerd_clean_loop() ?
> 
>                 if (ns > 0) {
>                         ret = nilfs_cleanerd_clean_segments(
>                                 cleanerd, segnums, ns, sustat.ss_prot_seq,
>                                 prottime, &ndone);
>                         if (ret < 0)
>                                 return -1;
>                 } else {
>                         cleanerd->retry_cleaning = 0;
> + 			cleanerd->no_timeout = 0;
>                 }

It is important to make sure that no_timeout is set to 1 for only one
iteration of nilfs_cleanerd_clean_loop. Otherwise it would permanently
disable the timeout. But you are right, this is probably not a good
place to do it. In version 5 I moved it.

>>  
>>  	memset(&stat, 0, sizeof(stat));
>>  	ret = nilfs_xreclaim_segment(cleanerd->nilfs, segnums, nsegs, 0,
>> @@ -1409,16 +1411,18 @@ static int nilfs_cleanerd_clean_segments(struct nilfs_cleanerd *cleanerd,
>>  		goto out;
>>  	}
>>  
>> -	if (stat.cleaned_segs > 0) {
>> -		if (stat.deferred_segs > 0) {
>> -			for (i = 0; i < stat.cleaned_segs; i++)
>> -				syslog(LOG_DEBUG, "segment %llu deferred",
>> -				       (unsigned long long)segnums[i]);
>> -		} else {
>> -			for (i = 0; i < stat.cleaned_segs; i++)
>> -				syslog(LOG_DEBUG, "segment %llu cleaned",
>> -				       (unsigned long long)segnums[i]);
>> -		}
>> +	if (stat.deferred_segs > 0) {
>> +		for (i = 0; i < stat.cleaned_segs; i++)
> 
> Should be stat.deferred_segs ?
> 
> Looks like you took the meaning of stat.cleaned_segs differently.
> 
> I meant stat.cleaned_segs is decreased if stat.deferred_segs > 0.
> 
> So, the following relation will be fulfilled.
> 
>   cleaned_segs + deferred_segs + protected_segs == nsegs (number of requested segments)
> 
>> +			syslog(LOG_DEBUG, "segment %llu deferred",
>> +			       (unsigned long long)segnums[i]);
>> +		nilfs_cleanerd_progress(cleanerd, stat.cleaned_segs);
>> +		cleanerd->fallback = 0;
>> +		cleanerd->retry_cleaning = 0;
> 
>> +		cleanerd->no_timeout = 1;
> 
> So, I think this should be set only if
> stat.deferred_segs > 0 && stat.cleaned_segs == 0

Ok I interpreted it to be a subset of cleaned_segs. So deferred_segs is
the number of segments out of cleaned_segs that were deferred. But your
interpretation makes more sense.

In version 5 I also renamed the return parameter ncleaned of
nilfs_cleanerd_clean_segments to ndone, meaning "cleaned or deferred".

Regards,
Andreas Rohner

> Regards,
> Ryusuke Konishi
> 
> 
>> +	} else if (stat.cleaned_segs > 0) {
>> +		for (i = 0; i < stat.cleaned_segs; i++)
>> +			syslog(LOG_DEBUG, "segment %llu cleaned",
>> +			       (unsigned long long)segnums[i]);
>>  		nilfs_cleanerd_progress(cleanerd, stat.cleaned_segs);
>>  		cleanerd->fallback = 0;
>>  		cleanerd->retry_cleaning = 0;
>> @@ -1475,6 +1479,7 @@ static int nilfs_cleanerd_clean_loop(struct nilfs_cleanerd *cleanerd)
>>  	cleanerd->running = 1;
>>  	cleanerd->fallback = 0;
>>  	cleanerd->retry_cleaning = 0;
>> +	cleanerd->no_timeout = 0;
>>  	nilfs_cnoconv_reset(cleanerd->cnoconv);
>>  	nilfs_gc_logger = syslog;
>>  
>> -- 
>> 1.8.5.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-02-06 14:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 18:37 [PATCH 0/2] refactor reclaim function Ryusuke Konishi
     [not found] ` <1391539046-13046-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-02-04 18:37   ` [PATCH 1/2] lib/gc.c: " Ryusuke Konishi
2014-02-04 18:37   ` [PATCH 2/2] cleanerd: use nilfs_xreclaim_segment() Ryusuke Konishi
2014-02-04 18:42   ` [PATCH 0/2] refactor reclaim function Ryusuke Konishi
     [not found]     ` <20140205.034242.281476472.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-02-04 20:46       ` Andreas Rohner
2014-02-05  2:16       ` [PATCH v4 0/6] nilfs-utils: shortcut for certain GC operations Andreas Rohner
     [not found]         ` <cover.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-05  2:16           ` [PATCH v4 1/6] nilfs-utils: cldconfig add an option to set min. reclaimable blocks Andreas Rohner
     [not found]             ` <ede3809c3f131ed641336d7a078c4dc1d9d4b578.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-05 18:47               ` Ryusuke Konishi
2014-02-05  2:16           ` [PATCH v4 2/6] nilfs-utils: add NILFS_OPT_SET_SUINFO Andreas Rohner
     [not found]             ` <a55d555da27aea71386cfe777a0adec95e6ded2e.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-05 18:50               ` Ryusuke Konishi
2014-02-05  2:16           ` [PATCH v4 3/6] nilfs-utils: nilfs-clean add cmdline param min-reclaimable-blocks Andreas Rohner
     [not found]             ` <9004dd6e3a276447371eda93413a6f0766821510.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-05 19:16               ` Ryusuke Konishi
2014-02-05  2:16           ` [PATCH v4 4/6] nilfs-utils: add suport for NILFS_IOCTL_SET_SUINFO ioctl Andreas Rohner
     [not found]             ` <6b62cd72448c48055cfab9017753349cb2cd7da9.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-05 19:25               ` Ryusuke Konishi
     [not found]                 ` <20140206.042518.139122814.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-02-05 23:43                   ` Andreas Rohner
     [not found]                     ` <52F2CC85.3000004-hi6Y0CQ0nG0@public.gmane.org>
2014-02-06  0:04                       ` Ryusuke Konishi
2014-02-05  2:16           ` [PATCH v4 5/6] nilfs-utils: add optimized version of nilfs_xreclaim_segments Andreas Rohner
     [not found]             ` <f5be23fa1b72d7e7e2d1403bdd043ebeafd4407d.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-06  0:09               ` Andreas Rohner
     [not found]                 ` <52F2D2B5.1080109-hi6Y0CQ0nG0@public.gmane.org>
2014-02-06  0:24                   ` Ryusuke Konishi
2014-02-05  2:16           ` [PATCH v4 6/6] nilfs-utils: add a no_timeout flag to enable faster loop Andreas Rohner
     [not found]             ` <43f9673512b7a2e95d3036f2e829aa80fb2cca03.1391566347.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-02-06  1:16               ` Ryusuke Konishi
     [not found]                 ` <20140206.101641.184822830.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-02-06 14:37                   ` Andreas Rohner [this message]
     [not found]                     ` <52F39E20.8000803-hi6Y0CQ0nG0@public.gmane.org>
2014-02-06 15:07                       ` Andreas Rohner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F39E20.8000803@gmx.net \
    --to=andreas.rohner-hi6y0cq0ng0@public.gmane.org \
    --cc=konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox