aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2014-10-01 19:05:44 -0400
committerDave Chinner <david@fromorbit.com>2014-10-01 19:05:44 -0400
commit8c15612546bce1ecafb7dee3cce8a2a9b560e15e (patch)
treea0a7725332387d0a1bf9632e307343a7562544e3 /fs/xfs
parentba3726742c1712c43c5a18245476f3fe9fe74773 (diff)
xfs: simplify xfs_zero_remaining_bytes
xfs_zero_remaining_bytes() open codes a log of buffer manupulations to do a read forllowed by a write. It can simply be replaced by an uncached read followed by a xfs_bwrite() call. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_bmap_util.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index c53cc036d6e7..aa70620e0e62 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1122,14 +1122,6 @@ xfs_zero_remaining_bytes(
1122 if (endoff > XFS_ISIZE(ip)) 1122 if (endoff > XFS_ISIZE(ip))
1123 endoff = XFS_ISIZE(ip); 1123 endoff = XFS_ISIZE(ip);
1124 1124
1125 bp = xfs_buf_get_uncached(XFS_IS_REALTIME_INODE(ip) ?
1126 mp->m_rtdev_targp : mp->m_ddev_targp,
1127 BTOBB(mp->m_sb.sb_blocksize), 0);
1128 if (!bp)
1129 return -ENOMEM;
1130
1131 xfs_buf_unlock(bp);
1132
1133 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) { 1125 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
1134 uint lock_mode; 1126 uint lock_mode;
1135 1127
@@ -1152,32 +1144,24 @@ xfs_zero_remaining_bytes(
1152 ASSERT(imap.br_startblock != DELAYSTARTBLOCK); 1144 ASSERT(imap.br_startblock != DELAYSTARTBLOCK);
1153 if (imap.br_state == XFS_EXT_UNWRITTEN) 1145 if (imap.br_state == XFS_EXT_UNWRITTEN)
1154 continue; 1146 continue;
1155 XFS_BUF_UNDONE(bp);
1156 XFS_BUF_UNWRITE(bp);
1157 XFS_BUF_READ(bp);
1158 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));
1159 1147
1160 error = xfs_buf_submit_wait(bp); 1148 error = xfs_buf_read_uncached(XFS_IS_REALTIME_INODE(ip) ?
1161 if (error) { 1149 mp->m_rtdev_targp : mp->m_ddev_targp,
1162 xfs_buf_ioerror_alert(bp, 1150 xfs_fsb_to_db(ip, imap.br_startblock),
1163 "xfs_zero_remaining_bytes(read)"); 1151 BTOBB(mp->m_sb.sb_blocksize),
1164 break; 1152 0, &bp, NULL);
1165 } 1153 if (error)
1154 return error;
1155
1166 memset(bp->b_addr + 1156 memset(bp->b_addr +
1167 (offset - XFS_FSB_TO_B(mp, imap.br_startoff)), 1157 (offset - XFS_FSB_TO_B(mp, imap.br_startoff)),
1168 0, lastoffset - offset + 1); 1158 0, lastoffset - offset + 1);
1169 XFS_BUF_UNDONE(bp);
1170 XFS_BUF_UNREAD(bp);
1171 XFS_BUF_WRITE(bp);
1172 1159
1173 error = xfs_buf_submit_wait(bp); 1160 error = xfs_bwrite(bp);
1174 if (error) { 1161 xfs_buf_relse(bp);
1175 xfs_buf_ioerror_alert(bp, 1162 if (error)
1176 "xfs_zero_remaining_bytes(write)"); 1163 return error;
1177 break;
1178 }
1179 } 1164 }
1180 xfs_buf_free(bp);
1181 return error; 1165 return error;
1182} 1166}
1183 1167