diff options
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r-- | fs/xfs/xfs_log.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 6db1fef38bff..6b965bf450e4 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -18,9 +18,7 @@ | |||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
21 | #include "xfs_bit.h" | ||
22 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_trans.h" | 22 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | 23 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 24 | #include "xfs_ag.h" |
@@ -35,7 +33,6 @@ | |||
35 | #include "xfs_trans_priv.h" | 33 | #include "xfs_trans_priv.h" |
36 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
37 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
38 | #include "xfs_rw.h" | ||
39 | #include "xfs_trace.h" | 36 | #include "xfs_trace.h" |
40 | 37 | ||
41 | kmem_zone_t *xfs_log_ticket_zone; | 38 | kmem_zone_t *xfs_log_ticket_zone; |
@@ -916,27 +913,42 @@ xfs_log_need_covered(xfs_mount_t *mp) | |||
916 | * We may be holding the log iclog lock upon entering this routine. | 913 | * We may be holding the log iclog lock upon entering this routine. |
917 | */ | 914 | */ |
918 | xfs_lsn_t | 915 | xfs_lsn_t |
919 | xlog_assign_tail_lsn( | 916 | xlog_assign_tail_lsn_locked( |
920 | struct xfs_mount *mp) | 917 | struct xfs_mount *mp) |
921 | { | 918 | { |
922 | xfs_lsn_t tail_lsn; | ||
923 | struct log *log = mp->m_log; | 919 | struct log *log = mp->m_log; |
920 | struct xfs_log_item *lip; | ||
921 | xfs_lsn_t tail_lsn; | ||
922 | |||
923 | assert_spin_locked(&mp->m_ail->xa_lock); | ||
924 | 924 | ||
925 | /* | 925 | /* |
926 | * To make sure we always have a valid LSN for the log tail we keep | 926 | * To make sure we always have a valid LSN for the log tail we keep |
927 | * track of the last LSN which was committed in log->l_last_sync_lsn, | 927 | * track of the last LSN which was committed in log->l_last_sync_lsn, |
928 | * and use that when the AIL was empty and xfs_ail_min_lsn returns 0. | 928 | * and use that when the AIL was empty. |
929 | * | ||
930 | * If the AIL has been emptied we also need to wake any process | ||
931 | * waiting for this condition. | ||
932 | */ | 929 | */ |
933 | tail_lsn = xfs_ail_min_lsn(mp->m_ail); | 930 | lip = xfs_ail_min(mp->m_ail); |
934 | if (!tail_lsn) | 931 | if (lip) |
932 | tail_lsn = lip->li_lsn; | ||
933 | else | ||
935 | tail_lsn = atomic64_read(&log->l_last_sync_lsn); | 934 | tail_lsn = atomic64_read(&log->l_last_sync_lsn); |
936 | atomic64_set(&log->l_tail_lsn, tail_lsn); | 935 | atomic64_set(&log->l_tail_lsn, tail_lsn); |
937 | return tail_lsn; | 936 | return tail_lsn; |
938 | } | 937 | } |
939 | 938 | ||
939 | xfs_lsn_t | ||
940 | xlog_assign_tail_lsn( | ||
941 | struct xfs_mount *mp) | ||
942 | { | ||
943 | xfs_lsn_t tail_lsn; | ||
944 | |||
945 | spin_lock(&mp->m_ail->xa_lock); | ||
946 | tail_lsn = xlog_assign_tail_lsn_locked(mp); | ||
947 | spin_unlock(&mp->m_ail->xa_lock); | ||
948 | |||
949 | return tail_lsn; | ||
950 | } | ||
951 | |||
940 | /* | 952 | /* |
941 | * Return the space in the log between the tail and the head. The head | 953 | * Return the space in the log between the tail and the head. The head |
942 | * is passed in the cycle/bytes formal parms. In the special case where | 954 | * is passed in the cycle/bytes formal parms. In the special case where |
@@ -1172,7 +1184,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1172 | xlog_get_iclog_buffer_size(mp, log); | 1184 | xlog_get_iclog_buffer_size(mp, log); |
1173 | 1185 | ||
1174 | error = ENOMEM; | 1186 | error = ENOMEM; |
1175 | bp = xfs_buf_alloc(mp->m_logdev_targp, 0, log->l_iclog_size, 0); | 1187 | bp = xfs_buf_alloc(mp->m_logdev_targp, 0, BTOBB(log->l_iclog_size), 0); |
1176 | if (!bp) | 1188 | if (!bp) |
1177 | goto out_free_log; | 1189 | goto out_free_log; |
1178 | bp->b_iodone = xlog_iodone; | 1190 | bp->b_iodone = xlog_iodone; |
@@ -1182,9 +1194,6 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1182 | spin_lock_init(&log->l_icloglock); | 1194 | spin_lock_init(&log->l_icloglock); |
1183 | init_waitqueue_head(&log->l_flush_wait); | 1195 | init_waitqueue_head(&log->l_flush_wait); |
1184 | 1196 | ||
1185 | /* log record size must be multiple of BBSIZE; see xlog_rec_header_t */ | ||
1186 | ASSERT((XFS_BUF_SIZE(bp) & BBMASK) == 0); | ||
1187 | |||
1188 | iclogp = &log->l_iclog; | 1197 | iclogp = &log->l_iclog; |
1189 | /* | 1198 | /* |
1190 | * The amount of memory to allocate for the iclog structure is | 1199 | * The amount of memory to allocate for the iclog structure is |
@@ -1204,7 +1213,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1204 | prev_iclog = iclog; | 1213 | prev_iclog = iclog; |
1205 | 1214 | ||
1206 | bp = xfs_buf_get_uncached(mp->m_logdev_targp, | 1215 | bp = xfs_buf_get_uncached(mp->m_logdev_targp, |
1207 | log->l_iclog_size, 0); | 1216 | BTOBB(log->l_iclog_size), 0); |
1208 | if (!bp) | 1217 | if (!bp) |
1209 | goto out_free_iclog; | 1218 | goto out_free_iclog; |
1210 | 1219 | ||
@@ -1224,7 +1233,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1224 | head->h_fmt = cpu_to_be32(XLOG_FMT); | 1233 | head->h_fmt = cpu_to_be32(XLOG_FMT); |
1225 | memcpy(&head->h_fs_uuid, &mp->m_sb.sb_uuid, sizeof(uuid_t)); | 1234 | memcpy(&head->h_fs_uuid, &mp->m_sb.sb_uuid, sizeof(uuid_t)); |
1226 | 1235 | ||
1227 | iclog->ic_size = XFS_BUF_SIZE(bp) - log->l_iclog_hsize; | 1236 | iclog->ic_size = BBTOB(bp->b_length) - log->l_iclog_hsize; |
1228 | iclog->ic_state = XLOG_STATE_ACTIVE; | 1237 | iclog->ic_state = XLOG_STATE_ACTIVE; |
1229 | iclog->ic_log = log; | 1238 | iclog->ic_log = log; |
1230 | atomic_set(&iclog->ic_refcnt, 0); | 1239 | atomic_set(&iclog->ic_refcnt, 0); |
@@ -1475,7 +1484,7 @@ xlog_sync(xlog_t *log, | |||
1475 | } else { | 1484 | } else { |
1476 | iclog->ic_bwritecnt = 1; | 1485 | iclog->ic_bwritecnt = 1; |
1477 | } | 1486 | } |
1478 | XFS_BUF_SET_COUNT(bp, count); | 1487 | bp->b_io_length = BTOBB(count); |
1479 | bp->b_fspriv = iclog; | 1488 | bp->b_fspriv = iclog; |
1480 | XFS_BUF_ZEROFLAGS(bp); | 1489 | XFS_BUF_ZEROFLAGS(bp); |
1481 | XFS_BUF_ASYNC(bp); | 1490 | XFS_BUF_ASYNC(bp); |
@@ -1573,7 +1582,7 @@ xlog_dealloc_log(xlog_t *log) | |||
1573 | * always need to ensure that the extra buffer does not point to memory | 1582 | * always need to ensure that the extra buffer does not point to memory |
1574 | * owned by another log buffer before we free it. | 1583 | * owned by another log buffer before we free it. |
1575 | */ | 1584 | */ |
1576 | xfs_buf_set_empty(log->l_xbuf, log->l_iclog_size); | 1585 | xfs_buf_set_empty(log->l_xbuf, BTOBB(log->l_iclog_size)); |
1577 | xfs_buf_free(log->l_xbuf); | 1586 | xfs_buf_free(log->l_xbuf); |
1578 | 1587 | ||
1579 | iclog = log->l_iclog; | 1588 | iclog = log->l_iclog; |
@@ -2932,6 +2941,7 @@ xfs_log_force( | |||
2932 | { | 2941 | { |
2933 | int error; | 2942 | int error; |
2934 | 2943 | ||
2944 | trace_xfs_log_force(mp, 0); | ||
2935 | error = _xfs_log_force(mp, flags, NULL); | 2945 | error = _xfs_log_force(mp, flags, NULL); |
2936 | if (error) | 2946 | if (error) |
2937 | xfs_warn(mp, "%s: error %d returned.", __func__, error); | 2947 | xfs_warn(mp, "%s: error %d returned.", __func__, error); |
@@ -3080,6 +3090,7 @@ xfs_log_force_lsn( | |||
3080 | { | 3090 | { |
3081 | int error; | 3091 | int error; |
3082 | 3092 | ||
3093 | trace_xfs_log_force(mp, lsn); | ||
3083 | error = _xfs_log_force_lsn(mp, lsn, flags, NULL); | 3094 | error = _xfs_log_force_lsn(mp, lsn, flags, NULL); |
3084 | if (error) | 3095 | if (error) |
3085 | xfs_warn(mp, "%s: error %d returned.", __func__, error); | 3096 | xfs_warn(mp, "%s: error %d returned.", __func__, error); |