Linux NFS development
 help / color / mirror / Atom feed
From: Ben Myers <bpm@sgi.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Steve Dickson <SteveD@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] mountd: use separate lockfiles
Date: Thu, 19 Mar 2009 14:53:57 -0500	[thread overview]
Message-ID: <20090319195357.GH26378@sgi.com> (raw)
In-Reply-To: <1237485682.7534.39.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>

Hi Trond,

On Thu, Mar 19, 2009 at 02:01:21PM -0400, Trond Myklebust wrote:
> On Thu, 2009-03-19 at 12:28 -0500, Ben Myers wrote:
> > @@ -58,12 +59,17 @@ xflock(char *fname, char *type)
> >  	struct flock	fl = { readonly? F_RDLCK : F_WRLCK, SEEK_SET, 0, 0, 0 };
> >  	int		fd;
> >  
> > -	if (readonly)
> > -		fd = open(fname, O_RDONLY);
> > -	else
> > -		fd = open(fname, (O_RDWR|O_CREAT), mode);
> > +again:
> > +	fd = open(fname, readonly ? O_RDONLY : (O_RDWR|O_CREAT), 0600);
> > +	if (fd < 0 && readonly && errno == ENOENT) {
> > +		/* create a new lockfile */
> > +		fd = open(fname, O_RDONLY|O_CREAT, 0600);
> 
> I don't see how you expect to get EEXIST with a non-exclusive create.
>
> Why do you need a second call to open() in the first place? How is this
> better than just doing
> 
> 	if (readonly)
> 		fd = open(fname, O_RDONLY|O_CREAT, 0600);
> 	else
> 		fd = open(fname, O_RDWR|O_CREAT, 0600);
>
> ...or, since these are now all private lockfiles, and so we shouldn't
> need to care much about read-only vs read-write

My O_RDONLY|O_CREAT open was failing with EACCES because of a problem
somewhere between my chair and keyboard.  Compounding that, I mistakenly
jumped to the conclusion that the errno was EEXIST.  ;(

I'll give it another try.

-Ben

  parent reply	other threads:[~2009-03-19 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 17:28 [PATCH] mountd: use separate lockfiles Ben Myers
2009-03-19 18:01 ` Trond Myklebust
     [not found]   ` <1237485682.7534.39.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-19 19:53     ` Ben Myers [this message]
2009-03-19 22:14       ` Ben Myers
2009-03-25 14:47         ` bpm
2009-04-04 11:53         ` 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=20090319195357.GH26378@sgi.com \
    --to=bpm@sgi.com \
    --cc=SteveD@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    /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