-
Notifications
You must be signed in to change notification settings - Fork 28
/
linux-3.11.10.diff
120 lines (113 loc) · 4.01 KB
/
linux-3.11.10.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
diff -ru linux-3.11.10-orig/arch/x86/include/asm/page_64_types.h linux-3.11.10/arch/x86/include/asm/page_64_types.h
--- linux-3.11.10-orig/arch/x86/include/asm/page_64_types.h 2013-11-29 13:42:37.000000000 -0500
+++ linux-3.11.10/arch/x86/include/asm/page_64_types.h 2016-02-13 17:20:55.178810833 -0500
@@ -1,7 +1,7 @@
#ifndef _ASM_X86_PAGE_64_DEFS_H
#define _ASM_X86_PAGE_64_DEFS_H
-#define THREAD_SIZE_ORDER 1
+#define THREAD_SIZE_ORDER 2
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
#define CURRENT_MASK (~(THREAD_SIZE - 1))
diff -ru linux-3.11.10-orig/fs/direct-io.c linux-3.11.10/fs/direct-io.c
--- linux-3.11.10-orig/fs/direct-io.c 2013-11-29 13:42:37.000000000 -0500
+++ linux-3.11.10/fs/direct-io.c 2016-02-12 23:28:35.200314074 -0500
@@ -154,6 +154,43 @@
return sdio->tail - sdio->head;
}
+int get_kernfs_pages(unsigned long start, int nr_pages, int write,
+ struct page **pages)
+{
+ int i;
+ if (is_vmalloc_addr((void *)start)) {
+ for (i = 0; i < nr_pages; i++) {
+ struct page *page;
+ /*
+ * wkj: touch each to fault it in if necessary
+ * there must be a more elegant way to do
+ * this... but write is ignored anyway.
+ */
+ write = *(int *)start;
+ page = vmalloc_to_page((void *)start);
+ pages[i] = page;
+ page_cache_get(page);
+ start += PAGE_SIZE;
+ }
+ } else {
+ int ret;
+ WARN_ON(!PAGE_ALIGNED(start));
+ for (i = 0; i < nr_pages; i++) {
+ const struct kvec kiov = {
+ .iov_base = (void *)start,
+ .iov_len = PAGE_SIZE
+ };
+ ret = get_kernel_pages(&kiov, 1, write, pages + i);
+ if (ret < 0)
+ return i;
+ start += PAGE_SIZE;
+ }
+
+ }
+
+ return i;
+}
+
/*
* Go grab and pin some userspace pages. Typically we'll get 64 at a time.
*/
@@ -163,11 +200,19 @@
int nr_pages;
nr_pages = min(sdio->total_pages - sdio->curr_page, DIO_PAGES);
- ret = get_user_pages_fast(
- sdio->curr_user_address, /* Where from? */
- nr_pages, /* How many pages? */
- dio->rw == READ, /* Write to memory? */
- &dio->pages[0]); /* Put results here */
+ if (dio->iocb->ki_filp->f_flags & __O_KERNFS) {
+ ret = get_kernfs_pages(
+ sdio->curr_user_address, /* Where from? */
+ nr_pages, /* How many pages? */
+ dio->rw == READ, /* Write to memory? */
+ &dio->pages[0]); /* Put results here */
+ } else {
+ ret = get_user_pages_fast(
+ sdio->curr_user_address, /* Where from? */
+ nr_pages, /* How many pages? */
+ dio->rw == READ, /* Write to memory? */
+ &dio->pages[0]); /* Put results here */
+ }
if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
struct page *page = ZERO_PAGE(0);
diff -ru linux-3.11.10-orig/fs/fcntl.c linux-3.11.10/fs/fcntl.c
--- linux-3.11.10-orig/fs/fcntl.c 2013-11-29 13:42:37.000000000 -0500
+++ linux-3.11.10/fs/fcntl.c 2016-02-12 23:30:28.436311429 -0500
@@ -730,14 +730,15 @@
* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
* is defined as O_NONBLOCK on some platforms and not on others.
*/
- BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
+ BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
O_RDONLY | O_WRONLY | O_RDWR |
O_CREAT | O_EXCL | O_NOCTTY |
O_TRUNC | O_APPEND | /* O_NONBLOCK | */
__O_SYNC | O_DSYNC | FASYNC |
O_DIRECT | O_LARGEFILE | O_DIRECTORY |
O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
- __FMODE_EXEC | O_PATH | __O_TMPFILE
+ __FMODE_EXEC | O_PATH | __O_TMPFILE |
+ __O_KERNFS
));
fasync_cache = kmem_cache_create("fasync_cache",
diff -ru linux-3.11.10-orig/include/uapi/asm-generic/fcntl.h linux-3.11.10/include/uapi/asm-generic/fcntl.h
--- linux-3.11.10-orig/include/uapi/asm-generic/fcntl.h 2013-11-29 13:42:37.000000000 -0500
+++ linux-3.11.10/include/uapi/asm-generic/fcntl.h 2016-02-12 23:30:49.772310930 -0500
@@ -88,6 +88,11 @@
#define __O_TMPFILE 020000000
#endif
+#ifndef __O_KERNFS
+#define __O_KERNFS 040000000
+#endif
+
+
/* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)