mailing list of musl libc
 help / color / mirror / code / Atom feed
* posix_fallocate() fails on some machines
@ 2018-04-26 19:54 John Mudd
  2018-04-26 20:08 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: John Mudd @ 2018-04-26 19:54 UTC (permalink / raw)
  To: musl; +Cc: John Mudd

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

I built a 32-bit dynamically linked Postgres using musl but I can't run on
some machines because posix_fallocate() returns 95, "not supported".

Here's a sample program that reproduces the issue even when compiled
statically. Any suggestions?

# Build a 32-bit static executable. Works.
$ cat test_posix_fallocate.c
#include <stdio.h>
#include <fcntl.h>
int main() {
    int fd = open("foo", O_RDWR|O_CREAT, 0666);
    if (fd < 0) return 1;
    printf("posix_fallocate() returned %d\n", posix_fallocate(fd, 0,
400000));
}
$
$ uname -mrs
Linux 4.4.0-116-generic i686
$ musl-gcc -static -o test_posix_fallocate test_posix_fallocate.c
$ test_posix_fallocate
posix_fallocate() returned 0
$

# Copy it to an older OS. Fails.
$ uname -mrs
Linux 2.6.32-358.14.1.el6.x86_64 x86_64
$ test_posix_fallocate
posix_fallocate() returned 95
$

[-- Attachment #2: Type: text/html, Size: 1233 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: posix_fallocate() fails on some machines
  2018-04-26 19:54 posix_fallocate() fails on some machines John Mudd
@ 2018-04-26 20:08 ` Rich Felker
  2018-04-26 20:21   ` John Mudd
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2018-04-26 20:08 UTC (permalink / raw)
  To: John Mudd; +Cc: musl

On Thu, Apr 26, 2018 at 03:54:19PM -0400, John Mudd wrote:
> I built a 32-bit dynamically linked Postgres using musl but I can't run on
> some machines because posix_fallocate() returns 95, "not supported".
> 
> Here's a sample program that reproduces the issue even when compiled
> statically. Any suggestions?
> 
> # Build a 32-bit static executable. Works.
> $ cat test_posix_fallocate.c
> #include <stdio.h>
> #include <fcntl.h>
> int main() {
>     int fd = open("foo", O_RDWR|O_CREAT, 0666);
>     if (fd < 0) return 1;
>     printf("posix_fallocate() returned %d\n", posix_fallocate(fd, 0,
> 400000));
> }
> $
> $ uname -mrs
> Linux 4.4.0-116-generic i686
> $ musl-gcc -static -o test_posix_fallocate test_posix_fallocate.c
> $ test_posix_fallocate
> posix_fallocate() returned 0
> $
> 
> # Copy it to an older OS. Fails.
> $ uname -mrs
> Linux 2.6.32-358.14.1.el6.x86_64 x86_64
> $ test_posix_fallocate
> posix_fallocate() returned 95
> $

This is a bug in postgresql. It must accept that some underlying
filesystems do not support posix_fallocate. The reason it doesn't is
that glibc implements a buggy and dangerous fallback when it's not
supported, resolved WONTFIX:

https://sourceware.org/bugzilla/show_bug.cgi?id=6865

Simply patch postgresql not to consider this a fatal error, or use a
filesystem where posix_fallocate is supported (e.g. ext3/4).

Rich


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: posix_fallocate() fails on some machines
  2018-04-26 20:08 ` Rich Felker
@ 2018-04-26 20:21   ` John Mudd
  2018-04-26 20:52     ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: John Mudd @ 2018-04-26 20:21 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

Thanks. It seems my mistake was to build on a VM with ext4 file system. My
intention was for the build VM to be the lowest common denominator of my
production PCs. That's why I use 32-bit. I'll change to ext3 on the build
VM.

On Thu, Apr 26, 2018 at 4:08 PM, Rich Felker <dalias@libc.org> wrote:

> On Thu, Apr 26, 2018 at 03:54:19PM -0400, John Mudd wrote:
> > I built a 32-bit dynamically linked Postgres using musl but I can't run
> on
> > some machines because posix_fallocate() returns 95, "not supported".
> >
> > Here's a sample program that reproduces the issue even when compiled
> > statically. Any suggestions?
> >
> > # Build a 32-bit static executable. Works.
> > $ cat test_posix_fallocate.c
> > #include <stdio.h>
> > #include <fcntl.h>
> > int main() {
> >     int fd = open("foo", O_RDWR|O_CREAT, 0666);
> >     if (fd < 0) return 1;
> >     printf("posix_fallocate() returned %d\n", posix_fallocate(fd, 0,
> > 400000));
> > }
> > $
> > $ uname -mrs
> > Linux 4.4.0-116-generic i686
> > $ musl-gcc -static -o test_posix_fallocate test_posix_fallocate.c
> > $ test_posix_fallocate
> > posix_fallocate() returned 0
> > $
> >
> > # Copy it to an older OS. Fails.
> > $ uname -mrs
> > Linux 2.6.32-358.14.1.el6.x86_64 x86_64
> > $ test_posix_fallocate
> > posix_fallocate() returned 95
> > $
>
> This is a bug in postgresql. It must accept that some underlying
> filesystems do not support posix_fallocate. The reason it doesn't is
> that glibc implements a buggy and dangerous fallback when it's not
> supported, resolved WONTFIX:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=6865
>
> Simply patch postgresql not to consider this a fatal error, or use a
> filesystem where posix_fallocate is supported (e.g. ext3/4).
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2550 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: posix_fallocate() fails on some machines
  2018-04-26 20:21   ` John Mudd
@ 2018-04-26 20:52     ` Rich Felker
  2018-04-27 20:01       ` John Mudd
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2018-04-26 20:52 UTC (permalink / raw)
  To: John Mudd; +Cc: musl

On Thu, Apr 26, 2018 at 04:21:07PM -0400, John Mudd wrote:
> Thanks. It seems my mistake was to build on a VM with ext4 file system. My
> intention was for the build VM to be the lowest common denominator of my
> production PCs. That's why I use 32-bit. I'll change to ext3 on the build
> VM.

ext3 (and even ext2 I think) should support it fine. The problem is
wacky stuff like btrfs or xfs or whatnot (not sure which one(s)).

Rich


> On Thu, Apr 26, 2018 at 4:08 PM, Rich Felker <dalias@libc.org> wrote:
> 
> > On Thu, Apr 26, 2018 at 03:54:19PM -0400, John Mudd wrote:
> > > I built a 32-bit dynamically linked Postgres using musl but I can't run
> > on
> > > some machines because posix_fallocate() returns 95, "not supported".
> > >
> > > Here's a sample program that reproduces the issue even when compiled
> > > statically. Any suggestions?
> > >
> > > # Build a 32-bit static executable. Works.
> > > $ cat test_posix_fallocate.c
> > > #include <stdio.h>
> > > #include <fcntl.h>
> > > int main() {
> > >     int fd = open("foo", O_RDWR|O_CREAT, 0666);
> > >     if (fd < 0) return 1;
> > >     printf("posix_fallocate() returned %d\n", posix_fallocate(fd, 0,
> > > 400000));
> > > }
> > > $
> > > $ uname -mrs
> > > Linux 4.4.0-116-generic i686
> > > $ musl-gcc -static -o test_posix_fallocate test_posix_fallocate.c
> > > $ test_posix_fallocate
> > > posix_fallocate() returned 0
> > > $
> > >
> > > # Copy it to an older OS. Fails.
> > > $ uname -mrs
> > > Linux 2.6.32-358.14.1.el6.x86_64 x86_64
> > > $ test_posix_fallocate
> > > posix_fallocate() returned 95
> > > $
> >
> > This is a bug in postgresql. It must accept that some underlying
> > filesystems do not support posix_fallocate. The reason it doesn't is
> > that glibc implements a buggy and dangerous fallback when it's not
> > supported, resolved WONTFIX:
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=6865
> >
> > Simply patch postgresql not to consider this a fatal error, or use a
> > filesystem where posix_fallocate is supported (e.g. ext3/4).
> >
> > Rich
> >


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: posix_fallocate() fails on some machines
  2018-04-26 20:52     ` Rich Felker
@ 2018-04-27 20:01       ` John Mudd
  0 siblings, 0 replies; 5+ messages in thread
From: John Mudd @ 2018-04-27 20:01 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 2492 bytes --]

I replaced the file system on my build VM with ext3. Now the test program
returns 95, not supported.

For now my plan is to change the Postgres source code to call ftruncate(fd,
size) in place of posix_fallocate(fd, 0, size). That seems to work.



On Thu, Apr 26, 2018 at 4:52 PM, Rich Felker <dalias@libc.org> wrote:

> On Thu, Apr 26, 2018 at 04:21:07PM -0400, John Mudd wrote:
> > Thanks. It seems my mistake was to build on a VM with ext4 file system.
> My
> > intention was for the build VM to be the lowest common denominator of my
> > production PCs. That's why I use 32-bit. I'll change to ext3 on the build
> > VM.
>
> ext3 (and even ext2 I think) should support it fine. The problem is
> wacky stuff like btrfs or xfs or whatnot (not sure which one(s)).
>
> Rich
>
>
> > On Thu, Apr 26, 2018 at 4:08 PM, Rich Felker <dalias@libc.org> wrote:
> >
> > > On Thu, Apr 26, 2018 at 03:54:19PM -0400, John Mudd wrote:
> > > > I built a 32-bit dynamically linked Postgres using musl but I can't
> run
> > > on
> > > > some machines because posix_fallocate() returns 95, "not supported".
> > > >
> > > > Here's a sample program that reproduces the issue even when compiled
> > > > statically. Any suggestions?
> > > >
> > > > # Build a 32-bit static executable. Works.
> > > > $ cat test_posix_fallocate.c
> > > > #include <stdio.h>
> > > > #include <fcntl.h>
> > > > int main() {
> > > >     int fd = open("foo", O_RDWR|O_CREAT, 0666);
> > > >     if (fd < 0) return 1;
> > > >     printf("posix_fallocate() returned %d\n", posix_fallocate(fd, 0,
> > > > 400000));
> > > > }
> > > > $
> > > > $ uname -mrs
> > > > Linux 4.4.0-116-generic i686
> > > > $ musl-gcc -static -o test_posix_fallocate test_posix_fallocate.c
> > > > $ test_posix_fallocate
> > > > posix_fallocate() returned 0
> > > > $
> > > >
> > > > # Copy it to an older OS. Fails.
> > > > $ uname -mrs
> > > > Linux 2.6.32-358.14.1.el6.x86_64 x86_64
> > > > $ test_posix_fallocate
> > > > posix_fallocate() returned 95
> > > > $
> > >
> > > This is a bug in postgresql. It must accept that some underlying
> > > filesystems do not support posix_fallocate. The reason it doesn't is
> > > that glibc implements a buggy and dangerous fallback when it's not
> > > supported, resolved WONTFIX:
> > >
> > > https://sourceware.org/bugzilla/show_bug.cgi?id=6865
> > >
> > > Simply patch postgresql not to consider this a fatal error, or use a
> > > filesystem where posix_fallocate is supported (e.g. ext3/4).
> > >
> > > Rich
> > >
>

[-- Attachment #2: Type: text/html, Size: 3747 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-27 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 19:54 posix_fallocate() fails on some machines John Mudd
2018-04-26 20:08 ` Rich Felker
2018-04-26 20:21   ` John Mudd
2018-04-26 20:52     ` Rich Felker
2018-04-27 20:01       ` John Mudd

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).