Skip to content

Commit eedffa2

Browse files
jtlaytonaxboe
authored andcommitted
loop: clear wb_err in bd_inode when detaching backing file
When a loop block device encounters a writeback error, that error will get propagated to the bd_inode's wb_err field. If we then detach the backing file from it, attach another and fsync it, we'll get back the writeback error that we had from the previous backing file. This is a bit of a grey area as POSIX doesn't cover loop devices, but it is somewhat counterintuitive. If we detach a backing file from the loopdev while there are still unreported errors, take it as a sign that we're no longer interested in the previous file, and clear out the wb_err in the loop blockdev. Reported-and-Tested-by: Theodore Y. Ts'o <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent f706811 commit eedffa2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/block/loop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ static int loop_clr_fd(struct loop_device *lo)
10681068
if (bdev) {
10691069
bdput(bdev);
10701070
invalidate_bdev(bdev);
1071+
bdev->bd_inode->i_mapping->wb_err = 0;
10711072
}
10721073
set_capacity(lo->lo_disk, 0);
10731074
loop_sysfs_exit(lo);

0 commit comments

Comments
 (0)