162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 462306a36Sopenharmony_ci * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef __LOG_DOT_H__ 862306a36Sopenharmony_ci#define __LOG_DOT_H__ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/list.h> 1162306a36Sopenharmony_ci#include <linux/spinlock.h> 1262306a36Sopenharmony_ci#include <linux/writeback.h> 1362306a36Sopenharmony_ci#include "incore.h" 1462306a36Sopenharmony_ci#include "inode.h" 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * The minimum amount of log space required for a log flush is one block for 1862306a36Sopenharmony_ci * revokes and one block for the log header. Log flushes other than 1962306a36Sopenharmony_ci * GFS2_LOG_HEAD_FLUSH_NORMAL may write one or two more log headers. 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci#define GFS2_LOG_FLUSH_MIN_BLOCKS 4 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/** 2462306a36Sopenharmony_ci * gfs2_log_lock - acquire the right to mess with the log manager 2562306a36Sopenharmony_ci * @sdp: the filesystem 2662306a36Sopenharmony_ci * 2762306a36Sopenharmony_ci */ 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistatic inline void gfs2_log_lock(struct gfs2_sbd *sdp) 3062306a36Sopenharmony_ci__acquires(&sdp->sd_log_lock) 3162306a36Sopenharmony_ci{ 3262306a36Sopenharmony_ci spin_lock(&sdp->sd_log_lock); 3362306a36Sopenharmony_ci} 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/** 3662306a36Sopenharmony_ci * gfs2_log_unlock - release the right to mess with the log manager 3762306a36Sopenharmony_ci * @sdp: the filesystem 3862306a36Sopenharmony_ci * 3962306a36Sopenharmony_ci */ 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistatic inline void gfs2_log_unlock(struct gfs2_sbd *sdp) 4262306a36Sopenharmony_ci__releases(&sdp->sd_log_lock) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci spin_unlock(&sdp->sd_log_lock); 4562306a36Sopenharmony_ci} 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cistatic inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, 4862306a36Sopenharmony_ci unsigned int value) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci if (++value == sdp->sd_jdesc->jd_blocks) { 5162306a36Sopenharmony_ci value = 0; 5262306a36Sopenharmony_ci } 5362306a36Sopenharmony_ci sdp->sd_log_tail = value; 5462306a36Sopenharmony_ci sdp->sd_log_flush_tail = value; 5562306a36Sopenharmony_ci sdp->sd_log_head = value; 5662306a36Sopenharmony_ci} 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistatic inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) 5962306a36Sopenharmony_ci{ 6062306a36Sopenharmony_ci struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp)) 6362306a36Sopenharmony_ci return; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci if (list_empty(&ip->i_ordered)) { 6662306a36Sopenharmony_ci spin_lock(&sdp->sd_ordered_lock); 6762306a36Sopenharmony_ci if (list_empty(&ip->i_ordered)) 6862306a36Sopenharmony_ci list_add(&ip->i_ordered, &sdp->sd_log_ordered); 6962306a36Sopenharmony_ci spin_unlock(&sdp->sd_ordered_lock); 7062306a36Sopenharmony_ci } 7162306a36Sopenharmony_ci} 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciextern void gfs2_ordered_del_inode(struct gfs2_inode *ip); 7462306a36Sopenharmony_ciextern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct); 7562306a36Sopenharmony_ciextern void gfs2_remove_from_ail(struct gfs2_bufdata *bd); 7662306a36Sopenharmony_ciextern bool gfs2_log_is_empty(struct gfs2_sbd *sdp); 7762306a36Sopenharmony_ciextern void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes); 7862306a36Sopenharmony_ciextern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks); 7962306a36Sopenharmony_ciextern bool gfs2_log_try_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, 8062306a36Sopenharmony_ci unsigned int *extra_revokes); 8162306a36Sopenharmony_ciextern void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, 8262306a36Sopenharmony_ci unsigned int *extra_revokes); 8362306a36Sopenharmony_ciextern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd, 8462306a36Sopenharmony_ci u64 seq, u32 tail, u32 lblock, u32 flags, 8562306a36Sopenharmony_ci blk_opf_t op_flags); 8662306a36Sopenharmony_ciextern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, 8762306a36Sopenharmony_ci u32 type); 8862306a36Sopenharmony_ciextern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); 8962306a36Sopenharmony_ciextern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc); 9062306a36Sopenharmony_ciextern void log_flush_wait(struct gfs2_sbd *sdp); 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciextern int gfs2_logd(void *data); 9362306a36Sopenharmony_ciextern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); 9462306a36Sopenharmony_ciextern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); 9562306a36Sopenharmony_ciextern void gfs2_flush_revokes(struct gfs2_sbd *sdp); 9662306a36Sopenharmony_ciextern void gfs2_ail_drain(struct gfs2_sbd *sdp); 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#endif /* __LOG_DOT_H__ */ 99