summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch b/meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch
new file mode 100644
index 0000000000..e0b68df607
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0003-readahead-cleanups.patch
@@ -0,0 +1,86 @@
1Upstream-Status: Backport
2
3-Khem 2013/03/28
4
5From b0640287f784a320661f7206c9ade07b99003fd5 Mon Sep 17 00:00:00 2001
6From: Auke Kok <auke-jan.h.kok@intel.com>
7Date: Tue, 26 Mar 2013 11:13:47 -0700
8Subject: [PATCH 03/17] readahead: cleanups
9
10- check for OOM
11- no need to use floats and round()
12---
13 Makefile.am | 2 +-
14 src/readahead/readahead-collect.c | 20 ++++++++++++++------
15 2 files changed, 15 insertions(+), 7 deletions(-)
16
17diff --git a/Makefile.am b/Makefile.am
18index 5861976..37c1cc2 100644
19--- a/Makefile.am
20+++ b/Makefile.am
21@@ -2956,7 +2956,7 @@ systemd_readahead_SOURCES = \
22 systemd_readahead_LDADD = \
23 libsystemd-shared.la \
24 libsystemd-daemon.la \
25- libudev.la -lm
26+ libudev.la
27
28 dist_doc_DATA += \
29 src/readahead/sd-readahead.c \
30diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c
31index 5d22949..e2fd8df 100644
32--- a/src/readahead/readahead-collect.c
33+++ b/src/readahead/readahead-collect.c
34@@ -68,7 +68,7 @@
35 */
36
37 static ReadaheadShared *shared = NULL;
38-static struct timespec starttime;
39+static usec_t starttime;
40
41 /* Avoid collisions with the NULL pointer */
42 #define SECTOR_TO_PTR(s) ULONG_TO_PTR((s)+1)
43@@ -260,7 +260,7 @@ static int collect(const char *root) {
44 goto finish;
45 }
46
47- clock_gettime(CLOCK_MONOTONIC, &starttime);
48+ starttime = now(CLOCK_MONOTONIC);
49
50 /* If there's no pack file yet we lower the kernel readahead
51 * so that mincore() is accurate. If there is a pack file
52@@ -459,19 +459,27 @@ static int collect(const char *root) {
53 free(p);
54 else {
55 unsigned long ul;
56- struct timespec ts;
57+ usec_t entrytime;
58 struct item *entry;
59
60 entry = new0(struct item, 1);
61+ if (!entry) {
62+ r = log_oom();
63+ goto finish;
64+ }
65
66 ul = fd_first_block(m->fd);
67
68- clock_gettime(CLOCK_MONOTONIC, &ts);
69+ entrytime = now(CLOCK_MONOTONIC);
70
71 entry->block = ul;
72 entry->path = strdup(p);
73- entry->bin = round((ts.tv_sec - starttime.tv_sec +
74- ((ts.tv_nsec - starttime.tv_nsec) / 1000000000.0)) / 2.0);
75+ if (!entry->path) {
76+ free(entry);
77+ r = log_oom();
78+ goto finish;
79+ }
80+ entry->bin = (entrytime - starttime) / 2000000;
81
82 if ((k = hashmap_put(files, p, entry)) < 0) {
83 log_warning("set_put() failed: %s", strerror(-k));
84--
851.7.9.5
86