Whamcloud - gitweb
LU-2139 osc: Track and limit "unstable" pages
[fs/lustre-release.git] / lustre / include / obd.h
index 6afec97..bf14b7d 100644 (file)
@@ -266,22 +266,23 @@ struct brw_page {
 
 /* llog contexts */
 enum llog_ctxt_id {
-        LLOG_CONFIG_ORIG_CTXT  =  0,
-        LLOG_CONFIG_REPL_CTXT,
-        LLOG_MDS_OST_ORIG_CTXT,
-        LLOG_MDS_OST_REPL_CTXT,
-        LLOG_SIZE_ORIG_CTXT,
-        LLOG_SIZE_REPL_CTXT,
-        LLOG_RD1_ORIG_CTXT,
-        LLOG_RD1_REPL_CTXT,
-        LLOG_TEST_ORIG_CTXT,
-        LLOG_TEST_REPL_CTXT,
-        LLOG_LOVEA_ORIG_CTXT,
-        LLOG_LOVEA_REPL_CTXT,
-        LLOG_CHANGELOG_ORIG_CTXT,      /**< changelog generation on mdd */
-        LLOG_CHANGELOG_REPL_CTXT,      /**< changelog access on clients */
-        LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */
-        LLOG_MAX_CTXTS
+       LLOG_CONFIG_ORIG_CTXT  =  0,
+       LLOG_CONFIG_REPL_CTXT,
+       LLOG_MDS_OST_ORIG_CTXT,
+       LLOG_MDS_OST_REPL_CTXT,
+       LLOG_SIZE_ORIG_CTXT,
+       LLOG_SIZE_REPL_CTXT,
+       LLOG_RD1_ORIG_CTXT,
+       LLOG_RD1_REPL_CTXT,
+       LLOG_TEST_ORIG_CTXT,
+       LLOG_TEST_REPL_CTXT,
+       LLOG_LOVEA_ORIG_CTXT,
+       LLOG_LOVEA_REPL_CTXT,
+       LLOG_CHANGELOG_ORIG_CTXT,       /**< changelog generation on mdd */
+       LLOG_CHANGELOG_REPL_CTXT,       /**< changelog access on clients */
+       LLOG_CHANGELOG_USER_ORIG_CTXT,  /**< for multiple changelog consumers */
+       LLOG_AGENT_ORIG_CTXT,           /**< agent requests generation on cdt */
+       LLOG_MAX_CTXTS
 };
 
 struct timeout_item {
@@ -403,15 +404,15 @@ struct client_obd {
 
         /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
         cfs_atomic_t             cl_destroy_in_flight;
-        cfs_waitq_t              cl_destroy_waitq;
+       wait_queue_head_t        cl_destroy_waitq;
 
         struct mdc_rpc_lock     *cl_rpc_lock;
         struct mdc_rpc_lock     *cl_close_lock;
 
         /* mgc datastruct */
        struct semaphore         cl_mgc_sem;
-        struct vfsmount         *cl_mgc_vfsmnt;
-        struct dentry           *cl_mgc_configs_dir;
+       struct local_oid_storage *cl_mgc_los;
+       struct dt_object        *cl_mgc_configs_dir;
         cfs_atomic_t             cl_mgc_refcount;
         struct obd_export       *cl_mgc_mgsexp;
 
@@ -516,10 +517,10 @@ struct lov_qos {
                             lq_reset:1,     /* zero current penalties */
                             lq_statfs_in_progress:1; /* statfs op in
                                                         progress */
-        /* qos statfs data */
-        struct lov_statfs_data *lq_statfs_data;
-        cfs_waitq_t         lq_statfs_waitq; /* waitqueue to notify statfs
-                                              * requests completion */
+       /* qos statfs data */
+       struct lov_statfs_data *lq_statfs_data;
+       wait_queue_head_t   lq_statfs_waitq; /* waitqueue to notify statfs
+                                             * requests completion */
 };
 
 struct lov_tgt_desc {
@@ -572,7 +573,7 @@ struct lov_obd {
         cfs_proc_dir_entry_t   *lov_pool_proc_entry;
         enum lustre_sec_part    lov_sp_me;
 
-       /* Cached LRU pages from upper layer */
+       /* Cached LRU and unstable data from upper layer */
        void                   *lov_cache;
 
        struct rw_semaphore     lov_notify_lock;
@@ -828,9 +829,9 @@ struct target_recovery_data {
 };
 
 struct obd_llog_group {
-        int                olg_seq;
-        struct llog_ctxt  *olg_ctxts[LLOG_MAX_CTXTS];
-        cfs_waitq_t        olg_waitq;
+       int                olg_seq;
+       struct llog_ctxt   *olg_ctxts[LLOG_MAX_CTXTS];
+       wait_queue_head_t  olg_waitq;
        spinlock_t         olg_lock;
        struct mutex       olg_cat_processing;
 };
@@ -840,35 +841,38 @@ struct obd_llog_group {
 #define OBD_DEV_BY_DEVNAME      0xffffd0de
 
 struct obd_device {
-        struct obd_type        *obd_type;
-        __u32                   obd_magic;
+       struct obd_type         *obd_type;
+       __u32                    obd_magic;
 
         /* common and UUID name of this device */
-        char                    obd_name[MAX_OBD_NAME];
-        struct obd_uuid         obd_uuid;
-
-        struct lu_device       *obd_lu_dev;
-
-        int                     obd_minor;
-        /* bitfield modification is protected by obd_dev_lock */
-        unsigned long obd_attached:1,      /* finished attach */
-                      obd_set_up:1,        /* finished setup */
-                      obd_recovering:1,    /* there are recoverable clients */
-                      obd_abort_recovery:1,/* recovery expired */
-                      obd_version_recov:1, /* obd uses version checking */
-                      obd_replayable:1,    /* recovery is 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 */
-                      obd_force:1,         /* cleanup with > 0 obd refcount */
-                      obd_fail:1,          /* cleanup with failover */
-                      obd_async_recov:1,   /* allow asynchronous orphan cleanup */
-                      obd_no_conn:1,       /* deny new connections */
-                      obd_inactive:1,      /* device active/inactive
-                                           * (for /proc/status only!!) */
-                      obd_no_ir:1,         /* no imperative recovery. */
-                      obd_process_conf:1;  /* device is processing mgs config */
+       char                     obd_name[MAX_OBD_NAME];
+       struct obd_uuid          obd_uuid;
+       int                      obd_minor;
+       struct lu_device        *obd_lu_dev;
+
+       /* bitfield modification is protected by obd_dev_lock */
+       unsigned long
+               obd_attached:1,         /* finished attach */
+               obd_set_up:1,           /* finished setup */
+               obd_recovering:1,       /* there are recoverable clients */
+               obd_abort_recovery:1,   /* recovery expired */
+               obd_version_recov:1,    /* obd uses version checking */
+               obd_replayable:1,       /* recovery is 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 */
+               obd_force:1,            /* cleanup with > 0 obd refcount */
+               obd_fail:1,             /* cleanup with failover */
+               obd_async_recov:1,      /* allow asynchronous orphan cleanup */
+               obd_no_conn:1,          /* deny new connections */
+               obd_inactive:1,         /* device active/inactive
+                                        * (for /proc/status only!!) */
+               obd_no_ir:1,            /* no imperative recovery. */
+               obd_process_conf:1,     /* device is processing mgs config */
+               obd_uses_nid_stats:1;   /* maintain per-client OBD stats */
+
         /* 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;
@@ -880,7 +884,6 @@ struct obd_device {
         cfs_hash_t             *obd_nid_stats_hash;
         cfs_list_t              obd_nid_stats;
         cfs_atomic_t            obd_refcount;
-        cfs_waitq_t             obd_refcount_waitq;
         cfs_list_t              obd_exports;
         cfs_list_t              obd_unlinked_exports;
         cfs_list_t              obd_delayed_exports;
@@ -892,7 +895,6 @@ struct obd_device {
        spinlock_t              obd_dev_lock; /* protect OBD bitfield above */
        struct mutex            obd_dev_mutex;
        __u64                   obd_last_committed;
-       struct fsfilt_operations *obd_fsops;
        spinlock_t              obd_osfs_lock;
        struct obd_statfs       obd_osfs;       /* locked by obd_osfs_lock */
        __u64                   obd_osfs_age;
@@ -914,16 +916,16 @@ struct obd_device {
          * obd_next_recovery_transno value */
        spinlock_t                       obd_recovery_task_lock;
         __u64                            obd_next_recovery_transno;
-        int                              obd_replayed_requests;
-        int                              obd_requests_queued_for_recovery;
-        cfs_waitq_t                      obd_next_transno_waitq;
-        /* protected by obd_recovery_task_lock */
-        cfs_timer_t                      obd_recovery_timer;
-        time_t                           obd_recovery_start; /* seconds */
-        time_t                           obd_recovery_end; /* seconds, for lprocfs_status */
-        int                              obd_recovery_time_hard;
-        int                              obd_recovery_timeout;
-        int                              obd_recovery_ir_factor;
+       int                              obd_replayed_requests;
+       int                              obd_requests_queued_for_recovery;
+       wait_queue_head_t                obd_next_transno_waitq;
+       /* protected by obd_recovery_task_lock */
+       struct timer_list                obd_recovery_timer;
+       time_t                           obd_recovery_start; /* seconds */
+       time_t                           obd_recovery_end; /* seconds, for lprocfs_status */
+       int                              obd_recovery_time_hard;
+       int                              obd_recovery_timeout;
+       int                              obd_recovery_ir_factor;
 
         /* new recovery stuff from CMD2 */
         struct target_recovery_data      obd_recovery_data;
@@ -934,7 +936,6 @@ struct obd_device {
         cfs_list_t                       obd_req_replay_queue;
         cfs_list_t                       obd_lock_replay_queue;
         cfs_list_t                       obd_final_req_queue;
-        int                              obd_recovery_stage;
 
        union {
 #ifdef HAVE_SERVER_SUPPORT
@@ -952,16 +953,16 @@ struct obd_device {
        unsigned int           obd_cntr_base;
        struct lprocfs_stats  *obd_stats;
 
-        unsigned int           md_cntr_base;
-        struct lprocfs_stats  *md_stats;
+       unsigned int           obd_md_cntr_base;
+       struct lprocfs_stats  *obd_md_stats;
 
         cfs_proc_dir_entry_t  *obd_proc_entry;
         cfs_proc_dir_entry_t  *obd_proc_exports_entry;
         cfs_proc_dir_entry_t  *obd_svc_procroot;
         struct lprocfs_stats  *obd_svc_stats;
-        cfs_atomic_t           obd_evict_inprogress;
-        cfs_waitq_t            obd_evict_inprogress_waitq;
-        cfs_list_t             obd_evict_list; /* protected with pet_lock */
+       cfs_atomic_t           obd_evict_inprogress;
+       wait_queue_head_t      obd_evict_inprogress_waitq;
+       cfs_list_t             obd_evict_list; /* protected with pet_lock */
 
         /**
          * Ldlm pool part. Save last calculated SLV and Limit.
@@ -1045,6 +1046,7 @@ struct lu_context;
 #define IT_LAYOUT   (1 << 10)
 #define IT_QUOTA_DQACQ (1 << 11)
 #define IT_QUOTA_CONN  (1 << 12)
+#define IT_SETXATTR (1 << 13)
 
 static inline int it_to_lock_mode(struct lookup_intent *it)
 {
@@ -1054,6 +1056,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it)
         else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP |
                               IT_LAYOUT))
                 return LCK_CR;
+       else if (it->it_op &  IT_GETXATTR)
+               return LCK_PR;
+       else if (it->it_op &  IT_SETXATTR)
+               return LCK_PW;
 
         LASSERTF(0, "Invalid it_op: %d\n", it->it_op);
         return -EINVAL;
@@ -1083,24 +1089,24 @@ struct md_op_data {
 #ifdef __KERNEL__
        unsigned int            op_attr_flags;
 #endif
-        __u64                   op_valid;
-        loff_t                  op_attr_blocks;
+       __u64                   op_valid;
+       loff_t                  op_attr_blocks;
 
-        /* Size-on-MDS epoch and flags. */
-        __u64                   op_ioepoch;
+       /* Size-on-MDS epoch and flags. */
+       __u64                   op_ioepoch;
        __u32                   op_flags;
 
-        /* Capa fields */
-        struct obd_capa        *op_capa1;
-        struct obd_capa        *op_capa2;
+       /* Capa fields */
+       struct obd_capa        *op_capa1;
+       struct obd_capa        *op_capa2;
 
-        /* Various operation flags. */
-       __u32                   op_bias;
+       /* Various operation flags. */
+       enum mds_op_bias        op_bias;
 
-        /* Operation type */
+       /* Operation type */
        __u32                   op_opc;
 
-        /* Used by readdir */
+       /* Used by readdir */
        __u64                   op_offset;
 
        /* Used by readdir */
@@ -1109,6 +1115,10 @@ struct md_op_data {
        /* used to transfer info between the stacks of MD client
         * see enum op_cli_flags */
        __u32                   op_cli_flags;
+
+       /* File object data version for HSM release, on client */
+       __u64                   op_data_version;
+       struct lustre_handle    op_lease_handle;
 };
 
 enum op_cli_flags {
@@ -1133,9 +1143,9 @@ struct md_enqueue_info {
 };
 
 struct obd_ops {
-        cfs_module_t *o_owner;
-        int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
-                           void *karg, void *uarg);
+       struct module *o_owner;
+       int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
+                          void *karg, void *uarg);
         int (*o_get_info)(const struct lu_env *env, struct obd_export *,
                           __u32 keylen, void *key, __u32 *vallen, void *val,
                           struct lov_stripe_md *lsm);
@@ -1345,90 +1355,67 @@ struct md_open_data {
 struct lookup_intent;
 
 struct md_ops {
-        int (*m_getstatus)(struct obd_export *, struct lu_fid *,
-                           struct obd_capa **);
-        int (*m_null_inode)(struct obd_export *, const struct lu_fid *);
-        int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *,
-                             ldlm_iterator_t, void *);
-        int (*m_close)(struct obd_export *, struct md_op_data *,
-                       struct md_open_data *, struct ptlrpc_request **);
-        int (*m_create)(struct obd_export *, struct md_op_data *,
-                        const void *, int, int, __u32, __u32, cfs_cap_t,
-                        __u64, struct ptlrpc_request **);
-        int (*m_done_writing)(struct obd_export *, struct md_op_data  *,
-                              struct md_open_data *);
-        int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
-                         struct lookup_intent *, struct md_op_data *,
-                         struct lustre_handle *, void *, int,
+       /* Every operation from MD_STATS_FIRST_OP up to and including
+        * MD_STATS_LAST_OP will be counted by EXP_MD_OP_INCREMENT()
+        * and will appear in /proc/fs/lustre/{lmv,mdc}/.../md_stats.
+        * Operations after MD_STATS_LAST_OP are excluded from stats.
+        * There are a few reasons for doing this: we prune the 17
+        * counters which will be of minimal use in understanding
+        * metadata utilization, we save memory by allocating 15
+        * instead of 32 counters, we save cycles by not counting.
+        *
+        * MD_STATS_FIRST_OP must be the first member of md_ops.
+        */
+#define MD_STATS_FIRST_OP m_close
+       int (*m_close)(struct obd_export *, struct md_op_data *,
+                      struct md_open_data *, struct ptlrpc_request **);
+
+       int (*m_create)(struct obd_export *, struct md_op_data *,
+                       const void *, int, int, __u32, __u32, cfs_cap_t,
+                       __u64, struct ptlrpc_request **);
+
+       int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
+                        struct lookup_intent *, struct md_op_data *,
+                        struct lustre_handle *, void *, int,
                         struct ptlrpc_request **, __u64);
-        int (*m_getattr)(struct obd_export *, struct md_op_data *,
-                         struct ptlrpc_request **);
-        int (*m_getattr_name)(struct obd_export *, struct md_op_data *,
-                              struct ptlrpc_request **);
-        int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
-                             void *, int, struct lookup_intent *, int,
-                             struct ptlrpc_request **,
+
+       int (*m_getattr)(struct obd_export *, struct md_op_data *,
+                        struct ptlrpc_request **);
+
+       int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
+                            void *, int, struct lookup_intent *, int,
+                            struct ptlrpc_request **,
                             ldlm_blocking_callback, __u64);
-        int (*m_link)(struct obd_export *, struct md_op_data *,
-                      struct ptlrpc_request **);
-        int (*m_rename)(struct obd_export *, struct md_op_data *,
-                        const char *, int, const char *, int,
-                        struct ptlrpc_request **);
-        int (*m_is_subdir)(struct obd_export *, const struct lu_fid *,
-                           const struct lu_fid *,
-                           struct ptlrpc_request **);
-        int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
-                         int , void *, int, struct ptlrpc_request **,
-                         struct md_open_data **mod);
-        int (*m_sync)(struct obd_export *, const struct lu_fid *,
-                      struct obd_capa *, struct ptlrpc_request **);
-        int (*m_readpage)(struct obd_export *, struct md_op_data *,
-                          struct page **, struct ptlrpc_request **);
-
-        int (*m_unlink)(struct obd_export *, struct md_op_data *,
-                        struct ptlrpc_request **);
-
-        int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
-                          struct obd_capa *, obd_valid, const char *,
-                          const char *, int, int, int, __u32,
-                          struct ptlrpc_request **);
-
-        int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
-                          struct obd_capa *, obd_valid, const char *,
-                          const char *, int, int, int,
-                          struct ptlrpc_request **);
-
-        int (*m_init_ea_size)(struct obd_export *, int, int, int);
-
-        int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
-                               struct obd_export *, struct obd_export *,
-                               struct lustre_md *);
-
-        int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
-
-        int (*m_set_open_replay_data)(struct obd_export *,
-                                      struct obd_client_handle *,
-                                      struct ptlrpc_request *);
-        int (*m_clear_open_replay_data)(struct obd_export *,
-                                        struct obd_client_handle *);
-        int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *);
 
-       ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64,
-                                    const struct lu_fid *, ldlm_type_t,
-                                    ldlm_policy_data_t *, ldlm_mode_t,
-                                    struct lustre_handle *);
+       int (*m_link)(struct obd_export *, struct md_op_data *,
+                     struct ptlrpc_request **);
 
-        int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
-                               ldlm_policy_data_t *, ldlm_mode_t,
-                               ldlm_cancel_flags_t flags, void *opaque);
-        int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
-                            renew_capa_cb_t cb);
-        int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *,
-                             const struct req_msg_field *, struct obd_capa **);
+       int (*m_rename)(struct obd_export *, struct md_op_data *,
+                       const char *, int, const char *, int,
+                       struct ptlrpc_request **);
+
+       int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
+                        int , void *, int, struct ptlrpc_request **,
+                        struct md_open_data **mod);
+
+       int (*m_fsync)(struct obd_export *, const struct lu_fid *,
+                      struct obd_capa *, struct ptlrpc_request **);
+
+       int (*m_readpage)(struct obd_export *, struct md_op_data *,
+                         struct page **, struct ptlrpc_request **);
 
-        int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
-                                 struct obd_capa *, __u32,
-                                 struct ptlrpc_request **);
+       int (*m_unlink)(struct obd_export *, struct md_op_data *,
+                       struct ptlrpc_request **);
+
+       int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
+                         struct obd_capa *, obd_valid, const char *,
+                         const char *, int, int, int, __u32,
+                         struct ptlrpc_request **);
+
+       int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
+                         struct obd_capa *, obd_valid, const char *,
+                         const char *, int, int, int,
+                         struct ptlrpc_request **);
 
         int (*m_intent_getattr_async)(struct obd_export *,
                                       struct md_enqueue_info *,
@@ -1436,12 +1423,61 @@ struct md_ops {
 
         int (*m_revalidate_lock)(struct obd_export *, struct lookup_intent *,
                                  struct lu_fid *, __u64 *bits);
+#define MD_STATS_LAST_OP m_revalidate_lock
 
-        /*
-         * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
-         * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
-         * wrapper function in include/linux/obd_class.h.
-         */
+       int (*m_getstatus)(struct obd_export *, struct lu_fid *,
+                          struct obd_capa **);
+
+       int (*m_null_inode)(struct obd_export *, const struct lu_fid *);
+
+       int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *,
+                            ldlm_iterator_t, void *);
+
+       int (*m_done_writing)(struct obd_export *, struct md_op_data  *,
+                             struct md_open_data *);
+
+       int (*m_getattr_name)(struct obd_export *, struct md_op_data *,
+                             struct ptlrpc_request **);
+
+       int (*m_is_subdir)(struct obd_export *, const struct lu_fid *,
+                          const struct lu_fid *,
+                          struct ptlrpc_request **);
+
+       int (*m_init_ea_size)(struct obd_export *, int, int, int);
+
+       int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
+                              struct obd_export *, struct obd_export *,
+                              struct lustre_md *);
+
+       int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
+
+       int (*m_set_open_replay_data)(struct obd_export *,
+                                     struct obd_client_handle *,
+                                     struct ptlrpc_request *);
+
+       int (*m_clear_open_replay_data)(struct obd_export *,
+                                       struct obd_client_handle *);
+
+       int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *);
+
+       ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64,
+                                   const struct lu_fid *, ldlm_type_t,
+                                   ldlm_policy_data_t *, ldlm_mode_t,
+                                   struct lustre_handle *);
+
+       int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
+                              ldlm_policy_data_t *, ldlm_mode_t,
+                              ldlm_cancel_flags_t flags, void *opaque);
+
+       int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
+                           renew_capa_cb_t cb);
+
+       int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *,
+                            const struct req_msg_field *, struct obd_capa **);
+
+       int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
+                                struct obd_capa *, __u32,
+                                struct ptlrpc_request **);
 };
 
 struct lsm_operations {