diff options
author | Dave Chinner <david@fromorbit.com> | 2009-10-06 16:29:30 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2009-10-08 13:01:49 -0400 |
commit | dce5065a57c158e0ca5db8e63c50118b2ecf4ac5 (patch) | |
tree | 3cd53a5fd21551585e0c01febbf9daebed8d5749 /fs/xfs/linux-2.6 | |
parent | 932640e8adaff3d0c28ee32d4863c7a7a74df055 (diff) |
xfs: make sure xfs_sync_fsdata covers the log
We want to always cover the log after writing out the superblock, and
in case of a synchronous writeout make sure we actually wait for the
log to be covered. That way a filesystem that has been sync()ed can
be considered clean by log recovery.
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sync.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index 7647b8db3ca3..961df0a22c78 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -309,11 +309,15 @@ xfs_sync_attr( | |||
309 | STATIC int | 309 | STATIC int |
310 | xfs_commit_dummy_trans( | 310 | xfs_commit_dummy_trans( |
311 | struct xfs_mount *mp, | 311 | struct xfs_mount *mp, |
312 | uint log_flags) | 312 | uint flags) |
313 | { | 313 | { |
314 | struct xfs_inode *ip = mp->m_rootip; | 314 | struct xfs_inode *ip = mp->m_rootip; |
315 | struct xfs_trans *tp; | 315 | struct xfs_trans *tp; |
316 | int error; | 316 | int error; |
317 | int log_flags = XFS_LOG_FORCE; | ||
318 | |||
319 | if (flags & SYNC_WAIT) | ||
320 | log_flags |= XFS_LOG_SYNC; | ||
317 | 321 | ||
318 | /* | 322 | /* |
319 | * Put a dummy transaction in the log to tell recovery | 323 | * Put a dummy transaction in the log to tell recovery |
@@ -331,13 +335,12 @@ xfs_commit_dummy_trans( | |||
331 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 335 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
332 | xfs_trans_ihold(tp, ip); | 336 | xfs_trans_ihold(tp, ip); |
333 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 337 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
334 | /* XXX(hch): ignoring the error here.. */ | ||
335 | error = xfs_trans_commit(tp, 0); | 338 | error = xfs_trans_commit(tp, 0); |
336 | |||
337 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 339 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
338 | 340 | ||
341 | /* the log force ensures this transaction is pushed to disk */ | ||
339 | xfs_log_force(mp, 0, log_flags); | 342 | xfs_log_force(mp, 0, log_flags); |
340 | return 0; | 343 | return error; |
341 | } | 344 | } |
342 | 345 | ||
343 | int | 346 | int |
@@ -385,7 +388,20 @@ xfs_sync_fsdata( | |||
385 | else | 388 | else |
386 | XFS_BUF_ASYNC(bp); | 389 | XFS_BUF_ASYNC(bp); |
387 | 390 | ||
388 | return xfs_bwrite(mp, bp); | 391 | error = xfs_bwrite(mp, bp); |
392 | if (error) | ||
393 | return error; | ||
394 | |||
395 | /* | ||
396 | * If this is a data integrity sync make sure all pending buffers | ||
397 | * are flushed out for the log coverage check below. | ||
398 | */ | ||
399 | if (flags & SYNC_WAIT) | ||
400 | xfs_flush_buftarg(mp->m_ddev_targp, 1); | ||
401 | |||
402 | if (xfs_log_need_covered(mp)) | ||
403 | error = xfs_commit_dummy_trans(mp, flags); | ||
404 | return error; | ||
389 | 405 | ||
390 | out_brelse: | 406 | out_brelse: |
391 | xfs_buf_relse(bp); | 407 | xfs_buf_relse(bp); |
@@ -572,8 +588,6 @@ xfs_sync_worker( | |||
572 | /* dgc: errors ignored here */ | 588 | /* dgc: errors ignored here */ |
573 | error = xfs_qm_sync(mp, SYNC_TRYLOCK); | 589 | error = xfs_qm_sync(mp, SYNC_TRYLOCK); |
574 | error = xfs_sync_fsdata(mp, SYNC_TRYLOCK); | 590 | error = xfs_sync_fsdata(mp, SYNC_TRYLOCK); |
575 | if (xfs_log_need_covered(mp)) | ||
576 | error = xfs_commit_dummy_trans(mp, XFS_LOG_FORCE); | ||
577 | } | 591 | } |
578 | mp->m_sync_seq++; | 592 | mp->m_sync_seq++; |
579 | wake_up(&mp->m_wait_single_sync_task); | 593 | wake_up(&mp->m_wait_single_sync_task); |