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

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