blob: 1c458487f000a42306cb44f14509d80fea0c2f02 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_LOG_H__
19#define __XFS_LOG_H__
20
Dave Chinnerfc06c6d2013-08-12 20:49:22 +100021#include "xfs_log_format.h"
Christoph Hellwigb53e6752007-10-12 10:59:34 +100022
Dave Chinnerfc06c6d2013-08-12 20:49:22 +100023struct xfs_log_vec {
24 struct xfs_log_vec *lv_next; /* next lv in build list */
25 int lv_niovecs; /* number of iovecs in lv */
26 struct xfs_log_iovec *lv_iovecp; /* iovec array */
27 struct xfs_log_item *lv_item; /* owner */
28 char *lv_buf; /* formatted buffer */
29 int lv_buf_len; /* size of formatted buffer */
Dave Chinner7492c5b2013-08-12 20:50:05 +100030 int lv_size; /* size of allocated lv */
Dave Chinnerfc06c6d2013-08-12 20:49:22 +100031};
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Dave Chinnerfc06c6d2013-08-12 20:49:22 +100033#define XFS_LOG_VEC_ORDERED (-1)
34
35/*
36 * Structure used to pass callback function and the function's argument
37 * to the log manager.
38 */
39typedef struct xfs_log_callback {
40 struct xfs_log_callback *cb_next;
41 void (*cb_func)(void *, int);
42 void *cb_arg;
43} xfs_log_callback_t;
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/*
Nathan Scottc41564b2006-03-29 08:55:14 +100046 * By comparing each component, we don't have to worry about extra
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 * endian issues in treating two 32 bit numbers as one 64 bit number
48 */
Andrew Mortona1365642006-01-08 01:04:09 -080049static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
52 return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
53
54 if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
55 return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
56
57 return 0;
58}
59
60#define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
61
62/*
63 * Macros, structures, prototypes for interface to the log manager.
64 */
65
66/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 * Flags to xfs_log_done()
68 */
69#define XFS_LOG_REL_PERM_RESERV 0x1
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 * Flags to xfs_log_force()
73 *
74 * XFS_LOG_SYNC: Synchronous force in-core log to disk
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 */
76#define XFS_LOG_SYNC 0x1
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078/* Log manager interfaces */
79struct xfs_mount;
Christoph Hellwig35a8a722010-02-15 23:34:54 +000080struct xlog_in_core;
Dave Chinnercc09c0d2008-11-17 17:37:10 +110081struct xlog_ticket;
Dave Chinner43f5efc2010-03-23 10:10:00 +110082struct xfs_log_item;
83struct xfs_item_ops;
Dave Chinner955833c2010-05-14 21:41:46 +100084struct xfs_trans;
Dave Chinner43f5efc2010-03-23 10:10:00 +110085
86void xfs_log_item_init(struct xfs_mount *mp,
87 struct xfs_log_item *item,
88 int type,
Christoph Hellwig272e42b2011-10-28 09:54:24 +000089 const struct xfs_item_ops *ops);
Christoph Hellwig35a8a722010-02-15 23:34:54 +000090
Linus Torvalds1da177e2005-04-16 15:20:36 -070091xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +000092 struct xlog_ticket *ticket,
93 struct xlog_in_core **iclog,
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 uint flags);
Christoph Hellwigf538d4d2005-11-02 10:26:59 +110095int _xfs_log_force(struct xfs_mount *mp,
Christoph Hellwigf538d4d2005-11-02 10:26:59 +110096 uint flags,
97 int *log_forced);
David Chinnerb911ca02008-04-10 12:24:30 +100098void xfs_log_force(struct xfs_mount *mp,
David Chinnerb911ca02008-04-10 12:24:30 +100099 uint flags);
Christoph Hellwiga14a3482010-01-19 09:56:46 +0000100int _xfs_log_force_lsn(struct xfs_mount *mp,
101 xfs_lsn_t lsn,
102 uint flags,
103 int *log_forced);
104void xfs_log_force_lsn(struct xfs_mount *mp,
105 xfs_lsn_t lsn,
106 uint flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107int xfs_log_mount(struct xfs_mount *mp,
108 struct xfs_buftarg *log_target,
109 xfs_daddr_t start_block,
110 int num_bblocks);
Christoph Hellwig42490232008-08-13 16:49:32 +1000111int xfs_log_mount_finish(struct xfs_mount *mp);
Christoph Hellwig09a423a2012-02-20 02:31:20 +0000112xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
Christoph Hellwig1c304622012-04-23 15:58:33 +1000113xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
Christoph Hellwigcfb7cdc2012-02-20 02:31:23 +0000114void xfs_log_space_wake(struct xfs_mount *mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115int xfs_log_notify(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000116 struct xlog_in_core *iclog,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 xfs_log_callback_t *callback_entry);
118int xfs_log_release_iclog(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000119 struct xlog_in_core *iclog);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120int xfs_log_reserve(struct xfs_mount *mp,
121 int length,
122 int count,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000123 struct xlog_ticket **ticket,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 __uint8_t clientid,
Christoph Hellwig9006fb92012-02-20 02:31:31 +0000125 bool permanent,
Tim Shimmin7e9c6392005-09-02 16:42:05 +1000126 uint t_type);
Christoph Hellwig9006fb92012-02-20 02:31:31 +0000127int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128int xfs_log_unmount_write(struct xfs_mount *mp);
Christoph Hellwig21b699c2009-03-16 08:19:29 +0100129void xfs_log_unmount(struct xfs_mount *mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130int xfs_log_force_umount(struct xfs_mount *mp, int logerror);
131int xfs_log_need_covered(struct xfs_mount *mp);
132
133void xlog_iodone(struct xfs_buf *);
134
Dave Chinner71e330b2010-05-21 14:37:18 +1000135struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
Dave Chinnercc09c0d2008-11-17 17:37:10 +1100136void xfs_log_ticket_put(struct xlog_ticket *ticket);
137
Christoph Hellwig0244b962011-12-06 21:58:08 +0000138int xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
Dave Chinner71e330b2010-05-21 14:37:18 +1000139 xfs_lsn_t *commit_lsn, int flags);
Dave Chinnerccf7c232010-05-20 23:19:42 +1000140bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
Dave Chinner71e330b2010-05-21 14:37:18 +1000141
Dave Chinnerf661f1e2012-10-08 21:56:02 +1100142void xfs_log_work_queue(struct xfs_mount *mp);
143void xfs_log_worker(struct work_struct *work);
Dave Chinnerc75921a2012-10-08 21:56:08 +1100144void xfs_log_quiesce(struct xfs_mount *mp);
Dave Chinnerf661f1e2012-10-08 21:56:02 +1100145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif /* __XFS_LOG_H__ */