lustre_dlm.h

来自「lustre 1.6.5 source code」· C头文件 代码 · 共 835 行 · 第 1/3 页

H
835
字号
        LDLM_NAMESPACE_MODEST = 1 << 1} ldlm_appetite_t;/* default values for the "max_nolock_size", "contention_time" * and "contended_locks" namespace tunables */#define NS_DEFAULT_MAX_NOLOCK_BYTES 0#define NS_DEFAULT_CONTENTION_SECONDS 2#define NS_DEFAULT_CONTENDED_LOCKS 32/* Default value for ->ns_shrink_thumb. If lock is not extent one its cost  * is one page. Here we have 256 pages which is 1M on i386. Thus by default * all extent locks which have more than 1M long extent will be kept in lru, * others (including ibits locks) will be canceled on memory pressure event. */#define LDLM_LOCK_SHRINK_THUMB 256struct ldlm_namespace {        char                  *ns_name;        ldlm_side_t            ns_client; /* is this a client-side lock tree? */        __u64                  ns_connect_flags; /* ns connect flags supported                                           * by server (may be changed via proc,                                           * lru resize may be disabled/enabled) */        __u64                  ns_orig_connect_flags; /* client side orig connect                                           * flags supported by server */        struct list_head      *ns_hash;   /* hash table for ns */        spinlock_t             ns_hash_lock;        __u32                  ns_refcount; /* count of resources in the hash */        struct list_head       ns_root_list; /* all root resources in ns */        struct list_head       ns_list_chain; /* position in global NS list */        struct list_head       ns_unused_list; /* all root resources in ns */        int                    ns_nr_unused;        spinlock_t             ns_unused_lock;        unsigned int           ns_max_unused;        unsigned int           ns_max_age;                /* Lower limit to number of pages in lock to keep it in cache */        unsigned int           ns_shrink_thumb;        cfs_time_t             ns_next_dump;   /* next debug dump, jiffies */        atomic_t               ns_locks;        __u64                  ns_resources;        ldlm_res_policy        ns_policy;        struct ldlm_valblock_ops *ns_lvbo;        void                  *ns_lvbp;        cfs_waitq_t            ns_waitq;        struct ldlm_pool       ns_pool;        ldlm_appetite_t        ns_appetite;        /* if more than @ns_contented_locks found, the resource considered         * as contended */        unsigned               ns_contended_locks;        /* the resource remembers contended state during @ns_contention_time,         * in seconds */        unsigned               ns_contention_time;        /* limit size of nolock requests, in bytes */        unsigned               ns_max_nolock_size;        struct adaptive_timeout ns_at_estimate;/* estimated lock callback time*/};static inline int ns_is_client(struct ldlm_namespace *ns){        LASSERT(ns != NULL);        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |                                     LDLM_NAMESPACE_SERVER)));        LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||                ns->ns_client == LDLM_NAMESPACE_SERVER);        return ns->ns_client == LDLM_NAMESPACE_CLIENT;}static inline int ns_is_server(struct ldlm_namespace *ns){        LASSERT(ns != NULL);        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |                                     LDLM_NAMESPACE_SERVER)));        LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||                ns->ns_client == LDLM_NAMESPACE_SERVER);        return ns->ns_client == LDLM_NAMESPACE_SERVER;}static inline int ns_connect_lru_resize(struct ldlm_namespace *ns){        LASSERT(ns != NULL);        return !!(ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE);}/* * * Resource hash table * */#define RES_HASH_BITS 10#define RES_HASH_SIZE (1UL << RES_HASH_BITS)#define RES_HASH_MASK (RES_HASH_SIZE - 1)struct ldlm_lock;typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,                                      struct ldlm_lock_desc *new, void *data,                                      int flag);typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,                                        void *data);typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);/* Interval node data for each LDLM_EXTENT lock */struct ldlm_interval {        struct interval_node li_node;   /* node for tree mgmt */        struct list_head     li_group;  /* the locks which have the same                                          * policy - group of the policy */};#define to_ldlm_interval(n) container_of(n, struct ldlm_interval, li_node)/* the interval tree must be accessed inside the resource lock. */struct ldlm_interval_tree {        /* tree size, this variable is used to count         * granted PW locks in ldlm_extent_policy()*/        int                   lit_size;        ldlm_mode_t           lit_mode; /* lock mode */        struct interval_node *lit_root; /* actually ldlm_interval */};struct ldlm_lock {        struct portals_handle l_handle; // must be first in the structure        atomic_t              l_refc;        /* internal spinlock protects l_resource.  we should hold this lock          * first before grabbing res_lock.*/        spinlock_t            l_lock;        /* ldlm_lock_change_resource() can change this */        struct ldlm_resource *l_resource;        /* protected by ns_hash_lock. FIXME */        struct list_head      l_lru;        /* protected by lr_lock */        struct list_head      l_res_link; // position in one of three res lists        struct list_head      l_sl_mode;        // skip pointer for request mode        struct list_head      l_sl_policy;      // skip pointer for inodebits        struct ldlm_interval *l_tree_node;      /* tree node for ldlm_extent */        /* protected by led_lock */        struct list_head      l_export_chain; // per-export chain of locks        /* protected by lr_lock */        ldlm_mode_t           l_req_mode;        ldlm_mode_t           l_granted_mode;        ldlm_completion_callback l_completion_ast;        ldlm_blocking_callback   l_blocking_ast;        ldlm_glimpse_callback    l_glimpse_ast;        struct obd_export    *l_export;        struct obd_export    *l_conn_export;        struct lustre_handle  l_remote_handle;        ldlm_policy_data_t    l_policy_data;        /* protected by lr_lock */        __u32                 l_flags;        __u32                 l_readers;        __u32                 l_writers;        __u8                  l_destroyed;        /* If the lock is granted, a process sleeps on this waitq to learn when         * it's no longer in use.  If the lock is not granted, a process sleeps         * on this waitq to learn when it becomes granted. */        cfs_waitq_t           l_waitq;        struct timeval        l_enqueued_time;        cfs_time_t            l_last_used;      /* jiffies */        struct ldlm_extent    l_req_extent;        /* Client-side-only members */        __u32                 l_lvb_len;        /* temporary storage for */        void                 *l_lvb_data;       /* an LVB received during */        void                 *l_lvb_swabber;    /* an enqueue */        void                 *l_ast_data;        spinlock_t            l_extents_list_lock;        struct list_head      l_extents_list;        struct list_head      l_cache_locks_list;        /* Server-side-only members */        /* protected by elt_lock */        struct list_head      l_pending_chain;  /* callbacks pending */        cfs_time_t            l_callback_timeout; /* jiffies */        __u32                 l_pid;            /* pid which created this lock */        /* for ldlm_add_ast_work_item() */        struct list_head      l_bl_ast;        struct list_head      l_cp_ast;        struct ldlm_lock     *l_blocking_lock;         int                   l_bl_ast_run;};struct ldlm_resource {        struct ldlm_namespace *lr_namespace;        /* protected by ns_hash_lock */        struct list_head       lr_hash;        struct ldlm_resource  *lr_parent;   /* 0 for a root resource */        struct list_head       lr_children; /* list head for child resources */        struct list_head       lr_childof;  /* part of ns_root_list if root res,                                             * part of lr_children if child */        spinlock_t             lr_lock;        /* protected by lr_lock */        struct list_head       lr_granted;        struct list_head       lr_converting;        struct list_head       lr_waiting;        ldlm_mode_t            lr_most_restr;        ldlm_type_t            lr_type; /* LDLM_{PLAIN,EXTENT,FLOCK} */        struct ldlm_res_id     lr_name;        atomic_t               lr_refcount;        struct ldlm_interval_tree lr_itree[LCK_MODE_NUM];  /* interval trees*/        /* Server-side-only lock value block elements */        struct semaphore       lr_lvb_sem;        __u32                  lr_lvb_len;        void                  *lr_lvb_data;        /* when the resource was considered as contended */        cfs_time_t             lr_contention_time;};struct ldlm_ast_work {        struct ldlm_lock *w_lock;        int               w_blocking;        struct ldlm_lock_desc w_desc;        struct list_head   w_list;        int w_flags;        void *w_data;        int w_datalen;};/* ldlm_enqueue parameters common */struct ldlm_enqueue_info {        __u32 ei_type;   /* Type of the lock being enqueued. */        __u32 ei_mode;   /* Mode of the lock being enqueued. */        void *ei_cb_bl;  /* Different callbacks for lock handling (blocking, */        void *ei_cb_cp;  /* completion, glimpse) */        void *ei_cb_gl;        void *ei_cbdata; /* Data to be passed into callbacks. */};extern struct obd_ops ldlm_obd_ops;extern char *ldlm_lockname[];extern char *ldlm_typename[];extern char *ldlm_it2str(int it);#define ldlm_lock_debug(cdls, level, lock, file, func, line, fmt, a...) do {  \        CHECK_STACK();                                                  \                                                                        \        if (((level) & D_CANTMASK) != 0 ||                              \            ((libcfs_debug & (level)) != 0 &&                           \             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) {        \                static struct libcfs_debug_msg_data _ldlm_dbg_data =    \                DEBUG_MSG_DATA_INIT(cdls, DEBUG_SUBSYSTEM,              \                                    file, func, line);                  \                _ldlm_lock_debug(lock, level, &_ldlm_dbg_data, fmt,     \                                 ##a );                                 \        }                                                               \} while(0)void _ldlm_lock_debug(struct ldlm_lock *lock, __u32 mask,                      struct libcfs_debug_msg_data *data, const char *fmt,                      ...)        __attribute__ ((format (printf, 4, 5)));#define LDLM_ERROR(lock, fmt, a...) do {                                 \

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?