aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-12-10 03:42:24 -0500
committerAlex Elder <aelder@sgi.com>2010-12-16 17:06:03 -0500
commitaeea1b1f81800e362a3aca86d769d02e137a8fa7 (patch)
treef010e3af9ade221ea76c368592c54a07aaa4ca82 /fs/xfs
parent2fa24f92530edaf86c3b5f662464e0d2e3b3e517 (diff)
xfs: refactor xfs_vm_writepage
After the last patches the code for overwrites is the same as for delayed and unwritten extents except that it doesn't need to call xfs_map_at_offset. Take care of that fact to simplify xfs_vm_writepage. The buffer loop now first checks the type of buffer and checks/sets the ioend type, or continues to the next buffer if it's not interesting to us. Only after that we validate the iomap and perform the block mapping if needed, all in common code for the cases where we have to do work. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c97
1 files changed, 39 insertions, 58 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 86f57f61939b..4d982dc8b862 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -999,74 +999,55 @@ xfs_vm_writepage(
999 continue; 999 continue;
1000 } 1000 }
1001 1001
1002 if (imap_valid) 1002 if (buffer_unwritten(bh)) {
1003 imap_valid = xfs_imap_valid(inode, &imap, offset); 1003 if (type != IO_UNWRITTEN) {
1004 1004 type = IO_UNWRITTEN;
1005 if (buffer_unwritten(bh) || buffer_delay(bh)) { 1005 imap_valid = 0;
1006 if (buffer_unwritten(bh)) {
1007 if (type != IO_UNWRITTEN) {
1008 type = IO_UNWRITTEN;
1009 imap_valid = 0;
1010 }
1011 } else if (buffer_delay(bh)) {
1012 if (type != IO_DELALLOC) {
1013 type = IO_DELALLOC;
1014 imap_valid = 0;
1015 }
1016 }
1017
1018 if (!imap_valid) {
1019 /*
1020 * If we didn't have a valid mapping then we
1021 * need to ensure that we put the new mapping
1022 * in a new ioend structure. This needs to be
1023 * done to ensure that the ioends correctly
1024 * reflect the block mappings at io completion
1025 * for unwritten extent conversion.
1026 */
1027 new_ioend = 1;
1028 err = xfs_map_blocks(inode, offset, &imap,
1029 type, nonblocking);
1030 if (err)
1031 goto error;
1032 imap_valid = xfs_imap_valid(inode, &imap,
1033 offset);
1034 } 1006 }
1035 if (imap_valid) { 1007 } else if (buffer_delay(bh)) {
1036 xfs_map_at_offset(inode, bh, &imap, offset); 1008 if (type != IO_DELALLOC) {
1037 xfs_add_to_ioend(inode, bh, offset, type, 1009 type = IO_DELALLOC;
1038 &ioend, new_ioend); 1010 imap_valid = 0;
1039 count++;
1040 } 1011 }
1041 } else if (buffer_uptodate(bh)) { 1012 } else if (buffer_uptodate(bh)) {
1042 /*
1043 * we got here because the buffer is already mapped.
1044 * That means it must already have extents allocated
1045 * underneath it. Map the extent by reading it.
1046 */
1047 if (type != IO_OVERWRITE) { 1013 if (type != IO_OVERWRITE) {
1048 type = IO_OVERWRITE; 1014 type = IO_OVERWRITE;
1049 imap_valid = 0; 1015 imap_valid = 0;
1050 } 1016 }
1051 if (!imap_valid) { 1017 } else {
1052 new_ioend = 1; 1018 if (PageUptodate(page)) {
1053 err = xfs_map_blocks(inode, offset, 1019 ASSERT(buffer_mapped(bh));
1054 &imap, type, nonblocking); 1020 imap_valid = 0;
1055 if (err)
1056 goto error;
1057 imap_valid = xfs_imap_valid(inode, &imap,
1058 offset);
1059 } 1021 }
1022 continue;
1023 }
1060 1024
1061 if (imap_valid) { 1025 if (imap_valid)
1026 imap_valid = xfs_imap_valid(inode, &imap, offset);
1027 if (!imap_valid) {
1028 /*
1029 * If we didn't have a valid mapping then we need to
1030 * put the new mapping into a separate ioend structure.
1031 * This ensures non-contiguous extents always have
1032 * separate ioends, which is particularly important
1033 * for unwritten extent conversion at I/O completion
1034 * time.
1035 */
1036 new_ioend = 1;
1037 err = xfs_map_blocks(inode, offset, &imap, type,
1038 nonblocking);
1039 if (err)
1040 goto error;
1041 imap_valid = xfs_imap_valid(inode, &imap, offset);
1042 }
1043 if (imap_valid) {
1044 if (type == IO_OVERWRITE)
1062 lock_buffer(bh); 1045 lock_buffer(bh);
1063 xfs_add_to_ioend(inode, bh, offset, type, 1046 else
1064 &ioend, new_ioend); 1047 xfs_map_at_offset(inode, bh, &imap, offset);
1065 count++; 1048 xfs_add_to_ioend(inode, bh, offset, type, &ioend,
1066 } 1049 new_ioend);
1067 } else if (PageUptodate(page)) { 1050 count++;
1068 ASSERT(buffer_mapped(bh));
1069 imap_valid = 0;
1070 } 1051 }
1071 1052
1072 if (!iohead) 1053 if (!iohead)