FreeBSD 8 - bug in rename(2)

Anton Yuzhaninov citrin at citrin.ru
Thu Oct 27 15:00:10 UTC 2011


After upgrade from old RELENG_7 to fresh RELENG_8 I've met with error in log rotation script.

After some digging I'v found, that rename(2) syscall sometime don't work properly. I can't reproduce problem with simple test case, but in production this problem appeared several time per day.

After rename(2) sometimes old name still exists.
stat for old and new names:

101 12153947 -rw-r--r-- 1 owner data 54507160 164374900 "Oct 27 13:58:06 2011" "Oct 27 13:58:06 2011" "Oct 27 13:58:06 2011" "Oct 27 13:56:05 2011" 16384 321248 0 /usr/local/run/nginx/access_log
101 12153947 -rw-r--r-- 1 owner data 54507160 164377726 "Oct 27 13:58:06 2011" "Oct 27 13:58:06 2011" "Oct 27 13:58:06 2011" "Oct 27 13:56:05 2011" 16384 321248 0 /usr/local/run/nginx/access_log.20111027T135806

2 files share same inode, but number of links is 1

2-nd rename for this file fail:
mv: rename /usr/local/run/nginx/access_log to /usr/local/run/nginx/access_log.tmp: No such file or directory

vfs.lookup_shared=0 don't affect this problem,

It seems to be, that problem is related to namei (vfs) cache - old entry sometimes is not removed.

Renamed file is open for write by nginx, but I don't know how this can affect namei.

-- 
 Anton Yuzhaninov


More information about the freebsd-stable mailing list