valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0337-readahead-do-not-increase-nr_requests-for-root-fs-bl.patch

803fb7
From 997778e332e9f6d3d1c42e9a222fcab8d4732c40 Mon Sep 17 00:00:00 2001
803fb7
From: Michal Sekletar <msekleta@redhat.com>
803fb7
Date: Fri, 27 May 2016 14:29:17 +0200
803fb7
Subject: [PATCH] readahead: do not increase nr_requests for root fs block
803fb7
 device
803fb7
803fb7
Having nr_requests can cause system lockups. Arguably, this should get
803fb7
fixed somehow in kernel. For now we just stop changing the
803fb7
value.
803fb7
803fb7
Note that not bumping a value may cause that posix_fadvise call
803fb7
will block in case there is no room in a request queue.
803fb7
803fb7
See: http://article.gmane.org/gmane.linux.kernel/1072356
803fb7
803fb7
RHEL-only
803fb7
Resolves: #1314559
803fb7
---
803fb7
 src/readahead/readahead-common.c | 64 ----------------------------------------
803fb7
 src/readahead/readahead-common.h |  2 --
803fb7
 src/readahead/readahead-replay.c |  2 --
803fb7
 3 files changed, 68 deletions(-)
803fb7
803fb7
diff --git a/src/readahead/readahead-common.c b/src/readahead/readahead-common.c
803fb7
index 3ca48a725..6cf33f7cf 100644
803fb7
--- a/src/readahead/readahead-common.c
803fb7
+++ b/src/readahead/readahead-common.c
803fb7
@@ -253,70 +253,6 @@ ReadaheadShared *shared_get(void) {
803fb7
         return m;
803fb7
 }
803fb7
 
803fb7
-/* We use 20K instead of the more human digestable 16K here. Why?
803fb7
-   Simply so that it is more unlikely that users end up picking this
803fb7
-   value too so that we can recognize better whether the user changed
803fb7
-   the value while we had it temporarily bumped. */
803fb7
-#define BUMP_REQUEST_NR (20*1024u)
803fb7
-
803fb7
-int block_bump_request_nr(const char *p) {
803fb7
-        struct stat st;
803fb7
-        uint64_t u;
803fb7
-        char *ap = NULL, *line = NULL;
803fb7
-        int r;
803fb7
-        dev_t d;
803fb7
-
803fb7
-        assert(p);
803fb7
-
803fb7
-        if (stat(p, &st) < 0)
803fb7
-                return -errno;
803fb7
-
803fb7
-        if (major(st.st_dev) == 0)
803fb7
-                return 0;
803fb7
-
803fb7
-        d = st.st_dev;
803fb7
-        block_get_whole_disk(d, &d);
803fb7
-
803fb7
-        if (asprintf(&ap, "/sys/dev/block/%u:%u/queue/nr_requests", major(d), minor(d)) < 0) {
803fb7
-                r= -ENOMEM;
803fb7
-                goto finish;
803fb7
-        }
803fb7
-
803fb7
-        r = read_one_line_file(ap, &line);
803fb7
-        if (r < 0) {
803fb7
-                if (r == -ENOENT)
803fb7
-                        r = 0;
803fb7
-                goto finish;
803fb7
-        }
803fb7
-
803fb7
-        r = safe_atou64(line, &u);
803fb7
-        if (r >= 0 && u >= BUMP_REQUEST_NR) {
803fb7
-                r = 0;
803fb7
-                goto finish;
803fb7
-        }
803fb7
-
803fb7
-        free(line);
803fb7
-        line = NULL;
803fb7
-
803fb7
-        if (asprintf(&line, "%u", BUMP_REQUEST_NR) < 0) {
803fb7
-                r = -ENOMEM;
803fb7
-                goto finish;
803fb7
-        }
803fb7
-
803fb7
-        r = write_string_file(ap, line);
803fb7
-        if (r < 0)
803fb7
-                goto finish;
803fb7
-
803fb7
-        log_info("Bumped block_nr parameter of %u:%u to %u. This is a temporary hack and should be removed one day.", major(d), minor(d), BUMP_REQUEST_NR);
803fb7
-        r = 1;
803fb7
-
803fb7
-finish:
803fb7
-        free(ap);
803fb7
-        free(line);
803fb7
-
803fb7
-        return r;
803fb7
-}
803fb7
-
803fb7
 int block_get_readahead(const char *p, uint64_t *bytes) {
803fb7
         struct stat st;
803fb7
         char *ap = NULL, *line = NULL;
803fb7
diff --git a/src/readahead/readahead-common.h b/src/readahead/readahead-common.h
803fb7
index b34f3aadd..cc2ea81a9 100644
803fb7
--- a/src/readahead/readahead-common.h
803fb7
+++ b/src/readahead/readahead-common.h
803fb7
@@ -51,8 +51,6 @@ typedef struct ReadaheadShared {
803fb7
 
803fb7
 ReadaheadShared *shared_get(void);
803fb7
 
803fb7
-int block_bump_request_nr(const char *p);
803fb7
-
803fb7
 int block_get_readahead(const char *p, uint64_t *bytes);
803fb7
 int block_set_readahead(const char *p, uint64_t bytes);
803fb7
 
803fb7
diff --git a/src/readahead/readahead-replay.c b/src/readahead/readahead-replay.c
803fb7
index f81e0fe55..c2e281687 100644
803fb7
--- a/src/readahead/readahead-replay.c
803fb7
+++ b/src/readahead/readahead-replay.c
803fb7
@@ -134,8 +134,6 @@ static int replay(const char *root) {
803fb7
 
803fb7
         assert(root);
803fb7
 
803fb7
-        block_bump_request_nr(root);
803fb7
-
803fb7
         if (asprintf(&pack_fn, "%s/.readahead", root) < 0)
803fb7
                 return log_oom();
803fb7