Whamcloud - gitweb
Branch: b_new_cmd
[fs/lustre-release.git] / lustre / include / obd.h
index 6838b97..65cd41a 100644 (file)
 #define IOC_MDC_TYPE         'i'
 #define IOC_MDC_MIN_NR       20
 /* Moved to lustre_user.h
-#define IOC_MDC_LOOKUP       _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
+#define IOC_MDC_LOOKUP       _IOWR(IOC_MDC_TYPE, 20, struct obd_ioctl_data *)
 #define IOC_MDC_GETSTRIPE    _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
 #define IOC_MDC_MAX_NR       50
 
 #include <lustre/lustre_idl.h>
+#include <lu_object.h>
 #include <lustre_lib.h>
 #include <lustre_export.h>
 #include <lustre_quota.h>
 #include <lustre_fld.h>
 
+#define MAX_OBD_DEVICES 8192
+
 /* this is really local to the OSC */
 struct loi_oap_pages {
         struct list_head        lop_pending;
-        int                     lop_num_pending;
         struct list_head        lop_urgent;
         struct list_head        lop_pending_group;
+        int                     lop_num_pending;
 };
 
 struct osc_async_rc {
@@ -104,7 +107,6 @@ struct lov_stripe_md {
                 __u64 lw_object_id;        /* lov object id */
                 __u64 lw_object_gr;        /* lov object group */
                 __u64 lw_maxbytes;         /* maximum possible file size */
-                unsigned long lw_xfersize; /* optimal transfer size */
 
                 /* LOV-private members start here -- only for use in lov/. */
                 __u32 lw_magic;
@@ -120,12 +122,55 @@ struct lov_stripe_md {
 #define lsm_object_id    lsm_wire.lw_object_id
 #define lsm_object_gr    lsm_wire.lw_object_gr
 #define lsm_maxbytes     lsm_wire.lw_maxbytes
-#define lsm_xfersize     lsm_wire.lw_xfersize
 #define lsm_magic        lsm_wire.lw_magic
 #define lsm_stripe_size  lsm_wire.lw_stripe_size
 #define lsm_pattern      lsm_wire.lw_pattern
 #define lsm_stripe_count lsm_wire.lw_stripe_count
 
+struct obd_info;
+
+typedef int (*obd_enqueue_update_f)(struct obd_info *oinfo, int rc);
+
+/* obd_enqueue parameters common for all levels (lov, osc). */
+struct obd_enqueue_info {
+        /* Flags used while lock handling. */
+        int   ei_flags;
+        /* Type of the lock being enqueued. */
+        __u32 ei_type;
+        /* Mode of the lock being enqueued. */
+        __u32 ei_mode;
+        /* Different callbacks for lock handling (blocking, completion,
+           glimpse */
+        void *ei_cb_bl;
+        void *ei_cb_cp;
+        void *ei_cb_gl;
+        /* Data to be passed into callbacks. */
+        void *ei_cbdata;
+        /* Request set for OSC async requests. */
+        struct ptlrpc_request_set *ei_rqset;
+};
+
+/* obd info for a particular level (lov, osc). */
+struct obd_info {
+        /* Lock policy. It keeps an extent which is specific for a particular
+         * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
+         * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
+        ldlm_policy_data_t      oi_policy;
+        /* Lock handle specific for every OSC lock. */
+        struct lustre_handle   *oi_lockh;
+        /* lsm data specific for every OSC. */
+        struct lov_stripe_md   *oi_md;
+        /* obdo data specific for every OSC, if needed at all. */
+        struct obdo            *oi_oa;
+        /* statfs data specific for every OSC, if needed at all. */
+        struct obd_statfs      *oi_osfs;
+        /* An update callback which is called to update some data on upper
+         * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
+         * request in osc level for enqueue requests. It is also possible to
+         * update some caller data from LOV layer if needed. */
+        obd_enqueue_update_f     oi_cb_up;
+};
+
 /* compare all relevant fields. */
 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
                                     struct lov_stripe_md *m2)
@@ -148,6 +193,7 @@ struct obd_type {
         char *typ_name;
         int  typ_refcnt;
         struct lu_device_type *typ_lu;
+        spinlock_t obd_type_lock;
 };
 
 struct brw_page {
@@ -174,7 +220,9 @@ struct obd_async_page_ops {
         int  (*ap_make_ready)(void *data, int cmd);
         int  (*ap_refresh_count)(void *data, int cmd);
         void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
-        void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
+        void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
+                               obd_valid valid);
+        int  (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
 };
 
 /* the `oig' is passed down from a caller of obd rw methods.  the callee
@@ -218,22 +266,66 @@ struct obd_device_target {
         struct lustre_quota_ctxt  obt_qctxt;
 };
 
+/* llog contexts */
+enum llog_ctxt_id {
+        LLOG_CONFIG_ORIG_CTXT  =  0,
+        LLOG_CONFIG_REPL_CTXT  =  1,
+        LLOG_MDS_OST_ORIG_CTXT =  2,
+        LLOG_MDS_OST_REPL_CTXT =  3,
+        LLOG_SIZE_ORIG_CTXT    =  4,
+        LLOG_SIZE_REPL_CTXT    =  5,
+        LLOG_MD_ORIG_CTXT      =  6,
+        LLOG_MD_REPL_CTXT      =  7,
+        LLOG_RD1_ORIG_CTXT     =  8,
+        LLOG_RD1_REPL_CTXT     =  9,
+        LLOG_TEST_ORIG_CTXT    = 10,
+        LLOG_TEST_REPL_CTXT    = 11,
+        LLOG_LOVEA_ORIG_CTXT   = 12,
+        LLOG_LOVEA_REPL_CTXT   = 13,
+        LLOG_MAX_CTXTS
+};
+
+#define FILTER_SUBDIR_COUNT      32            /* set to zero for no subdirs */
+
 #define FILTER_GROUP_LLOG 1
 #define FILTER_GROUP_ECHO 2
+#define FILTER_GROUP_MDS0 3
+
+struct filter_subdirs {
+       cfs_dentry_t *dentry[FILTER_SUBDIR_COUNT];
+};
+
 
 struct filter_ext {
         __u64                fe_start;
         __u64                fe_end;
 };
 
+struct obd_llogs {
+        struct llog_ctxt        *llog_ctxt[LLOG_MAX_CTXTS];
+};
+
+struct filter_group_llog {
+        struct list_head list;
+        int group;
+        struct obd_llogs *llogs;
+        struct obd_export *exp;
+};
+
 struct filter_obd {
         /* NB this field MUST be first */
         struct obd_device_target fo_obt;
         const char          *fo_fstype;
         struct vfsmount     *fo_vfsmnt;
+
+        int                  fo_group_count;
         cfs_dentry_t        *fo_dentry_O;
         cfs_dentry_t       **fo_dentry_O_groups;
-        cfs_dentry_t       **fo_dentry_O_sub;
+        struct filter_subdirs   *fo_dentry_O_sub;
+        struct semaphore     fo_init_lock;      /* group initialization lock */
+        int                  fo_committed_group;
+
+        
         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
         spinlock_t           fo_translock;      /* protect fsd_last_transno */
         struct file         *fo_rcvd_filp;
@@ -263,9 +355,8 @@ struct filter_obd {
 
         struct semaphore     fo_alloc_lock;
 
-        spinlock_t fo_stats_lock;
-        int fo_r_in_flight; /* protected by fo_stats_lock */
-        int fo_w_in_flight; /* protected by fo_stats_lock */
+        atomic_t             fo_r_in_flight;
+        atomic_t             fo_w_in_flight;
 
         /*
          * per-filter pool of kiobuf's allocated by filter_common_setup() and
@@ -294,10 +385,18 @@ struct filter_obd {
         struct obd_histogram     fo_w_discont_blocks;
         struct obd_histogram     fo_r_disk_iosize;
         struct obd_histogram     fo_w_disk_iosize;
+        struct obd_histogram     fo_r_dio_frags;
+        struct obd_histogram     fo_w_dio_frags;
+
+        struct list_head         fo_llog_list;
+        spinlock_t               fo_llog_list_lock;
 
         struct lustre_quota_ctxt fo_quota_ctxt;
         spinlock_t               fo_quotacheck_lock;
         atomic_t                 fo_quotachecking;
+
+        int                      fo_fmd_max_num; /* per exp filter_mod_data */
+        int                      fo_fmd_max_age; /* jiffies to fmd expiry */
 };
 
 #define OSC_MAX_RIF_DEFAULT       8
@@ -305,6 +404,9 @@ struct filter_obd {
 #define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
 #define OSC_MAX_DIRTY_MB_MAX   2048     /* totally arbitrary */
 
+#define MDC_MAX_RIF_DEFAULT       8
+#define MDC_MAX_RIF_MAX         512
+
 struct mdc_rpc_lock;
 struct obd_import;
 struct client_obd {
@@ -317,7 +419,9 @@ struct client_obd {
         int                      cl_default_mds_easize;
         int                      cl_max_mds_easize;
         int                      cl_max_mds_cookiesize;
-        kdev_t                   cl_sandev;
+
+        /* security configuration */
+        struct sec_flavor_config cl_sec_conf;
 
         //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
         void                    *cl_llcd_offset;
@@ -367,6 +471,7 @@ struct client_obd {
 
         struct mdc_rpc_lock     *cl_rpc_lock;
         struct mdc_rpc_lock     *cl_setattr_lock;
+        struct mdc_rpc_lock     *cl_close_lock;
         struct osc_creator       cl_oscc;
 
         /* mgc datastruct */
@@ -402,48 +507,15 @@ struct mgs_obd {
         struct semaphore                 mgs_sem;
 };
 
-struct md_lov_info;
-
-struct md_lov_ops {
-        int (*ml_read_objids)(struct obd_device *obd, struct md_lov_info *mli, 
-                              const void *ctxt);
-        int (*ml_write_objids)(struct obd_device *obd, struct md_lov_info *mli,
-                               const void *ctxt);
-};
-struct md_lov_info {
-        struct obd_device               *md_lov_obd; /* XXX lov_obd */
-        struct obd_uuid                  md_lov_uuid;
-        struct obd_export               *md_lov_exp; /* XXX lov_exp */
-        struct lov_desc                  md_lov_desc;
-        obd_id                          *md_lov_objids;
-        int                              md_lov_objids_size;
-        __u32                            md_lov_objids_in_file;
-        unsigned int                     md_lov_objids_dirty:1;
-        int                              md_lov_nextid_set;
-        void                            *md_lov_objid_obj;
-        struct lu_fid                    md_lov_objid_fid;
-        unsigned long                    md_lov_objids_valid:1;
-        int                              md_lov_max_mdsize;
-        int                              md_lov_max_cookiesize;
-        struct semaphore                 md_lov_orphan_recovery_sem;
-        struct md_lov_ops                *md_lov_ops;
+/* hah, upper limit 64 should be enough */
+#define N_NOSQUASH_NIDS 64
+struct rootsquash_info {
+        uid_t           rsi_uid;
+        gid_t           rsi_gid;
+        int             rsi_n_nosquash_nids;
+        lnet_nid_t      rsi_nosquash_nids[N_NOSQUASH_NIDS];
 };
 
-#define mds_osc_obd             mds_lov_info.md_lov_obd
-#define mds_lov_uuid            mds_lov_info.md_lov_uuid
-#define mds_osc_exp             mds_lov_info.md_lov_exp
-#define mds_lov_desc            mds_lov_info.md_lov_desc
-#define mds_lov_objids          mds_lov_info.md_lov_objids
-#define mds_lov_objids_size     mds_lov_info.md_lov_objids_size
-#define mds_lov_objids_in_file  mds_lov_info.md_lov_objids_in_file
-#define mds_lov_objids_dirty    mds_lov_info.md_lov_objids_dirty
-#define mds_lov_nextid_set      mds_lov_info.md_lov_nextid_set
-#define mds_lov_objid_filp      mds_lov_info.md_lov_objid_obj
-#define mds_lov_objids_valid    mds_lov_info.md_lov_objids_valid
-#define mds_max_mdsize          mds_lov_info.md_lov_max_mdsize
-#define mds_max_cookiesize      mds_lov_info.md_lov_max_cookiesize
-#define mds_orphan_recovery_sem mds_lov_info.md_lov_orphan_recovery_sem
-
 struct mds_obd {
         /* NB this field MUST be first */
         struct obd_device_target         mds_obt;
@@ -452,6 +524,8 @@ struct mds_obd {
         struct ptlrpc_service           *mds_readpage_service;
         struct vfsmount                 *mds_vfsmnt;
         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;
@@ -466,17 +540,37 @@ struct mds_obd {
         cfs_dentry_t                    *mds_objects_dir;
         struct llog_handle              *mds_cfg_llh;
 //        struct llog_handle              *mds_catalog;
-        struct md_lov_info              mds_lov_info;
+        struct obd_device               *mds_osc_obd; /* XXX lov_obd */
+        struct obd_uuid                  mds_lov_uuid;
         char                            *mds_profile;
+        struct obd_export               *mds_osc_exp; /* XXX lov_exp */
+        struct lov_desc                  mds_lov_desc;
+        __u32                            mds_id;
+        obd_id                          *mds_lov_objids;
+        int                              mds_lov_objids_size;
+        __u32                            mds_lov_objids_in_file;
+        unsigned int                     mds_lov_objids_dirty:1;
+        int                              mds_lov_nextid_set;
+        struct file                     *mds_lov_objid_filp;
         struct file                     *mds_health_check_filp;
         unsigned long                   *mds_client_bitmap;
-        struct upcall_cache             *mds_group_hash;
+//        struct upcall_cache             *mds_group_hash;
 
         struct lustre_quota_info         mds_quota_info;
         struct semaphore                 mds_qonoff_sem;
         struct semaphore                 mds_health_sem;
-        unsigned long                    mds_fl_user_xattr:1,
+        unsigned long                    mds_lov_objids_valid:1,
+                                         mds_fl_user_xattr:1,
                                          mds_fl_acl:1;
+
+        /* For CMD add mds_num */
+        int                              mds_num;
+
+        struct upcall_cache             *mds_identity_cache;
+        struct upcall_cache             *mds_rmtacl_cache;
+
+        /* root squash */
+        struct rootsquash_info          *mds_rootsquash_info;
 };
 
 struct echo_obd {
@@ -502,28 +596,63 @@ struct echo_client_obd {
         __u64                ec_unique;
 };
 
+struct lov_qos_oss {
+        struct obd_uuid     lqo_uuid;       /* ptlrpc's c_remote_uuid */
+        struct list_head    lqo_oss_list;   /* link to lov_qos */
+        __u32               lqo_ost_count;  /* number of osts on this oss */
+        __u64               lqo_bavail;     /* total bytes avail on OSS */
+        __u64               lqo_penalty;    /* current penalty */
+        __u64               lqo_penalty_per_obj; /* penalty decrease every obj*/
+};
+
+struct ltd_qos {
+        struct lov_qos_oss *ltq_oss;         /* oss info */
+        __u64               ltq_penalty;     /* current penalty */
+        __u64               ltq_penalty_per_obj; /* penalty decrease every obj*/
+        __u64               ltq_weight;      /* net weighting */
+        unsigned int        ltq_usable:1;    /* usable for striping */
+};
+
+struct lov_qos {
+        struct list_head    lq_oss_list;    /* list of OSSs that targets use */
+        struct rw_semaphore lq_rw_sem;
+        __u32               lq_active_oss_count;
+        __u32              *lq_rr_array;    /* round-robin optimized list */
+        unsigned int        lq_rr_size;     /* rr array size */
+        unsigned int        lq_prio_free;   /* priority for free space */
+        unsigned int        lq_dirty:1,     /* recalc qos data */
+                            lq_dirty_rr:1,  /* recalc round-robin list */
+                            lq_same_space:1,/* the ost's all have approx.
+                                               the same space avail */
+                            lq_reset:1;     /* zero current penalties */
+};
+
 struct lov_tgt_desc {
-        struct obd_uuid          uuid;
-        __u32                    ltd_gen;
-        struct obd_export       *ltd_exp;
-        unsigned int             active:1, /* is this target up for requests */
-                                 reap:1;   /* should this target be deleted */
-        int                      index;  /* index of target array in lov_obd */
-        struct list_head         qos_bavail_list; /* link entry to lov_obd */
+        struct obd_uuid     ltd_uuid;
+        struct obd_export  *ltd_exp;
+        struct ltd_qos      ltd_qos;     /* qos info per target */
+        __u32               ltd_gen;
+        __u32               ltd_index;   /* index in lov_obd->tgts */
+        unsigned int        ltd_active:1,/* is this target up for requests */
+                            ltd_activate:1,/* should this target be activated */
+                            ltd_reap:1;  /* should this target be deleted */
 };
 
 struct lov_obd {
-        struct semaphore lov_lock;
-        atomic_t refcount;
-        struct lov_desc desc;
-        struct obd_connect_data ocd;
-        int bufsize;
-        int connects;
-        int death_row;      /* Do we have tgts scheduled to be deleted?
-                               (Make this a linked list?) */
-        struct list_head qos_bavail_list; /* tgts list, sorted by available
-                                             space, protected by lov_lock */
-        struct lov_tgt_desc *tgts;
+        struct lov_desc         desc;
+        struct lov_tgt_desc   **lov_tgts;
+        struct semaphore        lov_lock;
+        struct obd_connect_data lov_ocd;
+        struct lov_qos          lov_qos;               /* qos info per lov */
+        atomic_t                lov_refcount;
+        __u32                   lov_tgt_count;         /* how many OBD's */
+        __u32                   lov_active_tgt_count;  /* how many active */
+        __u32                   lov_death_row;/* tgts scheduled to be deleted */
+        __u32                   lov_tgt_size;   /* size of tgts array */
+        __u32                   lov_start_idx;  /* start index of new inode */
+        __u32                   lov_offset_idx; /* aliasing for start_idx  */
+        int                     lov_start_count;/* reseed counter */
+        int                     lov_connects;
 };
 
 struct lmv_tgt_desc {
@@ -547,7 +676,7 @@ struct lmv_obd {
         int                     max_cookiesize;
         int                     server_timeout;
         struct semaphore        init_sem;
-        
+
         struct lmv_tgt_desc     *tgts;
         int                     tgts_size;
 
@@ -571,47 +700,42 @@ struct niobuf_local {
 #define LUSTRE_OPC_SYMLINK   (1 << 1)
 #define LUSTRE_OPC_MKNOD     (1 << 2)
 #define LUSTRE_OPC_CREATE    (1 << 3)
-        
+
 struct lu_placement_hint {
-        struct qstr *ph_pname;
-        struct qstr *ph_cname;
-        int          ph_opc;
+        struct qstr   *ph_pname;
+        struct lu_fid *ph_pfid;
+        struct qstr   *ph_cname;
+        int           ph_opc;
 };
 
-#define LUSTRE_FLD_NAME  "fld"
-#define LUSTRE_SEQ_NAME  "seq"
-
-/* device types (not names--FIXME) */
-/* FIXME all the references to these defines need to be updated */
-#define LUSTRE_MDS_NAME  "mds"
-#define LUSTRE_MDT_NAME  "mdt"
-
-/* new MDS layers. Prototype */
-#define LUSTRE_MDT0_NAME "mdt0"
-#define LUSTRE_CMM0_NAME "cmm0"
-#define LUSTRE_MDD0_NAME "mdd0"
-#define LUSTRE_OSD0_NAME "osd0"
-#define LUSTRE_MDC0_NAME "mdc0"
-
-#define LUSTRE_MDC_NAME  "mdc"
-#define LUSTRE_LOV_NAME  "lov"
-#define LUSTRE_LMV_NAME  "lmv"
-
-/* FIXME just the names need to be changed */
-#define LUSTRE_OSS_NAME "ost"       /* FIXME oss */
-#define LUSTRE_OST_NAME "obdfilter" /* FIXME ost */
-#define LUSTRE_OSTSAN_NAME "sanobdfilter"
-
-#define LUSTRE_OSC_NAME "osc"
-#define LUSTRE_FILTER_NAME "filter"
-#define LUSTRE_SANOSC_NAME "sanosc"
-#define LUSTRE_SANOST_NAME "sanost"
-#define LUSTRE_MGS_NAME "mgs"
-#define LUSTRE_MGC_NAME "mgc"
-
+#define LUSTRE_FLD_NAME         "fld"
+#define LUSTRE_SEQ_NAME         "seq"
+
+#define LUSTRE_CMM_NAME         "cmm"
+#define LUSTRE_MDD_NAME         "mdd"
+#define LUSTRE_OSD_NAME         "osd"
+#define LUSTRE_LMV_NAME         "lmv"
+#define LUSTRE_CMM_MDC_NAME     "cmm-mdc"
+
+/* obd device type names */
+ /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
+#define LUSTRE_MDS_NAME         "mds"
+#define LUSTRE_MDT_NAME         "mdt"
+#define LUSTRE_MDC_NAME         "mdc"
+#define LUSTRE_OSS_NAME         "ost"       /* FIXME change name to oss */
+#define LUSTRE_OST_NAME         "obdfilter" /* FIXME change name to ost */
+#define LUSTRE_OSC_NAME         "osc"
+#define LUSTRE_LOV_NAME         "lov"
+#define LUSTRE_MGS_NAME         "mgs"
+#define LUSTRE_MGC_NAME         "mgc"
+
+#define LUSTRE_CACHEOBD_NAME    "cobd"
 #define LUSTRE_ECHO_NAME        "obdecho"
 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
 
+/* Constant obd names (post-rename) */
+#define LUSTRE_MDS_OBDNAME "MDS"
+#define LUSTRE_OSS_OBDNAME "OSS"
 #define LUSTRE_MGS_OBDNAME "MGS"
 #define LUSTRE_MGC_OBDNAME "MGC"
 
@@ -620,6 +744,7 @@ struct lu_placement_hint {
 
 struct obd_trans_info {
         __u64                    oti_transno;
+        __u64                    oti_xid;
         __u64                   *oti_objid;
         /* Only used on the server side for tracking acks. */
         struct oti_req_ack_lock {
@@ -633,6 +758,7 @@ struct obd_trans_info {
 
         /* initial thread handling transaction */
         int                      oti_thread_id;
+        __u32                    oti_conn_cnt;
 };
 
 static inline void oti_init(struct obd_trans_info *oti,
@@ -645,9 +771,12 @@ static inline void oti_init(struct obd_trans_info *oti,
         if (req == NULL)
                 return;
 
+        oti->oti_xid = req->rq_xid;
+
         if (req->rq_repmsg && req->rq_reqmsg != 0)
-                oti->oti_transno = req->rq_repmsg->transno;
+                oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
         oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
+        oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
 }
 
 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
@@ -678,25 +807,6 @@ static inline void oti_free_cookies(struct obd_trans_info *oti)
         oti->oti_numcookies = 0;
 }
 
-/* llog contexts */
-enum llog_ctxt_id {
-        LLOG_CONFIG_ORIG_CTXT  =  0,
-        LLOG_CONFIG_REPL_CTXT  =  1,
-        LLOG_MDS_OST_ORIG_CTXT =  2,
-        LLOG_MDS_OST_REPL_CTXT =  3,
-        LLOG_SIZE_ORIG_CTXT    =  4,
-        LLOG_SIZE_REPL_CTXT    =  5,
-        LLOG_MD_ORIG_CTXT      =  6,
-        LLOG_MD_REPL_CTXT      =  7,
-        LLOG_RD1_ORIG_CTXT     =  8,
-        LLOG_RD1_REPL_CTXT     =  9,
-        LLOG_TEST_ORIG_CTXT    = 10,
-        LLOG_TEST_REPL_CTXT    = 11,
-        LLOG_LOVEA_ORIG_CTXT   = 12,
-        LLOG_LOVEA_REPL_CTXT   = 13,
-        LLOG_MAX_CTXTS
-};
-
 /*
  * Events signalled through obd_notify() upcall-chain.
  */
@@ -713,6 +823,7 @@ enum obd_notify_event {
 };
 
 #include <lu_object.h>
+
 /*
  * Data structure used to pass obd_notify()-event to non-obd listeners (llite
  * and liblustre being main examples).
@@ -725,33 +836,46 @@ struct obd_notify_upcall {
 };
 
 /* corresponds to one of the obd's */
+#define MAX_OBD_NAME 128
+#define OBD_DEVICE_MAGIC        0XAB5CD6EF
 struct obd_device {
         struct obd_type        *obd_type;
+        __u32                   obd_magic;
+
         /* common and UUID name of this device */
-        char                   *obd_name;
+        char                    obd_name[MAX_OBD_NAME];
         struct obd_uuid         obd_uuid;
 
         struct lu_device       *obd_lu_dev;
 
         int                     obd_minor;
-        unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
-                obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
-                obd_no_recov:1, obd_stopping:1, obd_starting:1,
-                obd_force:1, obd_fail:1, obd_async_recov:1;
+        unsigned int 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_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 asyncronous orphan cleanup */
         atomic_t obd_refcount;
         cfs_waitq_t             obd_refcount_waitq;
-        cfs_proc_dir_entry_t  *obd_proc_entry;
+        cfs_proc_dir_entry_t   *obd_proc_entry;
         struct list_head        obd_exports;
         int                     obd_num_exports;
         struct ldlm_namespace  *obd_namespace;
         struct ptlrpc_client    obd_ldlm_client; /* XXX OST/MDS only */
         /* a spinlock is OK for what we do now, may need a semaphore later */
         spinlock_t              obd_dev_lock;
+        struct semaphore        obd_dev_sem;
         __u64                   obd_last_committed;
         struct fsfilt_operations *obd_fsops;
         spinlock_t              obd_osfs_lock;
         struct obd_statfs       obd_osfs;       /* locked by obd_osfs_lock */
-        cfs_time_t              obd_osfs_age;   
+        __u64                   obd_osfs_age;
         struct lvfs_run_ctxt    obd_lvfs_ctxt;
         struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
         struct obd_device       *obd_observer;
@@ -766,7 +890,7 @@ struct obd_device {
         int                              obd_max_recoverable_clients;
         int                              obd_connected_clients;
         int                              obd_recoverable_clients;
-        spinlock_t                       obd_processing_task_lock;
+        spinlock_t                       obd_processing_task_lock; /* BH lock (timer) */
         pid_t                            obd_processing_task;
         __u64                            obd_next_recovery_transno;
         int                              obd_replayed_requests;
@@ -798,7 +922,7 @@ struct obd_device {
 
         unsigned int           md_cntr_base;
         struct lprocfs_stats  *md_stats;
-    
+
         cfs_proc_dir_entry_t  *obd_svc_procroot;
         struct lprocfs_stats  *obd_svc_stats;
 };
@@ -823,11 +947,14 @@ enum obd_cleanup_stage {
 };
 
 /* get/set_info keys */
-#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_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"
+
+struct lu_context;
 
 struct obd_ops {
         struct module *o_owner;
@@ -854,7 +981,8 @@ struct obd_ops {
          * data. @ocd->ocd_connect_flags is modified to reflect flags actually
          * granted by the target, which are guaranteed to be a subset of flags
          * asked for. If @ocd == NULL, use default parameters. */
-        int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
+        int (*o_connect)(const struct lu_context *ctx,
+                         struct lustre_handle *conn, struct obd_device *src,
                          struct obd_uuid *cluuid, struct obd_connect_data *ocd);
         int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
                            struct obd_uuid *cluuid,
@@ -867,11 +995,13 @@ struct obd_ops {
 
         int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
                            struct lu_placement_hint *hint);
-        
-        int (*o_fid_delete)(struct obd_export *exp, struct lu_fid *fid);
-        
+
+        int (*o_fid_delete)(struct obd_export *exp, const struct lu_fid *fid);
+
         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
-                        unsigned long max_age);
+                        __u64 max_age);
+        int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
+                              __u64 max_age, struct ptlrpc_request_set *set);
         int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
                         struct lov_stripe_md *mem_src);
         int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
@@ -885,22 +1015,21 @@ struct obd_ops {
         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);
-        int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
-                         struct lov_stripe_md *ea, struct obd_trans_info *oti);
-        int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
-                         struct lov_stripe_md *ea, struct obd_trans_info *oti);
-        int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
-                         struct lov_stripe_md *ea);
-        int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
-                               struct lov_stripe_md *ea,
+        int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
+                         struct obd_trans_info *oti);
+        int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
+                               struct obd_trans_info *oti,
+                               struct ptlrpc_request_set *rqset);
+        int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
+        int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
                                struct ptlrpc_request_set *set);
-        int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
-                     struct lov_stripe_md *ea, obd_count oa_bufs,
-                     struct brw_page *pgarr, struct obd_trans_info *oti);
-        int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
-                           struct lov_stripe_md *ea, obd_count oa_bufs,
-                           struct brw_page *pgarr, struct ptlrpc_request_set *,
-                           struct obd_trans_info *oti);
+        int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
+                     obd_count oa_bufs, struct brw_page *pgarr,
+                     struct obd_trans_info *oti);
+        int (*o_brw_async)(int rw, struct obd_export *exp,
+                           struct obd_info *oinfo, obd_count oa_bufs,
+                           struct brw_page *pgarr, struct obd_trans_info *oti,
+                           struct ptlrpc_request_set *);
         int (*o_prep_async_page)(struct obd_export *exp,
                                  struct lov_stripe_md *lsm,
                                  struct lov_oinfo *loi,
@@ -933,9 +1062,9 @@ struct obd_ops {
                            struct ost_lvb *lvb, int kms_only);
         int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
                             obd_off size, int shrink);
-        int (*o_punch)(struct obd_export *exp, struct obdo *oa,
-                       struct lov_stripe_md *ea, obd_size start,
-                       obd_size end, struct obd_trans_info *oti);
+        int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
+                       struct obd_trans_info *oti,
+                       struct ptlrpc_request_set *rqset);
         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
                       struct lov_stripe_md *ea, obd_size start, obd_size end);
         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
@@ -955,11 +1084,8 @@ struct obd_ops {
                           int objcount, struct obd_ioobj *obj,
                           int niocount, struct niobuf_local *local,
                           struct obd_trans_info *oti, int rc);
-        int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
-                         __u32 type, ldlm_policy_data_t *, __u32 mode,
-                         int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
-                         void *data, __u32 lvb_len, void *lvb_swabber,
-                         struct lustre_handle *lockh);
+        int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
+                         struct obd_enqueue_info *einfo);
         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
                        struct lustre_handle *lockh);
@@ -971,20 +1097,20 @@ struct obd_ops {
                                int flags, void *opaque);
         int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
                          int join);
-        int (*o_san_preprw)(int cmd, struct obd_export *exp,
-                            struct obdo *oa, int objcount,
-                            struct obd_ioobj *obj, int niocount,
-                            struct niobuf_remote *remote);
         int (*o_init_export)(struct obd_export *exp);
         int (*o_destroy_export)(struct obd_export *exp);
+        int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
+                             int cmd, obd_off *);
 
         /* llog related obd_methods */
-        int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
-                           int count, struct llog_catid *logid);
+        int (*o_llog_init)(struct obd_device *obd, struct obd_llogs *llog, 
+                           struct obd_device *disk_obd, int count, 
+                           struct llog_catid *logid, struct obd_uuid *uuid);
         int (*o_llog_finish)(struct obd_device *obd, int count);
-
+        int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *);
+        
         /* metadata-only methods */
-        int (*o_pin)(struct obd_export *, struct lu_fid *fid,
+        int (*o_pin)(struct obd_export *, const struct lu_fid *fid,
                      struct obd_client_handle *, int flag);
         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
 
@@ -1000,34 +1126,31 @@ struct obd_ops {
         int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
         int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
 
+        int (*o_ping)(struct obd_export *exp);
         /*
          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
-         * Also, add a wrapper function in include/linux/obd_class.h.
-         *
-         * Also note that if you add it to the END, you also have to change
-         * the num_stats calculation.
-         *
-         */
+         * Also, add a wrapper function in include/linux/obd_class.h. */
 };
 
 struct md_ops {
         int (*m_getstatus)(struct obd_export *, struct lu_fid *);
-        int (*m_change_cbdata)(struct obd_export *, struct lu_fid *,
+        int (*m_change_cbdata)(struct obd_export *, const struct lu_fid *,
                                ldlm_iterator_t, void *);
         int (*m_close)(struct obd_export *, struct md_op_data *,
                        struct obd_client_handle *, struct ptlrpc_request **);
         int (*m_create)(struct obd_export *, struct md_op_data *,
                         const void *, int, int, __u32, __u32, __u32,
                         __u64, struct ptlrpc_request **);
-        int (*m_done_writing)(struct obd_export *, struct md_op_data *);
+        int (*m_done_writing)(struct obd_export *, struct md_op_data  *,
+                              struct obd_client_handle *);
         int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *,
                          int, struct md_op_data *, struct lustre_handle *,
                          void *, int, ldlm_completion_callback,
                          ldlm_blocking_callback, void *, int);
-        int (*m_getattr)(struct obd_export *, struct lu_fid *,
+        int (*m_getattr)(struct obd_export *, const struct lu_fid *,
                          obd_valid, int, struct ptlrpc_request **);
-        int (*m_getattr_name)(struct obd_export *, struct lu_fid *,
+        int (*m_getattr_name)(struct obd_export *, const struct lu_fid *,
                               const char *, int, obd_valid,
                               int, struct ptlrpc_request **);
         int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
@@ -1039,45 +1162,51 @@ struct md_ops {
         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 *,
-                         struct iattr *, void *, int , void *, int,
-                         struct ptlrpc_request **);
-        int (*m_sync)(struct obd_export *, struct lu_fid *,
+        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 **);
+        int (*m_sync)(struct obd_export *, const struct lu_fid *,
                       struct ptlrpc_request **);
-        int (*m_readpage)(struct obd_export *, struct lu_fid *,
+        int (*m_readpage)(struct obd_export *, const struct lu_fid *,
                           __u64, struct page *, struct ptlrpc_request **);
+
         int (*m_unlink)(struct obd_export *, struct md_op_data *,
                         struct ptlrpc_request **);
 
-        int (*m_setxattr)(struct obd_export *, struct lu_fid *,
+        int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
                           obd_valid, const char *, const char *,
                           int, int, int, struct ptlrpc_request **);
 
-        int (*m_getxattr)(struct obd_export *, struct lu_fid *,
+        int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
                           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 *,
-                               int, struct obd_export *, struct lustre_md *);
-        
+                               int, 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 *);
-        
-        int (*m_lock_match)(struct obd_export *, int, struct lu_fid *,
+
+        int (*m_lock_match)(struct obd_export *, int, const struct lu_fid *,
                             ldlm_type_t, ldlm_policy_data_t *, ldlm_mode_t,
                             struct lustre_handle *);
-                
-        int (*m_cancel_unused)(struct obd_export *, struct lu_fid *,
+
+        int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
                                int flags, void *opaque);
 
+        int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
+                                 struct ptlrpc_request **);
+
         /*
          * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
          * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
@@ -1094,6 +1223,7 @@ struct lsm_operations {
         void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
                                      unsigned long *);
         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);
         int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
         int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
@@ -1112,13 +1242,17 @@ static inline struct lsm_operations *lsm_op_find(int magic)
         case LOV_MAGIC_JOIN:
                return &lsm_join_ops;
         default:
-               CERROR("Cannot recognize lsm_magic %d", magic);
+               CERROR("Cannot recognize lsm_magic %d\n", magic);
                return NULL;
         }
 }
 
 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
 
+/* Requests for obd_extent_calc() */
+#define OBD_CALC_STRIPE_START   1
+#define OBD_CALC_STRIPE_END     2
+
 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
                                          int error)
 {