Whamcloud - gitweb
Put checks for LOV magic into LOV code, what a good idea.
authoradilger <adilger>
Mon, 16 Sep 2002 22:46:35 +0000 (22:46 +0000)
committeradilger <adilger>
Mon, 16 Sep 2002 22:46:35 +0000 (22:46 +0000)
lustre/lov/lov_obd.c

index 36d5226..9c54c6a 100644 (file)
@@ -219,9 +219,10 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa,
         ENTRY;
 
         if (!ea) {
-                CERROR("lov_create needs EA for striping information\n");
+                CERROR("lov_create needs ea\n");
                 RETURN(-EINVAL);
         }
+
         if (!export)
                 RETURN(-EINVAL);
 
@@ -315,6 +316,12 @@ static int lov_destroy(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         if (!export || !export->exp_obd)
                 RETURN(-ENODEV);
 
@@ -348,6 +355,12 @@ static int lov_getattr(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         if (!export || !export->exp_obd)
                 RETURN(-ENODEV);
 
@@ -408,10 +421,16 @@ static int lov_setattr(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         if (!export || !export->exp_obd)
                 RETURN(-ENODEV);
 
-        if (oa->o_valid && OBD_MD_FLSIZE)
+        if (oa->o_valid & OBD_MD_FLSIZE)
                 CERROR("setting size on an LOV object is totally broken\n");
 
         lov = &export->exp_obd->u.lov;
@@ -449,6 +468,12 @@ static int lov_open(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         if (!export || !export->exp_obd)
                 RETURN(-ENODEV);
 
@@ -495,6 +520,12 @@ static int lov_close(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         if (!export || !export->exp_obd)
                 RETURN(-ENODEV);
 
@@ -573,7 +604,13 @@ static int lov_punch(struct lustre_handle *conn, struct obdo *oa,
         ENTRY;
 
         if (!lsm) {
-                CERROR("LOV requires striping ea for desctruction\n");
+                CERROR("LOV requires striping ea\n");
+                RETURN(-EINVAL);
+        }
+
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
                 RETURN(-EINVAL);
         }
 
@@ -647,6 +684,17 @@ static inline int lov_brw(int cmd, struct lustre_handle *conn,
         int *where;
         ENTRY;
 
+        if (!lsm) {
+                CERROR("LOV requires striping ea\n");
+                RETURN(-EINVAL);
+        }
+
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
+                RETURN(-EINVAL);
+        }
+
         lov = &export->exp_obd->u.lov;
 
         our_cb = ll_init_cb();
@@ -732,7 +780,13 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *lsm,
         ENTRY;
 
         if (!lsm) {
-                CERROR("LOV requires striping ea for desctruction\n");
+                CERROR("LOV requires striping ea\n");
+                RETURN(-EINVAL);
+        }
+
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
                 RETURN(-EINVAL);
         }
 
@@ -779,7 +833,13 @@ static int lov_cancel(struct lustre_handle *conn, struct lov_stripe_md *lsm,
         ENTRY;
 
         if (!lsm) {
-                CERROR("LOV requires striping ea for lock cancellation\n");
+                CERROR("LOV requires striping ea\n");
+                RETURN(-EINVAL);
+        }
+
+        if (lsm->lsm_magic != LOV_MAGIC) {
+                CERROR("LOV striping magic bad %#lx != %#lx\n",
+                       lsm->lsm_magic, LOV_MAGIC);
                 RETURN(-EINVAL);
         }