diff options
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
160 | 160 | ||
161 | info->nr = nr_events; /* trusted copy */ | 161 | info->nr = nr_events; /* trusted copy */ |
162 | 162 | ||
163 | ring = kmap_atomic(info->ring_pages[0], KM_USER0); | 163 | ring = kmap_atomic(info->ring_pages[0]); |
164 | ring->nr = nr_events; /* user copy */ | 164 | ring->nr = nr_events; /* user copy */ |
165 | ring->id = ctx->user_id; | 165 | ring->id = ctx->user_id; |
166 | ring->head = ring->tail = 0; | 166 | ring->head = ring->tail = 0; |
@@ -168,32 +168,32 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
168 | ring->compat_features = AIO_RING_COMPAT_FEATURES; | 168 | ring->compat_features = AIO_RING_COMPAT_FEATURES; |
169 | ring->incompat_features = AIO_RING_INCOMPAT_FEATURES; | 169 | ring->incompat_features = AIO_RING_INCOMPAT_FEATURES; |
170 | ring->header_length = sizeof(struct aio_ring); | 170 | ring->header_length = sizeof(struct aio_ring); |
171 | kunmap_atomic(ring, KM_USER0); | 171 | kunmap_atomic(ring); |
172 | 172 | ||
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | /* aio_ring_event: returns a pointer to the event at the given index from | 177 | /* aio_ring_event: returns a pointer to the event at the given index from |
178 | * kmap_atomic(, km). Release the pointer with put_aio_ring_event(); | 178 | * kmap_atomic(). Release the pointer with put_aio_ring_event(); |
179 | */ | 179 | */ |
180 | #define AIO_EVENTS_PER_PAGE (PAGE_SIZE / sizeof(struct io_event)) | 180 | #define AIO_EVENTS_PER_PAGE (PAGE_SIZE / sizeof(struct io_event)) |
181 | #define AIO_EVENTS_FIRST_PAGE ((PAGE_SIZE - sizeof(struct aio_ring)) / sizeof(struct io_event)) | 181 | #define AIO_EVENTS_FIRST_PAGE ((PAGE_SIZE - sizeof(struct aio_ring)) / sizeof(struct io_event)) |
182 | #define AIO_EVENTS_OFFSET (AIO_EVENTS_PER_PAGE - AIO_EVENTS_FIRST_PAGE) | 182 | #define AIO_EVENTS_OFFSET (AIO_EVENTS_PER_PAGE - AIO_EVENTS_FIRST_PAGE) |
183 | 183 | ||
184 | #define aio_ring_event(info, nr, km) ({ \ | 184 | #define aio_ring_event(info, nr) ({ \ |
185 | unsigned pos = (nr) + AIO_EVENTS_OFFSET; \ | 185 | unsigned pos = (nr) + AIO_EVENTS_OFFSET; \ |
186 | struct io_event *__event; \ | 186 | struct io_event *__event; \ |
187 | __event = kmap_atomic( \ | 187 | __event = kmap_atomic( \ |
188 | (info)->ring_pages[pos / AIO_EVENTS_PER_PAGE], km); \ | 188 | (info)->ring_pages[pos / AIO_EVENTS_PER_PAGE]); \ |
189 | __event += pos % AIO_EVENTS_PER_PAGE; \ | 189 | __event += pos % AIO_EVENTS_PER_PAGE; \ |
190 | __event; \ | 190 | __event; \ |
191 | }) | 191 | }) |
192 | 192 | ||
193 | #define put_aio_ring_event(event, km) do { \ | 193 | #define put_aio_ring_event(event) do { \ |
194 | struct io_event *__event = (event); \ | 194 | struct io_event *__event = (event); \ |
195 | (void)__event; \ | 195 | (void)__event; \ |
196 | kunmap_atomic((void *)((unsigned long)__event & PAGE_MASK), km); \ | 196 | kunmap_atomic((void *)((unsigned long)__event & PAGE_MASK)); \ |
197 | } while(0) | 197 | } while(0) |
198 | 198 | ||
199 | static void ctx_rcu_free(struct rcu_head *head) | 199 | static void ctx_rcu_free(struct rcu_head *head) |
@@ -1019,10 +1019,10 @@ int aio_complete(struct kiocb *iocb, long res, long res2) | |||
1019 | if (kiocbIsCancelled(iocb)) | 1019 | if (kiocbIsCancelled(iocb)) |
1020 | goto put_rq; | 1020 | goto put_rq; |
1021 | 1021 | ||
1022 | ring = kmap_atomic(info->ring_pages[0], KM_IRQ1); | 1022 | ring = kmap_atomic(info->ring_pages[0]); |
1023 | 1023 | ||
1024 | tail = info->tail; | 1024 | tail = info->tail; |
1025 | event = aio_ring_event(info, tail, KM_IRQ0); | 1025 | event = aio_ring_event(info, tail); |
1026 | if (++tail >= info->nr) | 1026 | if (++tail >= info->nr) |
1027 | tail = 0; | 1027 | tail = 0; |
1028 | 1028 | ||
@@ -1043,8 +1043,8 @@ int aio_complete(struct kiocb *iocb, long res, long res2) | |||
1043 | info->tail = tail; | 1043 | info->tail = tail; |
1044 | ring->tail = tail; | 1044 | ring->tail = tail; |
1045 | 1045 | ||
1046 | put_aio_ring_event(event, KM_IRQ0); | 1046 | put_aio_ring_event(event); |
1047 | kunmap_atomic(ring, KM_IRQ1); | 1047 | kunmap_atomic(ring); |
1048 | 1048 | ||
1049 | pr_debug("added to ring %p at [%lu]\n", iocb, tail); | 1049 | pr_debug("added to ring %p at [%lu]\n", iocb, tail); |
1050 | 1050 | ||
@@ -1089,7 +1089,7 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent) | |||
1089 | unsigned long head; | 1089 | unsigned long head; |
1090 | int ret = 0; | 1090 | int ret = 0; |
1091 | 1091 | ||
1092 | ring = kmap_atomic(info->ring_pages[0], KM_USER0); | 1092 | ring = kmap_atomic(info->ring_pages[0]); |
1093 | dprintk("in aio_read_evt h%lu t%lu m%lu\n", | 1093 | dprintk("in aio_read_evt h%lu t%lu m%lu\n", |
1094 | (unsigned long)ring->head, (unsigned long)ring->tail, | 1094 | (unsigned long)ring->head, (unsigned long)ring->tail, |
1095 | (unsigned long)ring->nr); | 1095 | (unsigned long)ring->nr); |
@@ -1101,18 +1101,18 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent) | |||
1101 | 1101 | ||
1102 | head = ring->head % info->nr; | 1102 | head = ring->head % info->nr; |
1103 | if (head != ring->tail) { | 1103 | if (head != ring->tail) { |
1104 | struct io_event *evp = aio_ring_event(info, head, KM_USER1); | 1104 | struct io_event *evp = aio_ring_event(info, head); |
1105 | *ent = *evp; | 1105 | *ent = *evp; |
1106 | head = (head + 1) % info->nr; | 1106 | head = (head + 1) % info->nr; |
1107 | smp_mb(); /* finish reading the event before updatng the head */ | 1107 | smp_mb(); /* finish reading the event before updatng the head */ |
1108 | ring->head = head; | 1108 | ring->head = head; |
1109 | ret = 1; | 1109 | ret = 1; |
1110 | put_aio_ring_event(evp, KM_USER1); | 1110 | put_aio_ring_event(evp); |
1111 | } | 1111 | } |
1112 | spin_unlock(&info->ring_lock); | 1112 | spin_unlock(&info->ring_lock); |
1113 | 1113 | ||
1114 | out: | 1114 | out: |
1115 | kunmap_atomic(ring, KM_USER0); | 1115 | kunmap_atomic(ring); |
1116 | dprintk("leaving aio_read_evt: %d h%lu t%lu\n", ret, | 1116 | dprintk("leaving aio_read_evt: %d h%lu t%lu\n", ret, |
1117 | (unsigned long)ring->head, (unsigned long)ring->tail); | 1117 | (unsigned long)ring->head, (unsigned long)ring->tail); |
1118 | return ret; | 1118 | return ret; |