18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __LOG_DOT_H__
88c2ecf20Sopenharmony_ci#define __LOG_DOT_H__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/list.h>
118c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
128c2ecf20Sopenharmony_ci#include <linux/writeback.h>
138c2ecf20Sopenharmony_ci#include "incore.h"
148c2ecf20Sopenharmony_ci#include "inode.h"
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/**
178c2ecf20Sopenharmony_ci * gfs2_log_lock - acquire the right to mess with the log manager
188c2ecf20Sopenharmony_ci * @sdp: the filesystem
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistatic inline void gfs2_log_lock(struct gfs2_sbd *sdp)
238c2ecf20Sopenharmony_ci__acquires(&sdp->sd_log_lock)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	spin_lock(&sdp->sd_log_lock);
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/**
298c2ecf20Sopenharmony_ci * gfs2_log_unlock - release the right to mess with the log manager
308c2ecf20Sopenharmony_ci * @sdp: the filesystem
318c2ecf20Sopenharmony_ci *
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
358c2ecf20Sopenharmony_ci__releases(&sdp->sd_log_lock)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	spin_unlock(&sdp->sd_log_lock);
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
418c2ecf20Sopenharmony_ci					  unsigned int value)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	if (++value == sdp->sd_jdesc->jd_blocks) {
448c2ecf20Sopenharmony_ci		value = 0;
458c2ecf20Sopenharmony_ci	}
468c2ecf20Sopenharmony_ci	sdp->sd_log_head = sdp->sd_log_tail = value;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistatic inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
548c2ecf20Sopenharmony_ci		return;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	if (list_empty(&ip->i_ordered)) {
578c2ecf20Sopenharmony_ci		spin_lock(&sdp->sd_ordered_lock);
588c2ecf20Sopenharmony_ci		if (list_empty(&ip->i_ordered))
598c2ecf20Sopenharmony_ci			list_add(&ip->i_ordered, &sdp->sd_log_ordered);
608c2ecf20Sopenharmony_ci		spin_unlock(&sdp->sd_ordered_lock);
618c2ecf20Sopenharmony_ci	}
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciextern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
658c2ecf20Sopenharmony_ciextern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
668c2ecf20Sopenharmony_ciextern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
678c2ecf20Sopenharmony_ciextern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
688c2ecf20Sopenharmony_ciextern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
698c2ecf20Sopenharmony_ciextern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
708c2ecf20Sopenharmony_ci				  u64 seq, u32 tail, u32 lblock, u32 flags,
718c2ecf20Sopenharmony_ci				  int op_flags);
728c2ecf20Sopenharmony_ciextern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
738c2ecf20Sopenharmony_ci			   u32 type);
748c2ecf20Sopenharmony_ciextern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
758c2ecf20Sopenharmony_ciextern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
768c2ecf20Sopenharmony_ciextern void log_flush_wait(struct gfs2_sbd *sdp);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciextern int gfs2_logd(void *data);
798c2ecf20Sopenharmony_ciextern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
808c2ecf20Sopenharmony_ciextern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
818c2ecf20Sopenharmony_ciextern void gfs2_write_revokes(struct gfs2_sbd *sdp);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#endif /* __LOG_DOT_H__ */
84