SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-10-24 13:30:04 +00:00 committed by Git OBS Bridge
parent 864d12612c
commit 3591e26a47
6 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,36 @@
Based on a2726e5cedfa5edeabd7e0784be11bc578555ac5 Mon Sep 17 00:00:00 2001
From: Marius Tessmann <mus.svz@gmail.com>
Date: Fri, 29 Aug 2014 17:51:45 +0200
Subject: [PATCH] shutdown: pass own argv to /run/initramfs/shutdown
Since commit b1e90ec515408aec2702522f6f68c4920b56375b systemd passes
its log settings to systemd-shutdown via command line parameters.
However, systemd-shutdown doesn't pass these parameters to
/run/initramfs/shutdown, causing it to fall back to the default log
settings.
This fixes the following bugs about the shutdown not being quiet
despite "quiet" being in the kernel parameters:
https://bugs.freedesktop.org/show_bug.cgi?id=79582
https://bugs.freedesktop.org/show_bug.cgi?id=57216
---
src/core/shutdown.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- src/core/shutdown.c
+++ src/core/shutdown.c 2014-10-24 12:32:44.704337960 +0000
@@ -377,11 +377,11 @@ int main(int argc, char *argv[]) {
if (prepare_new_root() >= 0 &&
pivot_to_new_root() >= 0) {
- arguments[0] = (char*) "/shutdown";
+ argv[0] = (char*) "/shutdown";
log_info("Returning to initrd...");
- execv("/shutdown", arguments);
+ execv("/shutdown", argv);
log_error("Failed to execute shutdown binary: %m");
}
}

View File

@ -0,0 +1,146 @@
---
src/journal/catalog.c | 21 +++++++++++++++++++--
src/journal/journal-authenticate.c | 4 ++--
src/journal/journal-file.c | 2 +-
src/journal/journald-kmsg.c | 2 +-
src/journal/mmap-cache.c | 24 ++++++++++++++++++++++--
5 files changed, 45 insertions(+), 8 deletions(-)
--- src/journal/catalog.c
+++ src/journal/catalog.c 2014-10-24 11:44:59.079838065 +0000
@@ -472,9 +472,19 @@ finish:
static int open_mmap(const char *database, int *_fd, struct stat *_st, void **_p) {
const CatalogHeader *h;
- int fd;
+ static const struct {
+ const int index;
+ int advise;
+ } advises[] = {
+ {0,MADV_WILLNEED},
+ {1,MADV_SEQUENTIAL},
+ {2,MADV_DONTDUMP},
+ {3,MADV_DONTFORK}
+ };
+ int n, fd;
void *p;
struct stat st;
+ size_t psize;
assert(_fd);
assert(_st);
@@ -494,12 +504,19 @@ static int open_mmap(const char *databas
return -EINVAL;
}
- p = mmap(NULL, PAGE_ALIGN(st.st_size), PROT_READ, MAP_SHARED, fd, 0);
+ psize = PAGE_ALIGN(st.st_size);
+ p = mmap(NULL, psize, PROT_READ, MAP_SHARED|MAP_POPULATE|MAP_NONBLOCK, fd, 0);
if (p == MAP_FAILED) {
close_nointr_nofail(fd);
return -errno;
}
+ for (n=0; n < sizeof(advises)/sizeof(advises[0]); n++) {
+ int r = madvise(p, psize, advises[n].advise);
+ if (r < 0)
+ log_warning("Failed to give advice about use of memory: %m");
+ }
+
h = p;
if (memcmp(h->signature, CATALOG_SIGNATURE, sizeof(h->signature)) != 0 ||
le64toh(h->header_size) < sizeof(CatalogHeader) ||
--- src/journal/journal-authenticate.c
+++ src/journal/journal-authenticate.c 2014-10-24 07:41:09.271837523 +0000
@@ -355,7 +355,7 @@ int journal_file_fss_load(JournalFile *f
goto finish;
}
- m = mmap(NULL, PAGE_ALIGN(sizeof(FSSHeader)), PROT_READ, MAP_SHARED, fd, 0);
+ m = mmap(NULL, PAGE_ALIGN(sizeof(FSSHeader)), PROT_READ, MAP_SHARED|MAP_STACK, fd, 0);
if (m == MAP_FAILED) {
m = NULL;
r = -errno;
@@ -399,7 +399,7 @@ int journal_file_fss_load(JournalFile *f
goto finish;
}
- f->fss_file = mmap(NULL, PAGE_ALIGN(f->fss_file_size), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ f->fss_file = mmap(NULL, PAGE_ALIGN(f->fss_file_size), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_STACK, fd, 0);
if (f->fss_file == MAP_FAILED) {
f->fss_file = NULL;
r = -errno;
--- src/journal/journal-file.c
+++ src/journal/journal-file.c 2014-10-24 07:39:25.603837720 +0000
@@ -2554,7 +2554,7 @@ int journal_file_open(
goto fail;
}
- f->header = mmap(NULL, PAGE_ALIGN(sizeof(Header)), prot_from_flags(flags), MAP_SHARED, f->fd, 0);
+ f->header = mmap(NULL, PAGE_ALIGN(sizeof(Header)), prot_from_flags(flags), MAP_SHARED|MAP_STACK, f->fd, 0);
if (f->header == MAP_FAILED) {
f->header = NULL;
r = -errno;
--- src/journal/journald-kmsg.c
+++ src/journal/journald-kmsg.c 2014-10-24 07:38:01.967837989 +0000
@@ -473,7 +473,7 @@ int server_open_kernel_seqnum(Server *s)
return 0;
}
- p = mmap(NULL, sizeof(uint64_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ p = mmap(NULL, sizeof(uint64_t), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_STACK, fd, 0);
if (p == MAP_FAILED) {
log_error("Failed to map sequential number file, ignoring: %m");
close_nointr_nofail(fd);
--- src/journal/mmap-cache.c
+++ src/journal/mmap-cache.c 2014-10-24 11:16:47.759837744 +0000
@@ -439,12 +439,21 @@ static int add_mmap(
struct stat *st,
void **ret) {
+ static const struct {
+ const int index;
+ int vise;
+ } ad[] = {
+ {0, MADV_WILLNEED},
+ {1, MADV_SEQUENTIAL},
+ {2, MADV_DONTDUMP},
+ {3, MADV_DONTFORK}
+ };
uint64_t woffset, wsize;
Context *c;
FileDescriptor *f;
Window *w;
void *d;
- int r;
+ int n, r;
assert(m);
assert(m->n_ref > 0);
@@ -481,7 +490,7 @@ static int add_mmap(
}
for (;;) {
- d = mmap(NULL, wsize, prot, MAP_SHARED, fd, woffset);
+ d = mmap(NULL, wsize, prot, MAP_SHARED|MAP_POPULATE|MAP_NONBLOCK, fd, woffset);
if (d != MAP_FAILED)
break;
if (errno != ENOMEM)
@@ -494,6 +503,17 @@ static int add_mmap(
return -ENOMEM;
}
+ for (n=0; n < sizeof(ad)/sizeof(ad[0]); n++) {
+ if (ad[n].vise == MADV_DONTFORK) {
+ int flags = fcntl(fd, F_GETFD);
+ if (flags < 0 || !(flags & FD_CLOEXEC))
+ continue;
+ }
+ r = madvise(d, wsize, ad[n].vise);
+ if (r < 0)
+ log_warning("Failed to give advice about use of memory: %m");
+ }
+
c = context_add(m, context);
if (!c)
goto outofmem;

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Oct 24 13:02:45 UTC 2014 - werner@suse.de
- Add upstream patch
0002-shutdown-pass-own-argv-to-run-initramfs-shutdown.patch
- Add patch journald-advice-about-use-of-memory.patch to use mmap()
flags as well as madvise(2) for journal files.
-------------------------------------------------------------------
Thu Oct 23 14:05:08 UTC 2014 - werner@suse.de

View File

@ -974,6 +974,10 @@ Patch471: 0003-journald-add-CAP_MAC_OVERRIDE-in-journald-for-SMACK-.patch
Patch472: 0004-journal-do-server_vacuum-for-sigusr1.patch
# PATCH-FIX-UPSTREAM added at 2014/10/23
Patch473: 0005-cryptsetup-fix-an-OOM-check.patch
# PATCH-FIX-UPSTREAM added at 2014/10/24
Patch474: 0002-shutdown-pass-own-argv-to-run-initramfs-shutdown.patch
# PATCH-FIX-SUSE added at 2014/10/24
Patch475: journald-advice-about-use-of-memory.patch
# UDEV PATCHES
# ============
@ -1793,6 +1797,8 @@ cp %{SOURCE7} m4/
%patch471 -p0
%patch472 -p0
%patch473 -p0
%patch474 -p0
%patch475 -p0
# udev patches
%patch1001 -p1

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Oct 24 13:02:45 UTC 2014 - werner@suse.de
- Add upstream patch
0002-shutdown-pass-own-argv-to-run-initramfs-shutdown.patch
- Add patch journald-advice-about-use-of-memory.patch to use mmap()
flags as well as madvise(2) for journal files.
-------------------------------------------------------------------
Thu Oct 23 14:05:08 UTC 2014 - werner@suse.de

View File

@ -969,6 +969,10 @@ Patch471: 0003-journald-add-CAP_MAC_OVERRIDE-in-journald-for-SMACK-.patch
Patch472: 0004-journal-do-server_vacuum-for-sigusr1.patch
# PATCH-FIX-UPSTREAM added at 2014/10/23
Patch473: 0005-cryptsetup-fix-an-OOM-check.patch
# PATCH-FIX-UPSTREAM added at 2014/10/24
Patch474: 0002-shutdown-pass-own-argv-to-run-initramfs-shutdown.patch
# PATCH-FIX-SUSE added at 2014/10/24
Patch475: journald-advice-about-use-of-memory.patch
# UDEV PATCHES
# ============
@ -1788,6 +1792,8 @@ cp %{SOURCE7} m4/
%patch471 -p0
%patch472 -p0
%patch473 -p0
%patch474 -p0
%patch475 -p0
# udev patches
%patch1001 -p1