Thomas Gleixner | 7336d0e | 2019-05-31 01:09:56 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __LOG_DOT_H__ |
| 8 | #define __LOG_DOT_H__ |
| 9 | |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 10 | #include <linux/list.h> |
| 11 | #include <linux/spinlock.h> |
Steven Whitehouse | 4667a0e | 2011-04-18 14:18:09 +0100 | [diff] [blame] | 12 | #include <linux/writeback.h> |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 13 | #include "incore.h" |
Andreas Gruenbacher | 845802b | 2018-06-04 07:50:16 -0500 | [diff] [blame] | 14 | #include "inode.h" |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 15 | |
Andreas Gruenbacher | fe3e397 | 2020-12-10 12:49:56 +0100 | [diff] [blame] | 16 | /* |
| 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 Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 23 | /** |
| 24 | * gfs2_log_lock - acquire the right to mess with the log manager |
| 25 | * @sdp: the filesystem |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | static inline void gfs2_log_lock(struct gfs2_sbd *sdp) |
Harvey Harrison | 2d81afb | 2008-05-29 18:27:51 -0700 | [diff] [blame] | 30 | __acquires(&sdp->sd_log_lock) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 31 | { |
| 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 | |
| 41 | static inline void gfs2_log_unlock(struct gfs2_sbd *sdp) |
Harvey Harrison | 2d81afb | 2008-05-29 18:27:51 -0700 | [diff] [blame] | 42 | __releases(&sdp->sd_log_lock) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 43 | { |
| 44 | spin_unlock(&sdp->sd_log_lock); |
| 45 | } |
| 46 | |
| 47 | static 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 Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 52 | } |
Andreas Gruenbacher | 5cb738b | 2020-12-19 07:15:17 +0100 | [diff] [blame] | 53 | sdp->sd_log_tail = value; |
| 54 | sdp->sd_log_flush_tail = value; |
| 55 | sdp->sd_log_head = value; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 58 | static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) |
| 59 | { |
Andreas Gruenbacher | 977767a | 2018-10-12 20:07:27 +0200 | [diff] [blame] | 60 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 61 | |
Andreas Gruenbacher | 977767a | 2018-10-12 20:07:27 +0200 | [diff] [blame] | 62 | if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp)) |
Andreas Gruenbacher | 845802b | 2018-06-04 07:50:16 -0500 | [diff] [blame] | 63 | return; |
| 64 | |
Bob Peterson | 7542486 | 2020-06-17 07:47:34 -0500 | [diff] [blame] | 65 | if (list_empty(&ip->i_ordered)) { |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 66 | spin_lock(&sdp->sd_ordered_lock); |
Bob Peterson | 7542486 | 2020-06-17 07:47:34 -0500 | [diff] [blame] | 67 | if (list_empty(&ip->i_ordered)) |
Andreas Gruenbacher | a5b1d3f | 2019-04-05 12:16:14 +0100 | [diff] [blame] | 68 | list_add(&ip->i_ordered, &sdp->sd_log_ordered); |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 69 | spin_unlock(&sdp->sd_ordered_lock); |
| 70 | } |
| 71 | } |
Bob Peterson | 2e9eeaa | 2019-12-13 08:10:51 -0600 | [diff] [blame] | 72 | |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 73 | extern void gfs2_ordered_del_inode(struct gfs2_inode *ip); |
Bob Peterson | 2e9eeaa | 2019-12-13 08:10:51 -0600 | [diff] [blame] | 74 | extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct); |
Bob Peterson | 6894287 | 2020-07-22 10:27:50 -0500 | [diff] [blame] | 75 | extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd); |
Andreas Gruenbacher | f3708fb | 2020-12-13 09:21:34 +0100 | [diff] [blame] | 76 | extern bool gfs2_log_is_empty(struct gfs2_sbd *sdp); |
Andreas Gruenbacher | 2129b42 | 2020-12-17 16:14:30 +0100 | [diff] [blame] | 77 | extern void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes); |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 78 | extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks); |
Andreas Gruenbacher | 2129b42 | 2020-12-17 16:14:30 +0100 | [diff] [blame] | 79 | extern bool gfs2_log_try_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, |
| 80 | unsigned int *extra_revokes); |
| 81 | extern void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr, |
| 82 | unsigned int *extra_revokes); |
Bob Peterson | c1696fb | 2018-01-17 00:01:33 +0100 | [diff] [blame] | 83 | extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd, |
Bob Peterson | 7c70b89 | 2019-03-25 09:34:19 -0600 | [diff] [blame] | 84 | u64 seq, u32 tail, u32 lblock, u32 flags, |
| 85 | int op_flags); |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 86 | extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, |
Bob Peterson | c1696fb | 2018-01-17 00:01:33 +0100 | [diff] [blame] | 87 | u32 type); |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 88 | extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); |
Steven Whitehouse | 4667a0e | 2011-04-18 14:18:09 +0100 | [diff] [blame] | 89 | extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc); |
Bob Peterson | 9ff7828 | 2019-11-13 13:47:02 -0600 | [diff] [blame] | 90 | extern void log_flush_wait(struct gfs2_sbd *sdp); |
Steven Whitehouse | 2bcd610 | 2007-11-08 14:25:12 +0000 | [diff] [blame] | 91 | |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 92 | extern int gfs2_logd(void *data); |
Benjamin Marzinski | 5d05496 | 2013-06-14 11:38:29 -0500 | [diff] [blame] | 93 | extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); |
Bob Peterson | fe5e7ba | 2019-11-14 09:49:11 -0500 | [diff] [blame] | 94 | extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); |
Andreas Gruenbacher | e7501bf | 2020-12-19 03:11:51 +0100 | [diff] [blame] | 95 | extern void gfs2_flush_revokes(struct gfs2_sbd *sdp); |
Bob Peterson | f5456b5 | 2021-05-19 14:54:02 -0400 | [diff] [blame] | 96 | extern void gfs2_ail_drain(struct gfs2_sbd *sdp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 97 | |
| 98 | #endif /* __LOG_DOT_H__ */ |