diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_lrw.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.c | 104 |
1 files changed, 43 insertions, 61 deletions
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 7e7aeb4c8a08..d6a8dddb2268 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "xfs_buf_item.h" | 48 | #include "xfs_buf_item.h" |
49 | #include "xfs_utils.h" | 49 | #include "xfs_utils.h" |
50 | #include "xfs_iomap.h" | 50 | #include "xfs_iomap.h" |
51 | #include "xfs_vnodeops.h" | ||
51 | 52 | ||
52 | #include <linux/capability.h> | 53 | #include <linux/capability.h> |
53 | #include <linux/writeback.h> | 54 | #include <linux/writeback.h> |
@@ -169,27 +170,22 @@ xfs_iozero( | |||
169 | 170 | ||
170 | ssize_t /* bytes read, or (-) error */ | 171 | ssize_t /* bytes read, or (-) error */ |
171 | xfs_read( | 172 | xfs_read( |
172 | bhv_desc_t *bdp, | 173 | xfs_inode_t *ip, |
173 | struct kiocb *iocb, | 174 | struct kiocb *iocb, |
174 | const struct iovec *iovp, | 175 | const struct iovec *iovp, |
175 | unsigned int segs, | 176 | unsigned int segs, |
176 | loff_t *offset, | 177 | loff_t *offset, |
177 | int ioflags, | 178 | int ioflags) |
178 | cred_t *credp) | ||
179 | { | 179 | { |
180 | struct file *file = iocb->ki_filp; | 180 | struct file *file = iocb->ki_filp; |
181 | struct inode *inode = file->f_mapping->host; | 181 | struct inode *inode = file->f_mapping->host; |
182 | bhv_vnode_t *vp = XFS_ITOV(ip); | ||
183 | xfs_mount_t *mp = ip->i_mount; | ||
182 | size_t size = 0; | 184 | size_t size = 0; |
183 | ssize_t ret = 0; | 185 | ssize_t ret = 0; |
184 | xfs_fsize_t n; | 186 | xfs_fsize_t n; |
185 | xfs_inode_t *ip; | ||
186 | xfs_mount_t *mp; | ||
187 | bhv_vnode_t *vp; | ||
188 | unsigned long seg; | 187 | unsigned long seg; |
189 | 188 | ||
190 | ip = XFS_BHVTOI(bdp); | ||
191 | vp = BHV_TO_VNODE(bdp); | ||
192 | mp = ip->i_mount; | ||
193 | 189 | ||
194 | XFS_STATS_INC(xs_read_calls); | 190 | XFS_STATS_INC(xs_read_calls); |
195 | 191 | ||
@@ -234,13 +230,11 @@ xfs_read( | |||
234 | mutex_lock(&inode->i_mutex); | 230 | mutex_lock(&inode->i_mutex); |
235 | xfs_ilock(ip, XFS_IOLOCK_SHARED); | 231 | xfs_ilock(ip, XFS_IOLOCK_SHARED); |
236 | 232 | ||
237 | if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) && | 233 | if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) { |
238 | !(ioflags & IO_INVIS)) { | ||
239 | bhv_vrwlock_t locktype = VRWLOCK_READ; | 234 | bhv_vrwlock_t locktype = VRWLOCK_READ; |
240 | int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags); | 235 | int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags); |
241 | 236 | ||
242 | ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, | 237 | ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *offset, size, |
243 | BHV_TO_VNODE(bdp), *offset, size, | ||
244 | dmflags, &locktype); | 238 | dmflags, &locktype); |
245 | if (ret) { | 239 | if (ret) { |
246 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 240 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
@@ -252,8 +246,9 @@ xfs_read( | |||
252 | 246 | ||
253 | if (unlikely(ioflags & IO_ISDIRECT)) { | 247 | if (unlikely(ioflags & IO_ISDIRECT)) { |
254 | if (VN_CACHED(vp)) | 248 | if (VN_CACHED(vp)) |
255 | ret = bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)), | 249 | ret = xfs_flushinval_pages(ip, |
256 | -1, FI_REMAPF_LOCKED); | 250 | ctooff(offtoct(*offset)), |
251 | -1, FI_REMAPF_LOCKED); | ||
257 | mutex_unlock(&inode->i_mutex); | 252 | mutex_unlock(&inode->i_mutex); |
258 | if (ret) { | 253 | if (ret) { |
259 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 254 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
@@ -277,16 +272,15 @@ xfs_read( | |||
277 | 272 | ||
278 | ssize_t | 273 | ssize_t |
279 | xfs_splice_read( | 274 | xfs_splice_read( |
280 | bhv_desc_t *bdp, | 275 | xfs_inode_t *ip, |
281 | struct file *infilp, | 276 | struct file *infilp, |
282 | loff_t *ppos, | 277 | loff_t *ppos, |
283 | struct pipe_inode_info *pipe, | 278 | struct pipe_inode_info *pipe, |
284 | size_t count, | 279 | size_t count, |
285 | int flags, | 280 | int flags, |
286 | int ioflags, | 281 | int ioflags) |
287 | cred_t *credp) | ||
288 | { | 282 | { |
289 | xfs_inode_t *ip = XFS_BHVTOI(bdp); | 283 | bhv_vnode_t *vp = XFS_ITOV(ip); |
290 | xfs_mount_t *mp = ip->i_mount; | 284 | xfs_mount_t *mp = ip->i_mount; |
291 | ssize_t ret; | 285 | ssize_t ret; |
292 | 286 | ||
@@ -296,13 +290,11 @@ xfs_splice_read( | |||
296 | 290 | ||
297 | xfs_ilock(ip, XFS_IOLOCK_SHARED); | 291 | xfs_ilock(ip, XFS_IOLOCK_SHARED); |
298 | 292 | ||
299 | if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) && | 293 | if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) { |
300 | (!(ioflags & IO_INVIS))) { | ||
301 | bhv_vrwlock_t locktype = VRWLOCK_READ; | 294 | bhv_vrwlock_t locktype = VRWLOCK_READ; |
302 | int error; | 295 | int error; |
303 | 296 | ||
304 | error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), | 297 | error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *ppos, count, |
305 | *ppos, count, | ||
306 | FILP_DELAY_FLAG(infilp), &locktype); | 298 | FILP_DELAY_FLAG(infilp), &locktype); |
307 | if (error) { | 299 | if (error) { |
308 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 300 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
@@ -321,16 +313,15 @@ xfs_splice_read( | |||
321 | 313 | ||
322 | ssize_t | 314 | ssize_t |
323 | xfs_splice_write( | 315 | xfs_splice_write( |
324 | bhv_desc_t *bdp, | 316 | xfs_inode_t *ip, |
325 | struct pipe_inode_info *pipe, | 317 | struct pipe_inode_info *pipe, |
326 | struct file *outfilp, | 318 | struct file *outfilp, |
327 | loff_t *ppos, | 319 | loff_t *ppos, |
328 | size_t count, | 320 | size_t count, |
329 | int flags, | 321 | int flags, |
330 | int ioflags, | 322 | int ioflags) |
331 | cred_t *credp) | ||
332 | { | 323 | { |
333 | xfs_inode_t *ip = XFS_BHVTOI(bdp); | 324 | bhv_vnode_t *vp = XFS_ITOV(ip); |
334 | xfs_mount_t *mp = ip->i_mount; | 325 | xfs_mount_t *mp = ip->i_mount; |
335 | xfs_iocore_t *io = &ip->i_iocore; | 326 | xfs_iocore_t *io = &ip->i_iocore; |
336 | ssize_t ret; | 327 | ssize_t ret; |
@@ -343,13 +334,11 @@ xfs_splice_write( | |||
343 | 334 | ||
344 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 335 | xfs_ilock(ip, XFS_IOLOCK_EXCL); |
345 | 336 | ||
346 | if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_WRITE) && | 337 | if (DM_EVENT_ENABLED(ip, DM_EVENT_WRITE) && !(ioflags & IO_INVIS)) { |
347 | (!(ioflags & IO_INVIS))) { | ||
348 | bhv_vrwlock_t locktype = VRWLOCK_WRITE; | 338 | bhv_vrwlock_t locktype = VRWLOCK_WRITE; |
349 | int error; | 339 | int error; |
350 | 340 | ||
351 | error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp), | 341 | error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp, *ppos, count, |
352 | *ppos, count, | ||
353 | FILP_DELAY_FLAG(outfilp), &locktype); | 342 | FILP_DELAY_FLAG(outfilp), &locktype); |
354 | if (error) { | 343 | if (error) { |
355 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 344 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); |
@@ -583,24 +572,22 @@ out_lock: | |||
583 | 572 | ||
584 | ssize_t /* bytes written, or (-) error */ | 573 | ssize_t /* bytes written, or (-) error */ |
585 | xfs_write( | 574 | xfs_write( |
586 | bhv_desc_t *bdp, | 575 | struct xfs_inode *xip, |
587 | struct kiocb *iocb, | 576 | struct kiocb *iocb, |
588 | const struct iovec *iovp, | 577 | const struct iovec *iovp, |
589 | unsigned int nsegs, | 578 | unsigned int nsegs, |
590 | loff_t *offset, | 579 | loff_t *offset, |
591 | int ioflags, | 580 | int ioflags) |
592 | cred_t *credp) | ||
593 | { | 581 | { |
594 | struct file *file = iocb->ki_filp; | 582 | struct file *file = iocb->ki_filp; |
595 | struct address_space *mapping = file->f_mapping; | 583 | struct address_space *mapping = file->f_mapping; |
596 | struct inode *inode = mapping->host; | 584 | struct inode *inode = mapping->host; |
585 | bhv_vnode_t *vp = XFS_ITOV(xip); | ||
597 | unsigned long segs = nsegs; | 586 | unsigned long segs = nsegs; |
598 | xfs_inode_t *xip; | ||
599 | xfs_mount_t *mp; | 587 | xfs_mount_t *mp; |
600 | ssize_t ret = 0, error = 0; | 588 | ssize_t ret = 0, error = 0; |
601 | xfs_fsize_t isize, new_size; | 589 | xfs_fsize_t isize, new_size; |
602 | xfs_iocore_t *io; | 590 | xfs_iocore_t *io; |
603 | bhv_vnode_t *vp; | ||
604 | int iolock; | 591 | int iolock; |
605 | int eventsent = 0; | 592 | int eventsent = 0; |
606 | bhv_vrwlock_t locktype; | 593 | bhv_vrwlock_t locktype; |
@@ -610,9 +597,6 @@ xfs_write( | |||
610 | 597 | ||
611 | XFS_STATS_INC(xs_write_calls); | 598 | XFS_STATS_INC(xs_write_calls); |
612 | 599 | ||
613 | vp = BHV_TO_VNODE(bdp); | ||
614 | xip = XFS_BHVTOI(bdp); | ||
615 | |||
616 | error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ); | 600 | error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ); |
617 | if (error) | 601 | if (error) |
618 | return error; | 602 | return error; |
@@ -626,7 +610,7 @@ xfs_write( | |||
626 | io = &xip->i_iocore; | 610 | io = &xip->i_iocore; |
627 | mp = io->io_mount; | 611 | mp = io->io_mount; |
628 | 612 | ||
629 | vfs_wait_for_freeze(vp->v_vfsp, SB_FREEZE_WRITE); | 613 | xfs_wait_for_freeze(mp, SB_FREEZE_WRITE); |
630 | 614 | ||
631 | if (XFS_FORCED_SHUTDOWN(mp)) | 615 | if (XFS_FORCED_SHUTDOWN(mp)) |
632 | return -EIO; | 616 | return -EIO; |
@@ -653,7 +637,7 @@ start: | |||
653 | goto out_unlock_mutex; | 637 | goto out_unlock_mutex; |
654 | } | 638 | } |
655 | 639 | ||
656 | if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) && | 640 | if ((DM_EVENT_ENABLED(xip, DM_EVENT_WRITE) && |
657 | !(ioflags & IO_INVIS) && !eventsent)) { | 641 | !(ioflags & IO_INVIS) && !eventsent)) { |
658 | int dmflags = FILP_DELAY_FLAG(file); | 642 | int dmflags = FILP_DELAY_FLAG(file); |
659 | 643 | ||
@@ -722,7 +706,7 @@ start: | |||
722 | */ | 706 | */ |
723 | 707 | ||
724 | if (pos > xip->i_size) { | 708 | if (pos > xip->i_size) { |
725 | error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, xip->i_size); | 709 | error = xfs_zero_eof(vp, io, pos, xip->i_size); |
726 | if (error) { | 710 | if (error) { |
727 | xfs_iunlock(xip, XFS_ILOCK_EXCL); | 711 | xfs_iunlock(xip, XFS_ILOCK_EXCL); |
728 | goto out_unlock_internal; | 712 | goto out_unlock_internal; |
@@ -758,7 +742,8 @@ retry: | |||
758 | WARN_ON(need_i_mutex == 0); | 742 | WARN_ON(need_i_mutex == 0); |
759 | xfs_inval_cached_trace(io, pos, -1, | 743 | xfs_inval_cached_trace(io, pos, -1, |
760 | ctooff(offtoct(pos)), -1); | 744 | ctooff(offtoct(pos)), -1); |
761 | error = bhv_vop_flushinval_pages(vp, ctooff(offtoct(pos)), | 745 | error = xfs_flushinval_pages(xip, |
746 | ctooff(offtoct(pos)), | ||
762 | -1, FI_REMAPF_LOCKED); | 747 | -1, FI_REMAPF_LOCKED); |
763 | if (error) | 748 | if (error) |
764 | goto out_unlock_internal; | 749 | goto out_unlock_internal; |
@@ -805,11 +790,9 @@ retry: | |||
805 | if (ret == -EIOCBQUEUED && !(ioflags & IO_ISAIO)) | 790 | if (ret == -EIOCBQUEUED && !(ioflags & IO_ISAIO)) |
806 | ret = wait_on_sync_kiocb(iocb); | 791 | ret = wait_on_sync_kiocb(iocb); |
807 | 792 | ||
808 | if ((ret == -ENOSPC) && | 793 | if (ret == -ENOSPC && |
809 | DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) && | 794 | DM_EVENT_ENABLED(xip, DM_EVENT_NOSPACE) && !(ioflags & IO_INVIS)) { |
810 | !(ioflags & IO_INVIS)) { | 795 | xfs_rwunlock(xip, locktype); |
811 | |||
812 | xfs_rwunlock(bdp, locktype); | ||
813 | if (need_i_mutex) | 796 | if (need_i_mutex) |
814 | mutex_unlock(&inode->i_mutex); | 797 | mutex_unlock(&inode->i_mutex); |
815 | error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, | 798 | error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, |
@@ -817,7 +800,7 @@ retry: | |||
817 | 0, 0, 0); /* Delay flag intentionally unused */ | 800 | 0, 0, 0); /* Delay flag intentionally unused */ |
818 | if (need_i_mutex) | 801 | if (need_i_mutex) |
819 | mutex_lock(&inode->i_mutex); | 802 | mutex_lock(&inode->i_mutex); |
820 | xfs_rwlock(bdp, locktype); | 803 | xfs_rwlock(xip, locktype); |
821 | if (error) | 804 | if (error) |
822 | goto out_unlock_internal; | 805 | goto out_unlock_internal; |
823 | pos = xip->i_size; | 806 | pos = xip->i_size; |
@@ -844,20 +827,19 @@ retry: | |||
844 | 827 | ||
845 | /* Handle various SYNC-type writes */ | 828 | /* Handle various SYNC-type writes */ |
846 | if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { | 829 | if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { |
847 | error = xfs_write_sync_logforce(mp, xip); | 830 | int error2; |
848 | if (error) | 831 | xfs_rwunlock(xip, locktype); |
849 | goto out_unlock_internal; | ||
850 | |||
851 | xfs_rwunlock(bdp, locktype); | ||
852 | if (need_i_mutex) | 832 | if (need_i_mutex) |
853 | mutex_unlock(&inode->i_mutex); | 833 | mutex_unlock(&inode->i_mutex); |
854 | 834 | error2 = sync_page_range(inode, mapping, pos, ret); | |
855 | error = sync_page_range(inode, mapping, pos, ret); | ||
856 | if (!error) | 835 | if (!error) |
857 | error = -ret; | 836 | error = error2; |
858 | if (need_i_mutex) | 837 | if (need_i_mutex) |
859 | mutex_lock(&inode->i_mutex); | 838 | mutex_lock(&inode->i_mutex); |
860 | xfs_rwlock(bdp, locktype); | 839 | xfs_rwlock(xip, locktype); |
840 | error2 = xfs_write_sync_logforce(mp, xip); | ||
841 | if (!error) | ||
842 | error = error2; | ||
861 | } | 843 | } |
862 | 844 | ||
863 | out_unlock_internal: | 845 | out_unlock_internal: |
@@ -875,7 +857,7 @@ retry: | |||
875 | xip->i_d.di_size = xip->i_size; | 857 | xip->i_d.di_size = xip->i_size; |
876 | xfs_iunlock(xip, XFS_ILOCK_EXCL); | 858 | xfs_iunlock(xip, XFS_ILOCK_EXCL); |
877 | } | 859 | } |
878 | xfs_rwunlock(bdp, locktype); | 860 | xfs_rwunlock(xip, locktype); |
879 | out_unlock_mutex: | 861 | out_unlock_mutex: |
880 | if (need_i_mutex) | 862 | if (need_i_mutex) |
881 | mutex_unlock(&inode->i_mutex); | 863 | mutex_unlock(&inode->i_mutex); |
@@ -914,14 +896,14 @@ xfs_bdstrat_cb(struct xfs_buf *bp) | |||
914 | 896 | ||
915 | 897 | ||
916 | int | 898 | int |
917 | xfs_bmap(bhv_desc_t *bdp, | 899 | xfs_bmap( |
900 | xfs_inode_t *ip, | ||
918 | xfs_off_t offset, | 901 | xfs_off_t offset, |
919 | ssize_t count, | 902 | ssize_t count, |
920 | int flags, | 903 | int flags, |
921 | xfs_iomap_t *iomapp, | 904 | xfs_iomap_t *iomapp, |
922 | int *niomaps) | 905 | int *niomaps) |
923 | { | 906 | { |
924 | xfs_inode_t *ip = XFS_BHVTOI(bdp); | ||
925 | xfs_iocore_t *io = &ip->i_iocore; | 907 | xfs_iocore_t *io = &ip->i_iocore; |
926 | 908 | ||
927 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); | 909 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); |