aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_aops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_aops.c')
-rw-r--r--fs/xfs/xfs_aops.c79
1 files changed, 47 insertions, 32 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 8dad722c0041..15052ff916ec 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -179,7 +179,7 @@ xfs_finish_ioend(
179 if (atomic_dec_and_test(&ioend->io_remaining)) { 179 if (atomic_dec_and_test(&ioend->io_remaining)) {
180 struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount; 180 struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount;
181 181
182 if (ioend->io_type == IO_UNWRITTEN) 182 if (ioend->io_type == XFS_IO_UNWRITTEN)
183 queue_work(mp->m_unwritten_workqueue, &ioend->io_work); 183 queue_work(mp->m_unwritten_workqueue, &ioend->io_work);
184 else if (ioend->io_append_trans) 184 else if (ioend->io_append_trans)
185 queue_work(mp->m_data_workqueue, &ioend->io_work); 185 queue_work(mp->m_data_workqueue, &ioend->io_work);
@@ -210,7 +210,7 @@ xfs_end_io(
210 * For unwritten extents we need to issue transactions to convert a 210 * For unwritten extents we need to issue transactions to convert a
211 * range to normal written extens after the data I/O has finished. 211 * range to normal written extens after the data I/O has finished.
212 */ 212 */
213 if (ioend->io_type == IO_UNWRITTEN) { 213 if (ioend->io_type == XFS_IO_UNWRITTEN) {
214 /* 214 /*
215 * For buffered I/O we never preallocate a transaction when 215 * For buffered I/O we never preallocate a transaction when
216 * doing the unwritten extent conversion, but for direct I/O 216 * doing the unwritten extent conversion, but for direct I/O
@@ -312,7 +312,7 @@ xfs_map_blocks(
312 if (XFS_FORCED_SHUTDOWN(mp)) 312 if (XFS_FORCED_SHUTDOWN(mp))
313 return -XFS_ERROR(EIO); 313 return -XFS_ERROR(EIO);
314 314
315 if (type == IO_UNWRITTEN) 315 if (type == XFS_IO_UNWRITTEN)
316 bmapi_flags |= XFS_BMAPI_IGSTATE; 316 bmapi_flags |= XFS_BMAPI_IGSTATE;
317 317
318 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { 318 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
@@ -323,10 +323,10 @@ xfs_map_blocks(
323 323
324 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || 324 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
325 (ip->i_df.if_flags & XFS_IFEXTENTS)); 325 (ip->i_df.if_flags & XFS_IFEXTENTS));
326 ASSERT(offset <= mp->m_maxioffset); 326 ASSERT(offset <= mp->m_super->s_maxbytes);
327 327
328 if (offset + count > mp->m_maxioffset) 328 if (offset + count > mp->m_super->s_maxbytes)
329 count = mp->m_maxioffset - offset; 329 count = mp->m_super->s_maxbytes - offset;
330 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); 330 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
331 offset_fsb = XFS_B_TO_FSBT(mp, offset); 331 offset_fsb = XFS_B_TO_FSBT(mp, offset);
332 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, 332 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
@@ -336,7 +336,7 @@ xfs_map_blocks(
336 if (error) 336 if (error)
337 return -XFS_ERROR(error); 337 return -XFS_ERROR(error);
338 338
339 if (type == IO_DELALLOC && 339 if (type == XFS_IO_DELALLOC &&
340 (!nimaps || isnullstartblock(imap->br_startblock))) { 340 (!nimaps || isnullstartblock(imap->br_startblock))) {
341 error = xfs_iomap_write_allocate(ip, offset, count, imap); 341 error = xfs_iomap_write_allocate(ip, offset, count, imap);
342 if (!error) 342 if (!error)
@@ -345,7 +345,7 @@ xfs_map_blocks(
345 } 345 }
346 346
347#ifdef DEBUG 347#ifdef DEBUG
348 if (type == IO_UNWRITTEN) { 348 if (type == XFS_IO_UNWRITTEN) {
349 ASSERT(nimaps); 349 ASSERT(nimaps);
350 ASSERT(imap->br_startblock != HOLESTARTBLOCK); 350 ASSERT(imap->br_startblock != HOLESTARTBLOCK);
351 ASSERT(imap->br_startblock != DELAYSTARTBLOCK); 351 ASSERT(imap->br_startblock != DELAYSTARTBLOCK);
@@ -634,11 +634,11 @@ xfs_check_page_type(
634 bh = head = page_buffers(page); 634 bh = head = page_buffers(page);
635 do { 635 do {
636 if (buffer_unwritten(bh)) 636 if (buffer_unwritten(bh))
637 acceptable += (type == IO_UNWRITTEN); 637 acceptable += (type == XFS_IO_UNWRITTEN);
638 else if (buffer_delay(bh)) 638 else if (buffer_delay(bh))
639 acceptable += (type == IO_DELALLOC); 639 acceptable += (type == XFS_IO_DELALLOC);
640 else if (buffer_dirty(bh) && buffer_mapped(bh)) 640 else if (buffer_dirty(bh) && buffer_mapped(bh))
641 acceptable += (type == IO_OVERWRITE); 641 acceptable += (type == XFS_IO_OVERWRITE);
642 else 642 else
643 break; 643 break;
644 } while ((bh = bh->b_this_page) != head); 644 } while ((bh = bh->b_this_page) != head);
@@ -721,11 +721,11 @@ xfs_convert_page(
721 if (buffer_unwritten(bh) || buffer_delay(bh) || 721 if (buffer_unwritten(bh) || buffer_delay(bh) ||
722 buffer_mapped(bh)) { 722 buffer_mapped(bh)) {
723 if (buffer_unwritten(bh)) 723 if (buffer_unwritten(bh))
724 type = IO_UNWRITTEN; 724 type = XFS_IO_UNWRITTEN;
725 else if (buffer_delay(bh)) 725 else if (buffer_delay(bh))
726 type = IO_DELALLOC; 726 type = XFS_IO_DELALLOC;
727 else 727 else
728 type = IO_OVERWRITE; 728 type = XFS_IO_OVERWRITE;
729 729
730 if (!xfs_imap_valid(inode, imap, offset)) { 730 if (!xfs_imap_valid(inode, imap, offset)) {
731 done = 1; 731 done = 1;
@@ -733,7 +733,7 @@ xfs_convert_page(
733 } 733 }
734 734
735 lock_buffer(bh); 735 lock_buffer(bh);
736 if (type != IO_OVERWRITE) 736 if (type != XFS_IO_OVERWRITE)
737 xfs_map_at_offset(inode, bh, imap, offset); 737 xfs_map_at_offset(inode, bh, imap, offset);
738 xfs_add_to_ioend(inode, bh, offset, type, 738 xfs_add_to_ioend(inode, bh, offset, type,
739 ioendp, done); 739 ioendp, done);
@@ -831,7 +831,7 @@ xfs_aops_discard_page(
831 struct buffer_head *bh, *head; 831 struct buffer_head *bh, *head;
832 loff_t offset = page_offset(page); 832 loff_t offset = page_offset(page);
833 833
834 if (!xfs_check_page_type(page, IO_DELALLOC)) 834 if (!xfs_check_page_type(page, XFS_IO_DELALLOC))
835 goto out_invalidate; 835 goto out_invalidate;
836 836
837 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 837 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
@@ -927,11 +927,26 @@ xfs_vm_writepage(
927 end_index = offset >> PAGE_CACHE_SHIFT; 927 end_index = offset >> PAGE_CACHE_SHIFT;
928 last_index = (offset - 1) >> PAGE_CACHE_SHIFT; 928 last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
929 if (page->index >= end_index) { 929 if (page->index >= end_index) {
930 if ((page->index >= end_index + 1) || 930 unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
931 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { 931
932 /*
933 * Just skip the page if it is fully outside i_size, e.g. due
934 * to a truncate operation that is in progress.
935 */
936 if (page->index >= end_index + 1 || offset_into_page == 0) {
932 unlock_page(page); 937 unlock_page(page);
933 return 0; 938 return 0;
934 } 939 }
940
941 /*
942 * The page straddles i_size. It must be zeroed out on each
943 * and every writepage invocation because it may be mmapped.
944 * "A file is mapped in multiples of the page size. For a file
945 * that is not a multiple of the page size, the remaining
946 * memory is zeroed when mapped, and writes to that region are
947 * not written out to the file."
948 */
949 zero_user_segment(page, offset_into_page, PAGE_CACHE_SIZE);
935 } 950 }
936 951
937 end_offset = min_t(unsigned long long, 952 end_offset = min_t(unsigned long long,
@@ -941,7 +956,7 @@ xfs_vm_writepage(
941 956
942 bh = head = page_buffers(page); 957 bh = head = page_buffers(page);
943 offset = page_offset(page); 958 offset = page_offset(page);
944 type = IO_OVERWRITE; 959 type = XFS_IO_OVERWRITE;
945 960
946 if (wbc->sync_mode == WB_SYNC_NONE) 961 if (wbc->sync_mode == WB_SYNC_NONE)
947 nonblocking = 1; 962 nonblocking = 1;
@@ -966,18 +981,18 @@ xfs_vm_writepage(
966 } 981 }
967 982
968 if (buffer_unwritten(bh)) { 983 if (buffer_unwritten(bh)) {
969 if (type != IO_UNWRITTEN) { 984 if (type != XFS_IO_UNWRITTEN) {
970 type = IO_UNWRITTEN; 985 type = XFS_IO_UNWRITTEN;
971 imap_valid = 0; 986 imap_valid = 0;
972 } 987 }
973 } else if (buffer_delay(bh)) { 988 } else if (buffer_delay(bh)) {
974 if (type != IO_DELALLOC) { 989 if (type != XFS_IO_DELALLOC) {
975 type = IO_DELALLOC; 990 type = XFS_IO_DELALLOC;
976 imap_valid = 0; 991 imap_valid = 0;
977 } 992 }
978 } else if (buffer_uptodate(bh)) { 993 } else if (buffer_uptodate(bh)) {
979 if (type != IO_OVERWRITE) { 994 if (type != XFS_IO_OVERWRITE) {
980 type = IO_OVERWRITE; 995 type = XFS_IO_OVERWRITE;
981 imap_valid = 0; 996 imap_valid = 0;
982 } 997 }
983 } else { 998 } else {
@@ -1013,7 +1028,7 @@ xfs_vm_writepage(
1013 } 1028 }
1014 if (imap_valid) { 1029 if (imap_valid) {
1015 lock_buffer(bh); 1030 lock_buffer(bh);
1016 if (type != IO_OVERWRITE) 1031 if (type != XFS_IO_OVERWRITE)
1017 xfs_map_at_offset(inode, bh, &imap, offset); 1032 xfs_map_at_offset(inode, bh, &imap, offset);
1018 xfs_add_to_ioend(inode, bh, offset, type, &ioend, 1033 xfs_add_to_ioend(inode, bh, offset, type, &ioend,
1019 new_ioend); 1034 new_ioend);
@@ -1054,7 +1069,7 @@ xfs_vm_writepage(
1054 * Reserve log space if we might write beyond the on-disk 1069 * Reserve log space if we might write beyond the on-disk
1055 * inode size. 1070 * inode size.
1056 */ 1071 */
1057 if (ioend->io_type != IO_UNWRITTEN && 1072 if (ioend->io_type != XFS_IO_UNWRITTEN &&
1058 xfs_ioend_is_append(ioend)) { 1073 xfs_ioend_is_append(ioend)) {
1059 err = xfs_setfilesize_trans_alloc(ioend); 1074 err = xfs_setfilesize_trans_alloc(ioend);
1060 if (err) 1075 if (err)
@@ -1162,9 +1177,9 @@ __xfs_get_blocks(
1162 lockmode = xfs_ilock_map_shared(ip); 1177 lockmode = xfs_ilock_map_shared(ip);
1163 } 1178 }
1164 1179
1165 ASSERT(offset <= mp->m_maxioffset); 1180 ASSERT(offset <= mp->m_super->s_maxbytes);
1166 if (offset + size > mp->m_maxioffset) 1181 if (offset + size > mp->m_super->s_maxbytes)
1167 size = mp->m_maxioffset - offset; 1182 size = mp->m_super->s_maxbytes - offset;
1168 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size); 1183 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
1169 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1184 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1170 1185
@@ -1351,7 +1366,7 @@ xfs_end_io_direct_write(
1351 ioend->io_iocb = iocb; 1366 ioend->io_iocb = iocb;
1352 ioend->io_result = ret; 1367 ioend->io_result = ret;
1353 if (private && size > 0) 1368 if (private && size > 0)
1354 ioend->io_type = IO_UNWRITTEN; 1369 ioend->io_type = XFS_IO_UNWRITTEN;
1355 1370
1356 if (is_async) { 1371 if (is_async) {
1357 ioend->io_isasync = 1; 1372 ioend->io_isasync = 1;
@@ -1383,7 +1398,7 @@ xfs_vm_direct_IO(
1383 * and converts at least on unwritten extent we will cancel 1398 * and converts at least on unwritten extent we will cancel
1384 * the still clean transaction after the I/O has finished. 1399 * the still clean transaction after the I/O has finished.
1385 */ 1400 */
1386 iocb->private = ioend = xfs_alloc_ioend(inode, IO_DIRECT); 1401 iocb->private = ioend = xfs_alloc_ioend(inode, XFS_IO_DIRECT);
1387 if (offset + size > XFS_I(inode)->i_d.di_size) { 1402 if (offset + size > XFS_I(inode)->i_d.di_size) {
1388 ret = xfs_setfilesize_trans_alloc(ioend); 1403 ret = xfs_setfilesize_trans_alloc(ioend);
1389 if (ret) 1404 if (ret)