statfs on NFS partition always returns "0"

Solution Verified - Updated -

Issue

Symptom/Problem

  • Even if an error occurs, statfs on NFS always returns 0
  • When an error like the server down occurs on NFS, if a program calls statfs() system call, it will return 0. However it should return a negative value.

Environment

  • Red Hat Enterprise Linux 5.3
  • Red Hat Enterprise Linux 4.8

Resolution

Root Cause

  • nfs_statfs() function shouldn't return 0.
  • The original patch upstream.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=fs/nfs/super.c;h=719464a04ddae4fc73dc81ba982ee827631fb9ad;hp=f1eae44b9a1aec5167dfefb934437ccaedba2576;hb=1a0ba9ae485c5fd17d0bff2f14d9dd75b8985593;hpb=d585158b608248a6ba8ae75e234672e048d3fde9

Diagnostic Steps

  • Start NFS service:

    # echo "/test        *(rw,no_root_squash)" >> /etc/exports
    # service nfs start
    
  • Setup client:

    # mount -t nfs -o soft,timeo=5 server:/test /mnt/nfs
    
  • Stop NFS service:

    # service nfs stop
    
  • From the client, run program such as:

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/statvfs.h>
    
    int main()
    {
         struct statvfs sv;
         int rc;
    
         rc = statvfs("/mnt/nfs", &sv);
    
         if (rc < 0) {
              perror("statvfs");
              exit(1);
         }
         return 0;
    }
    
  • Waiting  for awhile, it would return with 0 even NFS server is already offline.  The above program returns with 0, which actually should return negative  number according to statfs(2).

  • The call trace is as below:

    sys_statfs() => return 0
      vfs_statfs() => return 0
        nfs_statfs() => return 0
          nfs3_proc_statfs() => return -5
    

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content