All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Steve Dickson <SteveD@redhat.com>
Cc: Neil Brown <neilb@suse.de>, Chuck Lever <chuck.lever@oracle.com>,
	Phil Endecott
	<phil_bnaqb_endecott-wZDNlLIRyE5g9hUCZPvPmw@public.gmane.org>,
	linux-nfs@vger.kernel.org
Subject: Re: Make sm-notify faster if there are no servers to notify
Date: Fri, 5 Dec 2008 22:08:34 -0500	[thread overview]
Message-ID: <20081206030834.GD5464@fieldses.org> (raw)
In-Reply-To: <4939760A.9050304-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>

On Fri, Dec 05, 2008 at 01:42:18PM -0500, Steve Dickson wrote:
> J. Bruce Fields wrote:
> > On Fri, Dec 05, 2008 at 08:26:44AM -0500, Steve Dickson wrote:
> >> J. Bruce Fields wrote:
> >>>> I think it would still be valuable to replace the 'sync' with two
> >>>> 'fsync's, one of the file, one on the directory.
> >>> Sure, may as well.--b.
> >>>
> >> Something similar to this:
> >>
> >> diff -up nfs-utils/utils/statd/sm-notify.c.orig nfs-utils/utils/statd/sm-notify.c
> >> --- nfs-utils/utils/statd/sm-notify.c.orig	2008-11-17 15:06:13.000000000 -0500
> >> +++ nfs-utils/utils/statd/sm-notify.c	2008-12-05 08:21:52.000000000 -0500
> >> @@ -211,12 +211,6 @@ usage:		fprintf(stderr,
> >>  	backup_hosts(_SM_DIR_PATH, _SM_BAK_PATH);
> >>  	get_hosts(_SM_BAK_PATH);
> >>  
> >> -	/* If there are not hosts to notify, just exit */
> >> -	if (!hosts) {
> >> -		nsm_log(LOG_DEBUG, "No hosts to notify; exiting");
> >> -		return 0;
> >> -	}
> > 
> > This was still a huge boot-time win in the common case, so now that
> > we've committed to it I'd rather not regress.  
> I thought the idea was the state had to be updated even when there
> are no hosts...

I would prefer to increment the state file even in the absence of hosts
(it might be useful e.g. to a client that missed a previous grace period
due to a network problem to know that the current boot instance is later
than the one it needed to reclaim in).  But I don't believe it's
necessary.

The more immediate problem is that the state file no longer gets created
at all on a new system.   (Unless the package install scripts do it.  I
haven't checked.)

So, we could either make sure the state file gets created some other
way, or delay the syncs as described before.

> >> @@ -730,13 +725,16 @@ nsm_get_state(int update)
> >>  				"Failed to write state to %s", newfile);
> >>  			exit(1);
> >>  		}
> >> +		fsync(fd);
> >>  		close(fd);
> >> +		fp = opendir(_SM_STATE_PATH);
> > 
> > Also, I think you meant to:
> > 
> > 		fsync(fp);
> > 		close(fp);
> No... I don't think so... the fd is an open() of the new file and the
> fp is a DIR stream... But there was a cut/paste error... The fsync()
> of the DIR stream was missing... here is is again...

OK.

> @@ -694,6 +688,7 @@ nsm_get_state(int update)
>  {
>  	char		newfile[PATH_MAX];
>  	int		fd, state;
> +	DIR 	*fp;
>  
>  	if ((fd = open(_SM_STATE_PATH, O_RDONLY)) < 0) {
>  		if (!opt_quiet) {
> @@ -730,13 +725,18 @@ nsm_get_state(int update)
>  				"Failed to write state to %s", newfile);
>  			exit(1);
>  		}
> +		fsync(fd);
>  		close(fd);
> +		fp = opendir(_SM_STATE_PATH);
>  		if (rename(newfile, _SM_STATE_PATH) < 0) {
>  			nsm_log(LOG_ERR,
>  				"Cannot create %s: %m", _SM_STATE_PATH);
>  			exit(1);
>  		}
> -		sync();

May as well move that opendir down here where it's used, though.

> +		if (fp != NULL) {
> +			fsync(dirfd(fp));
> +			closedir(fp);
> +		}
>  	}
>  
>  	return state;

--b.

  parent reply	other threads:[~2008-12-06  3:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-29  0:13 Make sm-notify faster if there are no servers to notify Phil Endecott
     [not found] ` <1225239200402-YnoLgZYwwYuCbKHnblo0pmrPP3OPMK55cpQHUIT47Ck@public.gmane.org>
2008-10-29 17:18   ` J. Bruce Fields
2008-10-29 17:30     ` Phil Endecott
     [not found]       ` <1225301403729-YnoLgZYwwYuCbKHnblo0pmrPP3OPMK55cpQHUIT47Ck@public.gmane.org>
2008-10-29 17:37         ` J. Bruce Fields
2008-10-29 17:45           ` Phil Endecott
     [not found]             ` <1225302305994-YnoLgZYwwYuCbKHnblo0pmrPP3OPMK55cpQHUIT47Ck@public.gmane.org>
2008-10-29 18:41               ` J. Bruce Fields
2008-10-29 20:30                 ` Chuck Lever
2008-10-29 21:11                   ` J. Bruce Fields
2008-11-09 19:25                     ` J. Bruce Fields
2008-11-10  0:52                       ` Chuck Lever
2008-11-10  0:55                         ` J. Bruce Fields
2008-11-10  1:00                           ` Chuck Lever
2008-11-10  9:40                         ` Phil Endecott
2008-11-10 13:41                     ` Steve Dickson
     [not found]                       ` <49183A12.7010707-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-12-04 21:10                         ` J. Bruce Fields
2008-12-05  3:34                           ` Neil Brown
     [not found]                             ` <18744.41310.635618.148281-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-12-05  3:58                               ` J. Bruce Fields
2008-12-05 13:26                                 ` Steve Dickson
     [not found]                                   ` <49392C14.7000709-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-12-05 16:38                                     ` J. Bruce Fields
2008-12-05 17:29                                       ` J. Bruce Fields
2008-12-05 18:41                                         ` Chuck Lever
2008-12-06  2:42                                           ` J. Bruce Fields
2008-12-08 19:50                                             ` Chuck Lever
2008-12-11 22:44                                               ` J. Bruce Fields
2008-12-05 19:12                                         ` Steve Dickson
     [not found]                                           ` <49397D1B.3000701-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-12-06  2:49                                             ` J. Bruce Fields
2008-12-05 18:42                                       ` Steve Dickson
     [not found]                                         ` <4939760A.9050304-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-12-06  3:08                                           ` J. Bruce Fields [this message]
2008-10-31 17:52           ` Steve Dickson

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=20081206030834.GD5464@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=SteveD@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=phil_bnaqb_endecott-wZDNlLIRyE5g9hUCZPvPmw@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 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.