diff options
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 77b4c04a2809..f6cba566429d 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2241,11 +2241,15 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
2241 | 2241 | ||
2242 | mutex_lock(&inode->i_mutex); | 2242 | mutex_lock(&inode->i_mutex); |
2243 | 2243 | ||
2244 | ocfs2_iocb_clear_sem_locked(iocb); | ||
2245 | |||
2244 | relock: | 2246 | relock: |
2245 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ | 2247 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ |
2246 | if (direct_io) { | 2248 | if (direct_io) { |
2247 | down_read(&inode->i_alloc_sem); | 2249 | down_read(&inode->i_alloc_sem); |
2248 | have_alloc_sem = 1; | 2250 | have_alloc_sem = 1; |
2251 | /* communicate with ocfs2_dio_end_io */ | ||
2252 | ocfs2_iocb_set_sem_locked(iocb); | ||
2249 | } | 2253 | } |
2250 | 2254 | ||
2251 | /* | 2255 | /* |
@@ -2382,8 +2386,10 @@ out: | |||
2382 | ocfs2_rw_unlock(inode, rw_level); | 2386 | ocfs2_rw_unlock(inode, rw_level); |
2383 | 2387 | ||
2384 | out_sems: | 2388 | out_sems: |
2385 | if (have_alloc_sem) | 2389 | if (have_alloc_sem) { |
2386 | up_read(&inode->i_alloc_sem); | 2390 | up_read(&inode->i_alloc_sem); |
2391 | ocfs2_iocb_clear_sem_locked(iocb); | ||
2392 | } | ||
2387 | 2393 | ||
2388 | mutex_unlock(&inode->i_mutex); | 2394 | mutex_unlock(&inode->i_mutex); |
2389 | 2395 | ||
@@ -2527,6 +2533,8 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
2527 | goto bail; | 2533 | goto bail; |
2528 | } | 2534 | } |
2529 | 2535 | ||
2536 | ocfs2_iocb_clear_sem_locked(iocb); | ||
2537 | |||
2530 | /* | 2538 | /* |
2531 | * buffered reads protect themselves in ->readpage(). O_DIRECT reads | 2539 | * buffered reads protect themselves in ->readpage(). O_DIRECT reads |
2532 | * need locks to protect pending reads from racing with truncate. | 2540 | * need locks to protect pending reads from racing with truncate. |
@@ -2534,6 +2542,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
2534 | if (filp->f_flags & O_DIRECT) { | 2542 | if (filp->f_flags & O_DIRECT) { |
2535 | down_read(&inode->i_alloc_sem); | 2543 | down_read(&inode->i_alloc_sem); |
2536 | have_alloc_sem = 1; | 2544 | have_alloc_sem = 1; |
2545 | ocfs2_iocb_set_sem_locked(iocb); | ||
2537 | 2546 | ||
2538 | ret = ocfs2_rw_lock(inode, 0); | 2547 | ret = ocfs2_rw_lock(inode, 0); |
2539 | if (ret < 0) { | 2548 | if (ret < 0) { |
@@ -2575,8 +2584,10 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
2575 | } | 2584 | } |
2576 | 2585 | ||
2577 | bail: | 2586 | bail: |
2578 | if (have_alloc_sem) | 2587 | if (have_alloc_sem) { |
2579 | up_read(&inode->i_alloc_sem); | 2588 | up_read(&inode->i_alloc_sem); |
2589 | ocfs2_iocb_clear_sem_locked(iocb); | ||
2590 | } | ||
2580 | if (rw_level != -1) | 2591 | if (rw_level != -1) |
2581 | ocfs2_rw_unlock(inode, rw_level); | 2592 | ocfs2_rw_unlock(inode, rw_level); |
2582 | mlog_exit(ret); | 2593 | mlog_exit(ret); |