forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 958e46acc8e900e8569dd467c1af9b8d2d019394
kernel/fs/gfs2/util.h
....@@ -1,10 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
34 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4
- *
5
- * This copyrighted material is made available to anyone wishing to use,
6
- * modify, copy, or redistribute it subject to the terms and conditions
7
- * of the GNU General Public License version 2.
85 */
96
107 #ifndef __UTIL_DOT_H__
....@@ -39,41 +36,59 @@
3936 } while (0)
4037
4138
42
-int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
43
- const char *function, char *file, unsigned int line);
39
+void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
40
+ const char *function, char *file, unsigned int line,
41
+ bool delayed);
4442
4543 #define gfs2_assert_withdraw(sdp, assertion) \
46
-((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
47
- __func__, __FILE__, __LINE__))
44
+ ({ \
45
+ bool _bool = (assertion); \
46
+ if (unlikely(!_bool)) \
47
+ gfs2_assert_withdraw_i((sdp), #assertion, \
48
+ __func__, __FILE__, __LINE__, false); \
49
+ !_bool; \
50
+ })
4851
52
+#define gfs2_assert_withdraw_delayed(sdp, assertion) \
53
+ ({ \
54
+ bool _bool = (assertion); \
55
+ if (unlikely(!_bool)) \
56
+ gfs2_assert_withdraw_i((sdp), #assertion, \
57
+ __func__, __FILE__, __LINE__, true); \
58
+ !_bool; \
59
+ })
4960
50
-int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
51
- const char *function, char *file, unsigned int line);
61
+void gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
62
+ const char *function, char *file, unsigned int line);
5263
5364 #define gfs2_assert_warn(sdp, assertion) \
54
-((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
55
- __func__, __FILE__, __LINE__))
65
+ ({ \
66
+ bool _bool = (assertion); \
67
+ if (unlikely(!_bool)) \
68
+ gfs2_assert_warn_i((sdp), #assertion, \
69
+ __func__, __FILE__, __LINE__); \
70
+ !_bool; \
71
+ })
5672
57
-
58
-int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide,
59
- const char *function, char *file, unsigned int line);
73
+void gfs2_consist_i(struct gfs2_sbd *sdp,
74
+ const char *function, char *file, unsigned int line);
6075
6176 #define gfs2_consist(sdp) \
62
-gfs2_consist_i((sdp), 0, __func__, __FILE__, __LINE__)
77
+gfs2_consist_i((sdp), __func__, __FILE__, __LINE__)
6378
6479
65
-int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
66
- const char *function, char *file, unsigned int line);
80
+void gfs2_consist_inode_i(struct gfs2_inode *ip,
81
+ const char *function, char *file, unsigned int line);
6782
6883 #define gfs2_consist_inode(ip) \
69
-gfs2_consist_inode_i((ip), 0, __func__, __FILE__, __LINE__)
84
+gfs2_consist_inode_i((ip), __func__, __FILE__, __LINE__)
7085
7186
72
-int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
73
- const char *function, char *file, unsigned int line);
87
+void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
88
+ const char *function, char *file, unsigned int line);
7489
7590 #define gfs2_consist_rgrpd(rgd) \
76
-gfs2_consist_rgrpd_i((rgd), 0, __func__, __FILE__, __LINE__)
91
+gfs2_consist_rgrpd_i((rgd), __func__, __FILE__, __LINE__)
7792
7893
7994 int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
....@@ -86,7 +101,7 @@
86101 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
87102 u32 magic = be32_to_cpu(mh->mh_magic);
88103 if (unlikely(magic != GFS2_MAGIC)) {
89
- pr_err("Magic number missing at %llu\n",
104
+ fs_err(sdp, "Magic number missing at %llu\n",
90105 (unsigned long long)bh->b_blocknr);
91106 return -EIO;
92107 }
....@@ -132,6 +147,12 @@
132147 int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
133148 char *file, unsigned int line);
134149
150
+extern int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
151
+ bool verbose);
152
+extern int gfs2_freeze_lock(struct gfs2_sbd *sdp,
153
+ struct gfs2_holder *freeze_gh, int caller_flags);
154
+extern void gfs2_freeze_unlock(struct gfs2_holder *freeze_gh);
155
+
135156 #define gfs2_io_error(sdp) \
136157 gfs2_io_error_i((sdp), __func__, __FILE__, __LINE__);
137158
....@@ -154,6 +175,7 @@
154175 extern struct kmem_cache *gfs2_rgrpd_cachep;
155176 extern struct kmem_cache *gfs2_quotad_cachep;
156177 extern struct kmem_cache *gfs2_qadata_cachep;
178
+extern struct kmem_cache *gfs2_trans_cachep;
157179 extern mempool_t *gfs2_page_pool;
158180 extern struct workqueue_struct *gfs2_control_wq;
159181
....@@ -167,10 +189,40 @@
167189 return x;
168190 }
169191
192
+/**
193
+ * gfs2_withdraw_delayed - withdraw as soon as possible without deadlocks
194
+ * @sdp: the superblock
195
+ */
196
+static inline void gfs2_withdraw_delayed(struct gfs2_sbd *sdp)
197
+{
198
+ set_bit(SDF_WITHDRAWING, &sdp->sd_flags);
199
+}
200
+
201
+/**
202
+ * gfs2_withdrawn - test whether the file system is withdrawing or withdrawn
203
+ * @sdp: the superblock
204
+ */
205
+static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)
206
+{
207
+ return test_bit(SDF_WITHDRAWN, &sdp->sd_flags) ||
208
+ test_bit(SDF_WITHDRAWING, &sdp->sd_flags);
209
+}
210
+
211
+/**
212
+ * gfs2_withdrawing - check if a withdraw is pending
213
+ * @sdp: the superblock
214
+ */
215
+static inline bool gfs2_withdrawing(struct gfs2_sbd *sdp)
216
+{
217
+ return test_bit(SDF_WITHDRAWING, &sdp->sd_flags) &&
218
+ !test_bit(SDF_WITHDRAWN, &sdp->sd_flags);
219
+}
220
+
170221 #define gfs2_tune_get(sdp, field) \
171222 gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
172223
173224 __printf(2, 3)
174
-int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...);
225
+void gfs2_lm(struct gfs2_sbd *sdp, const char *fmt, ...);
226
+int gfs2_withdraw(struct gfs2_sbd *sdp);
175227
176228 #endif /* __UTIL_DOT_H__ */