Issue opening file on NFS read-only mount
Bob Apodaca
bob@phxlab.honeywell.com
Tue Nov 12 23:36:00 GMT 2013
On 10/31/2013 02:19 AM, N.M. Maclaren wrote:
> On Oct 30 2013, Janne Blomqvist wrote:
>>
>> I don't think it's a bug in gfortran; as you can see from the traces,
>> the exact same open() call is made in both cases.
>>
>> My guess it's a bug in the kernel. Googling for "Linux NFS ENOTDIR"
>> turns up a number of suspicious bugs that might be related to the
>> problem you're seeing.
>
> Or possibly one in the NFS server (or an incompatibility between it and
> the client), though I don't know the NFS protocol well enough to more
> than guess and haven't looked (as you have).
>
> But this class of failure is ancient (pre-Unix!) and ubiquitous, and
> is inherent in the conflict between Fortran's file model and almost
> every file system interface. I would dearly like to see not providing
> ACTION on OPEN deprecated, but have tried and failed with that one :-(
>
> Thinks: Hmm. That's a possible candidate for -Wextra!
>
>
> Regards,
> Nick Maclaren.
I am still investigating this issue and am not sure which direction to
go. Things I have tried:
1. ACTION='READ' and got the same failure.
2. Changed the server to export the NFS share as read-write and the
client to mount it as read-write. This fixed the problem but
unfortunately is not a workable solution.
Next, I wrote a small C program that I hoped with make similar system
calls I was seeing in the original FORTRAN code:
int main(void) {
const char * path = "/mnt/nfs/stuff/stuff/more_stuff/file";
FILE *fp;
fp = fopen(path, "r+");
if(fp == NULL) {
printf("fopen() failed for %s with mode 'r+'\n", path);
}
fp = fopen(path, "r");
if(fp == NULL) {
printf("fopen() failed for %s with mode 'r'\n", path);
} else {
fclose(fp);
}
return(0);
}
This works as expected and gives an strace output similar to:
open("/mnt/nfs/stuff/stuff/more_stuff/file", O_RDWR) = -1 EROFS
(Read-only file system)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb77a7000
write(1, "fopen() failed for /mnt/nfs"..., 91fopen() failed for
/mnt/nfs/stuff/stuff/more_stuff/file with mode 'rw'
) = 91
open("/mnt/nfs/stuff/stuff/more_stuff/file", O_RDONLY) = 3
close(3) = 0
exit_group(0) = ?
If you recall from my previous post, the FORTRAN strace was:
stat64("/mnt/nfs/stuff/stuff/more_stuff/file", {st_mode=S_IFREG|0664,
st_size=15533, ...}) = 0
open("/mnt/nfs/stuff/stuff/more_stuff/file", O_RDWR|O_CREAT|O_LARGEFILE,
0666) = -1 EROFS (Read-only file system)
open("/mnt/nfs/stuff/stuff/more_stuff/file",
O_RDONLY|O_CREAT|O_LARGEFILE, 0666) = -1 ENOTDIR (Not a directory)
write(2, "At line 10 of file file_open.f ("..., 53At line 10 of file
file_open.f (unit = 7, file = '')
) = 53
write(2, "Fortran runtime error: ", 23Fortran runtime error: ) = 23
write(2, "Not a directory", 15Not a directory) = 15
write(2, "\n", 1
) = 1
exit_group(2) = ?
Could the O_CREAT in the second open() call be causing the problem?
Would this be in the gfortran library?
More information about the Fortran
mailing list