Hello Kir,

Thank you very much for your patch.

Kir Kolyshkin:
> 1. By looking into strace output, it looks like default buffer
> for fread() (and thus getmntent()) is only 1K, while a line in
> /proc/self/mounts can easily be more than 4K.
> Set the libc reading buffer to 4K, as this is a page size for'
> most architectures and thus reading is more efficient.

Isn't it highly depending upon the internal implementation of libc?
There may exist libc which has larger buffer than 4K by default, and for
such system setting new 4K buffer unconditionally is a bad idea, I am
afraid.  So I'd like to keep away from resetting the buffer size.

On my glibc system, the buffer size inherits from struct
stat.st_blksize.  It means glibc asks the kernel about the ideal size of
the buffer, and the kernel answeres "It is 1K, man." in this case.

We can confirm this behaviour by these steps.
- develop a small program which calls setmntent(3) and getmntent(3).
- strace a.out /proc/mounts
- check the buffer size given to read(2).
  --> 1K
- cp /proc/mounts /tmp/m
- strace a.out /tmp/m
- check the buffer size given to read(2).
  --> 4K

This result indicates that if something is really needs to be changed,
then I'd suggest you to customize stat/fstat(2) for /proc/mounts in
kernel-space.


> 2. While doing massively parallel aufs mounts/umounts (256 or more
> in parallel) I observed that sometimes auplink fails to find
> a specified mountpoint in /proc/self/mounts. Presumably this happens

That is strange.
If your "parallel aufs mounts/umounts" means "umount before completing
mount", then it can happen.  Here "completing mount" means that
/sbin/mount.aufs ends.  Is that your case?  Otherwise it should not
happen.


> 3. Since reading /proc/self/mount is a relatively costly operation,
> try avoiding it by first checking that the mount point provided is
> indeed aufs mount point (check for aufs magic). This way, we will
> re-read /proc/self/mounts only if we're dealing with aufs mount.

I've got your point and agreed, but au_proc_getmntent() is not the place
to do that.  Because the function is called by mount.aufs.c, mtab.c, etc
too.  For other than auplink, such test is unnecessary.  So I'd like to
add the test into auplink.c only.  How do you think?


J. R. Okajima

Reply via email to