All of lore.kernel.org
 help / color / mirror / Atom feed
* Lock problem.
@ 2007-10-11  8:56 matteo.debiaggi
  2007-10-11 10:08 ` Neil Brown
  0 siblings, 1 reply; 7+ messages in thread
From: matteo.debiaggi @ 2007-10-11  8:56 UTC (permalink / raw)
  To: nfs

Hi at all,
Situation :

I have a linux client :
debian,  kernel  2.6.16
64bit
nfs-common_1%3a1.0.6-3.1_amd64.deb

rpcinfo -p localhosts stats(about nfs..)
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100021    1   udp  34865  nlockmgr
    100021    3   udp  34865  nlockmgr
    100021    4   udp  34865  nlockmgr
    100021    1   tcp  40293  nlockmgr
    100021    3   tcp  40293  nlockmgr
    100021    4   tcp  40293  nlockmgr

And a soalris 8 with all possible patches( or better, all patches i 
found..) relative to nfs.
32bit

rpcinfo -p localhost stats(about nfs..)
 program vers proto   port  service
    100011    1   udp  32773  rquotad
    100001    2   udp  32777  rstatd
    100001    3   udp  32777  rstatd
    100001    4   udp  32777  rstatd
    100021    1   udp   4045  nlockmgr
    100021    2   udp   4045  nlockmgr
    100021    3   udp   4045  nlockmgr
    100021    4   udp   4045  nlockmgr
    100021    1   tcp   4045  nlockmgr
    100021    2   tcp   4045  nlockmgr
    100021    3   tcp   4045  nlockmgr
    100021    4   tcp   4045  nlockmgr
    100005    1   udp  36355  mountd
    100005    2   udp  36355  mountd
    100005    3   udp  36355  mountd
    100005    1   tcp  49762  mountd
    100005    2   tcp  49762  mountd
    100005    3   tcp  49762  mountd
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl

Client wants work with files located in a dir shared with  parameters:
share   -F   nfs     -o rw,root=nb,anon=505 /dir
Client mounts dir  in this way :
....type nfs (rw,noexec,nosuid,nodev,sync,actimeo=0,noac,addr=....,user=...)

In the shared dir  there are concurrent processes writing their own 
content on the same file.
They make files as root but with ugo 666.

In the client side  another process has a loop looking for mentioned 
file. Whenever it finds file, it tryes to read it.

Problem :
 Some times, not every times ,we face a strange lock where reader waits 
more or less for the same time( about 30sec,uhm..) lock gets acquired, 
at the end it did it.

Here's simplyfied code:

WRITER:

for (;;) {
  fd = open(file, O_WRONLY|O_APPEND|O_CREAT, 0666);
  lockf(fd, F_LOCK, 0);
  write(fd, line, LINE_SIZE);
  lockf(fd, F_ULOCK, 0);
  close(fd);

  usleep(WR_PAUSE);
}


READER:

for (;;) {
  while(access(file, F_OK))
    usleep(RD_PAUSE);

  fd = open(file, O_RDWR);
  lockf(fd, F_LOCK, 0);
  unlink(file);
  lockf(fd, F_ULOCK, 0);
  lockf(fd, F_LOCK, 0); /* incriminated lock !!! */

  while (read(fd, line, LINE_SIZE) == LINE_SIZE)
    ++line_numb;

  close(fd);
}


Any help would be appreciated.
Thanks in advance.
Matteo.







-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

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

end of thread, other threads:[~2007-10-11 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-11  8:56 Lock problem matteo.debiaggi
2007-10-11 10:08 ` Neil Brown
2007-10-11 13:07   ` matteo.debiaggi
2007-10-11 13:50     ` Talpey, Thomas
2007-10-11 14:24       ` matteo.debiaggi
2007-10-11 14:37         ` Talpey, Thomas
2007-10-11 15:23           ` matteo.debiaggi

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.