Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 156493 - mail-filter/procmail locking failure w/ NFS and 2.6.17+ kernels
Summary: mail-filter/procmail locking failure w/ NFS and 2.6.17+ kernels
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-28 02:57 UTC by mi-g2bug
Modified: 2008-06-15 10:23 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mi-g2bug 2006-11-28 02:57:01 UTC
In its default configuration procmail will try to use all available
locking mechanisms, all at once: dot-locking, fcntl, lockf (basically
the same thing as fcntl) and flock. Unfortunately starting with the
2.6.17 kernels the fcntl and flock locking mechanisms do not work well
together over NFS. When an NFS file is locked with
fcntl(fd,F_SETLK,...) a subsequent flock() operation on the file will
fail.

The result is that procmail forever loops on the failing locks. 

To reproduce:

1. Use a 2.6.17 or 2.6.18 kernel
2. Put the following in test.rc:

:0: 
$HOME/testfolder

Replace $HOME with a directory that is located on NFS

3. Run the following command:
echo|procmail test.rc

Use strace to see the failing flock() system call:
fcntl64(7, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
fcntl64(7, F_SETLK, {type=F_WRLCK, whence=SEEK_CUR, start=0, len=0}) = 0
flock(7, LOCK_EX|LOCK_NB)               = -1 EAGAIN (Resource temporarily unavailable)

The following patch disables flock style locking:

--- procmail-3.22-r8.ebuild.orig	2006-10-07 18:06:20.000000000 -0700
+++ procmail-3.22-r8.ebuild	2006-11-28 01:59:22.000000000 -0800
@@ -28,6 +28,12 @@
 		-e "s:#LOCKINGTEST=/tmp:LOCKINGTEST=/tmp:" \
 		-i Makefile
 
+	# disable flock, using both fcntl and flock style locking
+	# doesn't work with NFS with 2.6.17+ kernels
+
+	sed -e "s:/\*#define NO_flock_LOCK:#define NO_flock_LOCK:" \
+		-i config.h
+
 	if ! use mbox ; then
 		echo "# Use maildir-style mailbox in user's home directory" > ${S}/procmailrc
 		echo 'DEFAULT=$HOME/.maildir/' >> ${S}/procmailrc

For what its worth, at least one other major distribution has been
shipping with a similar patch for many years.

Portage 2.1.1-r1 (default-linux/x86/2006.0, gcc-3.4.4, glibc-2.3.5-r2, 2.6.17.4 i686)
=================================================================
System uname: 2.6.17.4 i686 AMD Athlon(tm) 64 Processor 3200+
Gentoo Base System version 1.6.15
Last Sync: Tue, 21 Nov 2006 05:20:01 +0000
ccache version 2.3 [disabled]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.30
dev-lang/python:     2.4.2
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.12-r6
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/mozilla/defaults/pref /usr/share/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer nostrip notitles parallel-fetch sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="x86 3dnow X a52 aac alsa apache2 apm asf berkdb bitmap-fonts cli cracklib crypt cups dlloader doc dri dvd dvdread eds elibc_glibc emacs emboss encode ffmpeg flac foomaticdb fortran gdbm gif gstreamer gtk gtk2 iconv imlib input_devices_evdev input_devices_keyboard input_devices_mouse isdnlog javascript joystick jpeg kernel_linux libg++ libwww mad mailwrapper mikmod mmx mp3 mpeg ncurses nls nptl nvidia ogg opengl oss pam pcre perl png pppd python qt3 qt4 quicktime readline reflection sdl session spell spl ssl tcpd theora threads tiff truetype truetype-fonts type1-fonts udev userland_GNU video_cards_apm video_cards_ark video_cards_ati video_cards_chips video_cards_cirrus video_cards_cyrix video_cards_dummy video_cards_fbdev video_cards_glint video_cards_i128 video_cards_i740 video_cards_i810 video_cards_imstt video_cards_mga video_cards_neomagic video_cards_nsc video_cards_nv video_cards_rendition video_cards_s3 video_cards_s3virge video_cards_savage video_cards_siliconmotion video_cards_sis video_cards_sisusb video_cards_tdfx video_cards_tga video_cards_trident video_cards_tseng video_cards_v4l video_cards_vesa video_cards_vga video_cards_via video_cards_vmware video_cards_voodoo vorbis win32codecs xml xorg xv zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 1 Tobias Scherbaum (RETIRED) gentoo-dev 2008-06-15 10:23:11 UTC
This is fixed in procmail-3.22-r9.