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-2008 Red Hat, Inc.  All rights reserved.
0005  */
0006 
0007 #ifndef __INCORE_DOT_H__
0008 #define __INCORE_DOT_H__
0009 
0010 #include <linux/fs.h>
0011 #include <linux/kobject.h>
0012 #include <linux/workqueue.h>
0013 #include <linux/dlm.h>
0014 #include <linux/buffer_head.h>
0015 #include <linux/rcupdate.h>
0016 #include <linux/rculist_bl.h>
0017 #include <linux/completion.h>
0018 #include <linux/rbtree.h>
0019 #include <linux/ktime.h>
0020 #include <linux/percpu.h>
0021 #include <linux/lockref.h>
0022 #include <linux/rhashtable.h>
0023 #include <linux/mutex.h>
0024 
0025 #define DIO_WAIT    0x00000010
0026 #define DIO_METADATA    0x00000020
0027 
0028 struct gfs2_log_operations;
0029 struct gfs2_bufdata;
0030 struct gfs2_holder;
0031 struct gfs2_glock;
0032 struct gfs2_quota_data;
0033 struct gfs2_trans;
0034 struct gfs2_jdesc;
0035 struct gfs2_sbd;
0036 struct lm_lockops;
0037 
0038 typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret);
0039 
0040 struct gfs2_log_header_host {
0041     u64 lh_sequence;    /* Sequence number of this transaction */
0042     u32 lh_flags;       /* GFS2_LOG_HEAD_... */
0043     u32 lh_tail;        /* Block number of log tail */
0044     u32 lh_blkno;
0045 
0046     s64 lh_local_total;
0047     s64 lh_local_free;
0048     s64 lh_local_dinodes;
0049 };
0050 
0051 /*
0052  * Structure of operations that are associated with each
0053  * type of element in the log.
0054  */
0055 
0056 struct gfs2_log_operations {
0057     void (*lo_before_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
0058     void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
0059     void (*lo_before_scan) (struct gfs2_jdesc *jd,
0060                 struct gfs2_log_header_host *head, int pass);
0061     int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start,
0062                  struct gfs2_log_descriptor *ld, __be64 *ptr,
0063                  int pass);
0064     void (*lo_after_scan) (struct gfs2_jdesc *jd, int error, int pass);
0065     const char *lo_name;
0066 };
0067 
0068 #define GBF_FULL 1
0069 
0070 /**
0071  * Clone bitmaps (bi_clone):
0072  *
0073  * - When a block is freed, we remember the previous state of the block in the
0074  *   clone bitmap, and only mark the block as free in the real bitmap.
0075  *
0076  * - When looking for a block to allocate, we check for a free block in the
0077  *   clone bitmap, and if no clone bitmap exists, in the real bitmap.
0078  *
0079  * - For allocating a block, we mark it as allocated in the real bitmap, and if
0080  *   a clone bitmap exists, also in the clone bitmap.
0081  *
0082  * - At the end of a log_flush, we copy the real bitmap into the clone bitmap
0083  *   to make the clone bitmap reflect the current allocation state.
0084  *   (Alternatively, we could remove the clone bitmap.)
0085  *
0086  * The clone bitmaps are in-core only, and is never written to disk.
0087  *
0088  * These steps ensure that blocks which have been freed in a transaction cannot
0089  * be reallocated in that same transaction.
0090  */
0091 struct gfs2_bitmap {
0092     struct buffer_head *bi_bh;
0093     char *bi_clone;
0094     unsigned long bi_flags;
0095     u32 bi_offset;
0096     u32 bi_start;
0097     u32 bi_bytes;
0098     u32 bi_blocks;
0099 };
0100 
0101 struct gfs2_rgrpd {
0102     struct rb_node rd_node;     /* Link with superblock */
0103     struct gfs2_glock *rd_gl;   /* Glock for this rgrp */
0104     u64 rd_addr;            /* grp block disk address */
0105     u64 rd_data0;           /* first data location */
0106     u32 rd_length;          /* length of rgrp header in fs blocks */
0107     u32 rd_data;            /* num of data blocks in rgrp */
0108     u32 rd_bitbytes;        /* number of bytes in data bitmaps */
0109     u32 rd_free;
0110     u32 rd_requested;       /* number of blocks in rd_rstree */
0111     u32 rd_reserved;        /* number of reserved blocks */
0112     u32 rd_free_clone;
0113     u32 rd_dinodes;
0114     u64 rd_igeneration;
0115     struct gfs2_bitmap *rd_bits;
0116     struct gfs2_sbd *rd_sbd;
0117     struct gfs2_rgrp_lvb *rd_rgl;
0118     u32 rd_last_alloc;
0119     u32 rd_flags;
0120     u32 rd_extfail_pt;      /* extent failure point */
0121 #define GFS2_RDF_CHECK      0x10000000 /* check for unlinked inodes */
0122 #define GFS2_RDF_ERROR      0x40000000 /* error in rg */
0123 #define GFS2_RDF_PREFERRED  0x80000000 /* This rgrp is preferred */
0124 #define GFS2_RDF_MASK       0xf0000000 /* mask for internal flags */
0125     spinlock_t rd_rsspin;           /* protects reservation related vars */
0126     struct mutex rd_mutex;
0127     struct rb_root rd_rstree;       /* multi-block reservation tree */
0128 };
0129 
0130 enum gfs2_state_bits {
0131     BH_Pinned = BH_PrivateStart,
0132     BH_Escaped = BH_PrivateStart + 1,
0133 };
0134 
0135 BUFFER_FNS(Pinned, pinned)
0136 TAS_BUFFER_FNS(Pinned, pinned)
0137 BUFFER_FNS(Escaped, escaped)
0138 TAS_BUFFER_FNS(Escaped, escaped)
0139 
0140 struct gfs2_bufdata {
0141     struct buffer_head *bd_bh;
0142     struct gfs2_glock *bd_gl;
0143     u64 bd_blkno;
0144 
0145     struct list_head bd_list;
0146 
0147     struct gfs2_trans *bd_tr;
0148     struct list_head bd_ail_st_list;
0149     struct list_head bd_ail_gl_list;
0150 };
0151 
0152 /*
0153  * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
0154  * prefix of lock_dlm_ gets awkward.
0155  */
0156 
0157 #define GDLM_STRNAME_BYTES  25
0158 #define GDLM_LVB_SIZE       32
0159 
0160 /*
0161  * ls_recover_flags:
0162  *
0163  * DFL_BLOCK_LOCKS: dlm is in recovery and will grant locks that had been
0164  * held by failed nodes whose journals need recovery.  Those locks should
0165  * only be used for journal recovery until the journal recovery is done.
0166  * This is set by the dlm recover_prep callback and cleared by the
0167  * gfs2_control thread when journal recovery is complete.  To avoid
0168  * races between recover_prep setting and gfs2_control clearing, recover_spin
0169  * is held while changing this bit and reading/writing recover_block
0170  * and recover_start.
0171  *
0172  * DFL_NO_DLM_OPS: dlm lockspace ops/callbacks are not being used.
0173  *
0174  * DFL_FIRST_MOUNT: this node is the first to mount this fs and is doing
0175  * recovery of all journals before allowing other nodes to mount the fs.
0176  * This is cleared when FIRST_MOUNT_DONE is set.
0177  *
0178  * DFL_FIRST_MOUNT_DONE: this node was the first mounter, and has finished
0179  * recovery of all journals, and now allows other nodes to mount the fs.
0180  *
0181  * DFL_MOUNT_DONE: gdlm_mount has completed successfully and cleared
0182  * BLOCK_LOCKS for the first time.  The gfs2_control thread should now
0183  * control clearing BLOCK_LOCKS for further recoveries.
0184  *
0185  * DFL_UNMOUNT: gdlm_unmount sets to keep sdp off gfs2_control_wq.
0186  *
0187  * DFL_DLM_RECOVERY: set while dlm is in recovery, between recover_prep()
0188  * and recover_done(), i.e. set while recover_block == recover_start.
0189  */
0190 
0191 enum {
0192     DFL_BLOCK_LOCKS     = 0,
0193     DFL_NO_DLM_OPS      = 1,
0194     DFL_FIRST_MOUNT     = 2,
0195     DFL_FIRST_MOUNT_DONE    = 3,
0196     DFL_MOUNT_DONE      = 4,
0197     DFL_UNMOUNT     = 5,
0198     DFL_DLM_RECOVERY    = 6,
0199 };
0200 
0201 /*
0202  * We are using struct lm_lockname as an rhashtable key.  Avoid holes within
0203  * the struct; padding at the end is fine.
0204  */
0205 struct lm_lockname {
0206     u64 ln_number;
0207     struct gfs2_sbd *ln_sbd;
0208     unsigned int ln_type;
0209 };
0210 
0211 #define lm_name_equal(name1, name2) \
0212         (((name1)->ln_number == (name2)->ln_number) &&  \
0213      ((name1)->ln_type == (name2)->ln_type) &&  \
0214      ((name1)->ln_sbd == (name2)->ln_sbd))
0215 
0216 
0217 struct gfs2_glock_operations {
0218     int (*go_sync) (struct gfs2_glock *gl);
0219     int (*go_xmote_bh)(struct gfs2_glock *gl);
0220     void (*go_inval) (struct gfs2_glock *gl, int flags);
0221     int (*go_demote_ok) (const struct gfs2_glock *gl);
0222     int (*go_instantiate) (struct gfs2_glock *gl);
0223     int (*go_held)(struct gfs2_holder *gh);
0224     void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl,
0225             const char *fs_id_buf);
0226     void (*go_callback)(struct gfs2_glock *gl, bool remote);
0227     void (*go_free)(struct gfs2_glock *gl);
0228     const int go_subclass;
0229     const int go_type;
0230     const unsigned long go_flags;
0231 #define GLOF_ASPACE 1 /* address space attached */
0232 #define GLOF_LVB    2 /* Lock Value Block attached */
0233 #define GLOF_LRU    4 /* LRU managed */
0234 #define GLOF_NONDISK   8 /* not I/O related */
0235 };
0236 
0237 enum {
0238     GFS2_LKS_SRTT = 0,  /* Non blocking smoothed round trip time */
0239     GFS2_LKS_SRTTVAR = 1,   /* Non blocking smoothed variance */
0240     GFS2_LKS_SRTTB = 2, /* Blocking smoothed round trip time */
0241     GFS2_LKS_SRTTVARB = 3,  /* Blocking smoothed variance */
0242     GFS2_LKS_SIRT = 4,  /* Smoothed Inter-request time */
0243     GFS2_LKS_SIRTVAR = 5,   /* Smoothed Inter-request variance */
0244     GFS2_LKS_DCOUNT = 6,    /* Count of dlm requests */
0245     GFS2_LKS_QCOUNT = 7,    /* Count of gfs2_holder queues */
0246     GFS2_NR_LKSTATS
0247 };
0248 
0249 struct gfs2_lkstats {
0250     u64 stats[GFS2_NR_LKSTATS];
0251 };
0252 
0253 enum {
0254     /* States */
0255     HIF_MAY_DEMOTE      = 1,
0256     HIF_HOLDER      = 6,  /* Set for gh that "holds" the glock */
0257     HIF_WAIT        = 10,
0258 };
0259 
0260 struct gfs2_holder {
0261     struct list_head gh_list;
0262 
0263     struct gfs2_glock *gh_gl;
0264     struct pid *gh_owner_pid;
0265     u16 gh_flags;
0266     u16 gh_state;
0267 
0268     int gh_error;
0269     unsigned long gh_iflags; /* HIF_... */
0270     unsigned long gh_ip;
0271 };
0272 
0273 /* Number of quota types we support */
0274 #define GFS2_MAXQUOTAS 2
0275 
0276 struct gfs2_qadata { /* quota allocation data */
0277     /* Quota stuff */
0278     struct gfs2_quota_data *qa_qd[2 * GFS2_MAXQUOTAS];
0279     struct gfs2_holder qa_qd_ghs[2 * GFS2_MAXQUOTAS];
0280     unsigned int qa_qd_num;
0281     int qa_ref;
0282 };
0283 
0284 /* Resource group multi-block reservation, in order of appearance:
0285 
0286    Step 1. Function prepares to write, allocates a mb, sets the size hint.
0287    Step 2. User calls inplace_reserve to target an rgrp, sets the rgrp info
0288    Step 3. Function get_local_rgrp locks the rgrp, determines which bits to use
0289    Step 4. Bits are assigned from the rgrp based on either the reservation
0290            or wherever it can.
0291 */
0292 
0293 struct gfs2_blkreserv {
0294     struct rb_node rs_node;       /* node within rd_rstree */
0295     struct gfs2_rgrpd *rs_rgd;
0296     u64 rs_start;
0297     u32 rs_requested;
0298     u32 rs_reserved;              /* number of reserved blocks */
0299 };
0300 
0301 /*
0302  * Allocation parameters
0303  * @target: The number of blocks we'd ideally like to allocate
0304  * @aflags: The flags (e.g. Orlov flag)
0305  *
0306  * The intent is to gradually expand this structure over time in
0307  * order to give more information, e.g. alignment, min extent size
0308  * to the allocation code.
0309  */
0310 struct gfs2_alloc_parms {
0311     u64 target;
0312     u32 min_target;
0313     u32 aflags;
0314     u64 allowed;
0315 };
0316 
0317 enum {
0318     GLF_LOCK            = 1,
0319     GLF_INSTANTIATE_NEEDED      = 2, /* needs instantiate */
0320     GLF_DEMOTE          = 3,
0321     GLF_PENDING_DEMOTE      = 4,
0322     GLF_DEMOTE_IN_PROGRESS      = 5,
0323     GLF_DIRTY           = 6,
0324     GLF_LFLUSH          = 7,
0325     GLF_INVALIDATE_IN_PROGRESS  = 8,
0326     GLF_REPLY_PENDING       = 9,
0327     GLF_INITIAL         = 10,
0328     GLF_FROZEN          = 11,
0329     GLF_INSTANTIATE_IN_PROG     = 12, /* instantiate happening now */
0330     GLF_LRU             = 13,
0331     GLF_OBJECT          = 14, /* Used only for tracing */
0332     GLF_BLOCKING            = 15,
0333     GLF_PENDING_DELETE      = 17,
0334     GLF_FREEING         = 18, /* Wait for glock to be freed */
0335 };
0336 
0337 struct gfs2_glock {
0338     unsigned long gl_flags;     /* GLF_... */
0339     struct lm_lockname gl_name;
0340 
0341     struct lockref gl_lockref;
0342 
0343     /* State fields protected by gl_lockref.lock */
0344     unsigned int gl_state:2,    /* Current state */
0345              gl_target:2,   /* Target state */
0346              gl_demote_state:2, /* State requested by remote node */
0347              gl_req:2,      /* State in last dlm request */
0348              gl_reply:8;    /* Last reply from the dlm */
0349 
0350     unsigned long gl_demote_time; /* time of first demote request */
0351     long gl_hold_time;
0352     struct list_head gl_holders;
0353 
0354     const struct gfs2_glock_operations *gl_ops;
0355     ktime_t gl_dstamp;
0356     struct gfs2_lkstats gl_stats;
0357     struct dlm_lksb gl_lksb;
0358     unsigned long gl_tchange;
0359     void *gl_object;
0360 
0361     struct list_head gl_lru;
0362     struct list_head gl_ail_list;
0363     atomic_t gl_ail_count;
0364     atomic_t gl_revokes;
0365     struct delayed_work gl_work;
0366     /* For iopen glocks only */
0367     struct {
0368         struct delayed_work gl_delete;
0369         u64 gl_no_formal_ino;
0370     };
0371     struct rcu_head gl_rcu;
0372     struct rhash_head gl_node;
0373 };
0374 
0375 enum {
0376     GIF_QD_LOCKED       = 1,
0377     GIF_ALLOC_FAILED    = 2,
0378     GIF_SW_PAGED        = 3,
0379     GIF_FREE_VFS_INODE      = 5,
0380     GIF_GLOP_PENDING    = 6,
0381     GIF_DEFERRED_DELETE = 7,
0382 };
0383 
0384 struct gfs2_inode {
0385     struct inode i_inode;
0386     u64 i_no_addr;
0387     u64 i_no_formal_ino;
0388     u64 i_generation;
0389     u64 i_eattr;
0390     unsigned long i_flags;      /* GIF_... */
0391     struct gfs2_glock *i_gl;
0392     struct gfs2_holder i_iopen_gh;
0393     struct gfs2_qadata *i_qadata; /* quota allocation data */
0394     struct gfs2_holder i_rgd_gh;
0395     struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
0396     u64 i_goal; /* goal block for allocations */
0397     atomic_t i_sizehint;  /* hint of the write size */
0398     struct rw_semaphore i_rw_mutex;
0399     struct list_head i_ordered;
0400     __be64 *i_hash_cache;
0401     u32 i_entries;
0402     u32 i_diskflags;
0403     u8 i_height;
0404     u8 i_depth;
0405     u16 i_rahead;
0406 };
0407 
0408 /*
0409  * Since i_inode is the first element of struct gfs2_inode,
0410  * this is effectively a cast.
0411  */
0412 static inline struct gfs2_inode *GFS2_I(struct inode *inode)
0413 {
0414     return container_of(inode, struct gfs2_inode, i_inode);
0415 }
0416 
0417 static inline struct gfs2_sbd *GFS2_SB(const struct inode *inode)
0418 {
0419     return inode->i_sb->s_fs_info;
0420 }
0421 
0422 struct gfs2_file {
0423     struct mutex f_fl_mutex;
0424     struct gfs2_holder f_fl_gh;
0425 };
0426 
0427 struct gfs2_revoke_replay {
0428     struct list_head rr_list;
0429     u64 rr_blkno;
0430     unsigned int rr_where;
0431 };
0432 
0433 enum {
0434     QDF_CHANGE      = 1,
0435     QDF_LOCKED      = 2,
0436     QDF_REFRESH     = 3,
0437     QDF_QMSG_QUIET          = 4,
0438 };
0439 
0440 struct gfs2_quota_data {
0441     struct hlist_bl_node qd_hlist;
0442     struct list_head qd_list;
0443     struct kqid qd_id;
0444     struct gfs2_sbd *qd_sbd;
0445     struct lockref qd_lockref;
0446     struct list_head qd_lru;
0447     unsigned qd_hash;
0448 
0449     unsigned long qd_flags;     /* QDF_... */
0450 
0451     s64 qd_change;
0452     s64 qd_change_sync;
0453 
0454     unsigned int qd_slot;
0455     unsigned int qd_slot_count;
0456 
0457     struct buffer_head *qd_bh;
0458     struct gfs2_quota_change *qd_bh_qc;
0459     unsigned int qd_bh_count;
0460 
0461     struct gfs2_glock *qd_gl;
0462     struct gfs2_quota_lvb qd_qb;
0463 
0464     u64 qd_sync_gen;
0465     unsigned long qd_last_warn;
0466     struct rcu_head qd_rcu;
0467 };
0468 
0469 enum {
0470     TR_TOUCHED = 1,
0471     TR_ATTACHED = 2,
0472     TR_ONSTACK = 3,
0473 };
0474 
0475 struct gfs2_trans {
0476     unsigned long tr_ip;
0477 
0478     unsigned int tr_blocks;
0479     unsigned int tr_revokes;
0480     unsigned int tr_reserved;
0481     unsigned long tr_flags;
0482 
0483     unsigned int tr_num_buf_new;
0484     unsigned int tr_num_databuf_new;
0485     unsigned int tr_num_buf_rm;
0486     unsigned int tr_num_databuf_rm;
0487     unsigned int tr_num_revoke;
0488 
0489     struct list_head tr_list;
0490     struct list_head tr_databuf;
0491     struct list_head tr_buf;
0492 
0493     unsigned int tr_first;
0494     struct list_head tr_ail1_list;
0495     struct list_head tr_ail2_list;
0496 };
0497 
0498 struct gfs2_journal_extent {
0499     struct list_head list;
0500 
0501     unsigned int lblock; /* First logical block */
0502     u64 dblock; /* First disk block */
0503     u64 blocks;
0504 };
0505 
0506 struct gfs2_jdesc {
0507     struct list_head jd_list;
0508     struct list_head extent_list;
0509     unsigned int nr_extents;
0510     struct work_struct jd_work;
0511     struct inode *jd_inode;
0512     struct bio *jd_log_bio;
0513     unsigned long jd_flags;
0514 #define JDF_RECOVERY 1
0515     unsigned int jd_jid;
0516     u32 jd_blocks;
0517     int jd_recover_error;
0518     /* Replay stuff */
0519 
0520     unsigned int jd_found_blocks;
0521     unsigned int jd_found_revokes;
0522     unsigned int jd_replayed_blocks;
0523 
0524     struct list_head jd_revoke_list;
0525     unsigned int jd_replay_tail;
0526 
0527     u64 jd_no_addr;
0528 };
0529 
0530 struct gfs2_statfs_change_host {
0531     s64 sc_total;
0532     s64 sc_free;
0533     s64 sc_dinodes;
0534 };
0535 
0536 #define GFS2_QUOTA_DEFAULT  GFS2_QUOTA_OFF
0537 #define GFS2_QUOTA_OFF      0
0538 #define GFS2_QUOTA_ACCOUNT  1
0539 #define GFS2_QUOTA_ON       2
0540 
0541 #define GFS2_DATA_DEFAULT   GFS2_DATA_ORDERED
0542 #define GFS2_DATA_WRITEBACK 1
0543 #define GFS2_DATA_ORDERED   2
0544 
0545 #define GFS2_ERRORS_DEFAULT     GFS2_ERRORS_WITHDRAW
0546 #define GFS2_ERRORS_WITHDRAW    0
0547 #define GFS2_ERRORS_CONTINUE    1 /* place holder for future feature */
0548 #define GFS2_ERRORS_RO          2 /* place holder for future feature */
0549 #define GFS2_ERRORS_PANIC       3
0550 
0551 struct gfs2_args {
0552     char ar_lockproto[GFS2_LOCKNAME_LEN];   /* Name of the Lock Protocol */
0553     char ar_locktable[GFS2_LOCKNAME_LEN];   /* Name of the Lock Table */
0554     char ar_hostdata[GFS2_LOCKNAME_LEN];    /* Host specific data */
0555     unsigned int ar_spectator:1;        /* Don't get a journal */
0556     unsigned int ar_localflocks:1;      /* Let the VFS do flock|fcntl */
0557     unsigned int ar_debug:1;        /* Oops on errors */
0558     unsigned int ar_posix_acl:1;        /* Enable posix acls */
0559     unsigned int ar_quota:2;        /* off/account/on */
0560     unsigned int ar_suiddir:1;      /* suiddir support */
0561     unsigned int ar_data:2;         /* ordered/writeback */
0562     unsigned int ar_meta:1;         /* mount metafs */
0563     unsigned int ar_discard:1;      /* discard requests */
0564     unsigned int ar_errors:2;               /* errors=withdraw | panic */
0565     unsigned int ar_nobarrier:1;            /* do not send barriers */
0566     unsigned int ar_rgrplvb:1;      /* use lvbs for rgrp info */
0567     unsigned int ar_got_rgrplvb:1;      /* Was the rgrplvb opt given? */
0568     unsigned int ar_loccookie:1;        /* use location based readdir
0569                            cookies */
0570     s32 ar_commit;              /* Commit interval */
0571     s32 ar_statfs_quantum;          /* The fast statfs interval */
0572     s32 ar_quota_quantum;           /* The quota interval */
0573     s32 ar_statfs_percent;          /* The % change to force sync */
0574 };
0575 
0576 struct gfs2_tune {
0577     spinlock_t gt_spin;
0578 
0579     unsigned int gt_logd_secs;
0580 
0581     unsigned int gt_quota_warn_period; /* Secs between quota warn msgs */
0582     unsigned int gt_quota_scale_num; /* Numerator */
0583     unsigned int gt_quota_scale_den; /* Denominator */
0584     unsigned int gt_quota_quantum; /* Secs between syncs to quota file */
0585     unsigned int gt_new_files_jdata;
0586     unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */
0587     unsigned int gt_complain_secs;
0588     unsigned int gt_statfs_quantum;
0589     unsigned int gt_statfs_slow;
0590 };
0591 
0592 enum {
0593     SDF_JOURNAL_CHECKED = 0,
0594     SDF_JOURNAL_LIVE    = 1,
0595     SDF_WITHDRAWN       = 2,
0596     SDF_NOBARRIERS      = 3,
0597     SDF_NORECOVERY      = 4,
0598     SDF_DEMOTE      = 5,
0599     SDF_NOJOURNALID     = 6,
0600     SDF_RORECOVERY      = 7, /* read only recovery */
0601     SDF_SKIP_DLM_UNLOCK = 8,
0602     SDF_FORCE_AIL_FLUSH     = 9,
0603     SDF_FS_FROZEN           = 10,
0604     SDF_WITHDRAWING     = 11, /* Will withdraw eventually */
0605     SDF_WITHDRAW_IN_PROG    = 12, /* Withdraw is in progress */
0606     SDF_REMOTE_WITHDRAW = 13, /* Performing remote recovery */
0607     SDF_WITHDRAW_RECOVERY   = 14, /* Wait for journal recovery when we are
0608                      withdrawing */
0609 };
0610 
0611 enum gfs2_freeze_state {
0612     SFS_UNFROZEN        = 0,
0613     SFS_STARTING_FREEZE = 1,
0614     SFS_FROZEN      = 2,
0615 };
0616 
0617 #define GFS2_FSNAME_LEN     256
0618 
0619 struct gfs2_inum_host {
0620     u64 no_formal_ino;
0621     u64 no_addr;
0622 };
0623 
0624 struct gfs2_sb_host {
0625     u32 sb_magic;
0626     u32 sb_type;
0627 
0628     u32 sb_fs_format;
0629     u32 sb_multihost_format;
0630     u32 sb_bsize;
0631     u32 sb_bsize_shift;
0632 
0633     struct gfs2_inum_host sb_master_dir;
0634     struct gfs2_inum_host sb_root_dir;
0635 
0636     char sb_lockproto[GFS2_LOCKNAME_LEN];
0637     char sb_locktable[GFS2_LOCKNAME_LEN];
0638 };
0639 
0640 /*
0641  * lm_mount() return values
0642  *
0643  * ls_jid - the journal ID this node should use
0644  * ls_first - this node is the first to mount the file system
0645  * ls_lockspace - lock module's context for this file system
0646  * ls_ops - lock module's functions
0647  */
0648 
0649 struct lm_lockstruct {
0650     int ls_jid;
0651     unsigned int ls_first;
0652     const struct lm_lockops *ls_ops;
0653     dlm_lockspace_t *ls_dlm;
0654 
0655     int ls_recover_jid_done;   /* These two are deprecated, */
0656     int ls_recover_jid_status; /* used previously by gfs_controld */
0657 
0658     struct dlm_lksb ls_mounted_lksb; /* mounted_lock */
0659     struct dlm_lksb ls_control_lksb; /* control_lock */
0660     char ls_control_lvb[GDLM_LVB_SIZE]; /* control_lock lvb */
0661     struct completion ls_sync_wait; /* {control,mounted}_{lock,unlock} */
0662     char *ls_lvb_bits;
0663 
0664     spinlock_t ls_recover_spin; /* protects following fields */
0665     unsigned long ls_recover_flags; /* DFL_ */
0666     uint32_t ls_recover_mount; /* gen in first recover_done cb */
0667     uint32_t ls_recover_start; /* gen in last recover_done cb */
0668     uint32_t ls_recover_block; /* copy recover_start in last recover_prep */
0669     uint32_t ls_recover_size; /* size of recover_submit, recover_result */
0670     uint32_t *ls_recover_submit; /* gen in last recover_slot cb per jid */
0671     uint32_t *ls_recover_result; /* result of last jid recovery */
0672 };
0673 
0674 struct gfs2_pcpu_lkstats {
0675     /* One struct for each glock type */
0676     struct gfs2_lkstats lkstats[10];
0677 };
0678 
0679 /* List of local (per node) statfs inodes */
0680 struct local_statfs_inode {
0681     struct list_head si_list;
0682     struct inode *si_sc_inode;
0683     unsigned int si_jid; /* journal id this statfs inode corresponds to */
0684 };
0685 
0686 struct gfs2_sbd {
0687     struct super_block *sd_vfs;
0688     struct gfs2_pcpu_lkstats __percpu *sd_lkstats;
0689     struct kobject sd_kobj;
0690     struct completion sd_kobj_unregister;
0691     unsigned long sd_flags; /* SDF_... */
0692     struct gfs2_sb_host sd_sb;
0693 
0694     /* Constants computed on mount */
0695 
0696     u32 sd_fsb2bb;
0697     u32 sd_fsb2bb_shift;
0698     u32 sd_diptrs;  /* Number of pointers in a dinode */
0699     u32 sd_inptrs;  /* Number of pointers in a indirect block */
0700     u32 sd_ldptrs;  /* Number of pointers in a log descriptor block */
0701     u32 sd_jbsize;  /* Size of a journaled data block */
0702     u32 sd_hash_bsize;  /* sizeof(exhash block) */
0703     u32 sd_hash_bsize_shift;
0704     u32 sd_hash_ptrs;   /* Number of pointers in a hash block */
0705     u32 sd_qc_per_block;
0706     u32 sd_blocks_per_bitmap;
0707     u32 sd_max_dirres;  /* Max blocks needed to add a directory entry */
0708     u32 sd_max_height;  /* Max height of a file's metadata tree */
0709     u64 sd_heightsize[GFS2_MAX_META_HEIGHT + 1];
0710     u32 sd_max_dents_per_leaf; /* Max number of dirents in a leaf block */
0711 
0712     struct gfs2_args sd_args;   /* Mount arguments */
0713     struct gfs2_tune sd_tune;   /* Filesystem tuning structure */
0714 
0715     /* Lock Stuff */
0716 
0717     struct lm_lockstruct sd_lockstruct;
0718     struct gfs2_holder sd_live_gh;
0719     struct gfs2_glock *sd_rename_gl;
0720     struct gfs2_glock *sd_freeze_gl;
0721     struct work_struct sd_freeze_work;
0722     wait_queue_head_t sd_glock_wait;
0723     wait_queue_head_t sd_async_glock_wait;
0724     atomic_t sd_glock_disposal;
0725     struct completion sd_locking_init;
0726     struct completion sd_wdack;
0727     struct delayed_work sd_control_work;
0728 
0729     /* Inode Stuff */
0730 
0731     struct dentry *sd_master_dir;
0732     struct dentry *sd_root_dir;
0733 
0734     struct inode *sd_jindex;
0735     struct inode *sd_statfs_inode;
0736     struct inode *sd_sc_inode;
0737     struct list_head sd_sc_inodes_list;
0738     struct inode *sd_qc_inode;
0739     struct inode *sd_rindex;
0740     struct inode *sd_quota_inode;
0741 
0742     /* StatFS stuff */
0743 
0744     spinlock_t sd_statfs_spin;
0745     struct gfs2_statfs_change_host sd_statfs_master;
0746     struct gfs2_statfs_change_host sd_statfs_local;
0747     int sd_statfs_force_sync;
0748 
0749     /* Resource group stuff */
0750 
0751     int sd_rindex_uptodate;
0752     spinlock_t sd_rindex_spin;
0753     struct rb_root sd_rindex_tree;
0754     unsigned int sd_rgrps;
0755     unsigned int sd_max_rg_data;
0756 
0757     /* Journal index stuff */
0758 
0759     struct list_head sd_jindex_list;
0760     spinlock_t sd_jindex_spin;
0761     struct mutex sd_jindex_mutex;
0762     unsigned int sd_journals;
0763 
0764     struct gfs2_jdesc *sd_jdesc;
0765     struct gfs2_holder sd_journal_gh;
0766     struct gfs2_holder sd_jinode_gh;
0767     struct gfs2_glock *sd_jinode_gl;
0768 
0769     struct gfs2_holder sd_sc_gh;
0770     struct buffer_head *sd_sc_bh;
0771     struct gfs2_holder sd_qc_gh;
0772 
0773     struct completion sd_journal_ready;
0774 
0775     /* Daemon stuff */
0776 
0777     struct task_struct *sd_logd_process;
0778     struct task_struct *sd_quotad_process;
0779 
0780     /* Quota stuff */
0781 
0782     struct list_head sd_quota_list;
0783     atomic_t sd_quota_count;
0784     struct mutex sd_quota_mutex;
0785     struct mutex sd_quota_sync_mutex;
0786     wait_queue_head_t sd_quota_wait;
0787 
0788     unsigned int sd_quota_slots;
0789     unsigned long *sd_quota_bitmap;
0790     spinlock_t sd_bitmap_lock;
0791 
0792     u64 sd_quota_sync_gen;
0793 
0794     /* Log stuff */
0795 
0796     struct address_space sd_aspace;
0797 
0798     spinlock_t sd_log_lock;
0799 
0800     struct gfs2_trans *sd_log_tr;
0801     unsigned int sd_log_blks_reserved;
0802 
0803     atomic_t sd_log_pinned;
0804     unsigned int sd_log_num_revoke;
0805 
0806     struct list_head sd_log_revokes;
0807     struct list_head sd_log_ordered;
0808     spinlock_t sd_ordered_lock;
0809 
0810     atomic_t sd_log_thresh1;
0811     atomic_t sd_log_thresh2;
0812     atomic_t sd_log_blks_free;
0813     atomic_t sd_log_blks_needed;
0814     atomic_t sd_log_revokes_available;
0815     wait_queue_head_t sd_log_waitq;
0816     wait_queue_head_t sd_logd_waitq;
0817 
0818     u64 sd_log_sequence;
0819     int sd_log_idle;
0820 
0821     struct rw_semaphore sd_log_flush_lock;
0822     atomic_t sd_log_in_flight;
0823     wait_queue_head_t sd_log_flush_wait;
0824     int sd_log_error; /* First log error */
0825     wait_queue_head_t sd_withdraw_wait;
0826 
0827     unsigned int sd_log_tail;
0828     unsigned int sd_log_flush_tail;
0829     unsigned int sd_log_head;
0830     unsigned int sd_log_flush_head;
0831 
0832     spinlock_t sd_ail_lock;
0833     struct list_head sd_ail1_list;
0834     struct list_head sd_ail2_list;
0835 
0836     /* For quiescing the filesystem */
0837     struct gfs2_holder sd_freeze_gh;
0838     atomic_t sd_freeze_state;
0839     struct mutex sd_freeze_mutex;
0840 
0841     char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
0842     char sd_table_name[GFS2_FSNAME_LEN];
0843     char sd_proto_name[GFS2_FSNAME_LEN];
0844 
0845     /* Debugging crud */
0846 
0847     unsigned long sd_last_warning;
0848     struct dentry *debugfs_dir;    /* debugfs directory */
0849     unsigned long sd_glock_dqs_held;
0850 };
0851 
0852 static inline void gfs2_glstats_inc(struct gfs2_glock *gl, int which)
0853 {
0854     gl->gl_stats.stats[which]++;
0855 }
0856 
0857 static inline void gfs2_sbstats_inc(const struct gfs2_glock *gl, int which)
0858 {
0859     const struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
0860     preempt_disable();
0861     this_cpu_ptr(sdp->sd_lkstats)->lkstats[gl->gl_name.ln_type].stats[which]++;
0862     preempt_enable();
0863 }
0864 
0865 extern struct gfs2_rgrpd *gfs2_glock2rgrp(struct gfs2_glock *gl);
0866 
0867 static inline unsigned gfs2_max_stuffed_size(const struct gfs2_inode *ip)
0868 {
0869     return GFS2_SB(&ip->i_inode)->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
0870 }
0871 
0872 #endif /* __INCORE_DOT_H__ */
0873