diff options
author | Zhaohongjiang <zhaohongjiang@huawei.com> | 2015-10-12 00:28:39 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-10-12 00:28:39 -0400 |
commit | 5cb13dcd0fac071b45c4bebe1801a08ff0d89cad (patch) | |
tree | 7298328edbb828a0d4bb6177c50aec795340569b | |
parent | 1f93e4a96c9109378204c147b3eec0d0e8100fde (diff) |
cancel the setfilesize transation when io error happen
When I ran xfstest/073 case, the remount process was blocked to wait
transactions to be zero. I found there was a io error happened, and
the setfilesize transaction was not released properly. We should add
the changes to cancel the io error in this case.
Reproduction steps:
1. dd if=/dev/zero of=xfs1.img bs=1M count=2048
2. mkfs.xfs xfs1.img
3. losetup -f ./xfs1.img /dev/loop0
4. mount -t xfs /dev/loop0 /home/test_dir/
5. mkdir /home/test_dir/test
6. mkfs.xfs -dfile,name=image,size=2g
7. mount -t xfs -o loop image /home/test_dir/test
8. cp a file bigger than 2g to /home/test_dir/test
9. mount -t xfs -o remount,ro /home/test_dir/test
[ dchinner: moved io error detection to xfs_setfilesize_ioend() after
transaction context restoration. ]
Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/xfs_aops.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 50ab2879b9da..e485e31813fa 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -172,6 +172,12 @@ xfs_setfilesize_ioend( | |||
172 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); | 172 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); |
173 | __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS); | 173 | __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS); |
174 | 174 | ||
175 | /* we abort the update if there was an IO error */ | ||
176 | if (ioend->io_error) { | ||
177 | xfs_trans_cancel(tp); | ||
178 | return ioend->io_error; | ||
179 | } | ||
180 | |||
175 | return xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size); | 181 | return xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size); |
176 | } | 182 | } |
177 | 183 | ||
@@ -212,14 +218,17 @@ xfs_end_io( | |||
212 | ioend->io_error = -EIO; | 218 | ioend->io_error = -EIO; |
213 | goto done; | 219 | goto done; |
214 | } | 220 | } |
215 | if (ioend->io_error) | ||
216 | goto done; | ||
217 | 221 | ||
218 | /* | 222 | /* |
219 | * For unwritten extents we need to issue transactions to convert a | 223 | * For unwritten extents we need to issue transactions to convert a |
220 | * range to normal written extens after the data I/O has finished. | 224 | * range to normal written extens after the data I/O has finished. |
225 | * Detecting and handling completion IO errors is done individually | ||
226 | * for each case as different cleanup operations need to be performed | ||
227 | * on error. | ||
221 | */ | 228 | */ |
222 | if (ioend->io_type == XFS_IO_UNWRITTEN) { | 229 | if (ioend->io_type == XFS_IO_UNWRITTEN) { |
230 | if (ioend->io_error) | ||
231 | goto done; | ||
223 | error = xfs_iomap_write_unwritten(ip, ioend->io_offset, | 232 | error = xfs_iomap_write_unwritten(ip, ioend->io_offset, |
224 | ioend->io_size); | 233 | ioend->io_size); |
225 | } else if (ioend->io_append_trans) { | 234 | } else if (ioend->io_append_trans) { |