diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_sync.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sync.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index 320be6aea492..6fed97a8cd3e 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "xfs_inode_item.h" | 44 | #include "xfs_inode_item.h" |
45 | #include "xfs_rw.h" | 45 | #include "xfs_rw.h" |
46 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
47 | #include "xfs_trace.h" | ||
47 | 48 | ||
48 | #include <linux/kthread.h> | 49 | #include <linux/kthread.h> |
49 | #include <linux/freezer.h> | 50 | #include <linux/freezer.h> |
@@ -309,11 +310,15 @@ xfs_sync_attr( | |||
309 | STATIC int | 310 | STATIC int |
310 | xfs_commit_dummy_trans( | 311 | xfs_commit_dummy_trans( |
311 | struct xfs_mount *mp, | 312 | struct xfs_mount *mp, |
312 | uint log_flags) | 313 | uint flags) |
313 | { | 314 | { |
314 | struct xfs_inode *ip = mp->m_rootip; | 315 | struct xfs_inode *ip = mp->m_rootip; |
315 | struct xfs_trans *tp; | 316 | struct xfs_trans *tp; |
316 | int error; | 317 | int error; |
318 | int log_flags = XFS_LOG_FORCE; | ||
319 | |||
320 | if (flags & SYNC_WAIT) | ||
321 | log_flags |= XFS_LOG_SYNC; | ||
317 | 322 | ||
318 | /* | 323 | /* |
319 | * Put a dummy transaction in the log to tell recovery | 324 | * Put a dummy transaction in the log to tell recovery |
@@ -331,13 +336,12 @@ xfs_commit_dummy_trans( | |||
331 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 336 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
332 | xfs_trans_ihold(tp, ip); | 337 | xfs_trans_ihold(tp, ip); |
333 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 338 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
334 | /* XXX(hch): ignoring the error here.. */ | ||
335 | error = xfs_trans_commit(tp, 0); | 339 | error = xfs_trans_commit(tp, 0); |
336 | |||
337 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 340 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
338 | 341 | ||
342 | /* the log force ensures this transaction is pushed to disk */ | ||
339 | xfs_log_force(mp, 0, log_flags); | 343 | xfs_log_force(mp, 0, log_flags); |
340 | return 0; | 344 | return error; |
341 | } | 345 | } |
342 | 346 | ||
343 | int | 347 | int |
@@ -385,7 +389,20 @@ xfs_sync_fsdata( | |||
385 | else | 389 | else |
386 | XFS_BUF_ASYNC(bp); | 390 | XFS_BUF_ASYNC(bp); |
387 | 391 | ||
388 | return xfs_bwrite(mp, bp); | 392 | error = xfs_bwrite(mp, bp); |
393 | if (error) | ||
394 | return error; | ||
395 | |||
396 | /* | ||
397 | * If this is a data integrity sync make sure all pending buffers | ||
398 | * are flushed out for the log coverage check below. | ||
399 | */ | ||
400 | if (flags & SYNC_WAIT) | ||
401 | xfs_flush_buftarg(mp->m_ddev_targp, 1); | ||
402 | |||
403 | if (xfs_log_need_covered(mp)) | ||
404 | error = xfs_commit_dummy_trans(mp, flags); | ||
405 | return error; | ||
389 | 406 | ||
390 | out_brelse: | 407 | out_brelse: |
391 | xfs_buf_relse(bp); | 408 | xfs_buf_relse(bp); |
@@ -419,14 +436,16 @@ xfs_quiesce_data( | |||
419 | /* push non-blocking */ | 436 | /* push non-blocking */ |
420 | xfs_sync_data(mp, 0); | 437 | xfs_sync_data(mp, 0); |
421 | xfs_qm_sync(mp, SYNC_TRYLOCK); | 438 | xfs_qm_sync(mp, SYNC_TRYLOCK); |
422 | xfs_filestream_flush(mp); | ||
423 | 439 | ||
424 | /* push and block */ | 440 | /* push and block till complete */ |
425 | xfs_sync_data(mp, SYNC_WAIT); | 441 | xfs_sync_data(mp, SYNC_WAIT); |
426 | xfs_qm_sync(mp, SYNC_WAIT); | 442 | xfs_qm_sync(mp, SYNC_WAIT); |
427 | 443 | ||
444 | /* drop inode references pinned by filestreams */ | ||
445 | xfs_filestream_flush(mp); | ||
446 | |||
428 | /* write superblock and hoover up shutdown errors */ | 447 | /* write superblock and hoover up shutdown errors */ |
429 | error = xfs_sync_fsdata(mp, 0); | 448 | error = xfs_sync_fsdata(mp, SYNC_WAIT); |
430 | 449 | ||
431 | /* flush data-only devices */ | 450 | /* flush data-only devices */ |
432 | if (mp->m_rtdev_targp) | 451 | if (mp->m_rtdev_targp) |
@@ -570,8 +589,6 @@ xfs_sync_worker( | |||
570 | /* dgc: errors ignored here */ | 589 | /* dgc: errors ignored here */ |
571 | error = xfs_qm_sync(mp, SYNC_TRYLOCK); | 590 | error = xfs_qm_sync(mp, SYNC_TRYLOCK); |
572 | error = xfs_sync_fsdata(mp, SYNC_TRYLOCK); | 591 | error = xfs_sync_fsdata(mp, SYNC_TRYLOCK); |
573 | if (xfs_log_need_covered(mp)) | ||
574 | error = xfs_commit_dummy_trans(mp, XFS_LOG_FORCE); | ||
575 | } | 592 | } |
576 | mp->m_sync_seq++; | 593 | mp->m_sync_seq++; |
577 | wake_up(&mp->m_wait_single_sync_task); | 594 | wake_up(&mp->m_wait_single_sync_task); |
@@ -647,10 +664,9 @@ xfs_syncd_stop( | |||
647 | kthread_stop(mp->m_sync_task); | 664 | kthread_stop(mp->m_sync_task); |
648 | } | 665 | } |
649 | 666 | ||
650 | int | 667 | STATIC int |
651 | xfs_reclaim_inode( | 668 | xfs_reclaim_inode( |
652 | xfs_inode_t *ip, | 669 | xfs_inode_t *ip, |
653 | int locked, | ||
654 | int sync_mode) | 670 | int sync_mode) |
655 | { | 671 | { |
656 | xfs_perag_t *pag = xfs_get_perag(ip->i_mount, ip->i_ino); | 672 | xfs_perag_t *pag = xfs_get_perag(ip->i_mount, ip->i_ino); |
@@ -666,10 +682,6 @@ xfs_reclaim_inode( | |||
666 | !__xfs_iflags_test(ip, XFS_IRECLAIMABLE)) { | 682 | !__xfs_iflags_test(ip, XFS_IRECLAIMABLE)) { |
667 | spin_unlock(&ip->i_flags_lock); | 683 | spin_unlock(&ip->i_flags_lock); |
668 | write_unlock(&pag->pag_ici_lock); | 684 | write_unlock(&pag->pag_ici_lock); |
669 | if (locked) { | ||
670 | xfs_ifunlock(ip); | ||
671 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | ||
672 | } | ||
673 | return -EAGAIN; | 685 | return -EAGAIN; |
674 | } | 686 | } |
675 | __xfs_iflags_set(ip, XFS_IRECLAIM); | 687 | __xfs_iflags_set(ip, XFS_IRECLAIM); |
@@ -688,10 +700,8 @@ xfs_reclaim_inode( | |||
688 | * We get the flush lock regardless, though, just to make sure | 700 | * We get the flush lock regardless, though, just to make sure |
689 | * we don't free it while it is being flushed. | 701 | * we don't free it while it is being flushed. |
690 | */ | 702 | */ |
691 | if (!locked) { | 703 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
692 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 704 | xfs_iflock(ip); |
693 | xfs_iflock(ip); | ||
694 | } | ||
695 | 705 | ||
696 | /* | 706 | /* |
697 | * In the case of a forced shutdown we rely on xfs_iflush() to | 707 | * In the case of a forced shutdown we rely on xfs_iflush() to |
@@ -762,7 +772,7 @@ xfs_reclaim_inode_now( | |||
762 | } | 772 | } |
763 | read_unlock(&pag->pag_ici_lock); | 773 | read_unlock(&pag->pag_ici_lock); |
764 | 774 | ||
765 | return xfs_reclaim_inode(ip, 0, flags); | 775 | return xfs_reclaim_inode(ip, flags); |
766 | } | 776 | } |
767 | 777 | ||
768 | int | 778 | int |