Whamcloud - gitweb
LU-9679 lustre: remove some "#ifdef CONFIG*" from .c files.
[fs/lustre-release.git] / lustre / include / obd.h
index 96c77a0..c0d70c6 100644 (file)
 #ifndef __OBD_H
 #define __OBD_H
 
+#include <linux/fs.h>
+#include <linux/posix_acl.h>
 #include <linux/kobject.h>
 #include <linux/spinlock.h>
 #include <linux/sysfs.h>
+#include <linux/xarray.h>
 
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lustre_lib.h>
@@ -99,8 +102,8 @@ struct obd_info {
 };
 
 struct obd_type {
-       struct obd_ops          *typ_dt_ops;
-       struct md_ops           *typ_md_ops;
+       const struct obd_ops    *typ_dt_ops;
+       const struct md_ops     *typ_md_ops;
        struct proc_dir_entry   *typ_procroot;
        struct dentry           *typ_debugfs_entry;
 #ifdef HAVE_SERVER_SUPPORT
@@ -111,12 +114,18 @@ struct obd_type {
        struct kobject           typ_kobj;
 };
 #define typ_name typ_kobj.name
+#define OBD_LU_TYPE_SETUP ((void *)0x01UL)
 
 struct brw_page {
        u64              off;
        struct page     *pg;
        u32              count;
        u32              flag;
+       /* used for encryption: difference with offset in clear text page */
+       u16              bp_off_diff;
+       /* used for encryption: difference with count in clear text page */
+       u16              bp_count_diff;
+       u32              bp_padding;
 };
 
 struct timeout_item {
@@ -135,12 +144,11 @@ struct timeout_item {
 #define OSC_MAX_DIRTY_MB_MAX   2048     /* arbitrary, but < MAX_LONG bytes */
 #define OSC_DEFAULT_RESENDS    10
 
-/* possible values for fo_sync_lock_cancel */
-enum {
-        NEVER_SYNC_ON_CANCEL = 0,
-        BLOCKING_SYNC_ON_CANCEL = 1,
-        ALWAYS_SYNC_ON_CANCEL = 2,
-        NUM_SYNC_ON_CANCEL_STATES
+/* possible values for lut_sync_lock_cancel */
+enum tgt_sync_lock_cancel {
+       SYNC_LOCK_CANCEL_NEVER    = 0,
+       SYNC_LOCK_CANCEL_BLOCKING = 1,
+       SYNC_LOCK_CANCEL_ALWAYS   = 2,
 };
 
 /*
@@ -212,7 +220,6 @@ struct client_obd {
        /* the grant values are protected by loi_list_lock below */
        unsigned long            cl_dirty_pages;      /* all _dirty_ in pages */
        unsigned long            cl_dirty_max_pages;  /* allowed w/o rpc */
-       unsigned long            cl_dirty_transit;    /* dirty synchronous */
        unsigned long            cl_avail_grant;   /* bytes of credit for ost */
        unsigned long            cl_lost_grant;    /* lost credits (trunc) */
        /* grant consumed for dirty pages */
@@ -223,7 +230,7 @@ struct client_obd {
         * grant before trying to dirty a page and unreserve the rest.
         * See osc_{reserve|unreserve}_grant for details. */
        long                    cl_reserved_grant;
-       struct list_head        cl_cache_waiters; /* waiting for cache/grant */
+       wait_queue_head_t       cl_cache_waiters; /* waiting for cache/grant */
        time64_t                cl_next_shrink_grant;   /* seconds */
        struct list_head        cl_grant_chain;
        time64_t                cl_grant_shrink_interval; /* seconds */
@@ -403,7 +410,7 @@ struct lov_obd {
        __u32                   lov_tgt_size;   /* size of tgts array */
        int                     lov_connects;
        int                     lov_pool_count;
-       struct cfs_hash        *lov_pools_hash_body; /* used for key access */
+       struct rhashtable       lov_pools_hash_body; /* used for key access */
        struct list_head        lov_pool_list;  /* used for sequential access */
        struct proc_dir_entry  *lov_pool_proc_entry;
        enum lustre_sec_part    lov_sp_me;
@@ -612,7 +619,6 @@ struct obd_device {
                obd_abort_recovery:1,   /* recovery expired */
                obd_version_recov:1,    /* obd uses version checking */
                obd_replayable:1,       /* recovery enabled; inform clients */
-               obd_no_transno:1,       /* no committed-transno notification */
                obd_no_recov:1,         /* fail instead of retry messages */
                obd_stopping:1,         /* started cleanup */
                obd_starting:1,         /* started setup */
@@ -624,14 +630,18 @@ struct obd_device {
                obd_no_ir:1,            /* no imperative recovery. */
                obd_process_conf:1,     /* device is processing mgs config */
                obd_checksum_dump:1;    /* dump pages upon cksum error */
+#ifdef HAVE_SERVER_SUPPORT
+       /* no committed-transno notification */
+       unsigned long                   obd_no_transno:1;
+#endif
 
         /* use separate field as it is set in interrupt to don't mess with
          * protection of other bits using _bh lock */
         unsigned long obd_recovery_expired:1;
         /* uuid-export hash body */
-       struct cfs_hash             *obd_uuid_hash;
+       struct rhashtable               obd_uuid_hash;
         /* nid-export hash body */
-       struct cfs_hash             *obd_nid_hash;
+       struct rhltable                 obd_nid_hash;
        /* nid stats body */
        struct cfs_hash             *obd_nid_stats_hash;
        /* client_generation-export hash body */
@@ -680,12 +690,12 @@ struct obd_device {
        time64_t                obd_recovery_start;
        /* seconds, for lprocfs_status */
        time64_t                obd_recovery_end;
-       /* To tell timeouts from time stamps Lustre uses time_t
+       /* To tell timeouts from time stamps Lustre uses timeout_t
         * instead of time64_t.
         */
-       time_t                  obd_recovery_time_hard;
-       time_t                  obd_recovery_timeout;
-       int                     obd_recovery_ir_factor;
+       timeout_t                       obd_recovery_time_hard;
+       timeout_t                       obd_recovery_timeout;
+       int                             obd_recovery_ir_factor;
 
        /* new recovery stuff from CMD2 */
        int                             obd_replayed_locks;
@@ -745,6 +755,19 @@ struct obd_device {
        struct completion               obd_kobj_unregister;
 };
 
+int obd_uuid_add(struct obd_device *obd, struct obd_export *export);
+void obd_uuid_del(struct obd_device *obd, struct obd_export *export);
+#ifdef HAVE_SERVER_SUPPORT
+struct obd_export *obd_uuid_lookup(struct obd_device *obd,
+                                  struct obd_uuid *uuid);
+
+int obd_nid_export_for_each(struct obd_device *obd, lnet_nid_t nid,
+                           int cb(struct obd_export *exp, void *data),
+                           void *data);
+int obd_nid_add(struct obd_device *obd, struct obd_export *exp);
+void obd_nid_del(struct obd_device *obd, struct obd_export *exp);
+#endif
+
 /* get/set_info keys */
 #define KEY_ASYNC               "async"
 #define KEY_CHANGELOG_CLEAR     "changelog_clear"
@@ -806,19 +829,20 @@ static inline int it_to_lock_mode(struct lookup_intent *it)
 }
 
 enum md_op_flags {
-       MF_MDC_CANCEL_FID1      = 1 << 0,
-       MF_MDC_CANCEL_FID2      = 1 << 1,
-       MF_MDC_CANCEL_FID3      = 1 << 2,
-       MF_MDC_CANCEL_FID4      = 1 << 3,
-       MF_GET_MDT_IDX          = 1 << 4,
+       MF_MDC_CANCEL_FID1      = BIT(0),
+       MF_MDC_CANCEL_FID2      = BIT(1),
+       MF_MDC_CANCEL_FID3      = BIT(2),
+       MF_MDC_CANCEL_FID4      = BIT(3),
+       MF_GET_MDT_IDX          = BIT(4),
 };
 
 enum md_cli_flags {
-       CLI_SET_MEA     = 1 << 0,
-       CLI_RM_ENTRY    = 1 << 1,
-       CLI_HASH64      = 1 << 2,
-       CLI_API32       = 1 << 3,
-       CLI_MIGRATE     = 1 << 4,
+       CLI_SET_MEA     = BIT(0),
+       CLI_RM_ENTRY    = BIT(1),
+       CLI_HASH64      = BIT(2),
+       CLI_API32       = BIT(3),
+       CLI_MIGRATE     = BIT(4),
+       CLI_DIRTY_DATA  = BIT(5),
 };
 
 enum md_op_code {
@@ -897,14 +921,14 @@ struct md_op_data {
        __u16                   op_mirror_id;
 
        /*
-        * used to access migrating dir: if it's set, assume migration is
-        * finished, use the new layout to access dir, otherwise use old layout.
+        * used to access dir that is changing layout: if it's set, access
+        * dir by new layout, otherwise old layout.
         * By default it's not set, because new files are created under new
         * layout, if we can't find file with name under both old and new
         * layout, we are sure file with name doesn't exist, but in reverse
         * order there may be a race with creation by others.
         */
-       bool                    op_post_migrate;
+       bool                    op_new_layout;
        /* used to access dir with bash hash */
        __u32                   op_stripe_index;
        /* Archive ID for PCC attach */
@@ -943,11 +967,11 @@ struct obd_ops {
                                __u32 keylen, void *key,
                                __u32 vallen, void *val,
                                struct ptlrpc_request_set *set);
-       int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
-       int (*o_precleanup)(struct obd_device *dev);
-       int (*o_cleanup)(struct obd_device *dev);
-       int (*o_process_config)(struct obd_device *dev, size_t len, void *data);
-       int (*o_postrecov)(struct obd_device *dev);
+       int (*o_setup) (struct obd_device *obd, struct lustre_cfg *cfg);
+       int (*o_precleanup)(struct obd_device *obd);
+       int (*o_cleanup)(struct obd_device *obd);
+       int (*o_process_config)(struct obd_device *obd, size_t len, void *data);
+       int (*o_postrecov)(struct obd_device *obd);
        int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
                          int priority);
        int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
@@ -1039,6 +1063,25 @@ struct lustre_md {
 #endif
 };
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+       if (md->posix_acl) {
+               posix_acl_release(md->posix_acl);
+               md->posix_acl = NULL;
+       }
+}
+
+#define OBD_CONNECT_ACL_FLAGS  \
+       (OBD_CONNECT_ACL | OBD_CONNECT_UMASK | OBD_CONNECT_LARGE_ACL)
+#else
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+}
+
+#define OBD_CONNECT_ACL_FLAGS  (0)
+#endif
+
 struct md_open_data {
        struct obd_client_handle        *mod_och;
        struct ptlrpc_request           *mod_open_req;
@@ -1130,7 +1173,7 @@ struct md_ops {
 
        int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
 
-       int (*m_merge_attr)(struct obd_export *,
+       int (*m_merge_attr)(struct obd_export *, const struct lu_fid *fid,
                            const struct lmv_stripe_md *lsm,
                            struct cl_attr *attr, ldlm_blocking_callback);
 
@@ -1285,4 +1328,16 @@ static inline void client_adjust_max_dirty(struct client_obd *cli)
                                           1 << (20 - PAGE_SHIFT));
 }
 
+static inline struct inode *page2inode(struct page *page)
+{
+       if (page->mapping) {
+               if (PageAnon(page))
+                       return NULL;
+               else
+                       return page->mapping->host;
+       } else {
+               return NULL;
+       }
+}
+
 #endif /* __OBD_H */