LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Is this a bug, or a new feature? (http://www.linuxquestions.org/questions/programming-9/is-this-a-bug-or-a-new-feature-484993/)

zero_g 09-19-2006 11:12 AM

Is this a bug, or a new feature?
 
I think I have found a bug in the low level read() code of the 2.6.9-34 kernel from RedHat, or maybe a new feature.

To summarize, reading of a file in the same process which opened it with a F_WRLCK will fail in 2.6.9-34 but not in the 2.4.21-27 kernel.

It fails only when the disk is a cached nfs mounted disk. It works as before on local disks, and disks mounted with "noac".

Code:

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

int main (int argc, char *argv[] )
{
  int f;

  int i;
  char buff[10] = "TestBuffer";
  struct flock fl;
  fl.l_type=F_WRLCK;
  fl.l_whence=SEEK_CUR;
  fl.l_start=0;
  fl.l_len=0;

  f = open(argv[1],O_RDWR|O_CREAT|O_EXCL,0666);
  fcntl(f,F_SETLK, &fl);     
  lseek(f,0,SEEK_SET);
  write(f,buff,10);
  lseek(f,0,SEEK_SET);
  printf("read = %d\n",read(f,buff,10));
  close(f);
}

The program outputs "read = 0" on 2.6.9-34 when it cannot read from a file it opened with a F_WRLCK lock, the error condition. It will output "read = 10" always on 2.4.21-27 and when using a local disk like /tmp, or when using a disk mounted with a "noac". "read = 10" means things are working properly.

How do a report this bug? Or how do I determine if it is a bug or a new "feature"?

Lenard 09-19-2006 12:07 PM

Please see; https://rhn.redhat.com/errata/RHSA-2006-0617.html

zero_g 09-20-2006 07:57 AM

How is the update related to the bug?
 
Thanks for the link, however, it is not apparent to me how this update from Red Hat relates to my problem with the NFS disks.


All times are GMT -5. The time now is 04:47 PM.