0001
0002
0003
0004
0005
0006 #ifndef __XFS_LOG_H__
0007 #define __XFS_LOG_H__
0008
0009 struct xfs_cil_ctx;
0010
0011 struct xfs_log_vec {
0012 struct list_head lv_list;
0013 uint32_t lv_order_id;
0014 int lv_niovecs;
0015 struct xfs_log_iovec *lv_iovecp;
0016 struct xfs_log_item *lv_item;
0017 char *lv_buf;
0018 int lv_bytes;
0019 int lv_buf_len;
0020 int lv_size;
0021 };
0022
0023 #define XFS_LOG_VEC_ORDERED (-1)
0024
0025
0026
0027
0028
0029
0030 static inline int
0031 xlog_calc_iovec_len(int len)
0032 {
0033 return roundup(len, sizeof(uint32_t));
0034 }
0035
0036 void *xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
0037 uint type);
0038
0039 static inline void
0040 xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec,
0041 int data_len)
0042 {
0043 struct xlog_op_header *oph = vec->i_addr;
0044 int len;
0045
0046
0047
0048
0049
0050
0051
0052
0053 len = xlog_calc_iovec_len(data_len);
0054 if (len - data_len != 0) {
0055 char *buf = vec->i_addr + sizeof(struct xlog_op_header);
0056
0057 memset(buf + data_len, 0, len - data_len);
0058 }
0059
0060
0061
0062
0063
0064 oph->oh_len = cpu_to_be32(len);
0065
0066 len += sizeof(struct xlog_op_header);
0067 lv->lv_buf_len += len;
0068 lv->lv_bytes += len;
0069 vec->i_len = len;
0070
0071
0072 ASSERT((void *)lv->lv_buf + lv->lv_bytes <= (void *)lv + lv->lv_size);
0073 }
0074
0075
0076
0077
0078 static inline void *
0079 xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
0080 uint type, void *data, int len)
0081 {
0082 void *buf;
0083
0084 buf = xlog_prepare_iovec(lv, vecp, type);
0085 memcpy(buf, data, len);
0086 xlog_finish_iovec(lv, *vecp, len);
0087 return buf;
0088 }
0089
0090 static inline void *
0091 xlog_copy_from_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
0092 const struct xfs_log_iovec *src)
0093 {
0094 return xlog_copy_iovec(lv, vecp, src->i_type, src->i_addr, src->i_len);
0095 }
0096
0097
0098
0099
0100
0101 static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
0102 {
0103 if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
0104 return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
0105
0106 if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
0107 return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
0108
0109 return 0;
0110 }
0111
0112 #define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
0113
0114
0115
0116
0117
0118
0119 #define XFS_LOG_SYNC 0x1
0120
0121
0122 struct xfs_mount;
0123 struct xlog_in_core;
0124 struct xlog_ticket;
0125 struct xfs_log_item;
0126 struct xfs_item_ops;
0127 struct xfs_trans;
0128 struct xlog;
0129
0130 int xfs_log_force(struct xfs_mount *mp, uint flags);
0131 int xfs_log_force_seq(struct xfs_mount *mp, xfs_csn_t seq, uint flags,
0132 int *log_forced);
0133 int xfs_log_mount(struct xfs_mount *mp,
0134 struct xfs_buftarg *log_target,
0135 xfs_daddr_t start_block,
0136 int num_bblocks);
0137 int xfs_log_mount_finish(struct xfs_mount *mp);
0138 void xfs_log_mount_cancel(struct xfs_mount *);
0139 xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
0140 xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
0141 void xfs_log_space_wake(struct xfs_mount *mp);
0142 int xfs_log_reserve(struct xfs_mount *mp, int length, int count,
0143 struct xlog_ticket **ticket, bool permanent);
0144 int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
0145 void xfs_log_unmount(struct xfs_mount *mp);
0146 bool xfs_log_writable(struct xfs_mount *mp);
0147
0148 struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
0149 void xfs_log_ticket_put(struct xlog_ticket *ticket);
0150
0151 void xlog_cil_process_committed(struct list_head *list);
0152 bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
0153
0154 void xfs_log_work_queue(struct xfs_mount *mp);
0155 int xfs_log_quiesce(struct xfs_mount *mp);
0156 void xfs_log_clean(struct xfs_mount *mp);
0157 bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t);
0158
0159 xfs_lsn_t xlog_grant_push_threshold(struct xlog *log, int need_bytes);
0160 bool xlog_force_shutdown(struct xlog *log, uint32_t shutdown_flags);
0161
0162 void xlog_use_incompat_feat(struct xlog *log);
0163 void xlog_drop_incompat_feat(struct xlog *log);
0164 int xfs_attr_use_log_assist(struct xfs_mount *mp);
0165
0166 #endif