Whamcloud - gitweb
Land b_smallfix onto b1_2 (20040225_1544) (4pre1.2)
authoradilger <adilger>
Wed, 25 Feb 2004 23:04:56 +0000 (23:04 +0000)
committeradilger <adilger>
Wed, 25 Feb 2004 23:04:56 +0000 (23:04 +0000)
60 files changed:
lnet/include/linux/kp30.h
lnet/utils/debug.c
lustre/ChangeLog
lustre/include/linux/lustre_cfg.h
lustre/include/linux/lustre_export.h
lustre/include/linux/lustre_ha.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_import.h
lustre/include/linux/lustre_lib.h
lustre/include/linux/lustre_log.h
lustre/include/linux/lustre_net.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/lov/lov_internal.h
lustre/lov/lov_log.c
lustre/lvfs/lvfs_common.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_internal.h
lustre/mds/mds_log.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/llog_cat.c
lustre/obdclass/llog_internal.h
lustre/obdclass/llog_ioctl.c
lustre/obdclass/llog_lvfs.c
lustre/obdclass/llog_obd.c
lustre/obdclass/llog_test.c
lustre/obdclass/lprocfs_status.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_io.c
lustre/osc/lproc_osc.c
lustre/osc/osc_create.c
lustre/osc/osc_internal.h
lustre/osc/osc_request.c
lustre/portals/include/linux/kp30.h
lustre/portals/utils/debug.c
lustre/ptlrpc/client.c
lustre/ptlrpc/import.c
lustre/ptlrpc/llog_server.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpc_internal.h
lustre/ptlrpc/ptlrpc_module.c
lustre/ptlrpc/recover.c
lustre/scripts/land1.sh
lustre/scripts/lustre.spec.in
lustre/tests/conf-sanity.sh
lustre/tests/recovery-small.sh
lustre/tests/sanity.sh
lustre/tests/sanityN.sh
lustre/utils/llmount.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 75e83b4..3e5983c 100644 (file)
@@ -234,6 +234,12 @@ extern void kportal_assertion_failed(char *expr, char *file, const char *func,
 #define LASSERTF(cond, fmt...) do { } while (0)
 #endif
 
+#ifdef CONFIG_SMP
+#define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock))
+#else
+#define LASSERT_SPIN_LOCKED(lock) do {} while(0)
+#endif
+
 #ifdef __arch_um__
 #define LBUG_WITH_LOC(file, func, line)                                 \
 do {                                                                    \
index 2ca4dc3..01e690f 100644 (file)
@@ -66,7 +66,8 @@ static int debug_mask = ~0;
 static const char *portal_debug_subsystems[] =
         {"undefined", "mdc", "mds", "osc", "ost", "class", "log", "llite",
          "rpc", "mgmt", "portals", "socknal", "qswnal", "pinger", "filter",
-         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", NULL};
+         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", "ibnal",
+         NULL};
 static const char *portal_debug_masks[] =
         {"trace", "inode", "super", "ext2", "malloc", "cache", "info", "ioctl",
          "blocks", "net", "warning", "buffs", "other", "dentry", "portals",
index 0a5e0de..ddc110e 100644 (file)
@@ -37,6 +37,9 @@ tbd         Cluster File Systems, Inc. <info@clusterfs.com>
        - don't delete objects on OST if given a bogus objid from MDS (2751)
        - handle large client PAGE_SIZE readdir on small PAGE_SIZE MDS (2777)
        - if rq_no_resend, then timeout request after recovery (2432)
+       - fix MDS llog_logid record size, 64-bit array alignment (2733)
+       - don't call usermode_helper from ptlrpcd, DEFAULT upcall (2773)
+       - put magic in mount.lustre data, check for bad/NULL mount data (2529)
        * miscellania
        - return LL_SUPER_MAGIC from statfs for the filesystem type (1972)
 
index a9a278f..d8c84be 100644 (file)
@@ -248,6 +248,7 @@ static inline void lustre_cfg_freedata(char *buf, int len)
 
 /* Passed by mount */
 struct lustre_mount_data {
+        uint32_t lmd_magic;
         uint32_t lmd_version;
         uint64_t lmd_local_nid;
         uint64_t lmd_server_nid;
index 218807c..9be781f 100644 (file)
@@ -26,7 +26,7 @@ struct mds_export_data {
 struct osc_creator {
         spinlock_t              oscc_lock;
         struct list_head        oscc_list;
-        struct obd_export      *oscc_exp;
+        struct obd_device       *oscc_obd;
         obd_id                  oscc_last_id;//last available pre-created object
         obd_id                  oscc_next_id;// what object id to give out next
         int                     oscc_initial_create_count;
@@ -38,10 +38,6 @@ struct osc_creator {
         wait_queue_head_t       oscc_waitq; /* creating procs wait on this */
 };
 
-struct osc_export_data {
-        struct osc_creator      oed_oscc;
-};
-
 struct ldlm_export_data {
         struct list_head       led_held_locks; /* protected by namespace lock */
 };
@@ -83,14 +79,12 @@ struct obd_export {
                 struct mds_export_data    eu_mds_data;
                 struct filter_export_data eu_filter_data;
                 struct ec_export_data     eu_ec_data;
-                struct osc_export_data    eu_osc_data;
         } u;
 };
 
 #define exp_mds_data    u.eu_mds_data
 #define exp_lov_data    u.eu_lov_data
 #define exp_filter_data u.eu_filter_data
-#define exp_osc_data    u.eu_osc_data
 #define exp_ec_data     u.eu_ec_data
 
 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
index 4dfc81d..808ff44 100644 (file)
@@ -19,6 +19,7 @@ void ptlrpc_free_committed(struct obd_import *imp);
 void ptlrpc_wake_delayed(struct obd_import *imp);
 int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid);
 int ptlrpc_set_import_active(struct obd_import *imp, int active);
+void ptlrpc_invalidate_import(struct obd_import *imp);
 void ptlrpc_fail_import(struct obd_import *imp, int generation);
 void ptlrpc_fail_export(struct obd_export *exp);
 
index 119a506..efb441a 100644 (file)
@@ -864,6 +864,13 @@ struct llog_logid {
         __u32                   lgl_ogen;
 } __attribute__((packed));
 
+/* Records written to the CATALOGS list */
+#define CATLIST "CATALOGS"
+struct llog_catid {
+        struct llog_logid       lci_logid;
+        __u32                   lci_padding[3];
+} __attribute__((packed));
+
 /* Log data record types - there is no specific reason that these need to
  * be related to the RPC opcodes, but no reason not to (may be handy later?)
  */
@@ -875,7 +882,7 @@ typedef enum {
         PTL_CFG_REC      = 0x10630000,
         LLOG_GEN_REC     = 0x10640000,
         LLOG_HDR_MAGIC   = 0x10645539,
-        LLOG_LOGID_MAGIC = 0x1064553a,
+        LLOG_LOGID_MAGIC = 0x1064553b,
 } llog_op_type;
 
 /* Log record header - stored in little endian order.
@@ -897,7 +904,7 @@ struct llog_rec_tail {
 struct llog_logid_rec {
         struct llog_rec_hdr     lid_hdr;
         struct llog_logid       lid_id;
-        __u32                   padding;
+        __u32                   padding[5];
         struct llog_rec_tail    lid_tail;
 } __attribute__((packed));
 
index c940ac1..14943f8 100644 (file)
@@ -39,6 +39,11 @@ static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
         return import_state_names[state];
 }
 
+enum obd_import_event {
+        IMP_EVENT_DISCON     = 0x808001,
+        IMP_EVENT_INVALIDATE = 0x808002,
+        IMP_EVENT_ACTIVE     = 0x808003,
+};
 
 struct obd_import {
         struct portals_handle     imp_handle;
@@ -75,7 +80,8 @@ struct obd_import {
         /* flags */
         int                       imp_invalid:1, imp_replayable:1,
                                   imp_dlm_fake:1, imp_server_timeout:1,
-                                  imp_initial_recov:1;
+                                  imp_initial_recov:1, imp_force_verify:1,
+                                  imp_pingable:1;
         __u32                     imp_connect_op;
 };
 
index 9013e8a..4eef3be 100644 (file)
@@ -674,3 +674,23 @@ do {                                                                           \
 })
 
 #endif /* _LUSTRE_LIB_H */
+
+#define LMD_MAGIC 0xbdacbdac
+
+#define lmd_bad_magic(LMDP)                                             \
+({                                                                      \
+        struct lustre_mount_data *_lmd__ = (LMDP);                      \
+        int _ret__ = 0;                                                 \
+        if (!_lmd__) {                                                  \
+                CERROR("Missing mount data: "                           \
+                       "check that /sbin/mount.lustre is installed.\n");\
+                _ret__ = 1;                                             \
+        } else if (_lmd__->lmd_magic != LMD_MAGIC) {                    \
+                CERROR("Invalid mount data (%#x != %#x): "              \
+                       "check that /sbin/mount.lustre is installed\n",  \
+                       _lmd__->lmd_magic, LMD_MAGIC);                   \
+                _ret__ = 1;                                             \
+        }                                                               \
+        _ret__;                                                         \
+})
+
index 1ea4740..200d83f 100644 (file)
@@ -121,7 +121,7 @@ int llog_obd_origin_add(struct llog_ctxt *ctxt,
 
 int llog_cat_initialize(struct obd_device *obd, int count);
 int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd,
-                  int count, struct llog_logid *logid);
+                  int count, struct llog_catid *logid);
 
 int obd_llog_finish(struct obd_device *obd, int count);
 
@@ -174,10 +174,9 @@ struct llog_operations {
 };
 
 /* llog_lvfs.c */
-int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
-                      char *name, int count, struct llog_logid *idarray);
 extern struct llog_operations llog_lvfs_ops;
-
+int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
+                      char *name, int count, struct llog_catid *idarray);
 
 struct llog_ctxt {
         int                      loc_idx; /* my index the obd array of ctxt's */
@@ -222,7 +221,7 @@ static inline int llog_obd2ops(struct llog_ctxt *ctxt,
 {
        if (ctxt == NULL)
                 return -ENOTCONN;
-        
+
         *lop = ctxt->loc_logops;
         if (*lop == NULL)
                 return -EOPNOTSUPP;
index 8b34ada..ca7d26e 100644 (file)
@@ -243,8 +243,9 @@ struct ptlrpc_request {
         spinlock_t rq_lock;
         /* client-side flags */
         unsigned int rq_intr:1, rq_replied:1, rq_err:1,
-            rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
-            rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1;
+                rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
+                rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
+                rq_no_delay:1;
         int rq_phase;
         /* client-side refcount for SENT race */
         atomic_t rq_refcount;
index e911174..71110cc 100644 (file)
@@ -175,6 +175,7 @@ struct filter_obd {
 
         struct list_head     fo_export_list;
         int                  fo_subdir_count;
+
         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
         obd_size             fo_tot_granted;    /* all values in bytes */
         obd_size             fo_tot_pending;
@@ -249,6 +250,7 @@ struct client_obd {
 
         struct mdc_rpc_lock     *cl_rpc_lock;
         struct mdc_rpc_lock     *cl_setattr_lock;
+        struct osc_creator      cl_oscc;
 };
 
 /* Like a client, with some hangers-on.  Keep mc_client_obd first so that we
@@ -639,7 +641,7 @@ struct obd_ops {
 
         /* llog related obd_methods */
         int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
-                           int count, struct llog_logid *logid);
+                           int count, struct llog_catid *logid);
         int (*o_llog_finish)(struct obd_device *obd, int count);
 
         /* metadata-only methods */
@@ -647,7 +649,8 @@ struct obd_ops {
                      struct obd_client_handle *, int flag);
         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
 
-        int (*o_invalidate_import)(struct obd_device *, struct obd_import *);
+        int (*o_import_event)(struct obd_device *, struct obd_import *,
+                              enum obd_import_event);
 
         int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
                         int active);
index 90a521b..56a2683 100644 (file)
@@ -970,12 +970,14 @@ static inline int obd_unpin(struct obd_export *exp,
         return(rc);
 }
 
-static inline void obd_invalidate_import(struct obd_device *obd,
-                                         struct obd_import *imp)
+
+static inline void obd_import_event(struct obd_device *obd,
+                                    struct obd_import *imp,
+                                    enum obd_import_event event)
 {
-        if (obd->obd_set_up && OBP(obd, invalidate_import)) {
-                OBD_COUNTER_INCREMENT(obd, invalidate_import);
-                OBP(obd, invalidate_import)(obd, imp);
+        if (obd->obd_set_up && OBP(obd, import_event)) {
+                OBD_COUNTER_INCREMENT(obd, import_event);
+                OBP(obd, import_event)(obd, imp, event);
         }
 }
 
index 2787619..c5643db 100644 (file)
@@ -312,7 +312,7 @@ int client_disconnect_export(struct obd_export *exp, int failover)
 
         /* Yeah, obd_no_recov also (mainly) means "forced shutdown". */
         if (obd->obd_no_recov)
-                ptlrpc_set_import_active(imp, 0);
+                ptlrpc_invalidate_import(imp);
         else
                 rc = ptlrpc_disconnect_import(imp);
 
index a9020d3..2b7d3e1 100644 (file)
@@ -643,12 +643,6 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req,
 
         EXIT;
  out:
-        if (lock->l_resource->lr_lvb_len > 0) {
-                void *lvb = lustre_msg_buf(req->rq_repmsg, 1,
-                                           lock->l_resource->lr_lvb_len);
-                memcpy(lvb, lock->l_resource->lr_lvb_data,
-                       lock->l_resource->lr_lvb_len);
-        }
         req->rq_status = err;
 
         /* The LOCK_CHANGED code in ldlm_lock_enqueue depends on this
@@ -656,6 +650,14 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req,
         if (lock) {
                 LDLM_DEBUG(lock, "server-side enqueue handler, sending reply"
                            "(err=%d)", err);
+
+                if (lock->l_resource->lr_lvb_len > 0) {
+                        void *lvb = lustre_msg_buf(req->rq_repmsg, 1,
+                                                  lock->l_resource->lr_lvb_len);
+                        memcpy(lvb, lock->l_resource->lr_lvb_data,
+                               lock->l_resource->lr_lvb_len);
+                }
+
                 if (!err && dlm_req->lock_desc.l_resource.lr_type != LDLM_FLOCK)
                         ldlm_reprocess_all(lock->l_resource);
                 LDLM_LOCK_PUT(lock);
@@ -754,7 +756,7 @@ int ldlm_handle_cancel(struct ptlrpc_request *req)
                                 (res, NULL, 0);
                                 //(res, req->rq_reqmsg, 1);
                 }
-                        
+
                 ldlm_lock_cancel(lock);
                 if (ldlm_del_waiting_lock(lock))
                         CDEBUG(D_DLMTRACE, "cancelled waiting lock %p\n", lock);
@@ -902,9 +904,11 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 static int ldlm_callback_reply(struct ptlrpc_request *req, int rc)
 {
         req->rq_status = rc;
-        rc = lustre_pack_reply(req, 0, NULL, NULL);
-        if (rc)
-                return rc;
+        if (req->rq_reply_state == NULL) {
+                rc = lustre_pack_reply(req, 0, NULL, NULL);
+                if (rc)
+                        return rc;
+        }
         return ptlrpc_reply(req);
 }
 
@@ -969,58 +973,48 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
                 RETURN(0);
         }
 
-        if (req->rq_reqmsg->opc == LDLM_BL_CALLBACK) {
+        LASSERT(req->rq_export != NULL);
+        LASSERT(req->rq_export->exp_obd != NULL);
+
+        switch(req->rq_reqmsg->opc) {
+        case LDLM_BL_CALLBACK:
                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
-        } else if (req->rq_reqmsg->opc == LDLM_CP_CALLBACK) {
+                break;
+        case LDLM_CP_CALLBACK:
                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CP_CALLBACK, 0);
-        } else if (req->rq_reqmsg->opc == LDLM_GL_CALLBACK) {
+                break;
+        case LDLM_GL_CALLBACK:
                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_GL_CALLBACK, 0);
-        } else if (req->rq_reqmsg->opc == OBD_LOG_CANCEL) {
+                break;
+        case OBD_LOG_CANCEL:
                 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
-        } else if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_CREATE) {
-                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
-        } else if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_NEXT_BLOCK) {
-                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
-        } else if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_READ_HEADER) {
-                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
-        } else if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_CLOSE) {
-                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
-        } else {
-                ldlm_callback_reply(req, -EPROTO);
-                RETURN(0);
-        }
-
-        LASSERT(req->rq_export != NULL);
-        LASSERT(req->rq_export->exp_obd != NULL);
-
-        /* FIXME - how to send reply */
-        if (req->rq_reqmsg->opc == OBD_LOG_CANCEL) {
-                int rc = llog_origin_handle_cancel(req);
+                rc = llog_origin_handle_cancel(req);
                 ldlm_callback_reply(req, rc);
                 RETURN(0);
-        }
-        if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_CREATE) {
-                int rc = llog_origin_handle_create(req);
-                req->rq_status = rc;
-                ptlrpc_reply(req);
+        case LLOG_ORIGIN_HANDLE_CREATE:
+                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
+                rc = llog_origin_handle_create(req);
+                ldlm_callback_reply(req, rc);
                 RETURN(0);
-        }
-        if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_NEXT_BLOCK) {
-                int rc = llog_origin_handle_next_block(req);
-                req->rq_status = rc;
-                ptlrpc_reply(req);
+        case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
+                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
+                rc = llog_origin_handle_next_block(req);
+                ldlm_callback_reply(req, rc);
                 RETURN(0);
-        }
-        if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_READ_HEADER) {
-                int rc = llog_origin_handle_read_header(req);
-                req->rq_status = rc;
-                ptlrpc_reply(req);
+        case LLOG_ORIGIN_HANDLE_READ_HEADER:
+                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
+                rc = llog_origin_handle_read_header(req);
+                ldlm_callback_reply(req, rc);
                 RETURN(0);
-        }
-        if (req->rq_reqmsg->opc == LLOG_ORIGIN_HANDLE_CLOSE) {
-                int rc = llog_origin_handle_close(req);
+        case LLOG_ORIGIN_HANDLE_CLOSE:
+                OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
+                rc = llog_origin_handle_close(req);
                 ldlm_callback_reply(req, rc);
                 RETURN(0);
+        default:
+                CERROR("unknown opcode %u\n", req->rq_reqmsg->opc);
+                ldlm_callback_reply(req, -EPROTO);
+                RETURN(0);
         }
 
         ns = req->rq_export->exp_obd->obd_namespace;
@@ -1053,8 +1047,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
          * cancelling right now, because it's unused, or have an intent result
          * in the reply, so we might have to push the responsibility for sending
          * the reply down into the AST handlers, alas. */
-        if (req->rq_reqmsg->opc == LDLM_CP_CALLBACK)
-                ldlm_callback_reply(req, 0);
 
         switch (req->rq_reqmsg->opc) {
         case LDLM_BL_CALLBACK:
@@ -1070,6 +1062,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
                 break;
         case LDLM_CP_CALLBACK:
                 CDEBUG(D_INODE, "completion ast\n");
+                ldlm_callback_reply(req, 0);
                 ldlm_handle_cp_callback(req, ns, dlm_req, lock);
                 break;
         case LDLM_GL_CALLBACK:
index f6045f8..abcb6b7 100644 (file)
@@ -913,7 +913,8 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
         struct ptlrpc_request *req;
         struct ldlm_request *body;
         struct ldlm_reply *reply;
-        int size;
+        int buffers = 1;
+        int size[2];
         int flags;
 
         /*
@@ -939,8 +940,8 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
         else
                 flags = LDLM_FL_REPLAY;
 
-        size = sizeof(*body);
-        req = ptlrpc_prep_req(imp, LDLM_ENQUEUE, 1, &size, NULL);
+        size[0] = sizeof(*body);
+        req = ptlrpc_prep_req(imp, LDLM_ENQUEUE, 1, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -952,8 +953,12 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
         body->lock_flags = flags;
 
         ldlm_lock2handle(lock, &body->lock_handle1);
-        size = sizeof(*reply);
-        req->rq_replen = lustre_msg_size(1, &size);
+        size[0] = sizeof(*reply);
+        if (lock->l_lvb_len != 0) {
+                buffers = 2;
+                size[1] = lock->l_lvb_len;
+        }
+        req->rq_replen = lustre_msg_size(buffers, size);
 
         LDLM_DEBUG(lock, "replaying lock:");
 
index bac31cb..456156b 100644 (file)
@@ -569,7 +569,7 @@ static int ll_glimpse_callback(struct ldlm_lock *lock, void *reqp)
                 LBUG();
         }
 
-        LDLM_DEBUG(lock, "i_size: %Lu -> stripe number %d -> size %Lu",
+        LDLM_DEBUG(lock, "i_size: %llu -> stripe number %u -> size "LPU64,
                    inode->i_size, data.stripe_number, data.size);
 
         rc = lustre_pack_reply(req, 1, &size, NULL);
@@ -720,8 +720,8 @@ static ssize_t ll_file_read(struct file *filp, char *buf, size_t count,
                 inode->i_size = kms;
         }
 
-        CDEBUG(D_INFO, "Reading inode %lu, "LPSZ" bytes, offset %Ld, i_size "
-               LPU64"\n", inode->i_ino, count, *ppos, inode->i_size);
+        CDEBUG(D_INFO, "Read ino %lu, "LPSZ" bytes, offset %lld, i_size %llu\n",
+               inode->i_ino, count, *ppos, inode->i_size);
 
         /* turn off the kernel's read-ahead */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
index 36b0250..ceaa4e0 100644 (file)
@@ -385,6 +385,9 @@ int lustre_process_log(struct lustre_mount_data *lmd, char * profile,
         int err;
         ENTRY;
 
+        if (lmd_bad_magic(lmd))
+                RETURN(-EINVAL);
+
         generate_random_uuid(uuid);
         class_uuid_unparse(uuid, &mdc_uuid);
 
@@ -510,10 +513,9 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
-        if (lmd == NULL) {
-                CERROR("lustre_mount_data is NULL: check that /sbin/mount.lustre exists?\n");
+        if (lmd_bad_magic(lmd))
                 RETURN(-EINVAL);
-        }
+
         sbi = lustre_init_sbi(sb);
         if (!sbi)
                 RETURN(-ENOMEM);
index a565f51..aa04e4e 100644 (file)
@@ -31,7 +31,7 @@ void lov_free_memmd(struct lov_stripe_md **lsmp);
 
 /* lov_log.c */
 int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                  int count, struct llog_logid *logid);
+                  int count, struct llog_catid *logid);
 int lov_llog_finish(struct obd_device *obd, int count);
 
 /* lov_pack.c */
@@ -41,7 +41,7 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
                  struct lov_mds_md *lmm, int lmm_bytes);
 int lov_setstripe(struct obd_export *exp,
                   struct lov_stripe_md **lsmp, struct lov_user_md *lump);
-int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, 
+int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
               struct lov_user_md *lump);
 int lov_getstripe(struct obd_export *exp,
                   struct lov_stripe_md *lsm, struct lov_user_md *lump);
index 59dc29e..d7f1784 100644 (file)
@@ -156,18 +156,18 @@ static struct llog_operations lov_size_repl_logops = {
 
 
 int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                  int count, struct llog_logid *logid)
+                  int count, struct llog_catid *logid)
 {
         struct lov_obd *lov = &obd->u.lov;
         int i, rc = 0;
         ENTRY;
-        
+
         rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, 0, NULL,
                         &lov_unlink_orig_logops);
         if (rc)
                 RETURN(rc);
 
-        rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL, 
+        rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
                         &lov_size_repl_logops);
         if (rc)
                 RETURN(rc);
index 6d18d0d..c1a6640 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <linux/lvfs.h>
 
-struct dentry *lvfs_fid2dentry(struct obd_run_ctxt *ctxt, __u64 id, __u32 gen, __u64 gr,
-                               void *data)
+struct dentry *lvfs_fid2dentry(struct obd_run_ctxt *ctxt, __u64 id,
+                               __u32 gen, __u64 gr, void *data)
 {
         return ctxt->cb_ops.l_fid2dentry(id, gen, gr, data);
 }
index 51de280..9123e91 100644 (file)
@@ -812,6 +812,39 @@ static int mdc_detach(struct obd_device *dev)
         return lprocfs_obd_detach(dev);
 }
 
+static int mdc_import_event(struct obd_device *obd,
+                            struct obd_import *imp, 
+                            enum obd_import_event event)
+{
+        int rc = 0;
+
+        LASSERT(imp->imp_obd == obd);
+
+        switch (event) {
+        case IMP_EVENT_DISCON: {
+                break;
+        }
+        case IMP_EVENT_INVALIDATE: {
+                struct ldlm_namespace *ns = obd->obd_namespace;
+                
+                ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
+
+                if (obd->obd_observer)
+                        rc = obd_notify(obd->obd_observer, obd, 0);
+                break;
+        }
+        case IMP_EVENT_ACTIVE: {
+                if (obd->obd_observer)
+                        rc = obd_notify(obd->obd_observer, obd, 1);
+                break;
+        }
+        default:
+                CERROR("Unknown import event %d\n", event);
+                LBUG();
+        }
+        RETURN(rc);
+}
+
 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct client_obd *cli = &obd->u.cli;
@@ -906,7 +939,7 @@ static int mdc_cleanup(struct obd_device *obd, int flags)
 
 
 static int mdc_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                         int count, struct llog_logid *logid)
+                         int count, struct llog_catid *logid)
 {
         struct llog_ctxt *ctxt;
         int rc;
@@ -916,7 +949,7 @@ static int mdc_llog_init(struct obd_device *obd, struct obd_device *tgt,
                         &llog_client_ops);
         if (rc == 0) {
                 ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
-                ctxt->loc_imp = obd->u.cli.cl_import; 
+                ctxt->loc_imp = obd->u.cli.cl_import;
         }
 
         RETURN(rc);
@@ -945,6 +978,7 @@ struct obd_ops mdc_obd_ops = {
         o_statfs:      mdc_statfs,
         o_pin:         mdc_pin,
         o_unpin:       mdc_unpin,
+        o_import_event: mdc_import_event,
         o_llog_init:   mdc_llog_init,
         o_llog_finish: mdc_llog_finish,
 };
index fe28761..a8e7ff9 100644 (file)
@@ -355,34 +355,39 @@ static int mds_destroy_export(struct obd_export *export)
         RETURN(rc);
 }
 
-static int mds_disconnect(struct obd_export *export, int flags)
+static int mds_disconnect(struct obd_export *exp, int flags)
 {
         unsigned long irqflags;
         int rc;
         ENTRY;
 
-        ldlm_cancel_locks_for_export(export);
+        LASSERT(exp);
+        class_export_get(exp);
+
+        spin_lock_irqsave(&exp->exp_lock, irqflags);
+        exp->exp_flags = flags;
+        spin_unlock_irqrestore(&exp->exp_lock, irqflags);
+
+        /* Disconnect early so that clients can't keep using export */
+        rc = class_disconnect(exp, flags);
+        ldlm_cancel_locks_for_export(exp);
 
         /* complete all outstanding replies */
-        spin_lock_irqsave (&export->exp_lock, irqflags);
-        while (!list_empty (&export->exp_outstanding_replies)) {
+        spin_lock_irqsave(&exp->exp_lock, irqflags);
+        while (!list_empty(&exp->exp_outstanding_replies)) {
                 struct ptlrpc_reply_state *rs =
-                        list_entry (export->exp_outstanding_replies.next, 
-                                    struct ptlrpc_reply_state, rs_exp_list);
+                        list_entry(exp->exp_outstanding_replies.next,
+                                   struct ptlrpc_reply_state, rs_exp_list);
                 struct ptlrpc_service *svc = rs->rs_srv_ni->sni_service;
 
-                spin_lock (&svc->srv_lock);
-                list_del_init (&rs->rs_exp_list);
-                ptlrpc_schedule_difficult_reply (rs);
-                spin_unlock (&svc->srv_lock);
+                spin_lock(&svc->srv_lock);
+                list_del_init(&rs->rs_exp_list);
+                ptlrpc_schedule_difficult_reply(rs);
+                spin_unlock(&svc->srv_lock);
         }
-        spin_unlock_irqrestore (&export->exp_lock, irqflags);
+        spin_unlock_irqrestore(&exp->exp_lock, irqflags);
 
-        spin_lock_irqsave(&export->exp_lock, irqflags);
-        export->exp_flags = flags;
-        spin_unlock_irqrestore(&export->exp_lock, irqflags);
-
-        rc = class_disconnect(export, flags);
+        class_export_put(exp);
         RETURN(rc);
 }
 
index a6bba27..d8eb150 100644 (file)
@@ -51,11 +51,11 @@ int mds_cleanup_orphans(struct obd_device *obd);
 
 
 /* mds/mds_log.c */
-int mds_log_op_unlink(struct obd_device *obd, struct inode *inode, 
+int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
                       struct lov_mds_md *lmm, int lmm_size,
                       struct llog_cookie *logcookies, int cookies_size);
-int mds_llog_init(struct obd_device *obd, struct obd_device *tgt, int count, 
-                  struct llog_logid *logid);
+int mds_llog_init(struct obd_device *obd, struct obd_device *tgt, int count,
+                  struct llog_catid *logid);
 int mds_llog_finish(struct obd_device *obd, int count);
 
 /* mds/mds_lov.c */
index c4d5690..5c5fe7a 100644 (file)
@@ -118,7 +118,7 @@ static struct llog_operations mds_size_repl_logops = {
 };
 
 int mds_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                  int count, struct llog_logid *logid)
+                  int count, struct llog_catid *logid)
 {
         struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
         int rc;
index fdbfb91..5e2c305 100644 (file)
@@ -85,7 +85,7 @@ int proc_version;
 /* The following are visible and mutable through /proc/sys/lustre/. */
 unsigned int obd_fail_loc;
 unsigned int obd_timeout = 100;
-char obd_lustre_upcall[128] = "/usr/lib/lustre/lustre_upcall";
+char obd_lustre_upcall[128] = "DEFAULT"; /* or NONE or /full/path/to/upcall  */
 unsigned int obd_sync_filter; /* = 0, don't sync by default */
 
 #ifdef __KERNEL__
index 9ee9c4d..5088abb 100644 (file)
@@ -393,7 +393,6 @@ struct obd_import *class_conn2cliimp(struct lustre_handle *conn)
         return obd->u.cli.cl_import;
 }
 
-
 /* Export management functions */
 static void export_handle_addref(void *export)
 {
@@ -588,8 +587,7 @@ int class_disconnect(struct obd_export *export, int flags)
 
         if (export == NULL) {
                 fixme();
-                CDEBUG(D_IOCTL, "disconnect: attempting to free "
-                       "null export %p\n", export);
+                CDEBUG(D_IOCTL, "attempting to free NULL export %p\n", export);
                 RETURN(-EINVAL);
         }
 
index b0e82fe..cce91db 100644 (file)
@@ -51,7 +51,7 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle)
 {
         struct llog_handle *loghandle;
         struct llog_log_hdr *llh;
-        struct llog_logid_rec rec;
+        struct llog_logid_rec rec = { { 0 }, };
         int rc, index, bitmap_size;
         ENTRY;
 
@@ -264,6 +264,14 @@ int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec,
         /* loghandle is already locked by llog_cat_current_log() for us */
         rc = llog_write_rec(loghandle, rec, reccookie, 1, buf, -1);
         up_write(&loghandle->lgh_lock);
+        if (rc == -ENOSPC) {
+                /* to create a new plain log */
+                loghandle = llog_cat_current_log(cathandle, 1);
+                if (IS_ERR(loghandle))
+                        RETURN(PTR_ERR(loghandle));
+                rc = llog_write_rec(loghandle, rec, reccookie, 1, buf, -1);
+                up_write(&loghandle->lgh_lock);
+        }
 
         RETURN(rc);
 }
index 8674351..0066087 100644 (file)
@@ -1,10 +1,8 @@
 #ifndef __LLOG_INTERNAL_H__
 #define __LLOG_INTERNAL_H__
 
-int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, 
-                      char *name, int count, struct llog_logid *idarray);
-int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, 
-                      char *name, int count, struct llog_logid *);
+int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
+                      char *name, int count, struct llog_catid *idarray);
 int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res,
                        struct llog_logid *logid);
 #endif
index 310f122..baa12ad 100644 (file)
@@ -366,8 +366,9 @@ int llog_catlog_list(struct obd_device *obd, int count,
                      struct obd_ioctl_data *data)
 {
         int size, i;
-        struct llog_logid *idarray, *id;
-        char name[32] = "CATLIST";
+        struct llog_catid *idarray;
+        struct llog_logid *id;
+        char name[32] = CATLIST;
         char *out;
         int l, remains, rc = 0;
 
@@ -386,12 +387,11 @@ int llog_catlog_list(struct obd_device *obd, int count,
 
         out = data->ioc_bulk;
         remains = data->ioc_inllen1;
-        id = idarray;
         for (i = 0; i < count; i++) {
+                id = &idarray[i].lci_logid;
                 l = snprintf(out, remains,
                              "catalog log: #"LPX64"#"LPX64"#%08x\n",
                              id->lgl_oid, id->lgl_ogr, id->lgl_ogen);
-                id++;
                 out += l;
                 remains -= l;
                 if (remains <= 0) {
index ec32b11..d70d773 100644 (file)
@@ -52,7 +52,7 @@
 static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file,
                                 int len, int index)
 {
-        struct llog_rec_hdr rec;
+        struct llog_rec_hdr rec = { 0 };
         struct llog_rec_tail tail;
         int rc;
         ENTRY;
@@ -193,8 +193,8 @@ static int llog_lvfs_write_rec(struct llog_handle *loghandle,
 
         /* record length should not bigger than LLOG_CHUNK_SIZE */
         if (buf)
-                rc = (reclen > LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr)
-                      sizeof(struct llog_rec_tail)) ? -E2BIG : 0;
+                rc = (reclen > LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr) -
+                      sizeof(struct llog_rec_tail)) ? -E2BIG : 0;
         else
                 rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0;
         if (rc)
@@ -242,10 +242,14 @@ static int llog_lvfs_write_rec(struct llog_handle *loghandle,
         /* NOTE: padding is a record, but no bit is set */
         if (left != 0 && left != reclen &&
             left < (reclen + LLOG_MIN_REC_SIZE)) {
+                int bitmap_size = sizeof(llh->llh_bitmap) * 8;
                 loghandle->lgh_last_idx++;
                 rc = llog_lvfs_pad(obd, file, left, loghandle->lgh_last_idx);
                 if (rc)
                         RETURN(rc);
+                /* if it's the last idx in log file, then return -ENOSPC */
+                if (loghandle->lgh_last_idx == bitmap_size - 1)
+                        RETURN(-ENOSPC);
         }
 
         loghandle->lgh_last_idx++;
@@ -554,7 +558,7 @@ static int llog_lvfs_destroy(struct llog_handle *handle)
 
 /* reads the catalog list */
 int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
-                      char *name, int count, struct llog_logid *idarray)
+                      char *name, int count, struct llog_catid *idarray)
 {
         struct obd_run_ctxt saved;
         struct l_file *file;
@@ -596,7 +600,7 @@ EXPORT_SYMBOL(llog_get_cat_list);
 
 /* writes the cat list */
 int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
-                      char *name, int count, struct llog_logid *idarray)
+                      char *name, int count, struct llog_catid *idarray)
 {
         struct obd_run_ctxt saved;
         struct l_file *file;
index d01441a..446eb75 100644 (file)
@@ -280,9 +280,9 @@ EXPORT_SYMBOL(llog_obd_origin_add);
 
 int llog_cat_initialize(struct obd_device *obd, int count)
 {
-        struct llog_logid *idarray;
+        struct llog_catid *idarray;
         int size = sizeof(*idarray) * count;
-        char name[32] = "CATLIST";
+        char name[32] = CATLIST;
         int rc;
         ENTRY;
 
@@ -290,8 +290,6 @@ int llog_cat_initialize(struct obd_device *obd, int count)
         if (!idarray)
                 RETURN(-ENOMEM);
 
-        memset(idarray, 0, size);
-
         rc = llog_get_cat_list(obd, obd, name, count, idarray);
         if (rc) {
                 CERROR("rc: %d\n", rc);
@@ -317,7 +315,7 @@ int llog_cat_initialize(struct obd_device *obd, int count)
 EXPORT_SYMBOL(llog_cat_initialize);
 
 int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd,
-                  int count, struct llog_logid *logid)
+                  int count, struct llog_catid *logid)
 {
         int rc;
         ENTRY;
index 0607d12..997f1f5 100644 (file)
@@ -548,7 +548,7 @@ static int llog_run_tests(struct obd_device *obd)
 
 
 static int llog_test_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                               int count, struct llog_logid *logid)
+                               int count, struct llog_catid *logid)
 {
         int rc;
         ENTRY;
index 54a1d7b..119ca99 100644 (file)
@@ -646,7 +646,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, llog_finish); 
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, pin); 
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, unpin);
-        LPROCFS_OBD_OP_INIT(num_private_stats, stats, invalidate_import);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
         
         for (i = num_private_stats; i < num_stats; i++) {
index d3785d4..e658b3a 100644 (file)
@@ -1411,6 +1411,92 @@ static int filter_precleanup(struct obd_device *obd, int flags)
         RETURN(rc);
 }
 
+/* Do extra sanity checks for grant accounting.  We do this at connect,
+ * disconnect, and statfs RPC time, so it shouldn't be too bad.  We can
+ * always get rid of it or turn it off when we know accounting is good. */
+static void filter_grant_sanity_check(struct obd_device *obd, char *func)
+{
+        struct filter_export_data *fed;
+        struct obd_export *exp;
+        obd_size maxsize = obd->obd_osfs.os_blocks * obd->obd_osfs.os_bsize;
+        obd_size tot_dirty = 0, tot_pending = 0, tot_granted = 0;
+        obd_size fo_tot_dirty, fo_tot_pending, fo_tot_granted;
+
+        spin_lock(&obd->obd_osfs_lock);
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
+                fed = &exp->exp_filter_data;
+                LASSERTF(fed->fed_grant + fed->fed_pending <= maxsize,
+                         "cli %s/%p %lu+%lu > "LPU64"\n",
+                         exp->exp_client_uuid.uuid, exp,
+                         fed->fed_grant, fed->fed_pending, maxsize);
+                LASSERTF(fed->fed_dirty <= maxsize, "cli %s/%p %lu > "LPU64"\n",
+                         exp->exp_client_uuid.uuid, exp,fed->fed_dirty,maxsize);
+                CDEBUG(D_CACHE,"%s: cli %s/%p dirty %lu pend %lu grant %lu\n",
+                       obd->obd_name, exp->exp_client_uuid.uuid, exp,
+                       fed->fed_dirty, fed->fed_pending, fed->fed_grant);
+                tot_granted += fed->fed_grant + fed->fed_pending;
+                tot_pending += fed->fed_pending;
+                tot_dirty += fed->fed_dirty;
+        }
+        fo_tot_granted = obd->u.filter.fo_tot_granted;
+        fo_tot_pending = obd->u.filter.fo_tot_pending;
+        fo_tot_dirty = obd->u.filter.fo_tot_dirty;
+        spin_unlock(&obd->obd_dev_lock);
+        spin_unlock(&obd->obd_osfs_lock);
+
+        /* Do these assertions outside the spinlocks so we don't kill system */
+        LASSERTF(tot_granted == fo_tot_granted, "%s "LPU64" != "LPU64"\n",
+                 func, tot_granted, fo_tot_granted);
+        LASSERTF(tot_pending == fo_tot_pending, "%s "LPU64" != "LPU64"\n",
+                 func, tot_pending, fo_tot_pending);
+        LASSERTF(tot_dirty == fo_tot_dirty, "%s "LPU64" != "LPU64"\n",
+                 func, tot_dirty, fo_tot_dirty);
+        LASSERTF(tot_pending <= tot_granted, "%s "LPU64" > "LPU64"\n",
+                 func, tot_pending, tot_granted);
+        LASSERTF(tot_granted <= maxsize, "%s "LPU64" > "LPU64"\n",
+                 func, tot_granted, maxsize);
+        LASSERTF(tot_dirty <= maxsize, "%s "LPU64" > "LPU64"\n",
+                 func, tot_dirty, maxsize);
+}
+
+/* Remove this client from the grant accounting totals.  This is done at
+ * disconnect time and also at export destroy time in case there was a race
+ * between removing the export and an incoming BRW updating the client grant.
+ * The client should do something similar when it invalidates its import. */
+static void filter_grant_discard(struct obd_export *exp)
+{
+        struct obd_device *obd = exp->exp_obd;
+        struct filter_obd *filter = &obd->u.filter;
+        struct filter_export_data *fed = &exp->exp_filter_data;
+
+        filter_grant_sanity_check(obd, __FUNCTION__);
+
+        spin_lock(&obd->obd_osfs_lock);
+        CDEBUG(D_CACHE, "%s: cli %s/%p dirty %lu pend %lu grant %lu\n",
+               obd->obd_name, exp->exp_client_uuid.uuid, exp,
+               fed->fed_dirty, fed->fed_pending, fed->fed_grant);
+
+        LASSERTF(filter->fo_tot_granted >= fed->fed_grant,
+                 "%s: tot_granted "LPU64" cli %s/%p fed_grant %lu\n",
+                 obd->obd_name, filter->fo_tot_granted,
+                 exp->exp_client_uuid.uuid, exp, fed->fed_grant);
+        filter->fo_tot_granted -= fed->fed_grant;
+        LASSERTF(exp->exp_obd->u.filter.fo_tot_pending >= fed->fed_pending,
+                 "%s: tot_pending "LPU64" cli %s/%p fed_pending %lu\n",
+                 obd->obd_name, filter->fo_tot_pending,
+                 exp->exp_client_uuid.uuid, exp, fed->fed_pending);
+        LASSERTF(filter->fo_tot_dirty >= fed->fed_dirty,
+                 "%s: tot_dirty "LPU64" cli %s/%p fed_dirty %lu\n",
+                 obd->obd_name, filter->fo_tot_dirty,
+                 exp->exp_client_uuid.uuid, exp, fed->fed_dirty);
+        filter->fo_tot_dirty -= fed->fed_dirty;
+        fed->fed_dirty = 0;
+        fed->fed_grant = 0;
+
+        spin_unlock(&obd->obd_osfs_lock);
+}
+
 static int filter_destroy_export(struct obd_export *exp)
 {
         ENTRY;
@@ -1424,62 +1510,46 @@ static int filter_destroy_export(struct obd_export *exp)
 
         if (exp->exp_obd->obd_replayable)
                 filter_client_free(exp, exp->exp_flags);
+
+        filter_grant_sanity_check(exp->exp_obd, __FUNCTION__);
+
         RETURN(0);
 }
 
 /* also incredibly similar to mds_disconnect */
 static int filter_disconnect(struct obd_export *exp, int flags)
 {
-        struct filter_obd *filter = &exp->exp_obd->u.filter;
-        struct filter_export_data *fed = &exp->exp_filter_data;
+        struct obd_device *obd = exp->exp_obd;
         unsigned long irqflags;
         struct llog_ctxt *ctxt;
         int rc;
         ENTRY;
 
         LASSERT(exp);
-
-        /* This would imply RPCs still in flight or preprw/commitrw imbalance */
-        if (fed->fed_pending)
-                CWARN("%s: cli %s has %lu pending at disconnect time\n",
-                       exp->exp_obd->obd_name, exp->exp_client_uuid.uuid,
-                       fed->fed_pending);
-
-        /* Forget what this client had cached.  This is also done on the
-         * client when it invalidates its import.  Do this before unlinking
-         * from the export list so filter_grant_sanity_check totals are OK. */
-        spin_lock(&exp->exp_obd->obd_osfs_lock);
-        LASSERTF(exp->exp_obd->u.filter.fo_tot_dirty >= fed->fed_dirty,
-                 "%s: tot_dirty "LPU64" cli %s/%p fed_dirty %lu\n",
-                 exp->exp_obd->obd_name, exp->exp_obd->u.filter.fo_tot_dirty,
-                 exp->exp_client_uuid.uuid, exp, fed->fed_dirty);
-        exp->exp_obd->u.filter.fo_tot_dirty -= fed->fed_dirty;
-        LASSERTF(exp->exp_obd->u.filter.fo_tot_granted >= fed->fed_grant,
-                 "%s: tot_granted "LPU64" cli %s/%p fed_grant %lu\n",
-                 exp->exp_obd->obd_name, exp->exp_obd->u.filter.fo_tot_granted,
-                 exp->exp_client_uuid.uuid, exp, fed->fed_grant);
-        exp->exp_obd->u.filter.fo_tot_granted -= fed->fed_grant;
-        LASSERTF(exp->exp_obd->u.filter.fo_tot_pending >= fed->fed_pending,
-                 "%s: tot_pending "LPU64" cli %s/%p fed_pending %lu\n",
-                 exp->exp_obd->obd_name, exp->exp_obd->u.filter.fo_tot_pending,
-                 exp->exp_client_uuid.uuid, exp, fed->fed_pending);
-        fed->fed_dirty = 0;
-        fed->fed_grant = 0;
-        spin_unlock(&exp->exp_obd->obd_osfs_lock);
-
-        ldlm_cancel_locks_for_export(exp);
+        class_export_get(exp);
 
         spin_lock_irqsave(&exp->exp_lock, irqflags);
         exp->exp_flags = flags;
         spin_unlock_irqrestore(&exp->exp_lock, irqflags);
 
-        fsfilt_sync(exp->exp_obd, filter->fo_sb);
+        filter_grant_discard(exp);
+
+        /* Disconnect early so that clients can't keep using export */
+        rc = class_disconnect(exp, flags);
+
+        /* Do this twice in case a BRW arrived between the first call and
+         * the class_export_unlink() call (bug 2663) */
+        filter_grant_discard(exp);
+
+        ldlm_cancel_locks_for_export(exp);
+
+        fsfilt_sync(obd, obd->u.filter.fo_sb);
 
         /* flush any remaining cancel messages out to the target */
-        ctxt = llog_get_context(exp->exp_obd, LLOG_UNLINK_REPL_CTXT);
+        ctxt = llog_get_context(obd, LLOG_UNLINK_REPL_CTXT);
         llog_sync(ctxt, exp);
 
-        rc = class_disconnect(exp, flags);
+        class_export_put(exp);
         RETURN(rc);
 }
 
@@ -2091,59 +2161,10 @@ static int filter_sync(struct obd_export *exp, struct obdo *oa,
         RETURN(rc);
 }
 
-/* debugging to make sure that nothing bad happens, can be turned off soon.
- * caller must hold osfs lock */
-static void filter_grant_total_exports(struct obd_device *obd,
-                                       obd_size *tot_dirty,
-                                       obd_size *tot_pending,
-                                       obd_size *tot_granted,
-                                       obd_size maxsize)
-{
-        struct filter_export_data *fed;
-        struct obd_export *exp_pos;
-
-        spin_lock(&obd->obd_dev_lock);
-        list_for_each_entry(exp_pos, &obd->obd_exports, exp_obd_chain) {
-                fed = &exp_pos->exp_filter_data;
-                LASSERTF(fed->fed_dirty <= maxsize, "cli %s/%p %lu > "LPU64"\n",
-                         exp_pos->exp_client_uuid.uuid, exp_pos,
-                         fed->fed_dirty, maxsize);
-                LASSERTF(fed->fed_grant + fed->fed_pending <= maxsize,
-                         "cli %s/%p %lu+%lu > "LPU64"\n",
-                         exp_pos->exp_client_uuid.uuid, exp_pos,
-                         fed->fed_grant, fed->fed_pending, maxsize);
-                *tot_dirty += fed->fed_dirty;
-                *tot_pending += fed->fed_pending;
-                *tot_granted += fed->fed_grant + fed->fed_pending;
-        }
-        spin_unlock(&obd->obd_dev_lock);
-}
-
-static void filter_grant_sanity_check(obd_size tot_dirty, obd_size tot_pending,
-                                      obd_size tot_granted,
-                                      obd_size fo_tot_dirty,
-                                      obd_size fo_tot_pending,
-                                      obd_size fo_tot_granted, obd_size maxsize)
-{
-        LASSERTF(tot_dirty == fo_tot_dirty, LPU64" != "LPU64"\n",
-                 tot_dirty, fo_tot_dirty);
-        LASSERTF(tot_pending == fo_tot_pending, LPU64" != "LPU64"\n",
-                 tot_pending, fo_tot_pending);
-        LASSERTF(tot_granted == fo_tot_granted, LPU64" != "LPU64"\n",
-                 tot_granted, fo_tot_granted);
-        LASSERTF(tot_dirty <= maxsize, LPU64" > "LPU64"\n", tot_dirty, maxsize);
-        LASSERTF(tot_pending <= tot_granted, LPU64" > "LPU64"\n", tot_pending,
-                 tot_granted);
-        LASSERTF(tot_granted <= maxsize, LPU64" > "LPU64"\n",
-                 tot_granted, maxsize);
-}
-
 static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs,
                          unsigned long max_age)
 {
         struct filter_obd *filter = &obd->u.filter;
-        obd_size tot_cached = 0, tot_pending = 0, tot_granted = 0;
-        obd_size fo_tot_cached, fo_tot_pending, fo_tot_granted;
         int blockbits = filter->fo_sb->s_blocksize_bits;
         int rc;
         ENTRY;
@@ -2154,26 +2175,20 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         spin_lock(&obd->obd_osfs_lock);
         rc = fsfilt_statfs(obd, filter->fo_sb, max_age);
         memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
-        filter_grant_total_exports(obd, &tot_cached, &tot_pending, &tot_granted,
-                                   osfs->os_blocks << blockbits);
-        fo_tot_cached = filter->fo_tot_dirty;
-        fo_tot_pending = filter->fo_tot_pending;
-        fo_tot_granted = filter->fo_tot_granted;
         spin_unlock(&obd->obd_osfs_lock);
 
-        /* Do check outside spinlock, to avoid wedging system on failure */
-        filter_grant_sanity_check(tot_cached, tot_pending, tot_granted,
-                                  fo_tot_cached, fo_tot_pending,
-                                  fo_tot_granted, osfs->os_blocks << blockbits);
-
         CDEBUG(D_SUPER | D_CACHE, "blocks cached "LPU64" granted "LPU64
                "pending "LPU64" free "LPU64" avail "LPU64"\n",
-               tot_cached >> blockbits, tot_granted >> blockbits,
-               tot_pending >> blockbits, osfs->os_bfree, osfs->os_bavail);
+               filter->fo_tot_dirty >> blockbits,
+               filter->fo_tot_granted >> blockbits,
+               filter->fo_tot_pending >> blockbits,
+               osfs->os_bfree, osfs->os_bavail);
+
+        filter_grant_sanity_check(obd, __FUNCTION__);
 
         osfs->os_bavail -= min(osfs->os_bavail,
-                               (tot_cached +tot_pending +osfs->os_bsize -1) >>
-                                        blockbits);
+                               (filter->fo_tot_dirty + filter->fo_tot_pending +
+                                osfs->os_bsize -1) >> blockbits);
 
         RETURN(rc);
 }
@@ -2312,7 +2327,7 @@ static struct llog_operations filter_size_orig_logops = {
 };
 
 static int filter_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                            int count, struct llog_logid *logid)
+                            int count, struct llog_catid *logid)
 {
         struct llog_ctxt *ctxt;
         int rc;
index ad4298c..68a0f84 100644 (file)
@@ -108,6 +108,8 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
         struct obd_device *obd = exp->exp_obd;
         ENTRY;
 
+        LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
+
         if ((oa->o_valid & (OBD_MD_FLBLOCKS|OBD_MD_FLGRANT)) !=
                                         (OBD_MD_FLBLOCKS|OBD_MD_FLGRANT)) {
                 oa->o_valid &= ~OBD_MD_FLGRANT;
@@ -122,8 +124,8 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
          * leave this here in case there is a large error in accounting. */
         CDEBUG(oa->o_grant > fed->fed_grant + FILTER_GRANT_CHUNK ?
                D_ERROR : D_CACHE,
-               "%s: cli %s reports granted: "LPU64" dropped: %u, local: %lu\n",
-               obd->obd_name, exp->exp_client_uuid.uuid, oa->o_grant,
+               "%s: cli %s/%p reports grant: "LPU64" dropped: %u, local: %lu\n",
+               obd->obd_name, exp->exp_client_uuid.uuid, exp, oa->o_grant,
                oa->o_dropped, fed->fed_grant);
 
         /* Update our accounting now so that statfs takes it into account.
@@ -132,14 +134,14 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
          * on fed_dirty however. */
         obd->u.filter.fo_tot_dirty += oa->o_dirty - fed->fed_dirty;
         if (fed->fed_grant < oa->o_dropped) {
-                CERROR("%s: cli %s reports %u dropped > fed_grant %lu\n",
-                       obd->obd_name, exp->exp_client_uuid.uuid,
+                CERROR("%s: cli %s/%p reports %u dropped > fed_grant %lu\n",
+                       obd->obd_name, exp->exp_client_uuid.uuid, exp,
                        oa->o_dropped, fed->fed_grant);
                 oa->o_dropped = 0;
         }
         if (obd->u.filter.fo_tot_granted < oa->o_dropped) {
-                CERROR("%s: cli %s reports %u dropped > tot_granted "LPU64"\n",
-                       obd->obd_name, exp->exp_client_uuid.uuid,
+                CERROR("%s: cli %s/%p reports %u dropped > tot_grant "LPU64"\n",
+                       obd->obd_name, exp->exp_client_uuid.uuid, exp,
                        oa->o_dropped, obd->u.filter.fo_tot_granted);
                 oa->o_dropped = 0;
         }
@@ -163,6 +165,8 @@ obd_size filter_grant_space_left(struct obd_export *exp)
         obd_size tot_granted = obd->u.filter.fo_tot_granted, avail, left = 0;
         int rc, statfs_done = 0;
 
+        LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
+
         if (time_before(obd->obd_osfs_age, jiffies - HZ)) {
 restat:
                 rc = fsfilt_statfs(obd, obd->u.filter.fo_sb, jiffies + 1);
@@ -191,10 +195,10 @@ restat:
                 if (left < tot_granted - obd->u.filter.fo_tot_pending &&
                     time_after(jiffies, next)) {
                         spin_unlock(&obd->obd_osfs_lock);
-                        CERROR("%s: cli %s granted "LPU64" more than available "
+                        CERROR("%s: cli %s/%p grant "LPU64" > available "
                                LPU64" and pending "LPU64"\n", obd->obd_name,
-                               exp->exp_client_uuid.uuid, tot_granted, left,
-                               obd->u.filter.fo_tot_pending);
+                               exp->exp_client_uuid.uuid, exp, tot_granted,
+                               left, obd->u.filter.fo_tot_pending);
                         if (next == 0)
                                 portals_debug_dumplog();
                         next = jiffies + 20 * HZ;
@@ -203,11 +207,11 @@ restat:
                 left = 0;
         }
 
-        CDEBUG(D_CACHE, "%s: cli %s free: "LPU64" avail: "LPU64" grant "LPU64
+        CDEBUG(D_CACHE, "%s: cli %s/%p free: "LPU64" avail: "LPU64" grant "LPU64
                " left: "LPU64" pending: "LPU64"\n", obd->obd_name,
-               exp->exp_client_uuid.uuid, obd->obd_osfs.os_bfree << blockbits,
-               avail << blockbits, tot_granted, left,
-               obd->u.filter.fo_tot_pending);
+               exp->exp_client_uuid.uuid, exp,
+               obd->obd_osfs.os_bfree << blockbits, avail << blockbits,
+               tot_granted, left, obd->u.filter.fo_tot_pending);
 
         return left;
 }
@@ -224,6 +228,8 @@ long filter_grant(struct obd_export *exp, obd_size current_grant,
         int blockbits = obd->u.filter.fo_sb->s_blocksize_bits;
         __u64 grant = 0;
 
+        LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
+
         /* Grant some fraction of the client's requested grant space so that
          * they are not always waiting for write credits (not all of it to
          * avoid overgranting in face of multiple RPCs in flight).  This
@@ -246,12 +252,12 @@ long filter_grant(struct obd_export *exp, obd_size current_grant,
                 }
         }
 
-        CDEBUG(D_CACHE,"%s: cli %s wants: "LPU64" granting: "LPU64"\n",
-               obd->obd_name, exp->exp_client_uuid.uuid, want, grant);
+        CDEBUG(D_CACHE,"%s: cli %s/%p wants: "LPU64" granting: "LPU64"\n",
+               obd->obd_name, exp->exp_client_uuid.uuid, exp, want, grant);
         CDEBUG(D_CACHE,
-               "%s: cli %s tot cached:"LPU64" granted:"LPU64
+               "%s: cli %s/%p tot cached:"LPU64" granted:"LPU64
                " num_exports: %d\n", obd->obd_name, exp->exp_client_uuid.uuid,
-               obd->u.filter.fo_tot_dirty,
+               exp, obd->u.filter.fo_tot_dirty,
                obd->u.filter.fo_tot_granted, obd->obd_num_exports);
 
         return grant;
@@ -426,6 +432,8 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
         unsigned long used = 0, ungranted = 0, using;
         int i, rc = -ENOSPC, obj, n = 0, mask = D_CACHE;
 
+        LASSERT_SPIN_LOCKED(&exp->exp_obd->obd_osfs_lock);
+
         for (obj = 0; obj < objcount; obj++) {
                 for (i = 0; i < fso[obj].fso_bufcnt; i++, n++) {
                         int tmp, bytes;
@@ -440,10 +448,10 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
                         if (rnb[n].flags & OBD_BRW_FROM_GRANT) {
                                 if (fed->fed_grant < used + bytes) {
                                         CDEBUG(D_CACHE,
-                                               "%s: cli %s claims %ld+%d GRANT,"
-                                               " no such grant %lu, idx %d\n",
+                                               "%s: cli %s/%p claims %ld+%d "
+                                               "GRANT, real grant %lu idx %d\n",
                                                exp->exp_obd->obd_name,
-                                               exp->exp_client_uuid.uuid,
+                                               exp->exp_client_uuid.uuid, exp,
                                                used, bytes, fed->fed_grant, n);
                                         mask = D_ERROR;
                                 } else {
@@ -472,9 +480,9 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
                          * ignore this error. */
                         lnb[n].rc = -ENOSPC;
                         rnb[n].flags &= OBD_BRW_GRANTED;
-                        CDEBUG(D_CACHE, "%s: cli %s idx %d no space for %d\n",
+                        CDEBUG(D_CACHE,"%s: cli %s/%p idx %d no space for %d\n",
                                exp->exp_obd->obd_name,
-                               exp->exp_client_uuid.uuid, n, bytes);
+                               exp->exp_client_uuid.uuid, exp, n, bytes);
                 }
         }
 
@@ -488,8 +496,8 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
         exp->exp_obd->u.filter.fo_tot_pending += used;
 
         CDEBUG(mask,
-               "%s: cli %s used: %lu ungranted: %lu grant: %lu dirty: %lu\n",
-               exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, used,
+               "%s: cli %s/%p used: %lu ungranted: %lu grant: %lu dirty: %lu\n",
+               exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp, used,
                ungranted, fed->fed_grant, fed->fed_dirty);
 
         /* Rough calc in case we don't refresh cached statfs data */
@@ -501,8 +509,8 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
                 exp->exp_obd->obd_osfs.os_bavail = 0;
 
         if (fed->fed_dirty < used) {
-                CERROR("%s: cli %s claims used %lu > fed_dirty %lu\n",
-                       exp->exp_obd->obd_name, exp->exp_client_uuid.uuid,
+                CERROR("%s: cli %s/%p claims used %lu > fed_dirty %lu\n",
+                       exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp,
                        used, fed->fed_dirty);
                 used = fed->fed_dirty;
         }
index 9216ec0..0492fc6 100644 (file)
@@ -170,28 +170,21 @@ int osc_rd_create_low_wm(char *page, char **start, off_t off, int count,
                          int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, "%d\n",
-                        exp->exp_osc_data.oed_oscc.oscc_kick_barrier);
+                        obd->u.cli.cl_oscc.oscc_kick_barrier);
 }
 
 int osc_wr_create_low_wm(struct file *file, const char *buffer,
                          unsigned long count, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
         int val, rc;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
         rc = lprocfs_write_helper(buffer, count, &val);
@@ -202,9 +195,7 @@ int osc_wr_create_low_wm(struct file *file, const char *buffer,
                 return -ERANGE;
 
         spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        exp->exp_osc_data.oed_oscc.oscc_kick_barrier = val;
+        obd->u.cli.cl_oscc.oscc_kick_barrier = val;
         spin_unlock(&obd->obd_dev_lock);
 
         return count;
@@ -214,28 +205,21 @@ int osc_rd_create_count(char *page, char **start, off_t off, int count,
                         int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, "%d\n",
-                        exp->exp_osc_data.oed_oscc.oscc_grow_count);
+                        obd->u.cli.cl_oscc.oscc_grow_count);
 }
 
 int osc_wr_create_count(struct file *file, const char *buffer,
                         unsigned long count, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
         int val, rc;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
         rc = lprocfs_write_helper(buffer, count, &val);
@@ -245,11 +229,7 @@ int osc_wr_create_count(struct file *file, const char *buffer,
         if (val < 0)
                 return -ERANGE;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        exp->exp_osc_data.oed_oscc.oscc_grow_count = val;
-        spin_unlock(&obd->obd_dev_lock);
+        obd->u.cli.cl_oscc.oscc_grow_count = val;
 
         return count;
 }
@@ -258,36 +238,24 @@ int osc_rd_prealloc_next_id(char *page, char **start, off_t off, int count,
                             int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, LPU64"\n",
-                        exp->exp_osc_data.oed_oscc.oscc_next_id);
+                        obd->u.cli.cl_oscc.oscc_next_id);
 }
 
 int osc_rd_prealloc_last_id(char *page, char **start, off_t off, int count,
                             int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, LPU64"\n",
-                        exp->exp_osc_data.oed_oscc.oscc_last_id);
+                        obd->u.cli.cl_oscc.oscc_last_id);
 }
 
 static struct lprocfs_vars lprocfs_obd_vars[] = {
index 845b306..6edc2e1 100644 (file)
@@ -110,7 +110,7 @@ static int oscc_internal_create(struct osc_creator *oscc)
         oscc->oscc_flags |= OSCC_FLAG_CREATING;
         spin_unlock(&oscc->oscc_lock);
 
-        request = ptlrpc_prep_req(class_exp2cliimp(oscc->oscc_exp), OST_CREATE,
+        request = ptlrpc_prep_req(oscc->oscc_obd->u.cli.cl_import, OST_CREATE,
                                   1, &size, NULL);
         if (request == NULL) {
                 spin_lock(&oscc->oscc_lock);
@@ -163,8 +163,8 @@ static int oscc_wait_for_objects(struct osc_creator *oscc, int count)
         ost_full = (oscc->oscc_flags & OSCC_FLAG_NOSPC);
         spin_unlock(&oscc->oscc_lock);
 
-        osc_invalid = class_exp2cliimp(oscc->oscc_exp)->imp_invalid;
-
+        osc_invalid = oscc->oscc_obd->u.cli.cl_import->imp_invalid;
+                      
         return have_objs || ost_full || osc_invalid;
 }
 
@@ -186,7 +186,7 @@ static int oscc_precreate(struct osc_creator *oscc, int wait)
         if (!oscc_has_objects(oscc, 1) && (oscc->oscc_flags & OSCC_FLAG_NOSPC))
                 rc = -ENOSPC;
 
-        if (class_exp2cliimp(oscc->oscc_exp)->imp_invalid)
+        if (oscc->oscc_obd->u.cli.cl_import->imp_invalid)
                 rc = -EIO;
 
         RETURN(rc);
@@ -207,7 +207,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                struct lov_stripe_md **ea, struct obd_trans_info *oti)
 {
         struct lov_stripe_md *lsm;
-        struct osc_creator *oscc = &exp->u.eu_osc_data.oed_oscc;
+        struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
         int try_again = 1, rc = 0;
         ENTRY;
         LASSERT(oa);
@@ -236,7 +236,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                 oa->o_valid |= OBD_MD_FLID;
                 oa->o_id = oscc->oscc_next_id - 1;
 
-                rc = osc_real_create(oscc->oscc_exp, oa, ea, NULL);
+                rc = osc_real_create(exp, oa, ea, NULL);
 
                 spin_lock(&oscc->oscc_lock);
                 if (rc == -ENOSPC)
@@ -295,26 +295,27 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
         RETURN(rc);
 }
 
-void oscc_init(struct obd_export *exp)
+void oscc_init(struct obd_device *obd)
 {
-        struct osc_export_data *oed;
+        struct osc_creator *oscc;
 
-        if (exp == NULL)
+        if (obd == NULL)
                 return;
 
-        oed = &exp->exp_osc_data;
-        memset(oed, 0, sizeof(*oed));
-        INIT_LIST_HEAD(&oed->oed_oscc.oscc_list);
-        init_waitqueue_head(&oed->oed_oscc.oscc_waitq);
-        spin_lock_init(&oed->oed_oscc.oscc_lock);
-        oed->oed_oscc.oscc_exp = exp;
-        oed->oed_oscc.oscc_kick_barrier = 100;
-        oed->oed_oscc.oscc_grow_count = 2000;
-        oed->oed_oscc.oscc_initial_create_count = 2000;
-
-        oed->oed_oscc.oscc_next_id = 2;
-        oed->oed_oscc.oscc_last_id = 1;
-        oed->oed_oscc.oscc_flags |= OSCC_FLAG_RECOVERING;
+        oscc = &obd->u.cli.cl_oscc;
+
+        memset(oscc, 0, sizeof(*oscc));
+        INIT_LIST_HEAD(&oscc->oscc_list);
+        init_waitqueue_head(&oscc->oscc_waitq);
+        spin_lock_init(&oscc->oscc_lock);
+        oscc->oscc_obd = obd;
+        oscc->oscc_kick_barrier = 100;
+        oscc->oscc_grow_count = 2000;
+        oscc->oscc_initial_create_count = 2000;
+
+        oscc->oscc_next_id = 2;
+        oscc->oscc_last_id = 1;
+        oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
         /* XXX the export handle should give the oscc the last object */
         /* oed->oed_oscc.oscc_last_id = exph->....; */
 }
index ae3e010..f011d0e 100644 (file)
@@ -59,7 +59,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
               struct lov_stripe_md **ea, struct obd_trans_info *oti);
 int osc_real_create(struct obd_export *exp, struct obdo *oa,
               struct lov_stripe_md **ea, struct obd_trans_info *oti);
-void oscc_init(struct obd_export *exp);
+void oscc_init(struct obd_device *obd);
 void osc_wake_cache_waiters(struct client_obd *cli);
 
 #ifdef __KERNEL__
index b0686b3..39015f0 100644 (file)
@@ -2708,6 +2708,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                         void *key, obd_count vallen, void *val)
 {
         struct ptlrpc_request *req;
+        struct obd_device  *obd = exp->exp_obd;
         struct obd_import *imp = class_exp2cliimp(exp);
         struct llog_ctxt *ctxt;
         int rc, size = keylen;
@@ -2718,10 +2719,10 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
             memcmp(key, "next_id", strlen("next_id")) == 0) {
                 if (vallen != sizeof(obd_id))
                         RETURN(-EINVAL);
-               exp->u.eu_osc_data.oed_oscc.oscc_next_id = *((obd_id*)val) + 1;
+               obd->u.cli.cl_oscc.oscc_next_id = *((obd_id*)val) + 1;
                 CDEBUG(D_INODE, "%s: set oscc_next_id = "LPU64"\n",
                        exp->exp_obd->obd_name,
-                       exp->u.eu_osc_data.oed_oscc.oscc_next_id);
+                       obd->u.cli.cl_oscc.oscc_next_id);
 
                 RETURN(0);
         }
@@ -2730,13 +2731,13 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
             memcmp(key, "growth_count", strlen("growth_count")) == 0) {
                 if (vallen != sizeof(int))
                         RETURN(-EINVAL);
-               exp->u.eu_osc_data.oed_oscc.oscc_grow_count = *((int*)val);
+               obd->u.cli.cl_oscc.oscc_grow_count = *((int*)val);
                 RETURN(0);
         }
 
         if (keylen == strlen("unlinked") &&
             memcmp(key, "unlinked", keylen) == 0) {
-                struct osc_creator *oscc = &exp->u.eu_osc_data.oed_oscc;
+                struct osc_creator *oscc = &obd->u.cli.cl_oscc;
                 spin_lock(&oscc->oscc_lock);
                 oscc->oscc_flags &= ~OSCC_FLAG_NOSPC;
                 spin_unlock(&oscc->oscc_lock);
@@ -2778,7 +2779,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
 
         imp->imp_server_timeout = 1;
         CDEBUG(D_HA, "pinging OST %s\n", imp->imp_target_uuid.uuid);
-        ptlrpc_pinger_add_import(imp);
+        imp->imp_pingable = 1;
 
         RETURN(rc);
 }
@@ -2790,7 +2791,7 @@ static struct llog_operations osc_size_repl_logops = {
 
 static struct llog_operations osc_unlink_orig_logops;
 static int osc_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                        int count, struct llog_logid *logid)
+                        int count, struct llog_catid *catid)
 {
         int rc;
         ENTRY;
@@ -2801,8 +2802,8 @@ static int osc_llog_init(struct obd_device *obd, struct obd_device *tgt,
         osc_unlink_orig_logops.lop_add = llog_obd_origin_add;
         osc_unlink_orig_logops.lop_connect = llog_origin_connect;
 
-        rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, count, logid,
-                        &osc_unlink_orig_logops);
+        rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, count,
+                        &catid->lci_logid, &osc_unlink_orig_logops);
         if (rc)
                 RETURN(rc);
 
@@ -2829,15 +2830,9 @@ static int osc_connect(struct lustre_handle *exph,
                        struct obd_device *obd, struct obd_uuid *cluuid)
 {
         int rc;
-        struct obd_export *exp;
 
         rc = client_connect_import(exph, obd, cluuid);
 
-        if (obd->u.cli.cl_conn_count == 1) {
-                exp = class_conn2export(exph);
-                oscc_init(exp);
-        }
-
         return rc;
 }
 
@@ -2847,36 +2842,66 @@ static int osc_disconnect(struct obd_export *exp, int flags)
         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
         int rc;
 
-        if (obd->u.cli.cl_conn_count == 1) {
+        if (obd->u.cli.cl_conn_count == 1)
                 /* flush any remaining cancel messages out to the target */
                 llog_sync(ctxt, exp);
 
-                /* balance the conn2export for oscc in osc_connect */
-                class_export_put(exp);
-        }
-
         rc = client_disconnect_export(exp, flags);
         return rc;
 }
 
-static int osc_invalidate_import(struct obd_device *obd,
-                                 struct obd_import *imp)
+static int osc_import_event(struct obd_device *obd,
+                            struct obd_import *imp, 
+                            enum obd_import_event event)
 {
         struct client_obd *cli;
+        int rc = 0;
+
         LASSERT(imp->imp_obd == obd);
-        /* this used to try and tear down queued pages, but it was
-         * not correctly implemented.  We'll have to do it again once
-         * we call obd_invalidate_import() agian */
-        /* XXX And we still need to do this */
 
-        /* Reset grants, too */
-        cli = &obd->u.cli;
-        spin_lock(&cli->cl_loi_list_lock);
-        cli->cl_avail_grant = 0;
-        cli->cl_lost_grant = 0;
-        spin_unlock(&cli->cl_loi_list_lock);
+        switch (event) {
+        case IMP_EVENT_DISCON: {
+                /* Only do this on the MDS OSC's */
+                if (imp->imp_server_timeout) {
+                        struct osc_creator *oscc = &obd->u.cli.cl_oscc;
+                        
+                        spin_lock(&oscc->oscc_lock);
+                        oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
+                        spin_unlock(&oscc->oscc_lock);
+                }
+                break;
+        }
+        case IMP_EVENT_INVALIDATE: {
+                struct ldlm_namespace *ns = obd->obd_namespace;
 
-        RETURN(0);
+                /* this used to try and tear down queued pages, but it was
+                 * not correctly implemented.  We'll have to do it again once
+                 * we call obd_invalidate_import() agian */
+                /* XXX And we still need to do this */
+
+                /* Reset grants, too */
+                cli = &obd->u.cli;
+                spin_lock(&cli->cl_loi_list_lock);
+                cli->cl_avail_grant = 0;
+                cli->cl_lost_grant = 0;
+                spin_unlock(&cli->cl_loi_list_lock);
+                
+                ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
+
+                if (obd->obd_observer)
+                        rc = obd_notify(obd->obd_observer, obd, 0);
+                break;
+        }
+        case IMP_EVENT_ACTIVE: {
+                if (obd->obd_observer)
+                        rc = obd_notify(obd->obd_observer, obd, 1);
+                break;
+        }
+        default:
+                CERROR("Unknown import event %d\n", event);
+                LBUG();
+        }
+        RETURN(rc);
 }
 
 int osc_setup(struct obd_device *obd, obd_count len, void *buf)
@@ -2890,6 +2915,9 @@ int osc_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = client_obd_setup(obd, len, buf);
         if (rc)
                 ptlrpcd_decref();
+        else
+                oscc_init(obd);
+
         RETURN(rc);
 }
 
@@ -2937,7 +2965,7 @@ struct obd_ops osc_obd_ops = {
         o_iocontrol:    osc_iocontrol,
         o_get_info:     osc_get_info,
         o_set_info:     osc_set_info,
-        o_invalidate_import: osc_invalidate_import,
+        o_import_event: osc_import_event,
         o_llog_init:    osc_llog_init,
         o_llog_finish:  osc_llog_finish,
 };
@@ -2968,7 +2996,7 @@ struct obd_ops sanosc_obd_ops = {
         o_cancel:       osc_cancel,
         o_cancel_unused:osc_cancel_unused,
         o_iocontrol:    osc_iocontrol,
-        o_invalidate_import: osc_invalidate_import,
+        o_import_event: osc_import_event,
         o_llog_init:    osc_llog_init,
         o_llog_finish:  osc_llog_finish,
 };
index 75e83b4..3e5983c 100644 (file)
@@ -234,6 +234,12 @@ extern void kportal_assertion_failed(char *expr, char *file, const char *func,
 #define LASSERTF(cond, fmt...) do { } while (0)
 #endif
 
+#ifdef CONFIG_SMP
+#define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock))
+#else
+#define LASSERT_SPIN_LOCKED(lock) do {} while(0)
+#endif
+
 #ifdef __arch_um__
 #define LBUG_WITH_LOC(file, func, line)                                 \
 do {                                                                    \
index 2ca4dc3..01e690f 100644 (file)
@@ -66,7 +66,8 @@ static int debug_mask = ~0;
 static const char *portal_debug_subsystems[] =
         {"undefined", "mdc", "mds", "osc", "ost", "class", "log", "llite",
          "rpc", "mgmt", "portals", "socknal", "qswnal", "pinger", "filter",
-         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", NULL};
+         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", "ibnal",
+         NULL};
 static const char *portal_debug_masks[] =
         {"trace", "inode", "super", "ext2", "malloc", "cache", "info", "ioctl",
          "blocks", "net", "warning", "buffs", "other", "dentry", "portals",
index eac0e99..8dc4ad0 100644 (file)
@@ -383,7 +383,8 @@ static int ptlrpc_import_delay_req(struct obd_import *imp,
                 *status = -EIO;
         } 
         else if (req->rq_send_state != imp->imp_state) {
-                if (imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) 
+                if (imp->imp_obd->obd_no_recov || imp->imp_dlm_fake 
+                    || req->rq_no_delay) 
                         *status = -EWOULDBLOCK;
                 else
                         delay = 1;
@@ -546,9 +547,13 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
                 req->rq_waiting = 1;
                 spin_unlock (&req->rq_lock);
 
+                DEBUG_REQ(D_HA, req, "req from PID %d waiting for recovery: "
+                          "(%s != %s)",
+                          req->rq_reqmsg->status, 
+                          ptlrpc_import_state_name(req->rq_send_state),
+                          ptlrpc_import_state_name(imp->imp_state));
                 LASSERT(list_empty (&req->rq_list));
 
-                // list_del(&req->rq_list);
                 list_add_tail(&req->rq_list, &imp->imp_delayed_list);
                 spin_unlock_irqrestore(&imp->imp_lock, flags);
                 RETURN(0);
@@ -1055,9 +1060,7 @@ void ptlrpc_free_req(struct ptlrpc_request *request)
 static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked);
 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request)
 {
-#ifdef CONFIG_SMP
-        LASSERT(spin_is_locked(&request->rq_import->imp_lock));
-#endif
+        LASSERT_SPIN_LOCKED(&request->rq_import->imp_lock);
         (void)__ptlrpc_req_finished(request, 1);
 }
 
@@ -1142,9 +1145,7 @@ void ptlrpc_free_committed(struct obd_import *imp)
 
         LASSERT(imp != NULL);
 
-#ifdef CONFIG_SMP
-        LASSERT(spin_is_locked(&imp->imp_lock));
-#endif
+        LASSERT_SPIN_LOCKED(&imp->imp_lock);
 
         CDEBUG(D_HA, "%s: committing for last_committed "LPU64"\n",
                imp->imp_obd->obd_name, imp->imp_peer_committed_transno);
@@ -1213,7 +1214,6 @@ void ptlrpc_resend_req(struct ptlrpc_request *req)
         }
         ptlrpc_wake_client_req(req);
         spin_unlock_irqrestore (&req->rq_lock, flags);
-
 }
 
 /* XXX: this function and rq_status are currently unused */
@@ -1262,9 +1262,7 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
 {
         struct list_head *tmp;
 
-#ifdef CONFIG_SMP
-        LASSERT(spin_is_locked(&imp->imp_lock));
-#endif
+        LASSERT_SPIN_LOCKED(&imp->imp_lock);
 
         /* don't re-add requests that have been replayed */
         if (!list_empty(&req->rq_replay_list))
index b32eb2b..eefae9c 100644 (file)
@@ -102,26 +102,81 @@ int ptlrpc_set_import_discon(struct obd_import *imp)
 
         if (imp->imp_state == LUSTRE_IMP_FULL) {
                 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
+                spin_unlock_irqrestore(&imp->imp_lock, flags); 
+                obd_import_event(imp->imp_obd, imp, IMP_EVENT_DISCON);
                 rc = 1;
         } else {
+                spin_unlock_irqrestore(&imp->imp_lock, flags);
                 CDEBUG(D_HA, "%p %s: import already not connected: %s\n",
                        imp,imp->imp_client->cli_name, 
                        ptlrpc_import_state_name(imp->imp_state));
         }
-        spin_unlock_irqrestore(&imp->imp_lock, flags);
 
         return rc;
 }
 
+void ptlrpc_invalidate_import(struct obd_import *imp)
+{
+        struct obd_device *obd = imp->imp_obd;
+        unsigned long flags;
+        ENTRY;
+
+        spin_lock_irqsave(&imp->imp_lock, flags);
+        /* This is a bit of a hack, but invalidating replayable
+         * imports makes a temporary reconnect failure into a much more
+         * ugly -- and hard to remedy -- situation. */
+        if (!imp->imp_replayable) {
+                CDEBUG(D_HA, "setting import %s INVALID\n",
+                       imp->imp_target_uuid.uuid);
+                imp->imp_invalid = 1;
+        }
+        imp->imp_generation++;
+        spin_unlock_irqrestore(&imp->imp_lock, flags);
+
+        ptlrpc_abort_inflight(imp);
+        obd_import_event(obd, imp, IMP_EVENT_INVALIDATE);
+}
+
+void ptlrpc_validate_import(struct obd_import *imp)
+{
+        struct obd_device *obd = imp->imp_obd;
+        unsigned long flags;
+
+        spin_lock_irqsave(&imp->imp_lock, flags);
+        imp->imp_invalid = 0;
+        spin_unlock_irqrestore(&imp->imp_lock, flags);
+
+        obd_import_event(obd, imp, IMP_EVENT_ACTIVE);
+}
+
 void ptlrpc_fail_import(struct obd_import *imp, int generation)
 {
         ENTRY;
 
         LASSERT (!imp->imp_dlm_fake);
 
-        if (ptlrpc_set_import_discon(imp))
-                ptlrpc_handle_failed_import(imp);
+        if (ptlrpc_set_import_discon(imp)) {
+                unsigned long flags;
 
+                if (!imp->imp_replayable) {
+                        CDEBUG(D_HA, "import %s@%s for %s not replayable, "
+                               "auto-deactivating\n",
+                               imp->imp_target_uuid.uuid,
+                               imp->imp_connection->c_remote_uuid.uuid,
+                               imp->imp_obd->obd_name);
+                        ptlrpc_invalidate_import(imp);
+                }
+                
+                CDEBUG(D_HA, "%s: waking up pinger\n", 
+                       imp->imp_target_uuid.uuid);
+                
+                spin_lock_irqsave(&imp->imp_lock, flags);
+                imp->imp_force_verify = 1;
+                spin_unlock_irqrestore(&imp->imp_lock, flags);
+                
+                ptlrpc_pinger_wake_up();
+                
+        }
         EXIT;
 }
 
@@ -270,13 +325,13 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
                 if (msg_flags & MSG_CONNECT_REPLAYABLE) {
                         CDEBUG(D_HA, "connected to replayable target: %s\n",
                                imp->imp_target_uuid.uuid);
-                        imp->imp_replayable = 1;
-                        ptlrpc_pinger_add_import(imp);
+                        imp->imp_pingable = imp->imp_replayable = 1;
                 } else {
                         imp->imp_replayable = 0;
                 }
                 imp->imp_remote_handle = request->rq_repmsg->handle;
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
+                ptlrpc_pinger_add_import(imp);
                 GOTO(finish, rc = 0);
         }
 
@@ -338,9 +393,8 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
 finish:
         rc = ptlrpc_import_recovery_state_machine(imp);
         if (rc != 0) {
-                if (aa->pcaa_was_invalid) {
-                        ptlrpc_set_import_active(imp, 0);
-                }                
+                if (aa->pcaa_was_invalid)
+                        ptlrpc_invalidate_import(imp);
 
                 if (rc == -ENOTCONN) {
                         CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery;"
@@ -355,17 +409,13 @@ finish:
         if (rc != 0) {
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
                 if (aa->pcaa_initial_connect && !imp->imp_initial_recov) {
-                        ptlrpc_set_import_active(imp, 0);
-                        GOTO(norecov, rc);
+                        ptlrpc_invalidate_import(imp);
                 }
-                CDEBUG(D_ERROR, 
-                       "recovery of %s on %s failed (%d); restarting\n",
+                CDEBUG(D_ERROR, "recovery of %s on %s failed (%d)\n",
                        imp->imp_target_uuid.uuid,
                        (char *)imp->imp_connection->c_remote_uuid.uuid, rc);
-                ptlrpc_handle_failed_import(imp);
         }
 
-norecov:
         wake_up(&imp->imp_recovery_waitq);
         RETURN(rc);
 }
@@ -410,7 +460,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
                 CDEBUG(D_HA, "evicted from %s@%s; invalidating\n",
                        imp->imp_target_uuid.uuid,
                        imp->imp_connection->c_remote_uuid.uuid);
-                ptlrpc_set_import_active(imp, 0);
+                ptlrpc_invalidate_import(imp);
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
         } 
         
@@ -449,7 +499,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
                        imp->imp_target_uuid.uuid,
                        imp->imp_connection->c_remote_uuid.uuid);
 
-                ptlrpc_set_import_active(imp, 1);
+                ptlrpc_validate_import(imp);
                 rc = ptlrpc_resend(imp);
                 if (rc)
                         GOTO(out, rc);
@@ -509,8 +559,9 @@ int ptlrpc_disconnect_import(struct obd_import *imp)
                 /* For non-replayable connections, don't attempt
                    reconnect if this fails */
                 if (!imp->imp_replayable) {
-                        IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
-                        request->rq_send_state =  LUSTRE_IMP_DISCON;
+                        request->rq_no_resend = 1;
+                        IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
+                        request->rq_send_state =  LUSTRE_IMP_CONNECTING;
                 }
                 request->rq_replen = lustre_msg_size(0, NULL);
                 rc = ptlrpc_queue_wait(request);
index a15f67c..681c982 100644 (file)
@@ -185,7 +185,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req)
         struct obd_run_ctxt saved;
         struct llog_ctxt *ctxt;
         __u32 flags;
-        __u8 *buf;
         int size[] = {sizeof (*hdr)};
         int rc, rc2;
         ENTRY;
@@ -197,10 +196,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req)
                 GOTO(out, rc =-EFAULT);
         }
 
-        OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
-        if (!buf)
-                GOTO(out, rc = -ENOMEM);
-
         ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
         LASSERT(ctxt != NULL);
         disk_obd = ctxt->loc_exp->exp_obd;
@@ -216,7 +211,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req)
         if (rc)
                 GOTO(out_close, rc);
 
-
         rc = lustre_pack_reply(req, 1, size, NULL);
         if (rc)
                 GOTO(out_close, rc = -ENOMEM);
@@ -231,7 +225,6 @@ out_close:
 
 out_pop:
         pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
-        OBD_FREE(buf, LLOG_CHUNK_SIZE);
 
 out:
         RETURN(rc);
@@ -431,8 +424,9 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf,
         struct llog_handle *handle;
         struct obd_run_ctxt saved;
         int size, i, count;
-        struct llog_logid *idarray, *id;
-        char name[32] = "CATLIST";
+        struct llog_catid *idarray;
+        struct llog_logid *id;
+        char name[32] = CATLIST;
         int rc;
         struct cb_data data;
         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
@@ -446,7 +440,6 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf,
         OBD_ALLOC(idarray, size);
         if (!idarray)
                 RETURN(-ENOMEM);
-        memset(idarray, 0, size);
 
         rc = llog_get_cat_list(obd, obd, name, count, idarray);
         if (rc)
@@ -454,12 +447,13 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf,
 
         push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL);
 
-        id = idarray;
         data.ctxt = ctxt;
         data.out = buf;
         data.remains = buf_len;
         for (i = 0; i < count; i++) {
                 int l, index, uncanceled = 0;
+
+                id = &idarray[i].lci_logid;
                 rc = llog_create(ctxt, &handle, id, NULL);
                 if (rc)
                         GOTO(out_pop, rc);
index c25db89..d1a92f6 100644 (file)
@@ -438,10 +438,8 @@ int ptl_send_rpc(struct ptlrpc_request *request)
         LASSERT (request->rq_replen != 0);
         if (request->rq_repmsg == NULL)
                 OBD_ALLOC(request->rq_repmsg, request->rq_replen);
-        if (request->rq_repmsg == NULL) {
-                LBUG();
+        if (request->rq_repmsg == NULL)
                 GOTO(cleanup_bulk, rc = -ENOMEM);
-        }
 
         rc = PtlMEAttach(connection->c_peer.peer_ni->pni_ni_h,
                          request->rq_reply_portal, /* XXX FIXME bug 249 */
@@ -450,7 +448,6 @@ int ptl_send_rpc(struct ptlrpc_request *request)
         if (rc != PTL_OK) {
                 CERROR("PtlMEAttach failed: %d\n", rc);
                 LASSERT (rc == PTL_NOSPACE);
-                LBUG();
                 GOTO(cleanup_repmsg, rc = -ENOMEM);
         }
 
@@ -477,7 +474,6 @@ int ptl_send_rpc(struct ptlrpc_request *request)
         if (rc != PTL_OK) {
                 CERROR("PtlMDAttach failed: %d\n", rc);
                 LASSERT (rc == PTL_NOSPACE);
-                LBUG();
                 GOTO(cleanup_me, rc -ENOMEM);
         }
 
index 29c8e9c..b10f76d 100644 (file)
@@ -665,8 +665,8 @@ void lustre_swab_llogd_conn_body (struct llogd_conn_body *d)
 void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
-         * running on Linux adevi 2.4.18-p4smp-10pre1 #1 SMP Thu Feb 5 14:52:15 PST 2004 i686 unknown
-         * with gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) */
+         * running on Linux schnapps.adilger.int 2.4.22-l32 #4 Thu Jan 8 14:32:57 MST 2004 i686 i686 
+         * with gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) */
 
 
         /* Constants... */
@@ -1820,9 +1820,17 @@ void lustre_assert_wire_constants(void)
                  (long long)LLOG_GEN_REC);
         LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n",
                  (long long)LLOG_HDR_MAGIC);
-        LASSERTF(LLOG_LOGID_MAGIC == 275010874, " found %lld\n",
+        LASSERTF(LLOG_LOGID_MAGIC == 275010875, " found %lld\n",
                  (long long)LLOG_LOGID_MAGIC);
 
+        /* Checks for struct llog_catid */
+        LASSERTF((int)sizeof(struct llog_catid) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct llog_catid));
+        LASSERTF(offsetof(struct llog_catid, lci_logid) == 0, " found %lld\n",
+                 (long long)offsetof(struct llog_catid, lci_logid));
+        LASSERTF((int)sizeof(((struct llog_catid *)0)->lci_logid) == 20, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_catid *)0)->lci_logid));
+
         /* Checks for struct llog_rec_hdr */
         LASSERTF((int)sizeof(struct llog_rec_hdr) == 16, " found %lld\n",
                  (long long)(int)sizeof(struct llog_rec_hdr));
@@ -1852,7 +1860,7 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_index));
 
         /* Checks for struct llog_logid_rec */
-        LASSERTF((int)sizeof(struct llog_logid_rec) == 48, " found %lld\n",
+        LASSERTF((int)sizeof(struct llog_logid_rec) == 64, " found %lld\n",
                  (long long)(int)sizeof(struct llog_logid_rec));
         LASSERTF(offsetof(struct llog_logid_rec, lid_hdr) == 0, " found %lld\n",
                  (long long)offsetof(struct llog_logid_rec, lid_hdr));
@@ -1862,7 +1870,7 @@ void lustre_assert_wire_constants(void)
                  (long long)offsetof(struct llog_logid_rec, lid_id));
         LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_id));
-        LASSERTF(offsetof(struct llog_logid_rec, lid_tail) == 40, " found %lld\n",
+        LASSERTF(offsetof(struct llog_logid_rec, lid_tail) == 56, " found %lld\n",
                  (long long)offsetof(struct llog_logid_rec, lid_tail));
         LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_tail));
index ab85900..ab0f7b2 100644 (file)
@@ -41,6 +41,32 @@ static struct list_head pinger_imports = LIST_HEAD_INIT(pinger_imports);
 #ifdef __KERNEL__
 static struct ptlrpc_thread *pinger_thread = NULL;
 
+int ptlrpc_ping(struct obd_import *imp) 
+{
+        struct ptlrpc_request *req;
+        int rc = 0;
+        ENTRY;
+
+        req = ptlrpc_prep_req(imp, OBD_PING, 0, NULL,
+                              NULL);
+        if (req) {
+                DEBUG_REQ(D_HA, req, "pinging %s->%s",
+                          imp->imp_obd->obd_uuid.uuid,
+                          imp->imp_target_uuid.uuid);
+                req->rq_no_resend = req->rq_no_delay = 1;
+                req->rq_replen = lustre_msg_size(0, 
+                                                 NULL);
+                ptlrpcd_add_req(req);
+        } else {
+                CERROR("OOM trying to ping %s->%s\n",
+                          imp->imp_obd->obd_uuid.uuid,
+                          imp->imp_target_uuid.uuid);
+                rc = -ENOMEM;
+        }
+
+        RETURN(rc);
+}
+
 static int ptlrpc_pinger_main(void *arg)
 {
         struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg;
@@ -69,112 +95,52 @@ static int ptlrpc_pinger_main(void *arg)
                 long time_to_next_ping;
                 struct l_wait_info lwi = LWI_TIMEOUT(obd_timeout * HZ,
                                                      NULL, NULL);
-                struct ptlrpc_request_set *set;
-                struct ptlrpc_request *req;
                 struct list_head *iter;
-                wait_queue_t set_wait;
-                int rc;
 
-                set = ptlrpc_prep_set();
                 down(&pinger_sem);
                 list_for_each(iter, &pinger_imports) {
                         struct obd_import *imp =
                                 list_entry(iter, struct obd_import,
                                            imp_pinger_chain);
-                        int generation, level;
+                        int force, level;
                         unsigned long flags;
 
-                        if (imp->imp_next_ping <= this_ping) {
-                                /* Add a ping. */
-                                spin_lock_irqsave(&imp->imp_lock, flags);
-                                generation = imp->imp_generation;
-                                level = imp->imp_state;
-                                spin_unlock_irqrestore(&imp->imp_lock, flags);
-
-                                if (level != LUSTRE_IMP_FULL) {
-                                        CDEBUG(D_HA,
-                                               "not pinging %s (in recovery)\n",
-                                               imp->imp_target_uuid.uuid);
-                                        continue;
-                                }
-
-                                req = ptlrpc_prep_req(imp, OBD_PING, 0, NULL,
-                                                      NULL);
-                                if (!req) {
-                                        CERROR("OOM trying to ping\n");
-                                        break;
-                                }
-                                req->rq_no_resend = 1;
-                                req->rq_replen = lustre_msg_size(0, NULL);
-                                req->rq_send_state = LUSTRE_IMP_FULL;
-                                req->rq_phase = RQ_PHASE_RPC;
-                                req->rq_import_generation = generation;
-                                ptlrpc_set_add_req(set, req);
-                        } else {
-                                CDEBUG(D_HA, "don't need to ping %s (%lu > "
-                                       "%lu)\n", imp->imp_target_uuid.uuid,
-                                       imp->imp_next_ping, this_ping);
-                        }
-                }
-                up(&pinger_sem);
-
-                /* Might be empty, that's OK. */
-                if (set->set_remaining == 0)
-                        CDEBUG(D_HA, "nothing to ping\n");
-                list_for_each(iter, &set->set_requests) {
-                        struct ptlrpc_request *req =
-                                list_entry(iter, struct ptlrpc_request,
-                                           rq_set_chain);
-                        DEBUG_REQ(D_HA, req, "pinging %s->%s",
-                                  req->rq_import->imp_obd->obd_uuid.uuid,
-                                  req->rq_import->imp_target_uuid.uuid);
-                        (void)ptl_send_rpc(req);
-                }
-
-                /* Have to wait on both the thread's queue and the set's. */
-                init_waitqueue_entry(&set_wait, current);
-                add_wait_queue(&set->set_waitq, &set_wait);
-                rc = l_wait_event(thread->t_ctl_waitq,
-                                  thread->t_flags & SVC_STOPPING ||
-                                  ptlrpc_check_set(set),
-                                  &lwi);
-                remove_wait_queue(&set->set_waitq, &set_wait);
-                CDEBUG(D_HA, "ping complete (%lu)\n", jiffies);
-
-                if (thread->t_flags & SVC_STOPPING) {
-                        thread->t_flags &= ~SVC_STOPPING;
-                        list_for_each(iter, &set->set_requests) {
-                                req = list_entry(iter, struct ptlrpc_request,
-                                                 rq_set_chain);
-                                if (!req->rq_replied)
-                                        ptlrpc_unregister_reply(req);
-                        }
-                        ptlrpc_set_destroy(set);
-                        EXIT;
-                        break;
-                }
 
-                /* Expire all the requests that didn't come back. */
-                down(&pinger_sem);
-                list_for_each(iter, &set->set_requests) {
-                        req = list_entry(iter, struct ptlrpc_request,
-                                         rq_set_chain);
+                        spin_lock_irqsave(&imp->imp_lock, flags);
+                        level = imp->imp_state;
+                        force = imp->imp_force_verify;
+                        if (force)
+                                imp->imp_force_verify = 0;
+                        spin_unlock_irqrestore(&imp->imp_lock, flags);
 
-                        if (req->rq_replied)
-                                continue;
+                        if (imp->imp_next_ping <= this_ping || force) {
+                                if (level == LUSTRE_IMP_DISCON) {
+                                        /* wait at least a timeout before 
+                                           trying recovery again. */
+                                        imp->imp_next_ping = jiffies + 
+                                                (obd_timeout * HZ);
+                                        ptlrpc_initiate_recovery(imp);
+                                } 
+                                else if (level != LUSTRE_IMP_FULL) {
+                                        CDEBUG(D_HA, 
+                                               "not pinging %s " 
+                                               "(in recovery: %s)\n",
+                                               imp->imp_target_uuid.uuid,
+                                               ptlrpc_import_state_name(level));
+                                } 
+                                else if (imp->imp_pingable || force) {
+                                        ptlrpc_ping(imp);
+                                }
 
-                        req->rq_phase = RQ_PHASE_COMPLETE;
-                        set->set_remaining--;
-                        /* If it was disconnected, don't sweat it. */
-                        if (list_empty(&req->rq_import->imp_pinger_chain)) {
-                                ptlrpc_unregister_reply(req);
-                                continue;
+                        } else {
+                                if (imp->imp_pingable)
+                                        CDEBUG(D_HA, "don't need to ping %s "
+                                               "(%lu > %lu)\n", 
+                                               imp->imp_target_uuid.uuid,
+                                               imp->imp_next_ping, this_ping);
                         }
-
-                        ptlrpc_expire_one_request(req);
                 }
                 up(&pinger_sem);
-                ptlrpc_set_destroy(set);
 
                 /* Wait until the next ping time, or until we're stopped. */
                 time_to_next_ping = this_ping + (obd_timeout * HZ) - jiffies;
@@ -283,10 +249,7 @@ int ptlrpc_pinger_add_import(struct obd_import *imp)
         list_add_tail(&imp->imp_pinger_chain, &pinger_imports);
         class_import_get(imp);
 
-#ifdef ENABLE_PINGER
-        pinger_thread->t_flags |= SVC_EVENT;
-        wake_up(&pinger_thread->t_ctl_waitq);
-#endif
+        ptlrpc_pinger_wake_up();
         up(&pinger_sem);
 
         RETURN(0);
@@ -307,6 +270,14 @@ int ptlrpc_pinger_del_import(struct obd_import *imp)
         RETURN(0);
 }
 
+void ptlrpc_pinger_wake_up()
+{
+#ifdef ENABLE_PINGER
+        pinger_thread->t_flags |= SVC_EVENT;
+        wake_up(&pinger_thread->t_ctl_waitq);
+#endif
+}
+
 #else
 /* XXX
  * the current implementation of pinger in liblustre is not optimized
@@ -522,4 +493,10 @@ int ptlrpc_pinger_del_import(struct obd_import *imp)
         RETURN(0);
 }
 
+void ptlrpc_pinger_wake_up()
+{
+#ifdef ENABLE_PINGER
+        /* XXX force pinger to run, if needed */
+#endif
+}
 #endif /* !__KERNEL__ */
index a78cd0d..021fb0f 100644 (file)
@@ -40,6 +40,7 @@ int ptlrpc_import_in_recovery(struct obd_import *imp);
 int ptlrpc_set_import_discon(struct obd_import *imp);
 void ptlrpc_handle_failed_import(struct obd_import *imp);
 int ptlrpc_replay_next(struct obd_import *imp, int *inflight);
+void ptlrpc_initiate_recovery(struct obd_import *imp);
 
 
 #ifdef __KERNEL__
@@ -111,5 +112,6 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req);
 int ptlrpc_start_pinger(void);
 int ptlrpc_stop_pinger(void);
 void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
+void ptlrpc_pinger_wake_up(void);
 
 #endif /* PTLRPC_INTERNAL_H */
index 87b385d..dfb9635 100644 (file)
@@ -181,6 +181,7 @@ EXPORT_SYMBOL(ptlrpc_disconnect_import);
 EXPORT_SYMBOL(ptlrpc_resend);
 EXPORT_SYMBOL(ptlrpc_wake_delayed);
 EXPORT_SYMBOL(ptlrpc_set_import_active);
+EXPORT_SYMBOL(ptlrpc_invalidate_import);
 EXPORT_SYMBOL(ptlrpc_fail_import);
 EXPORT_SYMBOL(ptlrpc_fail_export);
 EXPORT_SYMBOL(ptlrpc_recover_import);
index 7eea191..1ff5f30 100644 (file)
@@ -121,6 +121,32 @@ void ptlrpc_run_failed_import_upcall(struct obd_import* imp)
 #endif
 }
 
+/* This might block waiting for the upcall to start, so it should
+ * not be called from a thread that shouldn't block. (Like ptlrpcd) */
+void ptlrpc_initiate_recovery(struct obd_import *imp)
+{
+        ENTRY;
+
+        LASSERT (obd_lustre_upcall != NULL);
+        
+        if (strcmp(obd_lustre_upcall, "DEFAULT") == 0) {
+                CDEBUG(D_ERROR, "%s: starting recovery without upcall\n",
+                        imp->imp_target_uuid.uuid);
+                ptlrpc_connect_import(imp, NULL);
+        } 
+        else if (strcmp(obd_lustre_upcall, "NONE") == 0) {
+                CDEBUG(D_ERROR, "%s: recovery diabled\n",
+                        imp->imp_target_uuid.uuid);
+        } 
+        else {
+                CDEBUG(D_ERROR, "%s: calling upcall to start recovery\n",
+                        imp->imp_target_uuid.uuid);
+                ptlrpc_run_failed_import_upcall(imp);
+        }
+
+        EXIT;
+}
+
 int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
 {
         int rc = 0;
@@ -220,35 +246,6 @@ void ptlrpc_wake_delayed(struct obd_import *imp)
         spin_unlock_irqrestore(&imp->imp_lock, flags);
 }
 
-inline void ptlrpc_invalidate_import_state(struct obd_import *imp)
-{
-        struct obd_device *obd = imp->imp_obd;
-        struct ldlm_namespace *ns = obd->obd_namespace;
-
-        ptlrpc_abort_inflight(imp);
-
-        obd_invalidate_import(obd, imp);
-
-        ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
-}
-
-void ptlrpc_handle_failed_import(struct obd_import *imp)
-{
-        ENTRY;
-
-        if (!imp->imp_replayable) {
-                CDEBUG(D_HA,
-                       "import %s@%s for %s not replayable, deactivating\n",
-                       imp->imp_target_uuid.uuid,
-                       imp->imp_connection->c_remote_uuid.uuid,
-                       imp->imp_obd->obd_name);
-                ptlrpc_set_import_active(imp, 0);
-        }
-
-        ptlrpc_run_failed_import_upcall(imp);
-        EXIT;
-}
-
 void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req)
 {
         int rc;
@@ -275,43 +272,41 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req)
         EXIT;
 }
 
+/*
+ * This should only be called by the ioctl interface, currently
+ * with the lctl deactivate and activate commands.
+ */
 int ptlrpc_set_import_active(struct obd_import *imp, int active)
 {
         struct obd_device *obd = imp->imp_obd;
         unsigned long flags;
+        int rc = 0;
 
         LASSERT(obd);
 
         /* When deactivating, mark import invalid, and abort in-flight
          * requests. */
         if (!active) {
-                spin_lock_irqsave(&imp->imp_lock, flags);
-                /* This is a bit of a hack, but invalidating replayable
-                 * imports makes a temporary reconnect failure into a much more
-                 * ugly -- and hard to remedy -- situation. */
-                if (!imp->imp_replayable) {
-                        CDEBUG(D_HA, "setting import %s INVALID\n",
-                               imp->imp_target_uuid.uuid);
-                        imp->imp_invalid = 1;
-                }
-                imp->imp_generation++;
-                spin_unlock_irqrestore(&imp->imp_lock, flags);
-                ptlrpc_invalidate_import_state(imp);
-        }
+                ptlrpc_invalidate_import(imp);
+        } 
 
-        /* When activating, mark import valid */
+        /* When activating, mark import valid, and attempt recovery */
         if (active) {
                 CDEBUG(D_HA, "setting import %s VALID\n",
                        imp->imp_target_uuid.uuid);
                 spin_lock_irqsave(&imp->imp_lock, flags);
                 imp->imp_invalid = 0;
                 spin_unlock_irqrestore(&imp->imp_lock, flags);
-        }
 
-        if (obd->obd_observer)
-                RETURN(obd_notify(obd->obd_observer, obd, active));
+                rc = ptlrpc_recover_import(imp, NULL);
+                if (rc) {
+                        spin_lock_irqsave(&imp->imp_lock, flags);
+                        imp->imp_invalid = 1;
+                        spin_unlock_irqrestore(&imp->imp_lock, flags);
+                }
+        }
 
-        RETURN(0);
+        RETURN(rc);
 }
 
 int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid)
index 0c07803..16f6b20 100755 (executable)
@@ -25,6 +25,17 @@ CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
 date=`date +%Y%m%d_%H%M`
 module=lustre
 
+case $parent in
+  HEAD) : ;;
+  b_*|b1*) : ;;
+  *) parent="b_$parent" ;;
+esac
+case $child in
+  HEAD) : ;;
+  b_*|b1*) : ;;
+  *) child="b_$child"
+esac
+
 if [ "$parent" != "HEAD" -a "`cat CVS/Tag`" != "T$parent" ]; then
         echo "This script must be run within the $parent branch"
        exit 1
@@ -32,13 +43,6 @@ fi
 
 dir=$3
 
-if [ $parent != "HEAD" ]; then
-  parent="b_$parent"
-fi
-if [ $child != "HEAD" ]; then
-  child="b_$child"
-fi
-
 cat << EOF > .mergeinfo
 parent=$parent
 PARENT=$PARENT
@@ -90,4 +94,3 @@ fi
 echo "done"
 
 echo "Test, commit and then run land2.sh (no arguments)"
-
index 4a465ad..297de89 100644 (file)
@@ -1,5 +1,5 @@
 # lustre.spec
-%define version b1_2
+%define version 4pre1.2.0
 %define kversion @LINUXRELEASE@
 %define linuxdir @LINUX@
 %define enable_doc @ENABLE_DOC@
index 9380a2d..bbfdbcf 100644 (file)
@@ -14,6 +14,7 @@ PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 RLUSTRE=${RLUSTRE:-$LUSTRE}
+MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
 
 . $LUSTRE/tests/test-framework.sh
 
@@ -534,4 +535,31 @@ test_14() {
 }
 run_test 14 "test mkfsoptions of ost for lmc and lconf"
 
+test_15() {
+        start_ost
+        start_mds
+        echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE....."
+        [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
+        [ ! `cp $LUSTRE/utils/llmount $MOUNTLUSTRE` ] || return $?
+        do_node `hostname` mkdir $MOUNT 2> /dev/null || :
+        do_node `hostname` mount -t lustre -o nettype=$NETTYPE `facet_active_host mds`:/mds_svc/client_facet $MOUNT || return $?
+        echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE: success"
+        [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
+        check_mount || return 41
+        cleanup || return $?
+
+        start_ost
+        start_mds
+        [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
+        echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
+        do_node `hostname` mkdir $MOUNT 2> /dev/null || :
+        do_node `hostname` mount -t lustre -o nettype=$NETTYPE `facet_active_host mds`:/mds_svc/client_facet $MOUNT && return $?
+        echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE should return error: success"
+        [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
+        check_mount || return 41
+        cleanup || return $?
+
+}
+run_test 15 "zconf-mount without /sbin/mount.lustre, should return error"
+
 equals_msg "Done"
index 1d4d976..5cd1e62 100755 (executable)
@@ -91,6 +91,7 @@ run_test 4 "open: drop req, drop rep"
 test_5() {
     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
     drop_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
+    do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
 }
 run_test 5 "rename: drop req, drop rep"
 
@@ -155,11 +156,12 @@ run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
 #b=2494
 test_12(){
     $LCTL mark multiop $MOUNT/$tfile OS_c 
+    do_facet mds "sysctl -w lustre.fail_loc=0x115"
+    clear_failloc mds $((TIMEOUT * 2)) &
     multiop $MOUNT/$tfile OS_c  &
     PID=$!
 #define OBD_FAIL_MDS_CLOSE_NET           0x115
-    do_facet mds "sysctl -w lustre.fail_loc=0x115"
-    clear_failloc mds $((TIMEOUT * 2)) &
+    sleep 2
     kill -USR1 $PID
     echo "waiting for multiop $PID"
     wait $PID || return 2
index ea4810e..9b57fd2 100644 (file)
@@ -697,7 +697,7 @@ run_test 26e "unlink multiple component recursive symlink ======"
 test_27a() {
        echo '== stripe sanity =============================================='
        mkdir $DIR/d27
-       $LSTRIPE $DIR/d27/f0 8192 0 1 || error
+       $LSTRIPE $DIR/d27/f0 65536 0 1 || error
        $CHECKSTAT -t file $DIR/d27/f0 || error
        pass
        log "== test_27b: write to one stripe file ========================="
@@ -710,7 +710,7 @@ test_27c() {
        if [ ! -d $DIR/d27 ]; then
                mkdir $DIR/d27
        fi
-       $LSTRIPE $DIR/d27/f01 8192 0 2 || error
+       $LSTRIPE $DIR/d27/f01 65536 0 2 || error
        [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
                error "two-stripe file doesn't have two stripes"
        pass
@@ -733,8 +733,8 @@ test_27e() {
        if [ ! -d $DIR/d27 ]; then
                mkdir $DIR/d27
        fi
-       $LSTRIPE $DIR/d27/f12 8192 0 2 || error
-       $LSTRIPE $DIR/d27/f12 8192 0 2 && error
+       $LSTRIPE $DIR/d27/f12 65536 0 2 || error
+       $LSTRIPE $DIR/d27/f12 65536 0 2 && error
        $CHECKSTAT -t file $DIR/d27/f12 || error
 }
 run_test 27e "lstripe existing file (should return error) ======"
@@ -768,7 +768,7 @@ test_27j() {
         if [ ! -d $DIR/d27 ]; then
                 mkdir $DIR/d27
         fi
-        $LSTRIPE $DIR/d27/f27j 8192 $STRIPECOUNT 1 && error || true
+        $LSTRIPE $DIR/d27/f27j 65536 $STRIPECOUNT 1 && error || true
 }
 run_test 27j "lstripe with bad stripe offset (should return error)"
 
index 6c8172b..7a333af 100644 (file)
@@ -214,7 +214,7 @@ test_9() {
                [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
        done
        [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
-               error "`od -a $DIR1/f10` != abcdefghijkl"
+               error "`od -a $DIR1/f9` != abcdefghijkl"
 }
 run_test 9 "append of file with sub-page size on multiple mounts"
 
index 2f35ded..4143d02 100644 (file)
@@ -70,6 +70,7 @@ int
 init_options(struct lustre_mount_data *lmd)
 {
         memset(lmd, 0, sizeof(lmd));
+        lmd->lmd_magic = LMD_MAGIC;
         lmd->lmd_server_nid = PTL_NID_ANY;
         lmd->lmd_local_nid = PTL_NID_ANY;
         lmd->lmd_port = 988;    /* XXX define LUSTRE_DEFAULT_PORT */
@@ -98,7 +99,7 @@ parse_options(char * options, struct lustre_mount_data *lmd)
         int val;
         char *opt;
         char * opteq;
-        
+
         /* parsing ideas here taken from util-linux/mount/nfsmount.c */
         for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
                 if ((opteq = strchr(opt, '='))) {
@@ -192,7 +193,7 @@ set_local(struct lustre_mount_data *lmd)
                         rc = get_local_elan_id(pfiles[i], buf);
                 } while (rc != 0 &&
                          pfiles[++i] != NULL);
-                
+
                 if (rc != 0) {
                         fprintf(stderr, "mount: can't read elan ID"
                                 " from /proc\n");
@@ -201,7 +202,7 @@ set_local(struct lustre_mount_data *lmd)
         }
 
         if (ptl_parse_nid (&nid, buf) != 0) {
-                fprintf (stderr, "mount: can't parse NID %s\n", 
+                fprintf (stderr, "mount: can't parse NID %s\n",
                          buf);
                 return (-1);
         }
@@ -261,6 +262,9 @@ build_data(char *source, char *options, struct lustre_mount_data *lmd)
         char *s;
         int rc;
 
+        if (lmd_bad_magic(lmd))
+                return -EINVAL;
+
         if (strlen(source) > sizeof(target) + 1) {
                 fprintf(stderr, "mount: "
                         "exessively long host:/mds/profile argument\n");
@@ -315,7 +319,6 @@ build_data(char *source, char *options, struct lustre_mount_data *lmd)
         }
         strcpy(lmd->lmd_profile, profile);
 
-        
         if (verbose)
                 print_options(lmd);
         return 0;
index 907e353..b94fddb 100644 (file)
@@ -523,6 +523,14 @@ check_llog_logid(void)
 }
 
 void
+check_llog_catid(void)
+{
+        BLANK_LINE();
+        CHECK_STRUCT(llog_catid);
+        CHECK_MEMBER(llog_catid, lci_logid);
+}
+
+void
 check_llog_rec_hdr(void)
 {
         BLANK_LINE();
@@ -878,6 +886,7 @@ main(int argc, char **argv)
         check_ptlbd_niob();
         check_ptlbd_rsp();
         check_llog_logid();
+        check_llog_catid();
         check_llog_rec_hdr();
         check_llog_rec_tail();
         check_llog_logid_rec();
index 0bbc4a3..f28a235 100644 (file)
@@ -25,8 +25,8 @@ int main()
 void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
-         * running on Linux adevi 2.4.18-p4smp-10pre1 #1 SMP Thu Feb 5 14:52:15 PST 2004 i686 unknown
-         * with gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) */
+         * running on Linux schnapps.adilger.int 2.4.22-l32 #4 Thu Jan 8 14:32:57 MST 2004 i686 i686 
+         * with gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) */
 
 
         /* Constants... */
@@ -1180,9 +1180,17 @@ void lustre_assert_wire_constants(void)
                  (long long)LLOG_GEN_REC);
         LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n",
                  (long long)LLOG_HDR_MAGIC);
-        LASSERTF(LLOG_LOGID_MAGIC == 275010874, " found %lld\n",
+        LASSERTF(LLOG_LOGID_MAGIC == 275010875, " found %lld\n",
                  (long long)LLOG_LOGID_MAGIC);
 
+        /* Checks for struct llog_catid */
+        LASSERTF((int)sizeof(struct llog_catid) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct llog_catid));
+        LASSERTF(offsetof(struct llog_catid, lci_logid) == 0, " found %lld\n",
+                 (long long)offsetof(struct llog_catid, lci_logid));
+        LASSERTF((int)sizeof(((struct llog_catid *)0)->lci_logid) == 20, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_catid *)0)->lci_logid));
+
         /* Checks for struct llog_rec_hdr */
         LASSERTF((int)sizeof(struct llog_rec_hdr) == 16, " found %lld\n",
                  (long long)(int)sizeof(struct llog_rec_hdr));
@@ -1212,7 +1220,7 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_index));
 
         /* Checks for struct llog_logid_rec */
-        LASSERTF((int)sizeof(struct llog_logid_rec) == 48, " found %lld\n",
+        LASSERTF((int)sizeof(struct llog_logid_rec) == 64, " found %lld\n",
                  (long long)(int)sizeof(struct llog_logid_rec));
         LASSERTF(offsetof(struct llog_logid_rec, lid_hdr) == 0, " found %lld\n",
                  (long long)offsetof(struct llog_logid_rec, lid_hdr));
@@ -1222,7 +1230,7 @@ void lustre_assert_wire_constants(void)
                  (long long)offsetof(struct llog_logid_rec, lid_id));
         LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_id));
-        LASSERTF(offsetof(struct llog_logid_rec, lid_tail) == 40, " found %lld\n",
+        LASSERTF(offsetof(struct llog_logid_rec, lid_tail) == 56, " found %lld\n",
                  (long long)offsetof(struct llog_logid_rec, lid_tail));
         LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_tail));