blob: e63d9e10bd69c350439821e59b5508bea9af5f0c [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 */
30};
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Dave Chinnerfc06c6d2013-08-12 20:49:22 +100032#define XFS_LOG_VEC_ORDERED (-1)
33
34/*
35 * Structure used to pass callback function and the function's argument
36 * to the log manager.
37 */
38typedef struct xfs_log_callback {
39 struct xfs_log_callback *cb_next;
40 void (*cb_func)(void *, int);
41 void *cb_arg;
42} xfs_log_callback_t;
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044/*
Nathan Scottc41564b2006-03-29 08:55:14 +100045 * By comparing each component, we don't have to worry about extra
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 * endian issues in treating two 32 bit numbers as one 64 bit number
47 */
Andrew Mortona1365642006-01-08 01:04:09 -080048static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
50 if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
51 return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
52
53 if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
54 return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
55
56 return 0;
57}
58
59#define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
60
61/*
62 * Macros, structures, prototypes for interface to the log manager.
63 */
64
65/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 * Flags to xfs_log_done()
67 */
68#define XFS_LOG_REL_PERM_RESERV 0x1
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 * Flags to xfs_log_force()
72 *
73 * XFS_LOG_SYNC: Synchronous force in-core log to disk
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 */
75#define XFS_LOG_SYNC 0x1
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Linus Torvalds1da177e2005-04-16 15:20:36 -070077/* Log manager interfaces */
78struct xfs_mount;
Christoph Hellwig35a8a722010-02-15 23:34:54 +000079struct xlog_in_core;
Dave Chinnercc09c0d2008-11-17 17:37:10 +110080struct xlog_ticket;
Dave Chinner43f5efc2010-03-23 10:10:00 +110081struct xfs_log_item;
82struct xfs_item_ops;
Dave Chinner955833c2010-05-14 21:41:46 +100083struct xfs_trans;
Dave Chinner43f5efc2010-03-23 10:10:00 +110084
85void xfs_log_item_init(struct xfs_mount *mp,
86 struct xfs_log_item *item,
87 int type,
Christoph Hellwig272e42b2011-10-28 09:54:24 +000088 const struct xfs_item_ops *ops);
Christoph Hellwig35a8a722010-02-15 23:34:54 +000089
Linus Torvalds1da177e2005-04-16 15:20:36 -070090xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +000091 struct xlog_ticket *ticket,
92 struct xlog_in_core **iclog,
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 uint flags);
Christoph Hellwigf538d4d2005-11-02 10:26:59 +110094int _xfs_log_force(struct xfs_mount *mp,
Christoph Hellwigf538d4d2005-11-02 10:26:59 +110095 uint flags,
96 int *log_forced);
David Chinnerb911ca02008-04-10 12:24:30 +100097void xfs_log_force(struct xfs_mount *mp,
David Chinnerb911ca02008-04-10 12:24:30 +100098 uint flags);
Christoph Hellwiga14a3482010-01-19 09:56:46 +000099int _xfs_log_force_lsn(struct xfs_mount *mp,
100 xfs_lsn_t lsn,
101 uint flags,
102 int *log_forced);
103void xfs_log_force_lsn(struct xfs_mount *mp,
104 xfs_lsn_t lsn,
105 uint flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106int xfs_log_mount(struct xfs_mount *mp,
107 struct xfs_buftarg *log_target,
108 xfs_daddr_t start_block,
109 int num_bblocks);
Christoph Hellwig42490232008-08-13 16:49:32 +1000110int xfs_log_mount_finish(struct xfs_mount *mp);
Christoph Hellwig09a423a2012-02-20 02:31:20 +0000111xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
Christoph Hellwig1c304622012-04-23 15:58:33 +1000112xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
Christoph Hellwigcfb7cdc2012-02-20 02:31:23 +0000113void xfs_log_space_wake(struct xfs_mount *mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114int xfs_log_notify(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000115 struct xlog_in_core *iclog,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 xfs_log_callback_t *callback_entry);
117int xfs_log_release_iclog(struct xfs_mount *mp,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000118 struct xlog_in_core *iclog);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119int xfs_log_reserve(struct xfs_mount *mp,
120 int length,
121 int count,
Christoph Hellwig35a8a722010-02-15 23:34:54 +0000122 struct xlog_ticket **ticket,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 __uint8_t clientid,
Christoph Hellwig9006fb92012-02-20 02:31:31 +0000124 bool permanent,
Tim Shimmin7e9c6392005-09-02 16:42:05 +1000125 uint t_type);
Christoph Hellwig9006fb92012-02-20 02:31:31 +0000126int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127int xfs_log_unmount_write(struct xfs_mount *mp);
Christoph Hellwig21b699c2009-03-16 08:19:29 +0100128void xfs_log_unmount(struct xfs_mount *mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129int xfs_log_force_umount(struct xfs_mount *mp, int logerror);
130int xfs_log_need_covered(struct xfs_mount *mp);
131
132void xlog_iodone(struct xfs_buf *);
133
Dave Chinner71e330b2010-05-21 14:37:18 +1000134struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
Dave Chinnercc09c0d2008-11-17 17:37:10 +1100135void xfs_log_ticket_put(struct xlog_ticket *ticket);
136
Christoph Hellwig0244b962011-12-06 21:58:08 +0000137int xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
Dave Chinner71e330b2010-05-21 14:37:18 +1000138 xfs_lsn_t *commit_lsn, int flags);
Dave Chinnerccf7c232010-05-20 23:19:42 +1000139bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
Dave Chinner71e330b2010-05-21 14:37:18 +1000140
Dave Chinnerf661f1e2012-10-08 21:56:02 +1100141void xfs_log_work_queue(struct xfs_mount *mp);
142void xfs_log_worker(struct work_struct *work);
Dave Chinnerc75921a2012-10-08 21:56:08 +1100143void xfs_log_quiesce(struct xfs_mount *mp);
Dave Chinnerf661f1e2012-10-08 21:56:02 +1100144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#endif /* __XFS_LOG_H__ */