diff options
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 3d7c082a8f58..93628b02ef5d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -200,7 +200,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
200 | 200 | ||
201 | mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); | 201 | mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); |
202 | 202 | ||
203 | ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); | 203 | ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); |
204 | if (ret != 0) { | 204 | if (ret != 0) { |
205 | if (ret == AOP_TRUNCATED_PAGE) | 205 | if (ret == AOP_TRUNCATED_PAGE) |
206 | unlock = 0; | 206 | unlock = 0; |
@@ -305,7 +305,7 @@ static int ocfs2_prepare_write(struct file *file, struct page *page, | |||
305 | 305 | ||
306 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); | 306 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); |
307 | 307 | ||
308 | ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); | 308 | ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); |
309 | if (ret != 0) { | 309 | if (ret != 0) { |
310 | mlog_errno(ret); | 310 | mlog_errno(ret); |
311 | goto out; | 311 | goto out; |
@@ -355,16 +355,16 @@ static int walk_page_buffers( handle_t *handle, | |||
355 | return ret; | 355 | return ret; |
356 | } | 356 | } |
357 | 357 | ||
358 | struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | 358 | handle_t *ocfs2_start_walk_page_trans(struct inode *inode, |
359 | struct page *page, | 359 | struct page *page, |
360 | unsigned from, | 360 | unsigned from, |
361 | unsigned to) | 361 | unsigned to) |
362 | { | 362 | { |
363 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 363 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
364 | struct ocfs2_journal_handle *handle = NULL; | 364 | handle_t *handle = NULL; |
365 | int ret = 0; | 365 | int ret = 0; |
366 | 366 | ||
367 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 367 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
368 | if (!handle) { | 368 | if (!handle) { |
369 | ret = -ENOMEM; | 369 | ret = -ENOMEM; |
370 | mlog_errno(ret); | 370 | mlog_errno(ret); |
@@ -372,7 +372,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | |||
372 | } | 372 | } |
373 | 373 | ||
374 | if (ocfs2_should_order_data(inode)) { | 374 | if (ocfs2_should_order_data(inode)) { |
375 | ret = walk_page_buffers(handle->k_handle, | 375 | ret = walk_page_buffers(handle, |
376 | page_buffers(page), | 376 | page_buffers(page), |
377 | from, to, NULL, | 377 | from, to, NULL, |
378 | ocfs2_journal_dirty_data); | 378 | ocfs2_journal_dirty_data); |
@@ -382,7 +382,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | |||
382 | out: | 382 | out: |
383 | if (ret) { | 383 | if (ret) { |
384 | if (handle) | 384 | if (handle) |
385 | ocfs2_commit_trans(handle); | 385 | ocfs2_commit_trans(osb, handle); |
386 | handle = ERR_PTR(ret); | 386 | handle = ERR_PTR(ret); |
387 | } | 387 | } |
388 | return handle; | 388 | return handle; |
@@ -394,7 +394,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
394 | int ret; | 394 | int ret; |
395 | struct buffer_head *di_bh = NULL; | 395 | struct buffer_head *di_bh = NULL; |
396 | struct inode *inode = page->mapping->host; | 396 | struct inode *inode = page->mapping->host; |
397 | struct ocfs2_journal_handle *handle = NULL; | 397 | handle_t *handle = NULL; |
398 | struct ocfs2_dinode *di; | 398 | struct ocfs2_dinode *di; |
399 | 399 | ||
400 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); | 400 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); |
@@ -412,7 +412,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
412 | * stale inode allocation image (i_size, i_clusters, etc). | 412 | * stale inode allocation image (i_size, i_clusters, etc). |
413 | */ | 413 | */ |
414 | 414 | ||
415 | ret = ocfs2_meta_lock_with_page(inode, NULL, &di_bh, 1, page); | 415 | ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); |
416 | if (ret != 0) { | 416 | if (ret != 0) { |
417 | mlog_errno(ret); | 417 | mlog_errno(ret); |
418 | goto out; | 418 | goto out; |
@@ -464,7 +464,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
464 | } | 464 | } |
465 | 465 | ||
466 | out_commit: | 466 | out_commit: |
467 | ocfs2_commit_trans(handle); | 467 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
468 | out_unlock_data: | 468 | out_unlock_data: |
469 | ocfs2_data_unlock(inode, 1); | 469 | ocfs2_data_unlock(inode, 1); |
470 | out_unlock_meta: | 470 | out_unlock_meta: |
@@ -490,7 +490,7 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) | |||
490 | * accessed concurrently from multiple nodes. | 490 | * accessed concurrently from multiple nodes. |
491 | */ | 491 | */ |
492 | if (!INODE_JOURNAL(inode)) { | 492 | if (!INODE_JOURNAL(inode)) { |
493 | err = ocfs2_meta_lock(inode, NULL, NULL, 0); | 493 | err = ocfs2_meta_lock(inode, NULL, 0); |
494 | if (err) { | 494 | if (err) { |
495 | if (err != -ENOENT) | 495 | if (err != -ENOENT) |
496 | mlog_errno(err); | 496 | mlog_errno(err); |
@@ -540,8 +540,7 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
540 | struct buffer_head *bh_result, int create) | 540 | struct buffer_head *bh_result, int create) |
541 | { | 541 | { |
542 | int ret; | 542 | int ret; |
543 | u64 vbo_max; /* file offset, max_blocks from iblock */ | 543 | u64 p_blkno, inode_blocks; |
544 | u64 p_blkno; | ||
545 | int contig_blocks; | 544 | int contig_blocks; |
546 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | 545 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; |
547 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; | 546 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; |
@@ -550,12 +549,23 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
550 | * nicely aligned and of the right size, so there's no need | 549 | * nicely aligned and of the right size, so there's no need |
551 | * for us to check any of that. */ | 550 | * for us to check any of that. */ |
552 | 551 | ||
553 | vbo_max = ((u64)iblock + max_blocks) << blocksize_bits; | ||
554 | |||
555 | spin_lock(&OCFS2_I(inode)->ip_lock); | 552 | spin_lock(&OCFS2_I(inode)->ip_lock); |
556 | if ((iblock + max_blocks) > | 553 | inode_blocks = ocfs2_clusters_to_blocks(inode->i_sb, |
557 | ocfs2_clusters_to_blocks(inode->i_sb, | 554 | OCFS2_I(inode)->ip_clusters); |
558 | OCFS2_I(inode)->ip_clusters)) { | 555 | |
556 | /* | ||
557 | * For a read which begins past the end of file, we return a hole. | ||
558 | */ | ||
559 | if (!create && (iblock >= inode_blocks)) { | ||
560 | spin_unlock(&OCFS2_I(inode)->ip_lock); | ||
561 | ret = 0; | ||
562 | goto bail; | ||
563 | } | ||
564 | |||
565 | /* | ||
566 | * Any write past EOF is not allowed because we'd be extending. | ||
567 | */ | ||
568 | if (create && (iblock + max_blocks) > inode_blocks) { | ||
559 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 569 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
560 | ret = -EIO; | 570 | ret = -EIO; |
561 | goto bail; | 571 | goto bail; |
@@ -595,7 +605,7 @@ static void ocfs2_dio_end_io(struct kiocb *iocb, | |||
595 | ssize_t bytes, | 605 | ssize_t bytes, |
596 | void *private) | 606 | void *private) |
597 | { | 607 | { |
598 | struct inode *inode = iocb->ki_filp->f_dentry->d_inode; | 608 | struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; |
599 | 609 | ||
600 | /* this io's submitter should not have unlocked this before we could */ | 610 | /* this io's submitter should not have unlocked this before we could */ |
601 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); | 611 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); |
@@ -611,7 +621,7 @@ static ssize_t ocfs2_direct_IO(int rw, | |||
611 | unsigned long nr_segs) | 621 | unsigned long nr_segs) |
612 | { | 622 | { |
613 | struct file *file = iocb->ki_filp; | 623 | struct file *file = iocb->ki_filp; |
614 | struct inode *inode = file->f_dentry->d_inode->i_mapping->host; | 624 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; |
615 | int ret; | 625 | int ret; |
616 | 626 | ||
617 | mlog_entry_void(); | 627 | mlog_entry_void(); |