Whamcloud - gitweb
- zero out used locks in MDT before finishing req handling;
[fs/lustre-release.git] / lustre / include / obd.h
index 65cd41a..b3f01af 100644 (file)
@@ -33,6 +33,7 @@
 #include <lustre_export.h>
 #include <lustre_quota.h>
 #include <lustre_fld.h>
+#include <lustre_capa.h>
 
 #define MAX_OBD_DEVICES 8192
 
@@ -168,7 +169,10 @@ struct obd_info {
          * 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;
+        obd_enqueue_update_f    oi_cb_up;
+        /* oss capability, its type is obd_capa in client to avoid copy.
+         * in contrary its type is lustre_capa in OSS. */
+        void                   *oi_capa;
 };
 
 /* compare all relevant fields. */
@@ -223,6 +227,7 @@ struct obd_async_page_ops {
         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);
+        struct obd_capa *(*ap_lookup_capa)(void *data, int cmd);
 };
 
 /* the `oig' is passed down from a caller of obd rw methods.  the callee
@@ -325,7 +330,7 @@ struct filter_obd {
         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;
@@ -397,6 +402,10 @@ struct filter_obd {
 
         int                      fo_fmd_max_num; /* per exp filter_mod_data */
         int                      fo_fmd_max_age; /* jiffies to fmd expiry */
+
+        /* capability related */
+        unsigned int             fo_fl_oss_capa;
+        struct list_head         fo_capa_keys;
 };
 
 #define OSC_MAX_RIF_DEFAULT       8
@@ -563,14 +572,15 @@ struct mds_obd {
                                          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;
+
+        /* for capability keys update */
+        struct lustre_capa_key          *mds_capa_keys;
 };
 
 struct echo_obd {
@@ -835,6 +845,13 @@ struct obd_notify_upcall {
         void *onu_owner;
 };
 
+struct target_recovery_data {
+        svc_handler_t     trd_recovery_handler;
+        pid_t             trd_processing_task;
+        struct completion trd_starting;
+        struct completion trd_finishing;
+};
+
 /* corresponds to one of the obd's */
 #define MAX_OBD_NAME 128
 #define OBD_DEVICE_MAGIC        0XAB5CD6EF
@@ -852,15 +869,17 @@ struct obd_device {
         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_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_req_replaying:1, /* replaying requests */
                      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 */
+                     obd_async_recov:1,   /* allow asyncronous orphan cleanup */
+                     obd_configured:1;    /* llog configuration finished successfully */
         atomic_t obd_refcount;
         cfs_waitq_t             obd_refcount_waitq;
         cfs_proc_dir_entry_t   *obd_proc_entry;
@@ -887,11 +906,13 @@ struct obd_device {
 
         /* XXX encapsulate all this recovery data into one struct */
         svc_handler_t                    obd_recovery_handler;
+        pid_t                            obd_processing_task;
+        
+        /* common recovery fields for b1_x and CMD2 */
         int                              obd_max_recoverable_clients;
         int                              obd_connected_clients;
         int                              obd_recoverable_clients;
         spinlock_t                       obd_processing_task_lock; /* BH lock (timer) */
-        pid_t                            obd_processing_task;
         __u64                            obd_next_recovery_transno;
         int                              obd_replayed_requests;
         int                              obd_requests_queued_for_recovery;
@@ -899,10 +920,18 @@ struct obd_device {
         struct list_head                 obd_uncommitted_replies;
         spinlock_t                       obd_uncommitted_replies_lock;
         cfs_timer_t                      obd_recovery_timer;
-        struct list_head                 obd_recovery_queue;
-        struct list_head                 obd_delayed_reply_queue;
         time_t                           obd_recovery_start;
         time_t                           obd_recovery_end;
+        
+        /* new recovery stuff from CMD2 */
+        struct target_recovery_data      obd_recovery_data;
+        int                              obd_replayed_locks;
+        atomic_t                         obd_req_replay_clients;
+        atomic_t                         obd_lock_replay_clients;
+        struct list_head                 obd_req_replay_queue;
+        struct list_head                 obd_lock_replay_queue;
+        struct list_head                 obd_final_req_queue;
+        int                              obd_recovery_stage;
 
         union {
                 struct obd_device_target obt;
@@ -953,6 +982,9 @@ enum obd_cleanup_stage {
 #define KEY_INIT_RECOV          "initial_recov"
 #define KEY_INIT_RECOV_BACKUP   "init_recov_bk"
 #define KEY_FLUSH_CTX           "flush_ctx"
+#define KEY_CAPA_KEY            "capa_key"
+#define KEY_CONN_DATA           "conn_data"
+#define KEY_MAX_EASIZE          "max_easize"
 
 struct lu_context;
 
@@ -981,7 +1013,7 @@ 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)(const struct lu_context *ctx,
+        int (*o_connect)(const struct lu_env *env,
                          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,
@@ -1010,6 +1042,7 @@ struct obd_ops {
                          struct lov_stripe_md *mem_tgt);
         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
                              obd_id *ids);
+        /* FIXME: add fid capability support for create & destroy! */
         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
@@ -1066,7 +1099,8 @@ struct obd_ops {
                        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);
+                      struct lov_stripe_md *ea, obd_size start, obd_size end,
+                      void *capa);
         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
                          struct lov_stripe_md *src, obd_size start,
                          obd_size end, struct obd_trans_info *oti);
@@ -1079,7 +1113,8 @@ struct obd_ops {
         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
                         int objcount, struct obd_ioobj *obj,
                         int niocount, struct niobuf_remote *remote,
-                        struct niobuf_local *local, struct obd_trans_info *oti);
+                        struct niobuf_local *local, struct obd_trans_info *oti,
+                        struct lustre_capa *capa);
         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
                           int objcount, struct obd_ioobj *obj,
                           int niocount, struct niobuf_local *local,
@@ -1103,15 +1138,15 @@ struct obd_ops {
                              int cmd, obd_off *);
 
         /* llog related obd_methods */
-        int (*o_llog_init)(struct obd_device *obd, struct obd_llogs *llog, 
-                           struct obd_device *disk_obd, int count, 
+        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 *, const struct lu_fid *fid,
-                     struct obd_client_handle *, int flag);
+                     struct obd_capa *, struct obd_client_handle *, int flag);
         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
 
         int (*o_import_event)(struct obd_device *, struct obd_import *,
@@ -1134,7 +1169,8 @@ struct obd_ops {
 };
 
 struct md_ops {
-        int (*m_getstatus)(struct obd_export *, struct lu_fid *);
+        int (*m_getstatus)(struct obd_export *, struct lu_fid *,
+                           struct obd_capa **);
         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 *,
@@ -1149,9 +1185,10 @@ struct md_ops {
                          void *, int, ldlm_completion_callback,
                          ldlm_blocking_callback, void *, int);
         int (*m_getattr)(struct obd_export *, const struct lu_fid *,
-                         obd_valid, int, struct ptlrpc_request **);
+                         struct obd_capa *, obd_valid, int,
+                         struct ptlrpc_request **);
         int (*m_getattr_name)(struct obd_export *, const struct lu_fid *,
-                              const char *, int, obd_valid,
+                              struct obd_capa *, const char *, int, obd_valid,
                               int, struct ptlrpc_request **);
         int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
                              void *, int, struct lookup_intent *, int,
@@ -1163,29 +1200,34 @@ struct md_ops {
                         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 **);
+                           const struct lu_fid *,
+                           struct obd_capa *, struct obd_capa *,
+                           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 **);
+                      struct obd_capa *, struct ptlrpc_request **);
         int (*m_readpage)(struct obd_export *, const struct lu_fid *,
-                          __u64, struct page *, struct ptlrpc_request **);
+                          struct obd_capa *, __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 *, const struct lu_fid *,
-                          obd_valid, const char *, const char *,
-                          int, int, int, struct ptlrpc_request **);
+                          struct obd_capa *, obd_valid, const char *,
+                          const char *, int, int, int,
+                          struct ptlrpc_request **);
 
         int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
-                          obd_valid, const char *, const char *,
-                          int, int, int, struct ptlrpc_request **);
+                          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 *,
-                               int, struct obd_export *, struct obd_export *, 
+                               int, struct obd_export *, struct obd_export *,
                                struct lustre_md *);
 
         int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
@@ -1203,9 +1245,11 @@ struct md_ops {
 
         int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
                                int flags, void *opaque);
+        int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
+                            renew_capa_cb_t cb);
 
         int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
-                                 struct ptlrpc_request **);
+                                 struct obd_capa *, struct ptlrpc_request **);
 
         /*
          * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
@@ -1280,4 +1324,14 @@ static inline void init_obd_quota_ops(quota_interface_t *interface,
         obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
 }
 
+static inline __u64 oinfo_mdsno(struct obd_info *oinfo)
+{
+        return oinfo->oi_oa->o_gr - FILTER_GROUP_MDS0;
+}
+
+static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo)
+{
+        return oinfo->oi_capa;
+}
+
 #endif /* __OBD_H */