17336d0e6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b3b94faaSDavid Teigland /*
3b3b94faaSDavid Teigland * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
429d38cd1SBob Peterson * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
5b3b94faaSDavid Teigland */
6b3b94faaSDavid Teigland
7b3b94faaSDavid Teigland #ifndef __INCORE_DOT_H__
8b3b94faaSDavid Teigland #define __INCORE_DOT_H__
9b3b94faaSDavid Teigland
10f2f7ba52SSteven Whitehouse #include <linux/fs.h>
1157cc7215SAlexey Dobriyan #include <linux/kobject.h>
12c4f68a13SBenjamin Marzinski #include <linux/workqueue.h>
13f057f6cdSSteven Whitehouse #include <linux/dlm.h>
14f057f6cdSSteven Whitehouse #include <linux/buffer_head.h>
15bc015cb8SSteven Whitehouse #include <linux/rcupdate.h>
16bc015cb8SSteven Whitehouse #include <linux/rculist_bl.h>
173942ae53SSteven Whitehouse #include <linux/completion.h>
187c9ca621SBob Peterson #include <linux/rbtree.h>
19a245769fSSteven Whitehouse #include <linux/ktime.h>
20a245769fSSteven Whitehouse #include <linux/percpu.h>
21e66cf161SSteven Whitehouse #include <linux/lockref.h>
2288ffbf3eSBob Peterson #include <linux/rhashtable.h>
239e514605SAndreas Gruenbacher #include <linux/mutex.h>
24f2f7ba52SSteven Whitehouse
25b3b94faaSDavid Teigland #define DIO_WAIT 0x00000010
26b3b94faaSDavid Teigland #define DIO_METADATA 0x00000020
27b3b94faaSDavid Teigland
28b3b94faaSDavid Teigland struct gfs2_log_operations;
29c0752aa7SBob Peterson struct gfs2_bufdata;
30b3b94faaSDavid Teigland struct gfs2_holder;
31b3b94faaSDavid Teigland struct gfs2_glock;
32b3b94faaSDavid Teigland struct gfs2_quota_data;
33b3b94faaSDavid Teigland struct gfs2_trans;
34b3b94faaSDavid Teigland struct gfs2_jdesc;
35b3b94faaSDavid Teigland struct gfs2_sbd;
36f057f6cdSSteven Whitehouse struct lm_lockops;
37b3b94faaSDavid Teigland
38b3b94faaSDavid Teigland typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret);
39b3b94faaSDavid Teigland
40bb8d8a6fSSteven Whitehouse struct gfs2_log_header_host {
41bb8d8a6fSSteven Whitehouse u64 lh_sequence; /* Sequence number of this transaction */
42bb8d8a6fSSteven Whitehouse u32 lh_flags; /* GFS2_LOG_HEAD_... */
43bb8d8a6fSSteven Whitehouse u32 lh_tail; /* Block number of log tail */
44bb8d8a6fSSteven Whitehouse u32 lh_blkno;
4573092698SAbhi Das
4673092698SAbhi Das s64 lh_local_total;
4773092698SAbhi Das s64 lh_local_free;
4873092698SAbhi Das s64 lh_local_dinodes;
49bb8d8a6fSSteven Whitehouse };
50bb8d8a6fSSteven Whitehouse
51b3b94faaSDavid Teigland /*
52b3b94faaSDavid Teigland * Structure of operations that are associated with each
53b3b94faaSDavid Teigland * type of element in the log.
54b3b94faaSDavid Teigland */
55b3b94faaSDavid Teigland
56b3b94faaSDavid Teigland struct gfs2_log_operations {
57d69a3c65SSteven Whitehouse void (*lo_before_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
5816ca9412SBenjamin Marzinski void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
59b3b94faaSDavid Teigland void (*lo_before_scan) (struct gfs2_jdesc *jd,
6055167622SAl Viro struct gfs2_log_header_host *head, int pass);
61b3b94faaSDavid Teigland int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start,
62b3b94faaSDavid Teigland struct gfs2_log_descriptor *ld, __be64 *ptr,
63b3b94faaSDavid Teigland int pass);
64b3b94faaSDavid Teigland void (*lo_after_scan) (struct gfs2_jdesc *jd, int error, int pass);
65b09e593dSSteven Whitehouse const char *lo_name;
66b3b94faaSDavid Teigland };
67b3b94faaSDavid Teigland
6860a0b8f9SSteven Whitehouse #define GBF_FULL 1
6960a0b8f9SSteven Whitehouse
70dffe12a8SBob Peterson /**
71dffe12a8SBob Peterson * Clone bitmaps (bi_clone):
72dffe12a8SBob Peterson *
73dffe12a8SBob Peterson * - When a block is freed, we remember the previous state of the block in the
74dffe12a8SBob Peterson * clone bitmap, and only mark the block as free in the real bitmap.
75dffe12a8SBob Peterson *
76dffe12a8SBob Peterson * - When looking for a block to allocate, we check for a free block in the
77dffe12a8SBob Peterson * clone bitmap, and if no clone bitmap exists, in the real bitmap.
78dffe12a8SBob Peterson *
79dffe12a8SBob Peterson * - For allocating a block, we mark it as allocated in the real bitmap, and if
80dffe12a8SBob Peterson * a clone bitmap exists, also in the clone bitmap.
81dffe12a8SBob Peterson *
82dffe12a8SBob Peterson * - At the end of a log_flush, we copy the real bitmap into the clone bitmap
83dffe12a8SBob Peterson * to make the clone bitmap reflect the current allocation state.
84dffe12a8SBob Peterson * (Alternatively, we could remove the clone bitmap.)
85dffe12a8SBob Peterson *
86dffe12a8SBob Peterson * The clone bitmaps are in-core only, and is never written to disk.
87dffe12a8SBob Peterson *
88dffe12a8SBob Peterson * These steps ensure that blocks which have been freed in a transaction cannot
89dffe12a8SBob Peterson * be reallocated in that same transaction.
90dffe12a8SBob Peterson */
91b3b94faaSDavid Teigland struct gfs2_bitmap {
92b3b94faaSDavid Teigland struct buffer_head *bi_bh;
93b3b94faaSDavid Teigland char *bi_clone;
9460a0b8f9SSteven Whitehouse unsigned long bi_flags;
95cd915493SSteven Whitehouse u32 bi_offset;
96cd915493SSteven Whitehouse u32 bi_start;
97281b4952SAndreas Gruenbacher u32 bi_bytes;
987e230f57SBob Peterson u32 bi_blocks;
99b3b94faaSDavid Teigland };
100b3b94faaSDavid Teigland
101b3b94faaSDavid Teigland struct gfs2_rgrpd {
1027c9ca621SBob Peterson struct rb_node rd_node; /* Link with superblock */
103b3b94faaSDavid Teigland struct gfs2_glock *rd_gl; /* Glock for this rgrp */
104bb8d8a6fSSteven Whitehouse u64 rd_addr; /* grp block disk address */
105bb8d8a6fSSteven Whitehouse u64 rd_data0; /* first data location */
106bb8d8a6fSSteven Whitehouse u32 rd_length; /* length of rgrp header in fs blocks */
107bb8d8a6fSSteven Whitehouse u32 rd_data; /* num of data blocks in rgrp */
108bb8d8a6fSSteven Whitehouse u32 rd_bitbytes; /* number of bytes in data bitmaps */
109cfc8b549SSteven Whitehouse u32 rd_free;
11007974d2aSAndreas Gruenbacher u32 rd_requested; /* number of blocks in rd_rstree */
111725d0e9dSAndreas Gruenbacher u32 rd_reserved; /* number of reserved blocks */
11273f74948SSteven Whitehouse u32 rd_free_clone;
11373f74948SSteven Whitehouse u32 rd_dinodes;
114d8b71f73SSteven Whitehouse u64 rd_igeneration;
115b3b94faaSDavid Teigland struct gfs2_bitmap *rd_bits;
116b3b94faaSDavid Teigland struct gfs2_sbd *rd_sbd;
11790306c41SBenjamin Marzinski struct gfs2_rgrp_lvb *rd_rgl;
11873f74948SSteven Whitehouse u32 rd_last_alloc;
1191ce97e56SSteven Whitehouse u32 rd_flags;
1205ea5050cSBob Peterson u32 rd_extfail_pt; /* extent failure point */
12109010978SSteven Whitehouse #define GFS2_RDF_CHECK 0x10000000 /* check for unlinked inodes */
12209010978SSteven Whitehouse #define GFS2_RDF_ERROR 0x40000000 /* error in rg */
1230e27c18cSBob Peterson #define GFS2_RDF_PREFERRED 0x80000000 /* This rgrp is preferred */
12409010978SSteven Whitehouse #define GFS2_RDF_MASK 0xf0000000 /* mask for internal flags */
1258e2e0047SBob Peterson spinlock_t rd_rsspin; /* protects reservation related vars */
1269e514605SAndreas Gruenbacher struct mutex rd_mutex;
1278e2e0047SBob Peterson struct rb_root rd_rstree; /* multi-block reservation tree */
128b3b94faaSDavid Teigland };
129b3b94faaSDavid Teigland
130b3b94faaSDavid Teigland enum gfs2_state_bits {
131b3b94faaSDavid Teigland BH_Pinned = BH_PrivateStart,
132f42faf4fSSteven Whitehouse BH_Escaped = BH_PrivateStart + 1,
133b3b94faaSDavid Teigland };
134b3b94faaSDavid Teigland
135b3b94faaSDavid Teigland BUFFER_FNS(Pinned, pinned)
136b3b94faaSDavid Teigland TAS_BUFFER_FNS(Pinned, pinned)
137f42faf4fSSteven Whitehouse BUFFER_FNS(Escaped, escaped)
138f42faf4fSSteven Whitehouse TAS_BUFFER_FNS(Escaped, escaped)
139b3b94faaSDavid Teigland
140b3b94faaSDavid Teigland struct gfs2_bufdata {
141b3b94faaSDavid Teigland struct buffer_head *bd_bh;
142b3b94faaSDavid Teigland struct gfs2_glock *bd_gl;
143c50b91c4SSteven Whitehouse u64 bd_blkno;
14482e86087SSteven Whitehouse
145c0752aa7SBob Peterson struct list_head bd_list;
146b3b94faaSDavid Teigland
14716ca9412SBenjamin Marzinski struct gfs2_trans *bd_tr;
148b3b94faaSDavid Teigland struct list_head bd_ail_st_list;
149b3b94faaSDavid Teigland struct list_head bd_ail_gl_list;
150b3b94faaSDavid Teigland };
151b3b94faaSDavid Teigland
152f057f6cdSSteven Whitehouse /*
153f057f6cdSSteven Whitehouse * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
154f057f6cdSSteven Whitehouse * prefix of lock_dlm_ gets awkward.
155f057f6cdSSteven Whitehouse */
156f057f6cdSSteven Whitehouse
157f057f6cdSSteven Whitehouse #define GDLM_STRNAME_BYTES 25
158f057f6cdSSteven Whitehouse #define GDLM_LVB_SIZE 32
159f057f6cdSSteven Whitehouse
160e0c2a9aaSDavid Teigland /*
161e0c2a9aaSDavid Teigland * ls_recover_flags:
162e0c2a9aaSDavid Teigland *
163e0c2a9aaSDavid Teigland * DFL_BLOCK_LOCKS: dlm is in recovery and will grant locks that had been
164e0c2a9aaSDavid Teigland * held by failed nodes whose journals need recovery. Those locks should
165e0c2a9aaSDavid Teigland * only be used for journal recovery until the journal recovery is done.
166e0c2a9aaSDavid Teigland * This is set by the dlm recover_prep callback and cleared by the
167e0c2a9aaSDavid Teigland * gfs2_control thread when journal recovery is complete. To avoid
168e0c2a9aaSDavid Teigland * races between recover_prep setting and gfs2_control clearing, recover_spin
169e0c2a9aaSDavid Teigland * is held while changing this bit and reading/writing recover_block
170e0c2a9aaSDavid Teigland * and recover_start.
171e0c2a9aaSDavid Teigland *
172e0c2a9aaSDavid Teigland * DFL_NO_DLM_OPS: dlm lockspace ops/callbacks are not being used.
173e0c2a9aaSDavid Teigland *
174e0c2a9aaSDavid Teigland * DFL_FIRST_MOUNT: this node is the first to mount this fs and is doing
175e0c2a9aaSDavid Teigland * recovery of all journals before allowing other nodes to mount the fs.
176e0c2a9aaSDavid Teigland * This is cleared when FIRST_MOUNT_DONE is set.
177e0c2a9aaSDavid Teigland *
178e0c2a9aaSDavid Teigland * DFL_FIRST_MOUNT_DONE: this node was the first mounter, and has finished
179e0c2a9aaSDavid Teigland * recovery of all journals, and now allows other nodes to mount the fs.
180e0c2a9aaSDavid Teigland *
181e0c2a9aaSDavid Teigland * DFL_MOUNT_DONE: gdlm_mount has completed successfully and cleared
182e0c2a9aaSDavid Teigland * BLOCK_LOCKS for the first time. The gfs2_control thread should now
183e0c2a9aaSDavid Teigland * control clearing BLOCK_LOCKS for further recoveries.
184e0c2a9aaSDavid Teigland *
185e0c2a9aaSDavid Teigland * DFL_UNMOUNT: gdlm_unmount sets to keep sdp off gfs2_control_wq.
186e0c2a9aaSDavid Teigland *
187e0c2a9aaSDavid Teigland * DFL_DLM_RECOVERY: set while dlm is in recovery, between recover_prep()
188e0c2a9aaSDavid Teigland * and recover_done(), i.e. set while recover_block == recover_start.
189e0c2a9aaSDavid Teigland */
190e0c2a9aaSDavid Teigland
191f057f6cdSSteven Whitehouse enum {
192f057f6cdSSteven Whitehouse DFL_BLOCK_LOCKS = 0,
193e0c2a9aaSDavid Teigland DFL_NO_DLM_OPS = 1,
194e0c2a9aaSDavid Teigland DFL_FIRST_MOUNT = 2,
195e0c2a9aaSDavid Teigland DFL_FIRST_MOUNT_DONE = 3,
196e0c2a9aaSDavid Teigland DFL_MOUNT_DONE = 4,
197e0c2a9aaSDavid Teigland DFL_UNMOUNT = 5,
198e0c2a9aaSDavid Teigland DFL_DLM_RECOVERY = 6,
199f057f6cdSSteven Whitehouse };
200f057f6cdSSteven Whitehouse
201972b044eSAndreas Gruenbacher /*
202972b044eSAndreas Gruenbacher * We are using struct lm_lockname as an rhashtable key. Avoid holes within
203972b044eSAndreas Gruenbacher * the struct; padding at the end is fine.
204972b044eSAndreas Gruenbacher */
205f057f6cdSSteven Whitehouse struct lm_lockname {
206f057f6cdSSteven Whitehouse u64 ln_number;
207972b044eSAndreas Gruenbacher struct gfs2_sbd *ln_sbd;
208f057f6cdSSteven Whitehouse unsigned int ln_type;
209972b044eSAndreas Gruenbacher };
210f057f6cdSSteven Whitehouse
211f057f6cdSSteven Whitehouse #define lm_name_equal(name1, name2) \
212f057f6cdSSteven Whitehouse (((name1)->ln_number == (name2)->ln_number) && \
21315562c43SBob Peterson ((name1)->ln_type == (name2)->ln_type) && \
21415562c43SBob Peterson ((name1)->ln_sbd == (name2)->ln_sbd))
215f057f6cdSSteven Whitehouse
216f057f6cdSSteven Whitehouse
217b3b94faaSDavid Teigland struct gfs2_glock_operations {
2181c634f94SBob Peterson int (*go_sync) (struct gfs2_glock *gl);
219f68effb3SBob Peterson int (*go_xmote_bh)(struct gfs2_glock *gl);
220b3b94faaSDavid Teigland void (*go_inval) (struct gfs2_glock *gl, int flags);
22197cc1025SSteven Whitehouse int (*go_demote_ok) (const struct gfs2_glock *gl);
2225f38a4d3SAndreas Gruenbacher int (*go_instantiate) (struct gfs2_glock *gl);
22386c30a01SAndreas Gruenbacher int (*go_held)(struct gfs2_holder *gh);
224f246dd4bSAndreas Gruenbacher void (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl,
2253792ce97SBob Peterson const char *fs_id_buf);
22681ffbf65SSteven Whitehouse void (*go_callback)(struct gfs2_glock *gl, bool remote);
227601ef0d5SBob Peterson void (*go_free)(struct gfs2_glock *gl);
228515b269dSAlexander Aring const int go_subclass;
2298fb4b536SSteven Whitehouse const int go_type;
230009d8518SSteven Whitehouse const unsigned long go_flags;
231a72d2401SBob Peterson #define GLOF_ASPACE 1 /* address space attached */
232a72d2401SBob Peterson #define GLOF_LVB 2 /* Lock Value Block attached */
233a72d2401SBob Peterson #define GLOF_LRU 4 /* LRU managed */
234a72d2401SBob Peterson #define GLOF_NONDISK 8 /* not I/O related */
235b3b94faaSDavid Teigland };
236b3b94faaSDavid Teigland
237b3b94faaSDavid Teigland enum {
238a245769fSSteven Whitehouse GFS2_LKS_SRTT = 0, /* Non blocking smoothed round trip time */
239a245769fSSteven Whitehouse GFS2_LKS_SRTTVAR = 1, /* Non blocking smoothed variance */
240a245769fSSteven Whitehouse GFS2_LKS_SRTTB = 2, /* Blocking smoothed round trip time */
241a245769fSSteven Whitehouse GFS2_LKS_SRTTVARB = 3, /* Blocking smoothed variance */
242a245769fSSteven Whitehouse GFS2_LKS_SIRT = 4, /* Smoothed Inter-request time */
243a245769fSSteven Whitehouse GFS2_LKS_SIRTVAR = 5, /* Smoothed Inter-request variance */
244a245769fSSteven Whitehouse GFS2_LKS_DCOUNT = 6, /* Count of dlm requests */
245a245769fSSteven Whitehouse GFS2_LKS_QCOUNT = 7, /* Count of gfs2_holder queues */
246a245769fSSteven Whitehouse GFS2_NR_LKSTATS
247a245769fSSteven Whitehouse };
248a245769fSSteven Whitehouse
249a245769fSSteven Whitehouse struct gfs2_lkstats {
2504d207133SBen Hutchings u64 stats[GFS2_NR_LKSTATS];
251a245769fSSteven Whitehouse };
252a245769fSSteven Whitehouse
253a245769fSSteven Whitehouse enum {
254b3b94faaSDavid Teigland /* States */
2556802e340SSteven Whitehouse HIF_HOLDER = 6, /* Set for gh that "holds" the glock */
256fee852e3SSteven Whitehouse HIF_WAIT = 10,
257b3b94faaSDavid Teigland };
258b3b94faaSDavid Teigland
259b3b94faaSDavid Teigland struct gfs2_holder {
260b3b94faaSDavid Teigland struct list_head gh_list;
261b3b94faaSDavid Teigland
262b3b94faaSDavid Teigland struct gfs2_glock *gh_gl;
263b1e058daSPavel Emelyanov struct pid *gh_owner_pid;
264b58bf407SBob Peterson u16 gh_flags;
265b58bf407SBob Peterson u16 gh_state;
266b3b94faaSDavid Teigland
267b3b94faaSDavid Teigland int gh_error;
2686802e340SSteven Whitehouse unsigned long gh_iflags; /* HIF_... */
269d0dc80dbSSteven Whitehouse unsigned long gh_ip;
270b3b94faaSDavid Teigland };
271b3b94faaSDavid Teigland
272a937cca2SJan Kara /* Number of quota types we support */
273a937cca2SJan Kara #define GFS2_MAXQUOTAS 2
274a937cca2SJan Kara
275b54e9a0bSBob Peterson struct gfs2_qadata { /* quota allocation data */
276b54e9a0bSBob Peterson /* Quota stuff */
277b54e9a0bSBob Peterson struct gfs2_quota_data *qa_qd[2 * GFS2_MAXQUOTAS];
278b54e9a0bSBob Peterson struct gfs2_holder qa_qd_ghs[2 * GFS2_MAXQUOTAS];
279b54e9a0bSBob Peterson unsigned int qa_qd_num;
2802fba46a0SBob Peterson int qa_ref;
281b54e9a0bSBob Peterson };
282b54e9a0bSBob Peterson
2838e2e0047SBob Peterson /* Resource group multi-block reservation, in order of appearance:
2848e2e0047SBob Peterson
2858e2e0047SBob Peterson Step 1. Function prepares to write, allocates a mb, sets the size hint.
2868e2e0047SBob Peterson Step 2. User calls inplace_reserve to target an rgrp, sets the rgrp info
2878e2e0047SBob Peterson Step 3. Function get_local_rgrp locks the rgrp, determines which bits to use
2888e2e0047SBob Peterson Step 4. Bits are assigned from the rgrp based on either the reservation
2898e2e0047SBob Peterson or wherever it can.
2908e2e0047SBob Peterson */
2918e2e0047SBob Peterson
2928e2e0047SBob Peterson struct gfs2_blkreserv {
293c65b76b8SAndreas Gruenbacher struct rb_node rs_node; /* node within rd_rstree */
294c65b76b8SAndreas Gruenbacher struct gfs2_rgrpd *rs_rgd;
29507974d2aSAndreas Gruenbacher u64 rs_start;
29607974d2aSAndreas Gruenbacher u32 rs_requested;
297725d0e9dSAndreas Gruenbacher u32 rs_reserved; /* number of reserved blocks */
2988e2e0047SBob Peterson };
2998e2e0047SBob Peterson
3007b9cff46SSteven Whitehouse /*
3017b9cff46SSteven Whitehouse * Allocation parameters
3027b9cff46SSteven Whitehouse * @target: The number of blocks we'd ideally like to allocate
3037b9cff46SSteven Whitehouse * @aflags: The flags (e.g. Orlov flag)
3047b9cff46SSteven Whitehouse *
3057b9cff46SSteven Whitehouse * The intent is to gradually expand this structure over time in
3067b9cff46SSteven Whitehouse * order to give more information, e.g. alignment, min extent size
3077b9cff46SSteven Whitehouse * to the allocation code.
3087b9cff46SSteven Whitehouse */
3097b9cff46SSteven Whitehouse struct gfs2_alloc_parms {
310b8fbf471SAbhi Das u64 target;
31125435e5eSAbhi Das u32 min_target;
3127b9cff46SSteven Whitehouse u32 aflags;
31325435e5eSAbhi Das u64 allowed;
3147b9cff46SSteven Whitehouse };
3157b9cff46SSteven Whitehouse
316b3b94faaSDavid Teigland enum {
317b3b94faaSDavid Teigland GLF_LOCK = 1,
318f2e70d8fSBob Peterson GLF_INSTANTIATE_NEEDED = 2, /* needs instantiate */
3193b8249f6SSteven Whitehouse GLF_DEMOTE = 3,
320c4f68a13SBenjamin Marzinski GLF_PENDING_DEMOTE = 4,
3216802e340SSteven Whitehouse GLF_DEMOTE_IN_PROGRESS = 5,
3226802e340SSteven Whitehouse GLF_DIRTY = 6,
3232bcd610dSSteven Whitehouse GLF_LFLUSH = 7,
3246802e340SSteven Whitehouse GLF_INVALIDATE_IN_PROGRESS = 8,
3256802e340SSteven Whitehouse GLF_REPLY_PENDING = 9,
326f057f6cdSSteven Whitehouse GLF_INITIAL = 10,
327f057f6cdSSteven Whitehouse GLF_FROZEN = 11,
328f2e70d8fSBob Peterson GLF_INSTANTIATE_IN_PROG = 12, /* instantiate happening now */
329627c10b7SSteven Whitehouse GLF_LRU = 13,
330627c10b7SSteven Whitehouse GLF_OBJECT = 14, /* Used only for tracing */
331a245769fSSteven Whitehouse GLF_BLOCKING = 15,
3323056dc46SAndreas Gruenbacher GLF_FREEING = 16, /* Wait for glock to be freed */
333f0e56edcSAndreas Gruenbacher GLF_TRY_TO_EVICT = 17, /* iopen glocks only */
334*4389447fSAndreas Gruenbacher GLF_VERIFY_DELETE = 18, /* iopen glocks only */
335b3b94faaSDavid Teigland };
336b3b94faaSDavid Teigland
337b3b94faaSDavid Teigland struct gfs2_glock {
338b3b94faaSDavid Teigland unsigned long gl_flags; /* GLF_... */
339b3b94faaSDavid Teigland struct lm_lockname gl_name;
340b3b94faaSDavid Teigland
341e66cf161SSteven Whitehouse struct lockref gl_lockref;
342b3b94faaSDavid Teigland
343f3dd1649SAndreas Gruenbacher /* State fields protected by gl_lockref.lock */
34447a25380SSteven Whitehouse unsigned int gl_state:2, /* Current state */
34547a25380SSteven Whitehouse gl_target:2, /* Target state */
34647a25380SSteven Whitehouse gl_demote_state:2, /* State requested by remote node */
34747a25380SSteven Whitehouse gl_req:2, /* State in last dlm request */
34847a25380SSteven Whitehouse gl_reply:8; /* Last reply from the dlm */
34947a25380SSteven Whitehouse
3503b8249f6SSteven Whitehouse unsigned long gl_demote_time; /* time of first demote request */
3517cf8dcd3SBob Peterson long gl_hold_time;
352b3b94faaSDavid Teigland struct list_head gl_holders;
353b3b94faaSDavid Teigland
3548fb4b536SSteven Whitehouse const struct gfs2_glock_operations *gl_ops;
355a245769fSSteven Whitehouse ktime_t gl_dstamp;
356a245769fSSteven Whitehouse struct gfs2_lkstats gl_stats;
357f057f6cdSSteven Whitehouse struct dlm_lksb gl_lksb;
358c4f68a13SBenjamin Marzinski unsigned long gl_tchange;
359b3b94faaSDavid Teigland void *gl_object;
360b3b94faaSDavid Teigland
36197cc1025SSteven Whitehouse struct list_head gl_lru;
362b3b94faaSDavid Teigland struct list_head gl_ail_list;
363b3b94faaSDavid Teigland atomic_t gl_ail_count;
364638803d4SBob Peterson atomic_t gl_revokes;
365c4f68a13SBenjamin Marzinski struct delayed_work gl_work;
366a0e3cc65SAndreas Gruenbacher /* For iopen glocks only */
367b0dcffd8SAndreas Gruenbacher struct {
368a0e3cc65SAndreas Gruenbacher struct delayed_work gl_delete;
369b0dcffd8SAndreas Gruenbacher u64 gl_no_formal_ino;
370b0dcffd8SAndreas Gruenbacher };
371961ae1d8SAndreas Gruenbacher struct rcu_head gl_rcu;
37288ffbf3eSBob Peterson struct rhash_head gl_node;
373b3b94faaSDavid Teigland };
374b3b94faaSDavid Teigland
375b3b94faaSDavid Teigland enum {
376b3b94faaSDavid Teigland GIF_QD_LOCKED = 1,
37740ac218fSSteven Whitehouse GIF_ALLOC_FAILED = 2,
378b3b94faaSDavid Teigland GIF_SW_PAGED = 3,
37905978803SAbhi Das GIF_FREE_VFS_INODE = 5,
3804fd1a579SAndreas Gruenbacher GIF_GLOP_PENDING = 6,
3818c7b9262SAndreas Gruenbacher GIF_DEFERRED_DELETE = 7,
382b3b94faaSDavid Teigland };
383b3b94faaSDavid Teigland
384b3b94faaSDavid Teigland struct gfs2_inode {
385320dd101SSteven Whitehouse struct inode i_inode;
386dbb7cae2SSteven Whitehouse u64 i_no_addr;
387dbb7cae2SSteven Whitehouse u64 i_no_formal_ino;
388bcf0b5b3SSteven Whitehouse u64 i_generation;
3893767ac21SSteven Whitehouse u64 i_eattr;
390b3b94faaSDavid Teigland unsigned long i_flags; /* GIF_... */
3911b223f70SAndreas Gruenbacher struct gfs2_glock *i_gl;
392b3b94faaSDavid Teigland struct gfs2_holder i_iopen_gh;
393b54e9a0bSBob Peterson struct gfs2_qadata *i_qadata; /* quota allocation data */
39421f09c43SAndreas Gruenbacher struct gfs2_holder i_rgd_gh;
395a097dc7eSBob Peterson struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
396ce276b06SSteven Whitehouse u64 i_goal; /* goal block for allocations */
39721f09c43SAndreas Gruenbacher atomic_t i_sizehint; /* hint of the write size */
398b3b94faaSDavid Teigland struct rw_semaphore i_rw_mutex;
39945138990SSteven Whitehouse struct list_head i_ordered;
40017d539f0SSteven Whitehouse __be64 *i_hash_cache;
401ad6203f2SSteven Whitehouse u32 i_entries;
402383f01fbSSteven Whitehouse u32 i_diskflags;
403ecc30c79SSteven Whitehouse u8 i_height;
4049a004508SSteven Whitehouse u8 i_depth;
405c8d57703SAndreas Gruenbacher u16 i_rahead;
406b3b94faaSDavid Teigland };
407b3b94faaSDavid Teigland
408feaa7bbaSSteven Whitehouse /*
409feaa7bbaSSteven Whitehouse * Since i_inode is the first element of struct gfs2_inode,
410feaa7bbaSSteven Whitehouse * this is effectively a cast.
411feaa7bbaSSteven Whitehouse */
GFS2_I(struct inode * inode)412320dd101SSteven Whitehouse static inline struct gfs2_inode *GFS2_I(struct inode *inode)
413320dd101SSteven Whitehouse {
414320dd101SSteven Whitehouse return container_of(inode, struct gfs2_inode, i_inode);
415320dd101SSteven Whitehouse }
416320dd101SSteven Whitehouse
GFS2_SB(const struct inode * inode)417bf36a713SSteven Whitehouse static inline struct gfs2_sbd *GFS2_SB(const struct inode *inode)
418feaa7bbaSSteven Whitehouse {
419feaa7bbaSSteven Whitehouse return inode->i_sb->s_fs_info;
420feaa7bbaSSteven Whitehouse }
421feaa7bbaSSteven Whitehouse
422b3b94faaSDavid Teigland struct gfs2_file {
423f55ab26aSSteven Whitehouse struct mutex f_fl_mutex;
424b3b94faaSDavid Teigland struct gfs2_holder f_fl_gh;
425b3b94faaSDavid Teigland };
426b3b94faaSDavid Teigland
427b3b94faaSDavid Teigland struct gfs2_revoke_replay {
428b3b94faaSDavid Teigland struct list_head rr_list;
429cd915493SSteven Whitehouse u64 rr_blkno;
430b3b94faaSDavid Teigland unsigned int rr_where;
431b3b94faaSDavid Teigland };
432b3b94faaSDavid Teigland
433b3b94faaSDavid Teigland enum {
434b3b94faaSDavid Teigland QDF_CHANGE = 1,
435b3b94faaSDavid Teigland QDF_LOCKED = 2,
436662e3a55SAbhijith Das QDF_REFRESH = 3,
4379cde2898SAbhi Das QDF_QMSG_QUIET = 4,
438b3b94faaSDavid Teigland };
439b3b94faaSDavid Teigland
440b3b94faaSDavid Teigland struct gfs2_quota_data {
441c754fbbbSSteven Whitehouse struct hlist_bl_node qd_hlist;
442b3b94faaSDavid Teigland struct list_head qd_list;
44305e0a60dSEric W. Biederman struct kqid qd_id;
444c754fbbbSSteven Whitehouse struct gfs2_sbd *qd_sbd;
4452147dbfdSSteven Whitehouse struct lockref qd_lockref;
4462147dbfdSSteven Whitehouse struct list_head qd_lru;
447c754fbbbSSteven Whitehouse unsigned qd_hash;
4482147dbfdSSteven Whitehouse
449b3b94faaSDavid Teigland unsigned long qd_flags; /* QDF_... */
450b3b94faaSDavid Teigland
451cd915493SSteven Whitehouse s64 qd_change;
452cd915493SSteven Whitehouse s64 qd_change_sync;
453b3b94faaSDavid Teigland
454b3b94faaSDavid Teigland unsigned int qd_slot;
4550e072cacSBob Peterson unsigned int qd_slot_ref;
456b3b94faaSDavid Teigland
457b3b94faaSDavid Teigland struct buffer_head *qd_bh;
458b3b94faaSDavid Teigland struct gfs2_quota_change *qd_bh_qc;
459b3b94faaSDavid Teigland unsigned int qd_bh_count;
460b3b94faaSDavid Teigland
461b3b94faaSDavid Teigland struct gfs2_glock *qd_gl;
462b3b94faaSDavid Teigland struct gfs2_quota_lvb qd_qb;
463b3b94faaSDavid Teigland
464cd915493SSteven Whitehouse u64 qd_sync_gen;
465b3b94faaSDavid Teigland unsigned long qd_last_warn;
466c754fbbbSSteven Whitehouse struct rcu_head qd_rcu;
467b3b94faaSDavid Teigland };
468b3b94faaSDavid Teigland
4699862ca05SBob Peterson enum {
4709862ca05SBob Peterson TR_TOUCHED = 1,
4719862ca05SBob Peterson TR_ATTACHED = 2,
472c968f578SAndreas Gruenbacher TR_ONSTACK = 3,
4739862ca05SBob Peterson };
4749862ca05SBob Peterson
475b3b94faaSDavid Teigland struct gfs2_trans {
476d0dc80dbSSteven Whitehouse unsigned long tr_ip;
477b3b94faaSDavid Teigland
478b3b94faaSDavid Teigland unsigned int tr_blocks;
479b3b94faaSDavid Teigland unsigned int tr_revokes;
480b3b94faaSDavid Teigland unsigned int tr_reserved;
4819862ca05SBob Peterson unsigned long tr_flags;
482b3b94faaSDavid Teigland
483b3b94faaSDavid Teigland unsigned int tr_num_buf_new;
4842332c443SRobert Peterson unsigned int tr_num_databuf_new;
485b3b94faaSDavid Teigland unsigned int tr_num_buf_rm;
4862332c443SRobert Peterson unsigned int tr_num_databuf_rm;
487b3b94faaSDavid Teigland unsigned int tr_num_revoke;
488b3b94faaSDavid Teigland
48916ca9412SBenjamin Marzinski struct list_head tr_list;
490d69a3c65SSteven Whitehouse struct list_head tr_databuf;
491d69a3c65SSteven Whitehouse struct list_head tr_buf;
492b3b94faaSDavid Teigland
49316ca9412SBenjamin Marzinski unsigned int tr_first;
49416ca9412SBenjamin Marzinski struct list_head tr_ail1_list;
49516ca9412SBenjamin Marzinski struct list_head tr_ail2_list;
496b3b94faaSDavid Teigland };
497b3b94faaSDavid Teigland
498da6dd40dSBob Peterson struct gfs2_journal_extent {
499b50f227bSSteven Whitehouse struct list_head list;
500da6dd40dSBob Peterson
501da6dd40dSBob Peterson unsigned int lblock; /* First logical block */
502da6dd40dSBob Peterson u64 dblock; /* First disk block */
503da6dd40dSBob Peterson u64 blocks;
504da6dd40dSBob Peterson };
505da6dd40dSBob Peterson
506b3b94faaSDavid Teigland struct gfs2_jdesc {
507b3b94faaSDavid Teigland struct list_head jd_list;
508da6dd40dSBob Peterson struct list_head extent_list;
509b50f227bSSteven Whitehouse unsigned int nr_extents;
5106ecd7c2dSTejun Heo struct work_struct jd_work;
5117359a19cSSteven Whitehouse struct inode *jd_inode;
51282218943SBob Peterson struct bio *jd_log_bio;
513fe64d517SSteven Whitehouse unsigned long jd_flags;
514fe64d517SSteven Whitehouse #define JDF_RECOVERY 1
515b3b94faaSDavid Teigland unsigned int jd_jid;
5167c70b896SBob Peterson u32 jd_blocks;
517376d3778SDavid Teigland int jd_recover_error;
518a17d758bSBob Peterson /* Replay stuff */
519a17d758bSBob Peterson
520a17d758bSBob Peterson unsigned int jd_found_blocks;
521a17d758bSBob Peterson unsigned int jd_found_revokes;
522a17d758bSBob Peterson unsigned int jd_replayed_blocks;
523a17d758bSBob Peterson
524a17d758bSBob Peterson struct list_head jd_revoke_list;
525a17d758bSBob Peterson unsigned int jd_replay_tail;
526a17d758bSBob Peterson
527a72d2401SBob Peterson u64 jd_no_addr;
528b3b94faaSDavid Teigland };
529b3b94faaSDavid Teigland
530bb8d8a6fSSteven Whitehouse struct gfs2_statfs_change_host {
531bb8d8a6fSSteven Whitehouse s64 sc_total;
532bb8d8a6fSSteven Whitehouse s64 sc_free;
533bb8d8a6fSSteven Whitehouse s64 sc_dinodes;
534bb8d8a6fSSteven Whitehouse };
535bb8d8a6fSSteven Whitehouse
536b3b94faaSDavid Teigland #define GFS2_QUOTA_DEFAULT GFS2_QUOTA_OFF
537b3b94faaSDavid Teigland #define GFS2_QUOTA_OFF 0
538b3b94faaSDavid Teigland #define GFS2_QUOTA_ACCOUNT 1
539b3b94faaSDavid Teigland #define GFS2_QUOTA_ON 2
540eef46ab7SBob Peterson #define GFS2_QUOTA_QUIET 3 /* on but not complaining */
541b3b94faaSDavid Teigland
542b3b94faaSDavid Teigland #define GFS2_DATA_DEFAULT GFS2_DATA_ORDERED
543b3b94faaSDavid Teigland #define GFS2_DATA_WRITEBACK 1
544b3b94faaSDavid Teigland #define GFS2_DATA_ORDERED 2
545b3b94faaSDavid Teigland
546d34843d0SBob Peterson #define GFS2_ERRORS_DEFAULT GFS2_ERRORS_WITHDRAW
547d34843d0SBob Peterson #define GFS2_ERRORS_WITHDRAW 0
548d34843d0SBob Peterson #define GFS2_ERRORS_CONTINUE 1 /* place holder for future feature */
549d34843d0SBob Peterson #define GFS2_ERRORS_RO 2 /* place holder for future feature */
550d34843d0SBob Peterson #define GFS2_ERRORS_PANIC 3
551d34843d0SBob Peterson
552b3b94faaSDavid Teigland struct gfs2_args {
553b3b94faaSDavid Teigland char ar_lockproto[GFS2_LOCKNAME_LEN]; /* Name of the Lock Protocol */
554b3b94faaSDavid Teigland char ar_locktable[GFS2_LOCKNAME_LEN]; /* Name of the Lock Table */
555b3b94faaSDavid Teigland char ar_hostdata[GFS2_LOCKNAME_LEN]; /* Host specific data */
55637ec89e8SSteven Whitehouse unsigned int ar_spectator:1; /* Don't get a journal */
55737ec89e8SSteven Whitehouse unsigned int ar_localflocks:1; /* Let the VFS do flock|fcntl */
55837ec89e8SSteven Whitehouse unsigned int ar_debug:1; /* Oops on errors */
55937ec89e8SSteven Whitehouse unsigned int ar_posix_acl:1; /* Enable posix acls */
56037ec89e8SSteven Whitehouse unsigned int ar_quota:2; /* off/account/on */
56137ec89e8SSteven Whitehouse unsigned int ar_suiddir:1; /* suiddir support */
56237ec89e8SSteven Whitehouse unsigned int ar_data:2; /* ordered/writeback */
56337ec89e8SSteven Whitehouse unsigned int ar_meta:1; /* mount metafs */
564f15ab561SSteven Whitehouse unsigned int ar_discard:1; /* discard requests */
565d34843d0SBob Peterson unsigned int ar_errors:2; /* errors=withdraw | panic */
566f25934c5SChristoph Hellwig unsigned int ar_nobarrier:1; /* do not send barriers */
56790306c41SBenjamin Marzinski unsigned int ar_rgrplvb:1; /* use lvbs for rgrp info */
56847b7ec1dSAndrew Price unsigned int ar_got_rgrplvb:1; /* Was the rgrplvb opt given? */
569471f3db2SBenjamin Marzinski unsigned int ar_loccookie:1; /* use location based readdir
570471f3db2SBenjamin Marzinski cookies */
5711f52aa08SAndrew Price s32 ar_commit; /* Commit interval */
5721f52aa08SAndrew Price s32 ar_statfs_quantum; /* The fast statfs interval */
5731f52aa08SAndrew Price s32 ar_quota_quantum; /* The quota interval */
5741f52aa08SAndrew Price s32 ar_statfs_percent; /* The % change to force sync */
575b3b94faaSDavid Teigland };
576b3b94faaSDavid Teigland
577b3b94faaSDavid Teigland struct gfs2_tune {
578b3b94faaSDavid Teigland spinlock_t gt_spin;
579b3b94faaSDavid Teigland
580b3b94faaSDavid Teigland unsigned int gt_logd_secs;
581b3b94faaSDavid Teigland
582b3b94faaSDavid Teigland unsigned int gt_quota_warn_period; /* Secs between quota warn msgs */
583b3b94faaSDavid Teigland unsigned int gt_quota_scale_num; /* Numerator */
584b3b94faaSDavid Teigland unsigned int gt_quota_scale_den; /* Denominator */
585b3b94faaSDavid Teigland unsigned int gt_quota_quantum; /* Secs between syncs to quota file */
586b3b94faaSDavid Teigland unsigned int gt_new_files_jdata;
587b3b94faaSDavid Teigland unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */
588b3b94faaSDavid Teigland unsigned int gt_complain_secs;
589b3b94faaSDavid Teigland unsigned int gt_statfs_quantum;
590b3b94faaSDavid Teigland unsigned int gt_statfs_slow;
591b3b94faaSDavid Teigland };
592b3b94faaSDavid Teigland
593b3b94faaSDavid Teigland enum {
594b3b94faaSDavid Teigland SDF_JOURNAL_CHECKED = 0,
595b3b94faaSDavid Teigland SDF_JOURNAL_LIVE = 1,
59604aea0caSBob Peterson SDF_WITHDRAWN = 2,
597254db57fSSteven Whitehouse SDF_NOBARRIERS = 3,
598fe64d517SSteven Whitehouse SDF_NORECOVERY = 4,
599913a71d2SSteven Whitehouse SDF_DEMOTE = 5,
600ba6e9364SSteven Whitehouse SDF_NOJOURNALID = 6,
601e8ca5cc5SDavid Teigland SDF_RORECOVERY = 7, /* read only recovery */
602fb6791d1SDavid Teigland SDF_SKIP_DLM_UNLOCK = 8,
603b066a4eeSAbhi Das SDF_FORCE_AIL_FLUSH = 9,
604cad1e158SAndreas Gruenbacher SDF_FREEZE_INITIATOR = 10,
605036330c9SBob Peterson SDF_WITHDRAWING = 11, /* Will withdraw eventually */
606601ef0d5SBob Peterson SDF_WITHDRAW_IN_PROG = 12, /* Withdraw is in progress */
607601ef0d5SBob Peterson SDF_REMOTE_WITHDRAW = 13, /* Performing remote recovery */
608601ef0d5SBob Peterson SDF_WITHDRAW_RECOVERY = 14, /* Wait for journal recovery when we are
609601ef0d5SBob Peterson withdrawing */
610e7beb8b6SAndreas Gruenbacher SDF_KILL = 15,
611b88beb9aSAndreas Gruenbacher SDF_EVICTING = 16,
6125432af15SAndreas Gruenbacher SDF_FROZEN = 17,
6132e60d768SBenjamin Marzinski };
6142e60d768SBenjamin Marzinski
615b3b94faaSDavid Teigland #define GFS2_FSNAME_LEN 256
616b3b94faaSDavid Teigland
617bb8d8a6fSSteven Whitehouse struct gfs2_inum_host {
618bb8d8a6fSSteven Whitehouse u64 no_formal_ino;
619bb8d8a6fSSteven Whitehouse u64 no_addr;
620bb8d8a6fSSteven Whitehouse };
621bb8d8a6fSSteven Whitehouse
622bb8d8a6fSSteven Whitehouse struct gfs2_sb_host {
623bb8d8a6fSSteven Whitehouse u32 sb_magic;
624bb8d8a6fSSteven Whitehouse u32 sb_type;
625bb8d8a6fSSteven Whitehouse
626bb8d8a6fSSteven Whitehouse u32 sb_fs_format;
627bb8d8a6fSSteven Whitehouse u32 sb_multihost_format;
628bb8d8a6fSSteven Whitehouse u32 sb_bsize;
629bb8d8a6fSSteven Whitehouse u32 sb_bsize_shift;
630bb8d8a6fSSteven Whitehouse
631bb8d8a6fSSteven Whitehouse struct gfs2_inum_host sb_master_dir;
632bb8d8a6fSSteven Whitehouse struct gfs2_inum_host sb_root_dir;
633bb8d8a6fSSteven Whitehouse
634bb8d8a6fSSteven Whitehouse char sb_lockproto[GFS2_LOCKNAME_LEN];
635bb8d8a6fSSteven Whitehouse char sb_locktable[GFS2_LOCKNAME_LEN];
636bb8d8a6fSSteven Whitehouse };
637bb8d8a6fSSteven Whitehouse
638f057f6cdSSteven Whitehouse /*
639f057f6cdSSteven Whitehouse * lm_mount() return values
640f057f6cdSSteven Whitehouse *
641f057f6cdSSteven Whitehouse * ls_jid - the journal ID this node should use
642f057f6cdSSteven Whitehouse * ls_first - this node is the first to mount the file system
643f057f6cdSSteven Whitehouse * ls_lockspace - lock module's context for this file system
644f057f6cdSSteven Whitehouse * ls_ops - lock module's functions
645f057f6cdSSteven Whitehouse */
646f057f6cdSSteven Whitehouse
647f057f6cdSSteven Whitehouse struct lm_lockstruct {
648feb47ca9SSteven Whitehouse int ls_jid;
649f057f6cdSSteven Whitehouse unsigned int ls_first;
650f057f6cdSSteven Whitehouse const struct lm_lockops *ls_ops;
651f057f6cdSSteven Whitehouse dlm_lockspace_t *ls_dlm;
652f057f6cdSSteven Whitehouse
653e0c2a9aaSDavid Teigland int ls_recover_jid_done; /* These two are deprecated, */
654e0c2a9aaSDavid Teigland int ls_recover_jid_status; /* used previously by gfs_controld */
655e0c2a9aaSDavid Teigland
656e0c2a9aaSDavid Teigland struct dlm_lksb ls_mounted_lksb; /* mounted_lock */
657e0c2a9aaSDavid Teigland struct dlm_lksb ls_control_lksb; /* control_lock */
658e0c2a9aaSDavid Teigland char ls_control_lvb[GDLM_LVB_SIZE]; /* control_lock lvb */
659e0c2a9aaSDavid Teigland struct completion ls_sync_wait; /* {control,mounted}_{lock,unlock} */
66057c7310bSDavid Teigland char *ls_lvb_bits;
661e0c2a9aaSDavid Teigland
662e0c2a9aaSDavid Teigland spinlock_t ls_recover_spin; /* protects following fields */
663e0c2a9aaSDavid Teigland unsigned long ls_recover_flags; /* DFL_ */
664e0c2a9aaSDavid Teigland uint32_t ls_recover_mount; /* gen in first recover_done cb */
665e0c2a9aaSDavid Teigland uint32_t ls_recover_start; /* gen in last recover_done cb */
666e0c2a9aaSDavid Teigland uint32_t ls_recover_block; /* copy recover_start in last recover_prep */
667e0c2a9aaSDavid Teigland uint32_t ls_recover_size; /* size of recover_submit, recover_result */
668e0c2a9aaSDavid Teigland uint32_t *ls_recover_submit; /* gen in last recover_slot cb per jid */
669e0c2a9aaSDavid Teigland uint32_t *ls_recover_result; /* result of last jid recovery */
670f057f6cdSSteven Whitehouse };
671f057f6cdSSteven Whitehouse
672a245769fSSteven Whitehouse struct gfs2_pcpu_lkstats {
673a245769fSSteven Whitehouse /* One struct for each glock type */
674a245769fSSteven Whitehouse struct gfs2_lkstats lkstats[10];
675a245769fSSteven Whitehouse };
676a245769fSSteven Whitehouse
67797fd734bSAbhi Das /* List of local (per node) statfs inodes */
67897fd734bSAbhi Das struct local_statfs_inode {
67997fd734bSAbhi Das struct list_head si_list;
68097fd734bSAbhi Das struct inode *si_sc_inode;
68197fd734bSAbhi Das unsigned int si_jid; /* journal id this statfs inode corresponds to */
68297fd734bSAbhi Das };
68397fd734bSAbhi Das
684b3b94faaSDavid Teigland struct gfs2_sbd {
685b3b94faaSDavid Teigland struct super_block *sd_vfs;
686a245769fSSteven Whitehouse struct gfs2_pcpu_lkstats __percpu *sd_lkstats;
687b3b94faaSDavid Teigland struct kobject sd_kobj;
688c2a04b02SJamie Iles struct completion sd_kobj_unregister;
689b3b94faaSDavid Teigland unsigned long sd_flags; /* SDF_... */
690f50dfaf7SAl Viro struct gfs2_sb_host sd_sb;
691b3b94faaSDavid Teigland
692b3b94faaSDavid Teigland /* Constants computed on mount */
693b3b94faaSDavid Teigland
694cd915493SSteven Whitehouse u32 sd_fsb2bb;
695cd915493SSteven Whitehouse u32 sd_fsb2bb_shift;
696cd915493SSteven Whitehouse u32 sd_diptrs; /* Number of pointers in a dinode */
697cd915493SSteven Whitehouse u32 sd_inptrs; /* Number of pointers in a indirect block */
6982e9eeaa1SBob Peterson u32 sd_ldptrs; /* Number of pointers in a log descriptor block */
699cd915493SSteven Whitehouse u32 sd_jbsize; /* Size of a journaled data block */
700cd915493SSteven Whitehouse u32 sd_hash_bsize; /* sizeof(exhash block) */
701cd915493SSteven Whitehouse u32 sd_hash_bsize_shift;
702cd915493SSteven Whitehouse u32 sd_hash_ptrs; /* Number of pointers in a hash block */
703cd915493SSteven Whitehouse u32 sd_qc_per_block;
704a68a0a35SBob Peterson u32 sd_blocks_per_bitmap;
705cd915493SSteven Whitehouse u32 sd_max_dirres; /* Max blocks needed to add a directory entry */
706cd915493SSteven Whitehouse u32 sd_max_height; /* Max height of a file's metadata tree */
707ecc30c79SSteven Whitehouse u64 sd_heightsize[GFS2_MAX_META_HEIGHT + 1];
708471f3db2SBenjamin Marzinski u32 sd_max_dents_per_leaf; /* Max number of dirents in a leaf block */
709b3b94faaSDavid Teigland
710b3b94faaSDavid Teigland struct gfs2_args sd_args; /* Mount arguments */
711b3b94faaSDavid Teigland struct gfs2_tune sd_tune; /* Filesystem tuning structure */
712b3b94faaSDavid Teigland
713b3b94faaSDavid Teigland /* Lock Stuff */
714b3b94faaSDavid Teigland
715b3b94faaSDavid Teigland struct lm_lockstruct sd_lockstruct;
716b3b94faaSDavid Teigland struct gfs2_holder sd_live_gh;
717b3b94faaSDavid Teigland struct gfs2_glock *sd_rename_gl;
71824972557SBenjamin Marzinski struct gfs2_glock *sd_freeze_gl;
7192e60d768SBenjamin Marzinski struct work_struct sd_freeze_work;
7203c69c437SAndreas Gruenbacher wait_queue_head_t sd_kill_wait;
721ad26967bSBob Peterson wait_queue_head_t sd_async_glock_wait;
722e402746aSSteven Whitehouse atomic_t sd_glock_disposal;
7233942ae53SSteven Whitehouse struct completion sd_locking_init;
724fd95e81cSSteven Whitehouse struct completion sd_wdack;
725e0c2a9aaSDavid Teigland struct delayed_work sd_control_work;
726b3b94faaSDavid Teigland
727b3b94faaSDavid Teigland /* Inode Stuff */
728b3b94faaSDavid Teigland
7299b8df98fSSteven Whitehouse struct dentry *sd_master_dir;
7309b8df98fSSteven Whitehouse struct dentry *sd_root_dir;
7319b8df98fSSteven Whitehouse
732f42faf4fSSteven Whitehouse struct inode *sd_jindex;
733f42faf4fSSteven Whitehouse struct inode *sd_statfs_inode;
734f42faf4fSSteven Whitehouse struct inode *sd_sc_inode;
73597fd734bSAbhi Das struct list_head sd_sc_inodes_list;
736f42faf4fSSteven Whitehouse struct inode *sd_qc_inode;
737f42faf4fSSteven Whitehouse struct inode *sd_rindex;
738f42faf4fSSteven Whitehouse struct inode *sd_quota_inode;
739b3b94faaSDavid Teigland
740b3b94faaSDavid Teigland /* StatFS stuff */
741b3b94faaSDavid Teigland
742b3b94faaSDavid Teigland spinlock_t sd_statfs_spin;
743bd209cc0SAl Viro struct gfs2_statfs_change_host sd_statfs_master;
744bd209cc0SAl Viro struct gfs2_statfs_change_host sd_statfs_local;
7453d3c10f2SBenjamin Marzinski int sd_statfs_force_sync;
746b3b94faaSDavid Teigland
747b3b94faaSDavid Teigland /* Resource group stuff */
748b3b94faaSDavid Teigland
749cf45b752SBob Peterson int sd_rindex_uptodate;
750b3b94faaSDavid Teigland spinlock_t sd_rindex_spin;
7517c9ca621SBob Peterson struct rb_root sd_rindex_tree;
752b3b94faaSDavid Teigland unsigned int sd_rgrps;
7533921120eSBenjamin Marzinski unsigned int sd_max_rg_data;
754b3b94faaSDavid Teigland
755b3b94faaSDavid Teigland /* Journal index stuff */
756b3b94faaSDavid Teigland
757b3b94faaSDavid Teigland struct list_head sd_jindex_list;
758b3b94faaSDavid Teigland spinlock_t sd_jindex_spin;
759f55ab26aSSteven Whitehouse struct mutex sd_jindex_mutex;
760b3b94faaSDavid Teigland unsigned int sd_journals;
761b3b94faaSDavid Teigland
762b3b94faaSDavid Teigland struct gfs2_jdesc *sd_jdesc;
763b3b94faaSDavid Teigland struct gfs2_holder sd_journal_gh;
764b3b94faaSDavid Teigland struct gfs2_holder sd_jinode_gh;
765601ef0d5SBob Peterson struct gfs2_glock *sd_jinode_gl;
766b3b94faaSDavid Teigland
767b3b94faaSDavid Teigland struct gfs2_holder sd_sc_gh;
76870c11ba8SBob Peterson struct buffer_head *sd_sc_bh;
769b3b94faaSDavid Teigland struct gfs2_holder sd_qc_gh;
770b3b94faaSDavid Teigland
7710e48e055SBob Peterson struct completion sd_journal_ready;
7720e48e055SBob Peterson
7730247f4e9SAndreas Gruenbacher /* Workqueue stuff */
7740247f4e9SAndreas Gruenbacher
7750247f4e9SAndreas Gruenbacher struct workqueue_struct *sd_delete_wq;
7760247f4e9SAndreas Gruenbacher
777b3b94faaSDavid Teigland /* Daemon stuff */
778b3b94faaSDavid Teigland
779b3b94faaSDavid Teigland struct task_struct *sd_logd_process;
780b3b94faaSDavid Teigland struct task_struct *sd_quotad_process;
781b3b94faaSDavid Teigland
782b3b94faaSDavid Teigland /* Quota stuff */
783b3b94faaSDavid Teigland
784b3b94faaSDavid Teigland struct list_head sd_quota_list;
785b3b94faaSDavid Teigland atomic_t sd_quota_count;
786f55ab26aSSteven Whitehouse struct mutex sd_quota_mutex;
787e46c772dSSteven Whitehouse struct mutex sd_quota_sync_mutex;
78837b2c837SSteven Whitehouse wait_queue_head_t sd_quota_wait;
789b3b94faaSDavid Teigland
790b3b94faaSDavid Teigland unsigned int sd_quota_slots;
791ee2411a8SSteven Whitehouse unsigned long *sd_quota_bitmap;
7922d9e7230SSteven Whitehouse spinlock_t sd_bitmap_lock;
793b3b94faaSDavid Teigland
794cd915493SSteven Whitehouse u64 sd_quota_sync_gen;
795b3b94faaSDavid Teigland
796b3b94faaSDavid Teigland /* Log stuff */
797b3b94faaSDavid Teigland
79870d4ee94SSteven Whitehouse struct address_space sd_aspace;
79970d4ee94SSteven Whitehouse
800b3b94faaSDavid Teigland spinlock_t sd_log_lock;
801b3b94faaSDavid Teigland
80216ca9412SBenjamin Marzinski struct gfs2_trans *sd_log_tr;
803b3b94faaSDavid Teigland unsigned int sd_log_blks_reserved;
804b3b94faaSDavid Teigland
8055e687eacSBenjamin Marzinski atomic_t sd_log_pinned;
806b3b94faaSDavid Teigland unsigned int sd_log_num_revoke;
807f42faf4fSSteven Whitehouse
808a5b1d3fcSAndreas Gruenbacher struct list_head sd_log_revokes;
809a5b1d3fcSAndreas Gruenbacher struct list_head sd_log_ordered;
81045138990SSteven Whitehouse spinlock_t sd_ordered_lock;
811b3b94faaSDavid Teigland
8125e687eacSBenjamin Marzinski atomic_t sd_log_thresh1;
8135e687eacSBenjamin Marzinski atomic_t sd_log_thresh2;
814fd041f0bSSteven Whitehouse atomic_t sd_log_blks_free;
815f07b3520SBob Peterson atomic_t sd_log_blks_needed;
8162129b428SAndreas Gruenbacher atomic_t sd_log_revokes_available;
8175e687eacSBenjamin Marzinski wait_queue_head_t sd_log_waitq;
8185e687eacSBenjamin Marzinski wait_queue_head_t sd_logd_waitq;
819b3b94faaSDavid Teigland
820cd915493SSteven Whitehouse u64 sd_log_sequence;
821b3b94faaSDavid Teigland int sd_log_idle;
822b3b94faaSDavid Teigland
823484adff8SSteven Whitehouse struct rw_semaphore sd_log_flush_lock;
82416615be1SSteven Whitehouse atomic_t sd_log_in_flight;
82516615be1SSteven Whitehouse wait_queue_head_t sd_log_flush_wait;
826036330c9SBob Peterson int sd_log_error; /* First log error */
827601ef0d5SBob Peterson wait_queue_head_t sd_withdraw_wait;
828b3b94faaSDavid Teigland
8295cb738b5SAndreas Gruenbacher unsigned int sd_log_tail;
8305cb738b5SAndreas Gruenbacher unsigned int sd_log_flush_tail;
8315cb738b5SAndreas Gruenbacher unsigned int sd_log_head;
832b3b94faaSDavid Teigland unsigned int sd_log_flush_head;
833b3b94faaSDavid Teigland
834d6a079e8SDave Chinner spinlock_t sd_ail_lock;
835b3b94faaSDavid Teigland struct list_head sd_ail1_list;
836b3b94faaSDavid Teigland struct list_head sd_ail2_list;
837b3b94faaSDavid Teigland
838b3b94faaSDavid Teigland /* For quiescing the filesystem */
839b3b94faaSDavid Teigland struct gfs2_holder sd_freeze_gh;
8402e60d768SBenjamin Marzinski struct mutex sd_freeze_mutex;
8410636b34bSAndreas Gruenbacher struct list_head sd_dead_glocks;
842b3b94faaSDavid Teigland
843561b7969SAndreas Gruenbacher char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
844b3b94faaSDavid Teigland char sd_table_name[GFS2_FSNAME_LEN];
845b3b94faaSDavid Teigland char sd_proto_name[GFS2_FSNAME_LEN];
846b3b94faaSDavid Teigland
847b3b94faaSDavid Teigland /* Debugging crud */
848b3b94faaSDavid Teigland
849b3b94faaSDavid Teigland unsigned long sd_last_warning;
8505f882096SRobert Peterson struct dentry *debugfs_dir; /* debugfs directory */
851601ef0d5SBob Peterson unsigned long sd_glock_dqs_held;
852b3b94faaSDavid Teigland };
853b3b94faaSDavid Teigland
gfs2_glstats_inc(struct gfs2_glock * gl,int which)854a245769fSSteven Whitehouse static inline void gfs2_glstats_inc(struct gfs2_glock *gl, int which)
855a245769fSSteven Whitehouse {
856a245769fSSteven Whitehouse gl->gl_stats.stats[which]++;
857a245769fSSteven Whitehouse }
858a245769fSSteven Whitehouse
gfs2_sbstats_inc(const struct gfs2_glock * gl,int which)859a245769fSSteven Whitehouse static inline void gfs2_sbstats_inc(const struct gfs2_glock *gl, int which)
860a245769fSSteven Whitehouse {
86115562c43SBob Peterson const struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
862a245769fSSteven Whitehouse preempt_disable();
863a245769fSSteven Whitehouse this_cpu_ptr(sdp->sd_lkstats)->lkstats[gl->gl_name.ln_type].stats[which]++;
864a245769fSSteven Whitehouse preempt_enable();
865a245769fSSteven Whitehouse }
866a245769fSSteven Whitehouse
867d312fbf6SAndreas Gruenbacher struct gfs2_rgrpd *gfs2_glock2rgrp(struct gfs2_glock *gl);
8686f6597baSAndreas Gruenbacher
gfs2_max_stuffed_size(const struct gfs2_inode * ip)869235628c5SAndreas Gruenbacher static inline unsigned gfs2_max_stuffed_size(const struct gfs2_inode *ip)
870235628c5SAndreas Gruenbacher {
871235628c5SAndreas Gruenbacher return GFS2_SB(&ip->i_inode)->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
872235628c5SAndreas Gruenbacher }
873235628c5SAndreas Gruenbacher
874b3b94faaSDavid Teigland #endif /* __INCORE_DOT_H__ */
875b3b94faaSDavid Teigland
876