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 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 16 | /** |
| 17 | * gfs2_log_lock - acquire the right to mess with the log manager |
| 18 | * @sdp: the filesystem |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | static inline void gfs2_log_lock(struct gfs2_sbd *sdp) |
Harvey Harrison | 2d81afb | 2008-05-29 18:27:51 -0700 | [diff] [blame] | 23 | __acquires(&sdp->sd_log_lock) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 24 | { |
| 25 | spin_lock(&sdp->sd_log_lock); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * gfs2_log_unlock - release the right to mess with the log manager |
| 30 | * @sdp: the filesystem |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | static inline void gfs2_log_unlock(struct gfs2_sbd *sdp) |
Harvey Harrison | 2d81afb | 2008-05-29 18:27:51 -0700 | [diff] [blame] | 35 | __releases(&sdp->sd_log_lock) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 36 | { |
| 37 | spin_unlock(&sdp->sd_log_lock); |
| 38 | } |
| 39 | |
| 40 | static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, |
| 41 | unsigned int value) |
| 42 | { |
| 43 | if (++value == sdp->sd_jdesc->jd_blocks) { |
| 44 | value = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 45 | } |
| 46 | sdp->sd_log_head = sdp->sd_log_tail = value; |
| 47 | } |
| 48 | |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 49 | static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) |
| 50 | { |
Andreas Gruenbacher | 977767a | 2018-10-12 20:07:27 +0200 | [diff] [blame] | 51 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 52 | |
Andreas Gruenbacher | 977767a | 2018-10-12 20:07:27 +0200 | [diff] [blame] | 53 | if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp)) |
Andreas Gruenbacher | 845802b | 2018-06-04 07:50:16 -0500 | [diff] [blame] | 54 | return; |
| 55 | |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 56 | if (!test_bit(GIF_ORDERED, &ip->i_flags)) { |
| 57 | spin_lock(&sdp->sd_ordered_lock); |
| 58 | if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags)) |
Andreas Gruenbacher | a5b1d3f | 2019-04-05 12:16:14 +0100 | [diff] [blame] | 59 | list_add(&ip->i_ordered, &sdp->sd_log_ordered); |
Steven Whitehouse | 4513899 | 2013-01-28 09:30:07 +0000 | [diff] [blame] | 60 | spin_unlock(&sdp->sd_ordered_lock); |
| 61 | } |
| 62 | } |
| 63 | extern void gfs2_ordered_del_inode(struct gfs2_inode *ip); |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 64 | extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 65 | unsigned int ssize); |
| 66 | |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 67 | extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks); |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 68 | extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks); |
Bob Peterson | c1696fb | 2018-01-17 00:01:33 +0100 | [diff] [blame] | 69 | 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] | 70 | u64 seq, u32 tail, u32 lblock, u32 flags, |
| 71 | int op_flags); |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 72 | 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] | 73 | u32 type); |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 74 | 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] | 75 | extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc); |
Steven Whitehouse | 2bcd610 | 2007-11-08 14:25:12 +0000 | [diff] [blame] | 76 | |
Bob Peterson | ed4878e | 2010-05-20 23:30:11 -0400 | [diff] [blame] | 77 | extern int gfs2_logd(void *data); |
Benjamin Marzinski | 5d05496 | 2013-06-14 11:38:29 -0500 | [diff] [blame] | 78 | 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^] | 79 | extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); |
Benjamin Marzinski | 5d05496 | 2013-06-14 11:38:29 -0500 | [diff] [blame] | 80 | extern void gfs2_write_revokes(struct gfs2_sbd *sdp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 81 | |
| 82 | #endif /* __LOG_DOT_H__ */ |