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

Bug#699321: libc6: statvfs() calling stat() unnecessarily (2.6.36)



Package: libc6
Version: 2.13-37
Severity: normal

Running statvfs() my machine still results in stat() being called, and from
what I can tell, it's being called _before_ __statvfs_getflags() is called.   I
have not yet determined where stat() is called, but strace on my C program (see
below) confirms stat() is called after statfs(), but before the fprintf() I
added in sysdeps/unix/sysv/linux/internal_statvfs.c:

  /*
   * I added the following fprintf() in my local build and confirmed
   * ST_VALID (0x20) is set here by my 3.7.5 kernel:
   */
   fprintf(stderr, "f_flags: 0x%lx\n", fsbuf->f_flags);

#ifndef __ASSUME_STATFS_F_FLAGS
  if ((fsbuf->f_flags & ST_VALID) == 0)
    /* Determining the flags is tricky.  We have to read /proc/mounts or
       the /etc/mtab file and search for the entry which matches the given
       file.  The way we can test for matching filesystem is using the
       device number.  */
    buf->f_flag = __statvfs_getflags (name, fsbuf->f_type, st);
  else
#endif
    buf->f_flag = fsbuf->f_flags ^ ST_VALID;

Here is my trivial C program I straced to confirm stat() being called
after statfs():
--------------------------------------------
/* gcc -o statvfs -Wall statvfs.c */
#include <sys/statvfs.h>
int main(void)
{
	struct statvfs svf;
	statvfs("/mnt", &svf);
	return 0;
}
--------------------------------------------

I do not expect stat() to be called with statvfs(), since ST_VALID helps
avoid this expensive check.  stat() also has detrimental effects on
unreachable/slow network mounts.

-- System Information:
Debian Release: 7.0
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.7.5 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6 depends on:
ii  libc-bin  2.13-37
ii  libgcc1   1:4.7.2-5

libc6 recommends no packages.

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.49
ii  glibc-doc              2.13-37
ii  locales                2.13-37

-- debconf information excluded


Reply to: