17336d0e6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b3b94faaSDavid Teigland /* 3b3b94faaSDavid Teigland * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 43a8a9a10SSteven Whitehouse * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 5b3b94faaSDavid Teigland */ 6b3b94faaSDavid Teigland 7b3b94faaSDavid Teigland #ifndef __LOG_DOT_H__ 8b3b94faaSDavid Teigland #define __LOG_DOT_H__ 9b3b94faaSDavid Teigland 10f2f7ba52SSteven Whitehouse #include <linux/list.h> 11f2f7ba52SSteven Whitehouse #include <linux/spinlock.h> 124667a0ecSSteven Whitehouse #include <linux/writeback.h> 13f2f7ba52SSteven Whitehouse #include "incore.h" 14845802b1SAndreas Gruenbacher #include "inode.h" 15f2f7ba52SSteven Whitehouse 16fe3e3976SAndreas Gruenbacher /* 17fe3e3976SAndreas Gruenbacher * The minimum amount of log space required for a log flush is one block for 18fe3e3976SAndreas Gruenbacher * revokes and one block for the log header. Log flushes other than 19fe3e3976SAndreas Gruenbacher * GFS2_LOG_HEAD_FLUSH_NORMAL may write one or two more log headers. 20fe3e3976SAndreas Gruenbacher */ 21fe3e3976SAndreas Gruenbacher #define GFS2_LOG_FLUSH_MIN_BLOCKS 4 22fe3e3976SAndreas Gruenbacher 23b3b94faaSDavid Teigland /** 24b3b94faaSDavid Teigland * gfs2_log_lock - acquire the right to mess with the log manager 25b3b94faaSDavid Teigland * @sdp: the filesystem 26b3b94faaSDavid Teigland * 27b3b94faaSDavid Teigland */ 28b3b94faaSDavid Teigland 29b3b94faaSDavid Teigland static inline void gfs2_log_lock(struct gfs2_sbd *sdp) 302d81afb8SHarvey Harrison __acquires(&sdp->sd_log_lock) 31b3b94faaSDavid Teigland { 32b3b94faaSDavid Teigland spin_lock(&sdp->sd_log_lock); 33b3b94faaSDavid Teigland } 34b3b94faaSDavid Teigland 35b3b94faaSDavid Teigland /** 36b3b94faaSDavid Teigland * gfs2_log_unlock - release the right to mess with the log manager 37b3b94faaSDavid Teigland * @sdp: the filesystem 38b3b94faaSDavid Teigland * 39b3b94faaSDavid Teigland */ 40b3b94faaSDavid Teigland 41b3b94faaSDavid Teigland static inline void gfs2_log_unlock(struct gfs2_sbd *sdp) 422d81afb8SHarvey Harrison __releases(&sdp->sd_log_lock) 43b3b94faaSDavid Teigland { 44b3b94faaSDavid Teigland spin_unlock(&sdp->sd_log_lock); 45b3b94faaSDavid Teigland } 46b3b94faaSDavid Teigland 47b3b94faaSDavid Teigland static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, 48b3b94faaSDavid Teigland unsigned int value) 49b3b94faaSDavid Teigland { 50b3b94faaSDavid Teigland if (++value == sdp->sd_jdesc->jd_blocks) { 51b3b94faaSDavid Teigland value = 0; 52b3b94faaSDavid Teigland } 535cb738b5SAndreas Gruenbacher sdp->sd_log_tail = value; 545cb738b5SAndreas Gruenbacher sdp->sd_log_flush_tail = value; 555cb738b5SAndreas Gruenbacher sdp->sd_log_head = value; 56b3b94faaSDavid Teigland } 57b3b94faaSDavid Teigland 5845138990SSteven Whitehouse static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) 5945138990SSteven Whitehouse { 60977767a7SAndreas Gruenbacher struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 6145138990SSteven Whitehouse 62977767a7SAndreas Gruenbacher if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp)) 63845802b1SAndreas Gruenbacher return; 64845802b1SAndreas Gruenbacher 657542486bSBob Peterson if (list_empty(&ip->i_ordered)) { 6645138990SSteven Whitehouse spin_lock(&sdp->sd_ordered_lock); 677542486bSBob Peterson if (list_empty(&ip->i_ordered)) 68a5b1d3fcSAndreas Gruenbacher list_add(&ip->i_ordered, &sdp->sd_log_ordered); 6945138990SSteven Whitehouse spin_unlock(&sdp->sd_ordered_lock); 7045138990SSteven Whitehouse } 7145138990SSteven Whitehouse } 722e9eeaa1SBob Peterson 7345138990SSteven Whitehouse extern void gfs2_ordered_del_inode(struct gfs2_inode *ip); 742e9eeaa1SBob Peterson extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct); 7568942870SBob Peterson extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd); 76f3708fb5SAndreas Gruenbacher extern bool gfs2_log_is_empty(struct gfs2_sbd *sdp); 77*2129b428SAndreas Gruenbacher extern void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes); 7824972557SBenjamin Marzinski extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks); 79*2129b428SAndreas Gruenbacher extern bool gfs2_log_try_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, 80*2129b428SAndreas Gruenbacher unsigned int *extra_revokes); 81*2129b428SAndreas Gruenbacher extern void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, 82*2129b428SAndreas Gruenbacher unsigned int *extra_revokes); 83c1696fb8SBob Peterson extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd, 847c70b896SBob Peterson u64 seq, u32 tail, u32 lblock, u32 flags, 857c70b896SBob Peterson int op_flags); 8624972557SBenjamin Marzinski extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, 87c1696fb8SBob Peterson u32 type); 88ed4878e8SBob Peterson extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); 894667a0ecSSteven Whitehouse extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc); 909ff78289SBob Peterson extern void log_flush_wait(struct gfs2_sbd *sdp); 912bcd610dSSteven Whitehouse 92ed4878e8SBob Peterson extern int gfs2_logd(void *data); 935d054964SBenjamin Marzinski extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); 94fe5e7ba1SBob Peterson extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); 95e7501bf8SAndreas Gruenbacher extern void gfs2_flush_revokes(struct gfs2_sbd *sdp); 96b3b94faaSDavid Teigland 97b3b94faaSDavid Teigland #endif /* __LOG_DOT_H__ */ 98