Re: [PATCH] mountd: use separate lockfiles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux