Revision fc32a72d
b/block/raw-posix.c | ||
---|---|---|
185 | 185 |
} |
186 | 186 |
#endif |
187 | 187 |
|
188 |
#ifdef CONFIG_LINUX_AIO |
|
189 |
static int raw_set_aio(void **aio_ctx, int *use_aio, int bdrv_flags) |
|
190 |
{ |
|
191 |
int ret = -1; |
|
192 |
assert(aio_ctx != NULL); |
|
193 |
assert(use_aio != NULL); |
|
194 |
/* |
|
195 |
* Currently Linux do AIO only for files opened with O_DIRECT |
|
196 |
* specified so check NOCACHE flag too |
|
197 |
*/ |
|
198 |
if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == |
|
199 |
(BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { |
|
200 |
|
|
201 |
/* if non-NULL, laio_init() has already been run */ |
|
202 |
if (*aio_ctx == NULL) { |
|
203 |
*aio_ctx = laio_init(); |
|
204 |
if (!*aio_ctx) { |
|
205 |
goto error; |
|
206 |
} |
|
207 |
} |
|
208 |
*use_aio = 1; |
|
209 |
} else { |
|
210 |
*use_aio = 0; |
|
211 |
} |
|
212 |
|
|
213 |
ret = 0; |
|
214 |
|
|
215 |
error: |
|
216 |
return ret; |
|
217 |
} |
|
218 |
#endif |
|
219 |
|
|
188 | 220 |
static int raw_open_common(BlockDriverState *bs, const char *filename, |
189 | 221 |
int bdrv_flags, int open_flags) |
190 | 222 |
{ |
... | ... | |
240 | 272 |
} |
241 | 273 |
|
242 | 274 |
#ifdef CONFIG_LINUX_AIO |
243 |
/* |
|
244 |
* Currently Linux do AIO only for files opened with O_DIRECT |
|
245 |
* specified so check NOCACHE flag too |
|
246 |
*/ |
|
247 |
if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == |
|
248 |
(BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { |
|
249 |
|
|
250 |
s->aio_ctx = laio_init(); |
|
251 |
if (!s->aio_ctx) { |
|
252 |
goto out_free_buf; |
|
253 |
} |
|
254 |
s->use_aio = 1; |
|
255 |
} else |
|
256 |
#endif |
|
257 |
{ |
|
258 |
#ifdef CONFIG_LINUX_AIO |
|
259 |
s->use_aio = 0; |
|
260 |
#endif |
|
275 |
if (raw_set_aio(&s->aio_ctx, &s->use_aio, bdrv_flags)) { |
|
276 |
goto out_close; |
|
261 | 277 |
} |
278 |
#endif |
|
262 | 279 |
|
263 | 280 |
#ifdef CONFIG_XFS |
264 | 281 |
if (platform_test_xfs_fd(s->fd)) { |
Also available in: Unified diff