Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
0004  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
0005  */
0006 
0007 #ifndef __LOG_DOT_H__
0008 #define __LOG_DOT_H__
0009 
0010 #include <linux/list.h>
0011 #include <linux/spinlock.h>
0012 #include <linux/writeback.h>
0013 #include "incore.h"
0014 #include "inode.h"
0015 
0016 /*
0017  * The minimum amount of log space required for a log flush is one block for
0018  * revokes and one block for the log header.  Log flushes other than
0019  * GFS2_LOG_HEAD_FLUSH_NORMAL may write one or two more log headers.
0020  */
0021 #define GFS2_LOG_FLUSH_MIN_BLOCKS 4
0022 
0023 /**
0024  * gfs2_log_lock - acquire the right to mess with the log manager
0025  * @sdp: the filesystem
0026  *
0027  */
0028 
0029 static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
0030 __acquires(&sdp->sd_log_lock)
0031 {
0032     spin_lock(&sdp->sd_log_lock);
0033 }
0034 
0035 /**
0036  * gfs2_log_unlock - release the right to mess with the log manager
0037  * @sdp: the filesystem
0038  *
0039  */
0040 
0041 static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
0042 __releases(&sdp->sd_log_lock)
0043 {
0044     spin_unlock(&sdp->sd_log_lock);
0045 }
0046 
0047 static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
0048                       unsigned int value)
0049 {
0050     if (++value == sdp->sd_jdesc->jd_blocks) {
0051         value = 0;
0052     }
0053     sdp->sd_log_tail = value;
0054     sdp->sd_log_flush_tail = value;
0055     sdp->sd_log_head = value;
0056 }
0057 
0058 static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
0059 {
0060     struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
0061 
0062     if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
0063         return;
0064 
0065     if (list_empty(&ip->i_ordered)) {
0066         spin_lock(&sdp->sd_ordered_lock);
0067         if (list_empty(&ip->i_ordered))
0068             list_add(&ip->i_ordered, &sdp->sd_log_ordered);
0069         spin_unlock(&sdp->sd_ordered_lock);
0070     }
0071 }
0072 
0073 extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
0074 extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
0075 extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
0076 extern bool gfs2_log_is_empty(struct gfs2_sbd *sdp);
0077 extern void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes);
0078 extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
0079 extern bool gfs2_log_try_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
0080                  unsigned int *extra_revokes);
0081 extern void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
0082                  unsigned int *extra_revokes);
0083 extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
0084                   u64 seq, u32 tail, u32 lblock, u32 flags,
0085                   blk_opf_t op_flags);
0086 extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
0087                u32 type);
0088 extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
0089 extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
0090 extern void log_flush_wait(struct gfs2_sbd *sdp);
0091 
0092 extern int gfs2_logd(void *data);
0093 extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
0094 extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
0095 extern void gfs2_flush_revokes(struct gfs2_sbd *sdp);
0096 extern void gfs2_ail_drain(struct gfs2_sbd *sdp);
0097 
0098 #endif /* __LOG_DOT_H__ */