xfs: fix transient reference count error in xfs_buf_resubmit_failed_buffers
authorDave Chinner <dchinner@redhat.com>
Mon, 19 Nov 2018 21:31:08 +0000 (13:31 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 20 Nov 2018 18:36:01 +0000 (10:36 -0800)
commitd43aaf1685aa471f0593685c9f54d53e3af3cf3f
treebba393dac291862f520d931d9968fb8c4a030a9d
parentd61fa8cbf3da85ffca6620f261354941c126ee23
xfs: fix transient reference count error in xfs_buf_resubmit_failed_buffers

When retrying a failed inode or dquot buffer,
xfs_buf_resubmit_failed_buffers() clears all the failed flags from
the inde/dquot log items. In doing so, it also drops all the
reference counts on the buffer that the failed log items hold. This
means it can drop all the active references on the buffer and hence
free the buffer before it queues it for write again.

Putting the buffer on the delwri queue takes a reference to the
buffer (so that it hangs around until it has been written and
completed), but this goes bang if the buffer has already been freed.

Hence we need to add the buffer to the delwri queue before we remove
the failed flags from the log items attached to the buffer to ensure
it always remains referenced during the resubmit process.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_buf_item.c