dcavalca / rpms / systemd

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