Whamcloud - gitweb
Land first part of new dcache handling (bug 16654).
[fs/lustre-release.git] / lustre / include / obd.h
index 868e86f..3848808 100644 (file)
@@ -60,7 +60,7 @@
 #define IOC_MDC_MAX_NR       50
 
 #include <lustre/lustre_idl.h>
-#include <lu_object.h>
+#include <lu_target.h>
 #include <lu_ref.h>
 #include <lustre_lib.h>
 #include <lustre_export.h>
@@ -97,8 +97,8 @@ struct lov_oinfo {                 /* per-stripe data structure */
         /* used by the osc to keep track of what objects to build into rpcs */
         struct loi_oap_pages loi_read_lop;
         struct loi_oap_pages loi_write_lop;
-        /* _cli_ is poorly named, it should be _ready_ */
-        struct list_head loi_cli_item;
+        struct list_head loi_ready_item;
+        struct list_head loi_hp_ready_item;
         struct list_head loi_write_item;
         struct list_head loi_read_item;
 
@@ -122,7 +122,8 @@ static inline void loi_init(struct lov_oinfo *loi)
         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
-        CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
+        CFS_INIT_LIST_HEAD(&loi->loi_ready_item);
+        CFS_INIT_LIST_HEAD(&loi->loi_hp_ready_item);
         CFS_INIT_LIST_HEAD(&loi->loi_write_item);
         CFS_INIT_LIST_HEAD(&loi->loi_read_item);
 }
@@ -246,7 +247,21 @@ struct ost_server_data;
 /* hold common fields for "target" device */
 struct obd_device_target {
         struct super_block       *obt_sb;
-        atomic_t                  obt_quotachecking;
+        /** last_rcvd file */
+        struct file              *obt_rcvd_filp;
+        /** server data in last_rcvd file */
+        struct lr_server_data    *obt_lsd;
+        /** Lock protecting client bitmap */
+        spinlock_t                obt_client_bitmap_lock;
+        /** Bitmap of known clients */
+        unsigned long            *obt_client_bitmap;
+        /** Server last transaction number */
+        __u64                     obt_last_transno;
+        /** Lock protecting last transaction number */
+        spinlock_t                obt_translock;
+        /** Number of mounts */
+        __u64                     obt_mount_count;
+        struct semaphore          obt_quotachecking;
         struct lustre_quota_ctxt  obt_qctxt;
         lustre_quota_version_t    obt_qfmt;
         struct rw_semaphore       obt_rwsem;
@@ -266,7 +281,9 @@ enum llog_ctxt_id {
         LLOG_TEST_REPL_CTXT,
         LLOG_LOVEA_ORIG_CTXT,
         LLOG_LOVEA_REPL_CTXT,
-        LLOG_CHANGELOG_ORIG_CTXT,   /**< changelog context */
+        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
 };
 
@@ -285,6 +302,7 @@ struct filter_ext {
 struct filter_obd {
         /* NB this field MUST be first */
         struct obd_device_target fo_obt;
+        struct lu_target     fo_lut;
         const char          *fo_fstype;
         struct vfsmount     *fo_vfsmnt;
 
@@ -297,12 +315,7 @@ struct filter_obd {
 
 
         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
-        spinlock_t           fo_translock;      /* protect fsd_last_transno */
-        struct file         *fo_rcvd_filp;
         struct file         *fo_health_check_filp;
-        struct lr_server_data *fo_fsd;
-        unsigned long       *fo_last_rcvd_slots;
-        __u64                fo_mount_count;
 
         unsigned long        fo_destroys_in_progress;
         struct semaphore     fo_create_locks[FILTER_SUBDIR_COUNT];
@@ -313,10 +326,12 @@ struct filter_obd {
         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
         obd_size             fo_tot_granted;    /* all values in bytes */
         obd_size             fo_tot_pending;
+        int                  fo_tot_granted_clients;
 
         obd_size             fo_readcache_max_filesize;
-        int                  fo_read_cache;
-        int                  fo_writethrough_cache;
+        int                  fo_read_cache:1,   /**< enable read-only cache */
+                             fo_writethrough_cache:1,/**< read cache writes */
+                             fo_mds_ost_sync:1; /**< MDS-OST orphan recovery*/
 
         struct obd_import   *fo_mdc_imp;
         struct obd_uuid      fo_mdc_uuid;
@@ -368,6 +383,21 @@ struct filter_obd {
         int                      fo_sec_level;
 };
 
+#define fo_translock            fo_obt.obt_translock
+#define fo_rcvd_filp            fo_obt.obt_rcvd_filp
+#define fo_fsd                  fo_obt.obt_lsd
+#define fo_last_rcvd_slots      fo_obt.obt_client_bitmap
+#define fo_mount_count          fo_obt.obt_mount_count
+
+struct timeout_item {
+        enum timeout_event ti_event;
+        cfs_time_t         ti_timeout;
+        timeout_cb_t       ti_cb;
+        void              *ti_cb_data;
+        struct list_head   ti_obd_list;
+        struct list_head   ti_chain;
+};
+
 #define OSC_MAX_RIF_DEFAULT       8
 #define OSC_MAX_RIF_MAX         256
 #define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
@@ -404,6 +434,10 @@ struct client_obd {
         long                     cl_avail_grant;   /* bytes of credit for ost */
         long                     cl_lost_grant;    /* lost credits (trunc) */
         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
+        cfs_time_t               cl_next_shrink_grant;   /* jiffies */
+        struct list_head         cl_grant_shrink_list;  /* Timeout event list */
+        struct semaphore         cl_grant_sem;   /*grant shrink list semaphore*/
+        int                      cl_grant_shrink_interval; /* seconds */
 
         /* keep track of objects that have lois that contain pages which
          * have been queued for async brw.  this lock also protects the
@@ -425,6 +459,7 @@ struct client_obd {
          */
         client_obd_lock_t        cl_loi_list_lock;
         struct list_head         cl_loi_ready_list;
+        struct list_head         cl_loi_hp_ready_list;
         struct list_head         cl_loi_write_list;
         struct list_head         cl_loi_read_list;
         int                      cl_r_in_flight;
@@ -500,15 +535,10 @@ struct mds_obd {
         cfs_dentry_t                    *mds_fid_de;
         int                              mds_max_mdsize;
         int                              mds_max_cookiesize;
-        struct file                     *mds_rcvd_filp;
-        spinlock_t                       mds_transno_lock;
-        __u64                            mds_last_transno;
-        __u64                            mds_mount_count;
         __u64                            mds_io_epoch;
         unsigned long                    mds_atime_diff;
         struct semaphore                 mds_epoch_sem;
         struct ll_fid                    mds_rootfid;
-        struct lr_server_data           *mds_server_data;
         cfs_dentry_t                    *mds_pending_dir;
         cfs_dentry_t                    *mds_logs_dir;
         cfs_dentry_t                    *mds_objects_dir;
@@ -532,8 +562,6 @@ struct mds_obd {
         __u32                            mds_lov_objid_lastidx;
 
         struct file                     *mds_health_check_filp;
-        unsigned long                   *mds_client_bitmap;
-//        struct upcall_cache             *mds_group_hash;
 
         struct lustre_quota_info         mds_quota_info;
         struct semaphore                 mds_qonoff_sem;
@@ -554,6 +582,13 @@ struct mds_obd {
         struct rw_semaphore              mds_notify_lock;
 };
 
+#define mds_transno_lock         mds_obt.obt_translock
+#define mds_rcvd_filp            mds_obt.obt_rcvd_filp
+#define mds_server_data          mds_obt.obt_lsd
+#define mds_client_bitmap        mds_obt.obt_client_bitmap
+#define mds_mount_count          mds_obt.obt_mount_count
+#define mds_last_transno         mds_obt.obt_last_transno
+
 /* lov objid */
 extern __u32 mds_max_ost_index;
 
@@ -634,6 +669,10 @@ struct lov_qos_rr {
         unsigned long       lqr_dirty:1;     /* recalc round-robin list */
 };
 
+struct lov_statfs_data {
+        struct obd_info   lsd_oi;
+        struct obd_statfs lsd_statfs;
+};
 /* Stripe placement optimization */
 struct lov_qos {
         struct list_head    lq_oss_list;    /* list of OSSs that targets use */
@@ -645,12 +684,18 @@ struct lov_qos {
         unsigned long       lq_dirty:1,     /* recalc qos data */
                             lq_same_space:1,/* the ost's all have approx.
                                                the same space avail */
-                            lq_reset:1;     /* zero current penalties */
+                            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 */
 };
 
 struct lov_tgt_desc {
         struct list_head    ltd_kill;
         struct obd_uuid     ltd_uuid;
+        struct obd_device  *ltd_obd;
         struct obd_export  *ltd_exp;
         struct ltd_qos      ltd_qos;     /* qos info per target */
         __u32               ltd_gen;
@@ -804,6 +849,8 @@ struct obd_trans_info {
         /* initial thread handling transaction */
         struct ptlrpc_thread *   oti_thread;
         __u32                    oti_conn_cnt;
+        /** VBR: versions */
+        __u64                    oti_pre_version;
 
         struct obd_uuid         *oti_ost_uuid;
 };
@@ -819,7 +866,15 @@ static inline void oti_init(struct obd_trans_info *oti,
                 return;
 
         oti->oti_xid = req->rq_xid;
+        /** VBR: take versions from request */
+        if (req->rq_reqmsg != NULL &&
+            lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+                __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg);
+                oti->oti_pre_version = pre_version ? pre_version[0] : 0;
+                oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg);
+        }
 
+        /** called from mds_create_objects */
         if (req->rq_repmsg != NULL)
                 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
         oti->oti_thread = req->rq_svc_thread;
@@ -873,7 +928,9 @@ enum obd_notify_event {
         OBD_NOTIFY_SYNC_NONBLOCK,
         OBD_NOTIFY_SYNC,
         /* Configuration event */
-        OBD_NOTIFY_CONFIG
+        OBD_NOTIFY_CONFIG,
+        /* Trigger quota recovery */
+        OBD_NOTIFY_QUOTA
 };
 
 /* bit-mask flags for config events */
@@ -889,7 +946,7 @@ enum config_flags {
  */
 struct obd_notify_upcall {
         int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
-                          enum obd_notify_event ev, void *owner);
+                          enum obd_notify_event ev, void *owner, void *data);
         /* Opaque datum supplied by upper layer listener */
         void *onu_owner;
 };
@@ -965,7 +1022,8 @@ struct obd_device {
         unsigned long obd_attached:1,      /* finished attach */
                       obd_set_up:1,        /* finished setup */
                       obd_recovering:1,    /* there are recoverable clients */
-                      obd_abort_recovery:1,/* somebody ioctl'ed us to abort */
+                      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 */
@@ -976,8 +1034,9 @@ struct obd_device {
                       obd_fail:1,          /* cleanup with failover */
                       obd_async_recov:1,   /* allow asyncronous orphan cleanup */
                       obd_no_conn:1,       /* deny new connections */
-                      obd_inactive:1;      /* device active/inactive
+                      obd_inactive:1,      /* device active/inactive
                                            * (for /proc/status only!!) */
+                      obd_process_conf:1;  /* device is processing mgs config */
         /* uuid-export hash body */
         struct lustre_hash     *obd_uuid_hash;
         /* nid-export hash body */
@@ -988,6 +1047,8 @@ struct obd_device {
         atomic_t                obd_refcount;
         cfs_waitq_t             obd_refcount_waitq;
         struct list_head        obd_exports;
+        struct list_head        obd_unlinked_exports;
+        struct list_head        obd_delayed_exports;
         int                     obd_num_exports;
         spinlock_t              obd_nid_lock;
         struct ldlm_namespace  *obd_namespace;
@@ -1016,13 +1077,13 @@ struct obd_device {
         int                              obd_max_recoverable_clients;
         int                              obd_connected_clients;
         int                              obd_recoverable_clients;
+        int                              obd_stale_clients;
+        int                              obd_delayed_clients;
         spinlock_t                       obd_processing_task_lock; /* BH lock (timer) */
         __u64                            obd_next_recovery_transno;
         int                              obd_replayed_requests;
         int                              obd_requests_queued_for_recovery;
         cfs_waitq_t                      obd_next_transno_waitq;
-        struct list_head                 obd_uncommitted_replies;
-        spinlock_t                       obd_uncommitted_replies_lock;
         cfs_timer_t                      obd_recovery_timer;
         time_t                           obd_recovery_start; /* seconds */
         time_t                           obd_recovery_end; /* seconds, for lprocfs_status */
@@ -1089,35 +1150,37 @@ enum obd_cleanup_stage {
 };
 
 /* get/set_info keys */
-#define KEY_READ_ONLY           "read-only"
-#define KEY_MDS_CONN            "mds_conn"
-#define KEY_NEXT_ID             "next_id"
-#define KEY_LOVDESC             "lovdesc"
-#define KEY_INIT_RECOV          "initial_recov"
-#define KEY_INIT_RECOV_BACKUP   "init_recov_bk"
-#define KEY_FLUSH_CTX           "flush_ctx"
+#define KEY_BLOCKSIZE_BITS      "blocksize_bits"
+#define KEY_BLOCKSIZE           "blocksize"
 #define KEY_CAPA_KEY            "capa_key"
+#define KEY_CHANGELOG_CLEAR     "changelog_clear"
+#define KEY_FID2PATH            "fid2path"
+#define KEY_CHECKSUM            "checksum"
+#define KEY_CLEAR_FS            "clear_fs"
 #define KEY_CONN_DATA           "conn_data"
-#define KEY_MAX_EASIZE          "max_easize"
-#define KEY_REVIMP_UPD          "revimp_update"
-#define KEY_LOV_IDX             "lov_idx"
+#define KEY_EVICT_BY_NID        "evict_by_nid"
+#define KEY_FIEMAP              "fiemap"
+#define KEY_FLUSH_CTX           "flush_ctx"
+#define KEY_INIT_RECOV_BACKUP   "init_recov_bk"
+#define KEY_INIT_RECOV          "initial_recov"
 #define KEY_LAST_ID             "last_id"
-#define KEY_READONLY            "read-only"
 #define KEY_LOCK_TO_STRIPE      "lock_to_stripe"
-#define KEY_CHECKSUM            "checksum"
-#define KEY_UNLINKED            "unlinked"
-#define KEY_EVICT_BY_NID        "evict_by_nid"
+#define KEY_LOVDESC             "lovdesc"
+#define KEY_LOV_IDX             "lov_idx"
+#define KEY_MAX_EASIZE          "max_easize"
+#define KEY_MDS_CONN            "mds_conn"
+#define KEY_MGSSEC              "mgssec"
+#define KEY_NEXT_ID             "next_id"
+#define KEY_READ_ONLY           "read-only"
 #define KEY_REGISTER_TARGET     "register_target"
+#define KEY_REVIMP_UPD          "revimp_update"
 #define KEY_SET_FS              "set_fs"
-#define KEY_CLEAR_FS            "clear_fs"
-#define KEY_BLOCKSIZE           "blocksize"
-#define KEY_BLOCKSIZE_BITS      "blocksize_bits"
-#define KEY_FIEMAP              "fiemap"
 #define KEY_SPTLRPC_CONF        "sptlrpc_conf"
-#define KEY_MGSSEC              "mgssec"
+#define KEY_UNLINKED            "unlinked"
 /* XXX unused ?*/
 #define KEY_INTERMDS            "inter_mds"
 #define KEY_ASYNC               "async"
+#define KEY_GRANT_SHRINK        "grant_shrink"
 
 struct lu_context;
 
@@ -1258,6 +1321,9 @@ struct obd_ops {
         int (*o_precreate)(struct obd_export *exp);
         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
+        int (*o_create_async)(struct obd_export *exp,  struct obd_info *oinfo,
+                              struct lov_stripe_md **ea,
+                              struct obd_trans_info *oti);
         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
                          struct lov_stripe_md *ea, struct obd_trans_info *oti,
                          struct obd_export *md_exp, void *capa);
@@ -1356,6 +1422,8 @@ struct obd_ops {
                           char *ostname);
         int (*o_pool_rem)(struct obd_device *obd, char *poolname,
                           char *ostname);
+        void (*o_getref)(struct obd_device *obd);
+        void (*o_putref)(struct obd_device *obd);
         /*
          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
@@ -1393,7 +1461,8 @@ struct lustre_md {
 
 struct md_open_data {
         struct obd_client_handle *mod_och;
-        struct list_head          mod_replay_list;
+        struct ptlrpc_request    *mod_open_req;
+        struct ptlrpc_request    *mod_close_req;
 };
 
 struct lookup_intent;
@@ -1467,7 +1536,7 @@ struct md_ops {
                                       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 *);
+        int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u32 *);
 
         ldlm_mode_t (*m_lock_match)(struct obd_export *, int,
                                     const struct lu_fid *, ldlm_type_t,
@@ -1506,9 +1575,9 @@ struct lsm_operations {
         int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
                            struct obd_export *md_exp);
         void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
-                                     unsigned long *);
+                                    obd_off *);
         void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
-                                     unsigned long *);
+                                     obd_off *);
         obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
         obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
         int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
@@ -1544,22 +1613,24 @@ int lvfs_check_io_health(struct obd_device *obd, struct file *file);
 #define OBD_CALC_STRIPE_END     2
 
 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
-                                         int error)
+                                         struct obd_export *exp, int error)
 {
         if (error) {
                 CERROR("%s: transno "LPU64" commit error: %d\n",
                        obd->obd_name, transno, error);
                 return;
         }
-        if (transno > obd->obd_last_committed) {
-                CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
+        if (exp && transno > exp->exp_last_committed) {
+                CDEBUG(D_HA, "%s: transno "LPU64" committed\n",
                        obd->obd_name, transno);
-                obd->obd_last_committed = transno;
-                ptlrpc_commit_replies (obd);
+                exp->exp_last_committed = transno;
+                ptlrpc_commit_replies(exp);
         } else {
-                CDEBUG(D_INFO, "%s: transno "LPD64" committed\n",
+                CDEBUG(D_INFO, "%s: transno "LPU64" committed\n",
                        obd->obd_name, transno);
         }
+        if (transno > obd->obd_last_committed)
+                obd->obd_last_committed = transno;
 }
 
 static inline void init_obd_quota_ops(quota_interface_t *interface,