Hi, AIX's implementation of posix_fallocate is a little bit, let me say, peculiar. Attached is a patch to "fix" (=work around) this. Without you'll see this in the logs: Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): posix_fallocate() failed: File exists Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): file_set_size() failed with mbox file /u/f0/rzuser/beckerr/Mail/Ham: File exists Funny, isn't it? This is what it should be: Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): posix_fallocate() failed: Operation not supported on socket Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): file_set_size() failed with mbox file /u/f0/rzuser/beckerr/Mail/Ham: Operation not supported on socket The problem is, that errno is not correcly set, when posix_fallocate returns EOPNOTSUPP (="Operation not supported on socket"). In this case the return code has to be checked rather than errno. When patched dovecot handles err==EOPNOTSUPP the same way like errno==EINVAL on Solaris. A note for all AIX Admins: Without APAR IZ48778: POSIX_FALLOCATE() FAILS WITH ERROR-25(ENOTTY) resp. IZ46961: POSIX_FALLOCATE() FAILS WITH ERROR-25(ENOTTY) APPLIES TO AIX 5300-06 you don't even get EOPNOTSUPP: posix_fallocate fails with NOTTY. So you have to install one of this fixes to make the patch work. Ralf -- ______________________________________________________________________ Dipl.-Inform. (FH) Ralf Becker Rechenzentrum (r/ft) der FH Trier (Network|Mail|Web|Firewall) University of applied sciences Administrator Schneidershof, D-54293 Trier Mail: beckerr at fh-trier.de Fon: +49 651 8103 499 Web: http://www.fh-trier.de/~beckerr Fax: +49 651 8103 214 PubKey: http://www.fh-trier.de/~beckerr Crypto: GnuPG, S/MIME ______________________________________________________________________ Wenn Gott gewollt haette, dass E-Mail in HTML geschrieben wuerden, endeten Gebete traditionell mit </amen>. (Tom Listen) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: dovecot-aix-posix_fallocate.patch URL: <http://dovecot.org/pipermail/dovecot/attachments/20090730/27a87d45/attachment-0002.pl> -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6074 bytes Desc: S/MIME Cryptographic Signature URL: <http://dovecot.org/pipermail/dovecot/attachments/20090730/27a87d45/attachment-0002.bin>
I bumped into this a while back, and having IBM support for both AIX and the C for AIX V9 compiler, went to the mat on it. What a pointless waste of time; the new IBM increasingly doesn't care about making things right. While IBM has been proclaiming its POSIX compliance, it turned out that AIX and the compiler development have been tasked with its implementation, such as it maybe, only on the JFS2 filesystem. Now they haven't discontinued JFS FS support, but it's a disinterested, neglectful support. Now in the old IBM, everything, but everything, would be tested in n! ways, and everything would work. In the posix_fallocate development, for both AIX and the IBM compiler, apparently nobody did nuffin' with it for the old JFS FS...so until I raised Hell, the call returned a random value error code. Which means that the design team didn't consider JFS at all; not even to the point of documenting non-suppport in JFS. Their charge was JFS2. So they figured out a fix: a patch to return a generic something-wrong errcode. I screamed some more. Their final fix was to return a function not supported errcode. There. Done. It only took 3-4 months. FWIW, the patch will be in the mainline Technical level as follows: "This APAR will be available 53V (AIX 53 TL11 ) and 61H (AIX 61 TL4 )." Their POSIX compliance position:> we would like to clarify you on > below points on posix compliant details in AIX. > > Your comment: > >> Obviously, if you don't support both of AIX's file systems, you are > not totally compliant. > > Response: > Unix standards for posix_fallocate( ) function does not state what all > filesystems the implementation need to support. > Having said that AIX implementation of posix_fallocate() only supports > JFS2. Hence not supporting JFS does not > mean that AIX implementation of posix_fallocate() is not posix > compliant. However as stated earlier you can open > a Design change request for AIX to implement the support of JFS. > > Regarding the list of non-posix compliant APIs we do not maintain any > separate list nor we have any known issues. > Developers can get information about APIs from IBM documentation > http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp > and also looking through Open Group standards specification > http://www.opengroup.org/onlinepubs/009695399/toc.htmWorking with the Indian IBM support was intriguing: they were always courteous, but they were only interested in fulfilling checklists, not in making the product right or necessarily making it work. They didn't, as I have seen elsewhere, declare victory by closing out the trouble ticket (PMR in IBMese) without informing you or getting your consent....but they would continue talking and doing not much of anything until you gave up. What I now do is to: 1) run configure 2) edit config.h and put // in front of the HAVE_POSIX_FALLOCATE define, like this: //#define HAVE_POSIX_FALLOCATE 3) then run make as usual I'm sorry; I should have posted this before, but the whole thing left such a bad taste in my mouth all I wanted to do was move on. S. Ralf Becker wrote:> Hi, > > AIX's implementation of posix_fallocate is a little bit, let me say, > peculiar. Attached is a patch to "fix" (=work around) this. > > Without you'll see this in the logs: > > Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): > posix_fallocate() failed: File exists > Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): > file_set_size() failed with mbox file > /u/f0/rzuser/beckerr/Mail/Ham: File exists > > Funny, isn't it? > > This is what it should be: > > Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): > posix_fallocate() failed: Operation not supported on socket > Jul 28 01:17:41 trevi mail:err|error dovecot: IMAP(beckerr): > file_set_size() failed with mbox file > /u/f0/rzuser/beckerr/Mail/Ham: Operation not supported on socket > > The problem is, that errno is not correcly set, when posix_fallocate > returns EOPNOTSUPP (="Operation not supported on socket"). In this > case the return code has to be checked rather than errno. > > When patched dovecot handles err==EOPNOTSUPP the same way like > errno==EINVAL on Solaris. > > > A note for all AIX Admins: > Without APAR > IZ48778: POSIX_FALLOCATE() FAILS WITH ERROR-25(ENOTTY) resp. > IZ46961: POSIX_FALLOCATE() FAILS WITH ERROR-25(ENOTTY) > APPLIES TO AIX 5300-06 > you don't even get EOPNOTSUPP: posix_fallocate fails with NOTTY. > So you have to install one of this fixes to make the patch work. > > Ralf > >-- ==== Once upon a time, the Internet was a friendly, neighbors-helping-neighbors small town, and no one locked their doors. Now it's like an apartment in Bed-Stuy: you need three heavy duty pick-proof locks, one of those braces that goes from the lock to the floor, and bars on the windows.... ==== Stewart Dean, Unix System Admin, Bard College, New York 12504 sdean at bard.edu voice: 845-758-7475, fax: 845-758-7035
On Thu, 2009-07-30 at 11:24 +0200, Ralf Becker wrote:> + if ((err = posix_fallocate(fd, st.st_size, size - st.st_size)) == 0) > return 0; > > + if (err == EOPNOTSUPP /* AIX */ ) { > + /* Ignore this error silently. > + You have to test err, because errno is not > + correcly set on some versions of AIX */ > + } elseFirst I thought: Why didn't IBM even fix this properly by setting errno? Then I read posix_fallocate man page:> RETURN VALUE > posix_fallocate() returns zero on success, or an error number on fail? > ure. Note that errno is not set.What the hell were POSIX people thinking?? This is the first syscall I've seen that behaves like this, and apparently without any good reason! Wonder how many other new system calls there are like this, that I haven't noticed yet.. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20090730/7244ac4f/attachment-0002.bin>
On Thu, 2009-07-30 at 20:21 +0200, Remi Gacogne wrote:> Le jeudi 30 juillet 2009, Timo Sirainen a ?crit : > > > > What the hell were POSIX people thinking?? This is the first syscall > > > I've seen that behaves like this, and apparently without any good > > > reason! Wonder how many other new system calls there are like this, that > > > I haven't noticed yet.. > > > > Looks like all posix_*() syscalls do that. Wonder if there are more. > > Looks like too many people were incorrectly using errno, especially in multi- > threaded context. > > From http://www.unix.org/whitepapers/reentrant.html : > > "In addition, all POSIX.1c functions avoid using errno and, instead, return > the error number directly as the function return value, with a return value of > zero indicating that no error was detected. This strategy is, in fact, being > followed on a POSIX-wide basis for all new functions. "But that doesn't solve anything, because old functions' API can't be changed. The only thing this change did was to make it more difficult for programmers to remember how functions' error handling should be done. In both APIs the success is indicated by returning 0, which makes it especially difficult to notice when it's being used wrong. If they really had to change this, it would have been much better to both set errno and return -error, that way it would have allowed also 2/3 of the old style error checks: if (posix_fallocate(..) < 0) perror() // works if (posix_fallocate(..) != 0) perror() // works if (posix_fallocate(..) == -1) perror() // doesn't work Now none of them work. I did also a quick google code search for posix_fallocate and found several other programs that handle the error wrong. And I'm sure it's only going to grow. Oh well, maybe some day gcc and libc add some features to catch at least the < 0 and == -1 usage (which would already work if posix_fallocate() had been specified to return unsigned int, not int). -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20090730/13b26d7c/attachment-0002.bin>