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