aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_lrw.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_lrw.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index e0ab45fbfebd..0169360475c4 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -83,7 +83,7 @@ xfs_rw_enter_trace(
83 (void *)((unsigned long)ioflags), 83 (void *)((unsigned long)ioflags),
84 (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), 84 (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
85 (void *)((unsigned long)(io->io_new_size & 0xffffffff)), 85 (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
86 (void *)NULL, 86 (void *)((unsigned long)current_pid()),
87 (void *)NULL, 87 (void *)NULL,
88 (void *)NULL, 88 (void *)NULL,
89 (void *)NULL, 89 (void *)NULL,
@@ -113,7 +113,7 @@ xfs_inval_cached_trace(
113 (void *)((unsigned long)(first & 0xffffffff)), 113 (void *)((unsigned long)(first & 0xffffffff)),
114 (void *)((unsigned long)((last >> 32) & 0xffffffff)), 114 (void *)((unsigned long)((last >> 32) & 0xffffffff)),
115 (void *)((unsigned long)(last & 0xffffffff)), 115 (void *)((unsigned long)(last & 0xffffffff)),
116 (void *)NULL, 116 (void *)((unsigned long)current_pid()),
117 (void *)NULL, 117 (void *)NULL,
118 (void *)NULL, 118 (void *)NULL,
119 (void *)NULL, 119 (void *)NULL,
@@ -249,9 +249,8 @@ xfs_read(
249 if (n < size) 249 if (n < size)
250 size = n; 250 size = n;
251 251
252 if (XFS_FORCED_SHUTDOWN(mp)) { 252 if (XFS_FORCED_SHUTDOWN(mp))
253 return -EIO; 253 return -EIO;
254 }
255 254
256 if (unlikely(ioflags & IO_ISDIRECT)) 255 if (unlikely(ioflags & IO_ISDIRECT))
257 mutex_lock(&inode->i_mutex); 256 mutex_lock(&inode->i_mutex);
@@ -267,10 +266,14 @@ xfs_read(
267 dmflags, &locktype); 266 dmflags, &locktype);
268 if (ret) { 267 if (ret) {
269 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 268 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
270 goto unlock_isem; 269 goto unlock_mutex;
271 } 270 }
272 } 271 }
273 272
273 if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp)))
274 VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(*offset)),
275 -1, FI_REMAPF_LOCKED);
276
274 xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, 277 xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
275 (void *)iovp, segs, *offset, ioflags); 278 (void *)iovp, segs, *offset, ioflags);
276 ret = __generic_file_aio_read(iocb, iovp, segs, offset); 279 ret = __generic_file_aio_read(iocb, iovp, segs, offset);
@@ -281,7 +284,7 @@ xfs_read(
281 284
282 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 285 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
283 286
284unlock_isem: 287unlock_mutex:
285 if (unlikely(ioflags & IO_ISDIRECT)) 288 if (unlikely(ioflags & IO_ISDIRECT))
286 mutex_unlock(&inode->i_mutex); 289 mutex_unlock(&inode->i_mutex);
287 return ret; 290 return ret;
@@ -432,7 +435,7 @@ xfs_zero_eof(
432 xfs_fsize_t isize, /* current inode size */ 435 xfs_fsize_t isize, /* current inode size */
433 xfs_fsize_t end_size) /* terminal inode size */ 436 xfs_fsize_t end_size) /* terminal inode size */
434{ 437{
435 struct inode *ip = LINVFS_GET_IP(vp); 438 struct inode *ip = vn_to_inode(vp);
436 xfs_fileoff_t start_zero_fsb; 439 xfs_fileoff_t start_zero_fsb;
437 xfs_fileoff_t end_zero_fsb; 440 xfs_fileoff_t end_zero_fsb;
438 xfs_fileoff_t zero_count_fsb; 441 xfs_fileoff_t zero_count_fsb;
@@ -573,7 +576,7 @@ xfs_write(
573 vrwlock_t locktype; 576 vrwlock_t locktype;
574 size_t ocount = 0, count; 577 size_t ocount = 0, count;
575 loff_t pos; 578 loff_t pos;
576 int need_isem = 1, need_flush = 0; 579 int need_i_mutex = 1, need_flush = 0;
577 580
578 XFS_STATS_INC(xs_write_calls); 581 XFS_STATS_INC(xs_write_calls);
579 582
@@ -622,14 +625,14 @@ xfs_write(
622 return XFS_ERROR(-EINVAL); 625 return XFS_ERROR(-EINVAL);
623 626
624 if (!VN_CACHED(vp) && pos < i_size_read(inode)) 627 if (!VN_CACHED(vp) && pos < i_size_read(inode))
625 need_isem = 0; 628 need_i_mutex = 0;
626 629
627 if (VN_CACHED(vp)) 630 if (VN_CACHED(vp))
628 need_flush = 1; 631 need_flush = 1;
629 } 632 }
630 633
631relock: 634relock:
632 if (need_isem) { 635 if (need_i_mutex) {
633 iolock = XFS_IOLOCK_EXCL; 636 iolock = XFS_IOLOCK_EXCL;
634 locktype = VRWLOCK_WRITE; 637 locktype = VRWLOCK_WRITE;
635 638
@@ -651,7 +654,7 @@ start:
651 S_ISBLK(inode->i_mode)); 654 S_ISBLK(inode->i_mode));
652 if (error) { 655 if (error) {
653 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 656 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
654 goto out_unlock_isem; 657 goto out_unlock_mutex;
655 } 658 }
656 659
657 new_size = pos + count; 660 new_size = pos + count;
@@ -663,7 +666,7 @@ start:
663 loff_t savedsize = pos; 666 loff_t savedsize = pos;
664 int dmflags = FILP_DELAY_FLAG(file); 667 int dmflags = FILP_DELAY_FLAG(file);
665 668
666 if (need_isem) 669 if (need_i_mutex)
667 dmflags |= DM_FLAGS_IMUX; 670 dmflags |= DM_FLAGS_IMUX;
668 671
669 xfs_iunlock(xip, XFS_ILOCK_EXCL); 672 xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -672,7 +675,7 @@ start:
672 dmflags, &locktype); 675 dmflags, &locktype);
673 if (error) { 676 if (error) {
674 xfs_iunlock(xip, iolock); 677 xfs_iunlock(xip, iolock);
675 goto out_unlock_isem; 678 goto out_unlock_mutex;
676 } 679 }
677 xfs_ilock(xip, XFS_ILOCK_EXCL); 680 xfs_ilock(xip, XFS_ILOCK_EXCL);
678 eventsent = 1; 681 eventsent = 1;
@@ -710,7 +713,7 @@ start:
710 isize, pos + count); 713 isize, pos + count);
711 if (error) { 714 if (error) {
712 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 715 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
713 goto out_unlock_isem; 716 goto out_unlock_mutex;
714 } 717 }
715 } 718 }
716 xfs_iunlock(xip, XFS_ILOCK_EXCL); 719 xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -731,7 +734,7 @@ start:
731 error = -remove_suid(file->f_dentry); 734 error = -remove_suid(file->f_dentry);
732 if (unlikely(error)) { 735 if (unlikely(error)) {
733 xfs_iunlock(xip, iolock); 736 xfs_iunlock(xip, iolock);
734 goto out_unlock_isem; 737 goto out_unlock_mutex;
735 } 738 }
736 } 739 }
737 740
@@ -747,14 +750,14 @@ retry:
747 -1, FI_REMAPF_LOCKED); 750 -1, FI_REMAPF_LOCKED);
748 } 751 }
749 752
750 if (need_isem) { 753 if (need_i_mutex) {
751 /* demote the lock now the cached pages are gone */ 754 /* demote the lock now the cached pages are gone */
752 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL); 755 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
753 mutex_unlock(&inode->i_mutex); 756 mutex_unlock(&inode->i_mutex);
754 757
755 iolock = XFS_IOLOCK_SHARED; 758 iolock = XFS_IOLOCK_SHARED;
756 locktype = VRWLOCK_WRITE_DIRECT; 759 locktype = VRWLOCK_WRITE_DIRECT;
757 need_isem = 0; 760 need_i_mutex = 0;
758 } 761 }
759 762
760 xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs, 763 xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
@@ -772,7 +775,7 @@ retry:
772 pos += ret; 775 pos += ret;
773 count -= ret; 776 count -= ret;
774 777
775 need_isem = 1; 778 need_i_mutex = 1;
776 ioflags &= ~IO_ISDIRECT; 779 ioflags &= ~IO_ISDIRECT;
777 xfs_iunlock(xip, iolock); 780 xfs_iunlock(xip, iolock);
778 goto relock; 781 goto relock;
@@ -794,14 +797,14 @@ retry:
794 !(ioflags & IO_INVIS)) { 797 !(ioflags & IO_INVIS)) {
795 798
796 xfs_rwunlock(bdp, locktype); 799 xfs_rwunlock(bdp, locktype);
797 if (need_isem) 800 if (need_i_mutex)
798 mutex_unlock(&inode->i_mutex); 801 mutex_unlock(&inode->i_mutex);
799 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, 802 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
800 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, 803 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
801 0, 0, 0); /* Delay flag intentionally unused */ 804 0, 0, 0); /* Delay flag intentionally unused */
802 if (error) 805 if (error)
803 goto out_nounlocks; 806 goto out_nounlocks;
804 if (need_isem) 807 if (need_i_mutex)
805 mutex_lock(&inode->i_mutex); 808 mutex_lock(&inode->i_mutex);
806 xfs_rwlock(bdp, locktype); 809 xfs_rwlock(bdp, locktype);
807 pos = xip->i_d.di_size; 810 pos = xip->i_d.di_size;
@@ -905,9 +908,9 @@ retry:
905 if (error) 908 if (error)
906 goto out_unlock_internal; 909 goto out_unlock_internal;
907 } 910 }
908 911
909 xfs_rwunlock(bdp, locktype); 912 xfs_rwunlock(bdp, locktype);
910 if (need_isem) 913 if (need_i_mutex)
911 mutex_unlock(&inode->i_mutex); 914 mutex_unlock(&inode->i_mutex);
912 915
913 error = sync_page_range(inode, mapping, pos, ret); 916 error = sync_page_range(inode, mapping, pos, ret);
@@ -918,8 +921,8 @@ retry:
918 921
919 out_unlock_internal: 922 out_unlock_internal:
920 xfs_rwunlock(bdp, locktype); 923 xfs_rwunlock(bdp, locktype);
921 out_unlock_isem: 924 out_unlock_mutex:
922 if (need_isem) 925 if (need_i_mutex)
923 mutex_unlock(&inode->i_mutex); 926 mutex_unlock(&inode->i_mutex);
924 out_nounlocks: 927 out_nounlocks:
925 return -error; 928 return -error;