vserver 1.9.3
[linux-2.6.git] / fs / xfs / xfs_log.c
index 8505f1d..7db33af 100644 (file)
@@ -122,9 +122,6 @@ STATIC void         xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket);
 /* local debug functions */
 #if defined(DEBUG) && !defined(XLOG_NOLOG)
 STATIC void    xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr);
-#ifdef XFSDEBUG
-STATIC void    xlog_verify_disk_cycle_no(xlog_t *log, xlog_in_core_t *iclog);
-#endif
 STATIC void    xlog_verify_grant_head(xlog_t *log, int equals);
 STATIC void    xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
                                  int count, boolean_t syncing);
@@ -132,7 +129,6 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
                                     xfs_lsn_t tail_lsn);
 #else
 #define xlog_verify_dest_ptr(a,b)
-#define xlog_verify_disk_cycle_no(a,b)
 #define xlog_verify_grant_head(a,b)
 #define xlog_verify_iclog(a,b,c,d)
 #define xlog_verify_tail_lsn(a,b,c)
@@ -339,13 +335,11 @@ xfs_log_force(xfs_mount_t *mp,
 
 }      /* xfs_log_force */
 
-
 /*
- * This function will take a log sequence number and check to see if that
- * lsn has been flushed to disk.  If it has, then the callback function is
- * called with the callback argument.  If the relevant in-core log has not
- * been synced to disk, we add the callback to the callback list of the
- * in-core log.
+ * Attaches a new iclog I/O completion callback routine during
+ * transaction commit.  If the log is in error state, a non-zero
+ * return code is handed back and the caller is responsible for
+ * executing the callback at an appropriate time.
  */
 int
 xfs_log_notify(xfs_mount_t       *mp,          /* mount of partition */
@@ -360,21 +354,18 @@ xfs_log_notify(xfs_mount_t          *mp,          /* mount of partition */
        if (!xlog_debug && xlog_target == log->l_targ)
                return 0;
 #endif
-       cb->cb_next = 0;
+       cb->cb_next = NULL;
        spl = LOG_LOCK(log);
        abortflg = (iclog->ic_state & XLOG_STATE_IOERROR);
        if (!abortflg) {
                ASSERT_ALWAYS((iclog->ic_state == XLOG_STATE_ACTIVE) ||
                              (iclog->ic_state == XLOG_STATE_WANT_SYNC));
-               cb->cb_next = 0;
+               cb->cb_next = NULL;
                *(iclog->ic_callback_tail) = cb;
                iclog->ic_callback_tail = &(cb->cb_next);
        }
        LOG_UNLOCK(log, spl);
-       if (abortflg) {
-               cb->cb_func(cb->cb_arg, abortflg);
-       }
-       return 0;
+       return abortflg;
 }      /* xfs_log_notify */
 
 int
@@ -497,7 +488,7 @@ xfs_log_mount(xfs_mount_t   *mp,
                if (readonly)
                        vfsp->vfs_flag |= VFS_RDONLY;
                if (error) {
-                       cmn_err(CE_WARN, "XFS: log mount/recovery failed");
+                       cmn_err(CE_WARN, "XFS: log mount/recovery failed: error %d", error);
                        xlog_unalloc_log(mp->m_log);
                        return error;
                }
@@ -571,7 +562,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
        xlog_in_core_t   *first_iclog;
 #endif
        xfs_log_iovec_t  reg[1];
-       xfs_log_ticket_t tic = 0;
+       xfs_log_ticket_t tic = NULL;
        xfs_lsn_t        lsn;
        int              error;
        SPLDECL(s);
@@ -820,7 +811,7 @@ xfs_log_need_covered(xfs_mount_t *mp)
        xlog_t          *log = mp->m_log;
        vfs_t           *vfsp = XFS_MTOVFS(mp);
 
-       if (vfsp->vfs_super->s_frozen || XFS_FORCED_SHUTDOWN(mp) ||
+       if (fs_frozen(vfsp) || XFS_FORCED_SHUTDOWN(mp) ||
            (vfsp->vfs_flag & VFS_RDONLY))
                return 0;
 
@@ -1284,7 +1275,7 @@ xlog_commit_record(xfs_mount_t  *mp,
        int             error;
        xfs_log_iovec_t reg[1];
 
-       reg[0].i_addr = 0;
+       reg[0].i_addr = NULL;
        reg[0].i_len = 0;
 
        ASSERT_ALWAYS(iclog);
@@ -1420,9 +1411,13 @@ xlog_sync(xlog_t         *log,
        xlog_pack_data(log, iclog);       /* put cycle number in every block */
 
        /* real byte length */
-       INT_SET(iclog->ic_header.h_len, 
-               ARCH_CONVERT,
-               iclog->ic_offset + iclog->ic_roundoff);
+       if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
+               INT_SET(iclog->ic_header.h_len, 
+                       ARCH_CONVERT,
+                       iclog->ic_offset + iclog->ic_roundoff);
+       } else {
+               INT_SET(iclog->ic_header.h_len, ARCH_CONVERT, iclog->ic_offset);
+       }
 
        /* put ops count in correct order */
        ops = iclog->ic_header.h_num_logops;
@@ -1664,7 +1659,6 @@ xlog_write(xfs_mount_t *  mp,
     int                     copy_len;       /* # bytes actually memcpy'ing */
     int                     copy_off;       /* # bytes from entry start */
     int                     contwr;         /* continued write of in-core log? */
-    int                     firstwr = 0;    /* first write of transaction */
     int                     error;
     int                     record_cnt = 0, data_cnt = 0;
 
@@ -1729,7 +1723,6 @@ xlog_write(xfs_mount_t *  mp,
                logop_head->oh_flags    = XLOG_START_TRANS;
                INT_ZERO(logop_head->oh_res2, ARCH_CONVERT);
                ticket->t_flags         &= ~XLOG_TIC_INITED;    /* clear bit */
-               firstwr = 1;                      /* increment log ops below */
                record_cnt++;
 
                start_rec_copy = sizeof(xlog_op_header_t);
@@ -1800,7 +1793,6 @@ xlog_write(xfs_mount_t *  mp,
            copy_len += start_rec_copy + sizeof(xlog_op_header_t);
            record_cnt++;
            data_cnt += contwr ? copy_len : 0;
-           firstwr = 0;
            if (partial_copy) {                 /* copied partial region */
                    /* already marked WANT_SYNC by xlog_state_get_iclog_space */
                    xlog_state_finish_copy(log, iclog, record_cnt, data_cnt);
@@ -1867,7 +1859,7 @@ xlog_state_clean_log(xlog_t *log)
                if (iclog->ic_state == XLOG_STATE_DIRTY) {
                        iclog->ic_state = XLOG_STATE_ACTIVE;
                        iclog->ic_offset       = 0;
-                       iclog->ic_callback      = 0;   /* don't need to free */
+                       iclog->ic_callback      = NULL;   /* don't need to free */
                        /*
                         * If the number of ops in this iclog indicate it just
                         * contains the dummy transaction, we can
@@ -2090,7 +2082,7 @@ xlog_state_do_callback(
 
                        while (cb != 0) {
                                iclog->ic_callback_tail = &(iclog->ic_callback);
-                               iclog->ic_callback = 0;
+                               iclog->ic_callback = NULL;
                                LOG_UNLOCK(log, s);
 
                                /* perform callbacks in the order given */
@@ -3108,7 +3100,7 @@ xlog_state_ticket_alloc(xlog_t *log)
                log->l_ticket_cnt++;
                log->l_ticket_tcnt++;
        }
-       t_list->t_next = 0;
+       t_list->t_next = NULL;
        log->l_tail = t_list;
        LOG_UNLOCK(log, s);
 }      /* xlog_state_ticket_alloc */
@@ -3136,7 +3128,7 @@ xlog_ticket_put(xlog_t            *log,
        /* no need to clear fields */
 #else
        /* When we debug, it is easier if tickets are cycled */
-       ticket->t_next     = 0;
+       ticket->t_next     = NULL;
        if (log->l_tail != 0) {
                log->l_tail->t_next = ticket;
        } else {
@@ -3252,33 +3244,6 @@ xlog_verify_dest_ptr(xlog_t     *log,
                xlog_panic("xlog_verify_dest_ptr: invalid ptr");
 }      /* xlog_verify_dest_ptr */
 
-
-#ifdef XFSDEBUG
-/* check split LR write */
-STATIC void
-xlog_verify_disk_cycle_no(xlog_t        *log,
-                         xlog_in_core_t *iclog)
-{
-    xfs_buf_t  *bp;
-    uint       cycle_no;
-    xfs_caddr_t ptr;
-    xfs_daddr_t        i;
-
-    if (BLOCK_LSN(iclog->ic_header.h_lsn, ARCH_CONVERT) < 10) {
-       cycle_no = CYCLE_LSN(iclog->ic_header.h_lsn, ARCH_CONVERT);
-       bp = xlog_get_bp(log, 1);
-       ASSERT(bp);
-       for (i = 0; i < BLOCK_LSN(iclog->ic_header.h_lsn, ARCH_CONVERT); i++) {
-           xlog_bread(log, i, 1, bp);
-           ptr = xlog_align(log, i, 1, bp);
-           if (GET_CYCLE(ptr, ARCH_CONVERT) != cycle_no)
-               xlog_warn("XFS: xlog_verify_disk_cycle_no: bad cycle no");
-       }
-       xlog_put_bp(bp);
-    }
-}      /* xlog_verify_disk_cycle_no */
-#endif
-
 STATIC void
 xlog_verify_grant_head(xlog_t *log, int equals)
 {