blob: fc905c2af53ce928fa1ea1ee8dc99e53271d9c1c [file] [log] [blame]
Thomas Gleixner7336d0e2019-05-31 01:09:56 -07001/* SPDX-License-Identifier: GPL-2.0-only */
David Teiglandb3b94fa2006-01-16 16:50:04 +00002/*
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04004 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00005 */
6
7#ifndef __LOG_DOT_H__
8#define __LOG_DOT_H__
9
Steven Whitehousef2f7ba52006-09-05 10:39:21 -040010#include <linux/list.h>
11#include <linux/spinlock.h>
Steven Whitehouse4667a0e2011-04-18 14:18:09 +010012#include <linux/writeback.h>
Steven Whitehousef2f7ba52006-09-05 10:39:21 -040013#include "incore.h"
Andreas Gruenbacher845802b2018-06-04 07:50:16 -050014#include "inode.h"
Steven Whitehousef2f7ba52006-09-05 10:39:21 -040015
Andreas Gruenbacherfe3e3972020-12-10 12:49:56 +010016/*
17 * The minimum amount of log space required for a log flush is one block for
18 * revokes and one block for the log header. Log flushes other than
19 * GFS2_LOG_HEAD_FLUSH_NORMAL may write one or two more log headers.
20 */
21#define GFS2_LOG_FLUSH_MIN_BLOCKS 4
22
David Teiglandb3b94fa2006-01-16 16:50:04 +000023/**
24 * gfs2_log_lock - acquire the right to mess with the log manager
25 * @sdp: the filesystem
26 *
27 */
28
29static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
Harvey Harrison2d81afb2008-05-29 18:27:51 -070030__acquires(&sdp->sd_log_lock)
David Teiglandb3b94fa2006-01-16 16:50:04 +000031{
32 spin_lock(&sdp->sd_log_lock);
33}
34
35/**
36 * gfs2_log_unlock - release the right to mess with the log manager
37 * @sdp: the filesystem
38 *
39 */
40
41static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
Harvey Harrison2d81afb2008-05-29 18:27:51 -070042__releases(&sdp->sd_log_lock)
David Teiglandb3b94fa2006-01-16 16:50:04 +000043{
44 spin_unlock(&sdp->sd_log_lock);
45}
46
47static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
48 unsigned int value)
49{
50 if (++value == sdp->sd_jdesc->jd_blocks) {
51 value = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +000052 }
Andreas Gruenbacher5cb738b2020-12-19 07:15:17 +010053 sdp->sd_log_tail = value;
54 sdp->sd_log_flush_tail = value;
55 sdp->sd_log_head = value;
David Teiglandb3b94fa2006-01-16 16:50:04 +000056}
57
Steven Whitehouse45138992013-01-28 09:30:07 +000058static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
59{
Andreas Gruenbacher977767a2018-10-12 20:07:27 +020060 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
Steven Whitehouse45138992013-01-28 09:30:07 +000061
Andreas Gruenbacher977767a2018-10-12 20:07:27 +020062 if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
Andreas Gruenbacher845802b2018-06-04 07:50:16 -050063 return;
64
Bob Peterson75424862020-06-17 07:47:34 -050065 if (list_empty(&ip->i_ordered)) {
Steven Whitehouse45138992013-01-28 09:30:07 +000066 spin_lock(&sdp->sd_ordered_lock);
Bob Peterson75424862020-06-17 07:47:34 -050067 if (list_empty(&ip->i_ordered))
Andreas Gruenbachera5b1d3f2019-04-05 12:16:14 +010068 list_add(&ip->i_ordered, &sdp->sd_log_ordered);
Steven Whitehouse45138992013-01-28 09:30:07 +000069 spin_unlock(&sdp->sd_ordered_lock);
70 }
71}
Bob Peterson2e9eeaa2019-12-13 08:10:51 -060072
Steven Whitehouse45138992013-01-28 09:30:07 +000073extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
Bob Peterson2e9eeaa2019-12-13 08:10:51 -060074extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
Bob Peterson68942872020-07-22 10:27:50 -050075extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
Andreas Gruenbacherf3708fb2020-12-13 09:21:34 +010076extern bool gfs2_log_is_empty(struct gfs2_sbd *sdp);
Andreas Gruenbacher2129b422020-12-17 16:14:30 +010077extern void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes);
Benjamin Marzinski24972552014-05-01 22:26:55 -050078extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
Andreas Gruenbacher2129b422020-12-17 16:14:30 +010079extern bool gfs2_log_try_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
80 unsigned int *extra_revokes);
81extern void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
82 unsigned int *extra_revokes);
Bob Petersonc1696fb2018-01-17 00:01:33 +010083extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
Bob Peterson7c70b892019-03-25 09:34:19 -060084 u64 seq, u32 tail, u32 lblock, u32 flags,
85 int op_flags);
Benjamin Marzinski24972552014-05-01 22:26:55 -050086extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
Bob Petersonc1696fb2018-01-17 00:01:33 +010087 u32 type);
Bob Petersoned4878e2010-05-20 23:30:11 -040088extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
Steven Whitehouse4667a0e2011-04-18 14:18:09 +010089extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
Bob Peterson9ff78282019-11-13 13:47:02 -060090extern void log_flush_wait(struct gfs2_sbd *sdp);
Steven Whitehouse2bcd6102007-11-08 14:25:12 +000091
Bob Petersoned4878e2010-05-20 23:30:11 -040092extern int gfs2_logd(void *data);
Benjamin Marzinski5d054962013-06-14 11:38:29 -050093extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
Bob Petersonfe5e7ba2019-11-14 09:49:11 -050094extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
Andreas Gruenbachere7501bf2020-12-19 03:11:51 +010095extern void gfs2_flush_revokes(struct gfs2_sbd *sdp);
Bob Petersonf5456b52021-05-19 14:54:02 -040096extern void gfs2_ail_drain(struct gfs2_sbd *sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +000097
98#endif /* __LOG_DOT_H__ */