Skip to contentSkip to conversation

xfs: wait for the write of the superblock on unmount

RFC Superseded [email protected] 3 participants 6 messages Jul 18, 2012 – Jul 24, 2012 1 message not in the archive XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

RFC 1/1 xfs: wait for the write of the superblock on unmount

Sorry, I have been distracted away from this regression. This was previously titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and causes a panic if the write does not win the race.

The log write of the superblock is important for possible recovery, but a second syncronous write of the same superblock seems redundant. Would just waiting for the iodone() of the log write before tearing down the log be enough?

---
 fs/xfs/xfs_mount.c |    8 ++++++++
 1 file changed, 8 insertions(+)
fs/xfs/xfs_mount.c +8 -0
Index: b/fs/xfs/xfs_mount.c
===================================================================
@@ -1457,6 +1457,7 @@ void
 xfs_unmountfs(
 	struct xfs_mount	*mp)
 {
+	struct xfs_buf		*bp = mp->m_sb_bp;
 	__uint64_t		resblks;
 	int			error;
 
@@ -1529,6 +1530,13 @@ xfs_unmountfs(
 	xfs_ail_push_all_sync(mp->m_ail);
 	xfs_wait_buftarg(mp->m_ddev_targp);
 
+	/*
+	 * Wait for the superblock to be written out. The superblock buffer
+	 * will remain locked until the iodone().
+	 */
+	xfs_buf_lock(bp);
+	xfs_buf_unlock(bp);
+
 	xfs_log_unmount_write(mp);
 	xfs_log_unmount(mp);
 	xfs_uuid_unmount(mp);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 11 lines · On Wed, Jul 18, 2012 at 12:33:58PM -0500, [email protected] wrote:

Sorry, I have been distracted away from this regression. This was previously titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and causes a panic if the write does not win the race.

The log write of the superblock is important for possible recovery, but a second syncronous write of the same superblock seems redundant. Would just waiting for the iodone() of the log write before tearing down the log be enough?

Yes. i.e. something like:

	/*
	 * The superblock buffer is uncached, so xfs_wait_buftarg()
	 * will not wait for it. Hence we need to explicitly wait
	 * for IO completion on the superblock to occur here.
	 */
	error = xfs_buf_iowait(mp->m_sb_bp);
	if (error)
		AAAAIEEEE!

This fix is also needed in xfs_quiesce_attr() for the freeze and ro,remount cases as well.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#3 lore raw
Quoted 24 lines · Dave Chinner
Quoted 11 lines · On Wed, Jul 18, 2012 at 12:33:58PM -0500, [email protected] wrote:

Sorry, I have been distracted away from this regression. This was previously titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and causes a panic if the write does not win the race.

The log write of the superblock is important for possible recovery, but a second syncronous write of the same superblock seems redundant. Would just waiting for the iodone() of the log write before tearing down the log be enough?

Yes. i.e. something like:

	/*
	 * The superblock buffer is uncached, so xfs_wait_buftarg()
	 * will not wait for it. Hence we need to explicitly wait
	 * for IO completion on the superblock to occur here.
	 */
	error = xfs_buf_iowait(mp->m_sb_bp);
	if (error)
		AAAAIEEEE!
Quoted 7 lines

This fix is also needed in xfs_quiesce_attr() for the freeze and ro,remount cases as well.

Cheers,

Dave.

Thanks for the feedback.

I chose the ugly lock to block on the superblock buffer because it has XBF_ASYNC set at that point and won't go through the complete() patch. I will look at turning the XBF_ASYNC flag off and wait on a xfs_buf_iowait().

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 37 lines · Mark Tinguely
Quoted 28 lines · Dave Chinner
Quoted 9 lines · On Wed, Jul 18, 2012 at 12:33:58PM -0500, [email protected] wrote:

Sorry, I have been distracted away from this regression. This was previously
titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and
causes a panic if the write does not win the race.

Quoted 6 lines

The log write of the superblock is important for possible recovery, but a
second syncronous write of the same superblock seems redundant. Would just
waiting for the iodone() of the log write before tearing down the log be enough?

Yes. i.e. something like:

/*
* The superblock buffer is uncached, so xfs_wait_buftarg()
* will not wait for it. Hence we need to explicitly wait
* for IO completion on the superblock to occur here. */
error = xfs_buf_iowait(mp->m_sb_bp);
if (error)
AAAAIEEEE!

Quoted 7 lines

This fix is also needed in xfs_quiesce_attr() for the freeze and ro,remount cases as well.

Cheers,

Dave.

Quoted 7 lines

Thanks for the feedback.

I chose the ugly lock to block on the superblock buffer because it has XBF_ASYNC set at that point and won't go through the complete() patch. I will look at turning the XBF_ASYNC flag off and wait on a xfs_buf_iowait().

--Mark.

Looks like the xfsaild_push() sets the XBF_ASYNC flag on the superblock buffer. Waiting on the xfs_buf_iowait() won't work but have to use the less elegant lock.

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#5 lore raw
In reply to [email protected]
Quoted 11 lines · On Wed, Jul 18, 2012 at 12:33:58PM -0500, [email protected] wrote:

Sorry, I have been distracted away from this regression. This was previously titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and causes a panic if the write does not win the race.

The log write of the superblock is important for possible recovery, but a second syncronous write of the same superblock seems redundant. Would just waiting for the iodone() of the log write before tearing down the log be enough?

This doesn't look beautiful, but I suspect there's no good way around it. Can you add your explanation from the reply on why xfs_buf_iowait does not work here to the comment above the lock/unlock pair?

With that:

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
Quoted 13 lines · Christoph Hellwig
Quoted 11 lines · On Wed, Jul 18, 2012 at 12:33:58PM -0500, [email protected] wrote:

Sorry, I have been distracted away from this regression. This was previously titled "xfs: synchronously write the superblock on unmount".

xfs_wait_buftarg() does not wait for the completion of the write of the uncached superblock. This write can race with the shutdown of the log and causes a panic if the write does not win the race.

The log write of the superblock is important for possible recovery, but a second syncronous write of the same superblock seems redundant. Would just waiting for the iodone() of the log write before tearing down the log be enough?

Quoted 7 lines

This doesn't look beautiful, but I suspect there's no good way around it. Can you add your explanation from the reply on why xfs_buf_iowait does not work here to the comment above the lock/unlock pair?

With that:

Thank-you. I will repost with the same xfs_buf_lock() entry to xfs_quiesce_attr().

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs