systemd: Check for HAVE_POSIX_FALLOCATE

Submitted by Drew Moseley on April 28, 2014, 3:38 p.m.

Details

Message ID 1398699537-28100-1-git-send-email-drew@moseleynet.net
State Accepted
Commit 7e498c4c17e2c1b6928d4c1fd127977bb588991f
Headers show

Commit Message

Drew Moseley April 28, 2014, 3:38 p.m.
From: Drew Moseley <drew_moseley@mentor.com>

The check for the config variable is using the wrong define
resulting in the #else always being used.

Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
---
 .../systemd/systemd-pam-fix-fallocate.patch        |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
index de73be9..d25acef 100644
--- a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
+++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
@@ -27,7 +27,7 @@  Index: systemd-209/src/journal/journal-file.c
          /* Note that the glibc fallocate() fallback is very
             inefficient, hence we try to minimize the allocation area
             as we can. */
-+#ifdef HAVE_POSIX_ALLOCATE
++#ifdef HAVE_POSIX_FALLOCATE
          r = posix_fallocate(f->fd, old_size, new_size - old_size);
          if (r != 0)
                  return -r;
@@ -66,7 +66,7 @@  Index: systemd-209/src/journal/journald-kmsg.c
          }
 -
 -        if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
-+#ifdef HAVE_POSIX_ALLOCATE
++#ifdef HAVE_POSIX_FALLOCATE
 +        r = posix_fallocate(fd, 0, sizeof(uint64_t));
 +#else
 +	/* Use good old method to write zeros into the journal file

Comments

Khem Raj April 28, 2014, 5:10 p.m.
On Mon, Apr 28, 2014 at 8:38 AM, Drew Moseley <drew@moseleynet.net> wrote:
> From: Drew Moseley <drew_moseley@mentor.com>
>
> The check for the config variable is using the wrong define
> resulting in the #else always being used.
>

good catch. Looks good to me Thanks for the patch.

> Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
> ---
>  .../systemd/systemd-pam-fix-fallocate.patch        |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
> index de73be9..d25acef 100644
> --- a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
> +++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
> @@ -27,7 +27,7 @@ Index: systemd-209/src/journal/journal-file.c
>           /* Note that the glibc fallocate() fallback is very
>              inefficient, hence we try to minimize the allocation area
>              as we can. */
> -+#ifdef HAVE_POSIX_ALLOCATE
> ++#ifdef HAVE_POSIX_FALLOCATE
>           r = posix_fallocate(f->fd, old_size, new_size - old_size);
>           if (r != 0)
>                   return -r;
> @@ -66,7 +66,7 @@ Index: systemd-209/src/journal/journald-kmsg.c
>           }
>  -
>  -        if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
> -+#ifdef HAVE_POSIX_ALLOCATE
> ++#ifdef HAVE_POSIX_FALLOCATE
>  +        r = posix_fallocate(fd, 0, sizeof(uint64_t));
>  +#else
>  +      /* Use good old method to write zeros into the journal file
> --
> 1.7.9.5
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Drew Moseley April 28, 2014, 5:34 p.m.
On Apr 28, 2014, at 1:10 PM, Khem Raj <raj.khem@gmail.com> wrote:
> On Mon, Apr 28, 2014 at 8:38 AM, Drew Moseley <drew@moseleynet.net> wrote:
>> From: Drew Moseley <drew_moseley@mentor.com>
>> 
>> The check for the config variable is using the wrong define
>> resulting in the #else always being used.
>> 
> 
> good catch. Looks good to me Thanks for the patch.

Hi Khem,

I'm curious about the safety of using alloca() here. In my
particular config, without the fix to use posix_fallocate(), it was
attempting to allocate 8MB on the stack, evidently failing, and
then segfaulting.  And there is evidently no error return value
from alloca so any time it fails a segfault is the likely result.

Thoughts?

Drew