Whamcloud - gitweb
A mostly-fix for "mknod /mnt/lustre/foofo p". It doesn't fail outright
authoradilger <adilger>
Thu, 18 Jul 2002 10:07:04 +0000 (10:07 +0000)
committeradilger <adilger>
Thu, 18 Jul 2002 10:07:04 +0000 (10:07 +0000)
anymore (S_IFREG only for regular files), it doesn't oops (pass in
dentry->d_it to ll_create), it only complains "file already exists" after
it has already created the file.  Definitely an intent thing, but it is
too late to fix that part.

Also includes the LOV changes from today, as they don't seem to harm
the current setup (runtests finishes).

lustre/include/linux/lustre_mds.h
lustre/llite/namei.c
lustre/llite/super.c
lustre/lov/lov_obd.c
lustre/mdc/Makefile.am
lustre/mdc/mdc_request.c
lustre/mds/mds_reint.c

index c58786f..da851e3 100644 (file)
@@ -149,6 +149,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                struct lookup_intent *it, int lock_mode, struct inode *dir,
                struct dentry *de, struct lustre_handle *h, __u64 id,
                char *tgt, int tgtlen, void *data, int datalen);
+int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
+                   uuid_t **uuids, struct ptlrpc_request **request);
 int mdc_getstatus(struct lustre_handle *conn,
                 struct ll_fid *rootfid, __u64 *last_committed, __u64 *last_rcvd,
                 __u32 *last_xid, struct ptlrpc_request **);
index df8edbd..39214e4 100644 (file)
@@ -227,7 +227,7 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
 static struct inode *ll_create_node(struct inode *dir, const char *name,
                                     int namelen, const char *tgt, int tgtlen,
                                     int mode, __u64 extra,
-                                    struct lookup_intent *it, 
+                                    struct lookup_intent *it,
                                     struct lov_stripe_md *smd)
 {
         struct inode *inode;
@@ -372,7 +372,6 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
                         RETURN(rc);
         }
 
-        mode = mode | S_IFREG;
         CDEBUG(D_DENTRY, "name %s mode %o o_id %lld\n",
                dentry->d_name.name, mode, (unsigned long long)oa.o_id);
         inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
@@ -414,7 +413,7 @@ static int ll_mknod(struct inode *dir, struct dentry *dentry, int mode,
 {
         struct inode * inode = ll_create_node(dir, dentry->d_name.name,
                                               dentry->d_name.len, NULL, 0,
-                                              mode, rdev, NULL, NULL);
+                                              mode, rdev, dentry->d_it, NULL);
         int err = PTR_ERR(inode);
         if (!IS_ERR(inode))
                 err = ext2_add_nondir(dentry, inode);
index 0c78f00..cc1e655 100644 (file)
@@ -119,8 +119,6 @@ static struct super_block * ll_read_super(struct super_block *sb,
                 GOTO(out_free, sb = NULL);
         }
 
-        /* First the MDS since an LOV requires an the MDC connection
-           to find its descriptor */
 #if 0
         err = connmgr_connect(ptlrpc_connmgr, sbi->ll_mds_conn);
         if (err) {
@@ -136,14 +134,11 @@ static struct super_block * ll_read_super(struct super_block *sb,
         }
         sbi2mdc(sbi)->mdc_conn->c_level = LUSTRE_CONN_FULL;
 
-        /* now the OST, which could be an LOV */
         obd = class_uuid2obd(ost);
         if (!obd) {
                 CERROR("OST %s: not setup or attached\n", ost);
                 GOTO(out_mdc, sb = NULL);
         }
-        /* hack: pass in the MDC connection information to LOV via osc_conn */
-        memcpy(&sbi->ll_osc_conn, &sbi->ll_mdc_conn, sizeof(sbi->ll_mdc_conn));
         err = obd_connect(&sbi->ll_osc_conn, obd);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", ost, err);
index d22151b..c0fd524 100644 (file)
@@ -26,74 +26,37 @@ extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 /* obd methods */
 
-static int lov_getinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
-                       struct lov_desc *desc, uuid_t **uuids,
-                       struct ptlrpc_request **request)
-{
-        struct ptlrpc_request *req;
-        struct mds_status_req *streq;
-        struct lov_obd *lov = &obd->u.lov;
-        struct mdc_obd *mdc = &lov->mdcobd->u.mdc;
-        int rc, size[2] = {sizeof(*streq)};
-        ENTRY;
-
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, mdc_connh,
-                               MDS_LOVINFO, 1, size, NULL);
-        if (!req)
-                GOTO(out, rc = -ENOMEM);
-
-        *request = req;
-        streq = lustre_msg_buf(req->rq_reqmsg, 0);
-        streq->flags = HTON__u32(MDS_STATUS_LOV);
-        streq->repbuf = HTON__u32(8000);
-
-        /* prepare for reply */
-        req->rq_level = LUSTRE_CONN_CON;
-        size[0] = sizeof(*desc);
-        size[1] = 8000;
-        req->rq_replen = lustre_msg_size(2, size);
-
-        rc = ptlrpc_queue_wait(req);
-        rc = ptlrpc_check_status(req, rc);
-
-        if (!rc) {
-                memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
-                *uuids = lustre_msg_buf(req->rq_repmsg, 1);
-                lov_unpackdesc(desc);
-        }
-        mdc->mdc_max_mdsize = sizeof(*desc) +
-                desc->ld_tgt_count * sizeof(uuid_t);
-
-        EXIT;
- out:
-        return rc;
-}
-
 static int lov_connect(struct lustre_handle *conn, struct obd_device *obd)
 {
         struct ptlrpc_request *req;
-        struct lustre_handle mdc_conn;
         struct lov_obd *lov = &obd->u.lov;
+        struct lustre_handle mdc_conn;
         uuid_t *uuidarray;
         int rc;
         int i;
 
         MOD_INC_USE_COUNT;
-        memcpy(&mdc_conn, conn, sizeof(mdc_conn));
-        conn->addr = -1;
-        conn->cookie = 0;
         rc = class_connect(conn, obd);
         if (rc) {
                 MOD_DEC_USE_COUNT;
                 RETURN(rc);
         }
 
-        rc = lov_getinfo(obd, &mdc_conn, &lov->desc, &uuidarray, &req);
+        rc = obd_connect(&mdc_conn, lov->mdcobd);
+        if (rc) {
+                CERROR("cannot connect to mdc: rc = %d\n", rc);
+                GOTO(out, rc = -EINVAL);
+        }
+
+        rc = mdc_getlovinfo(obd, &mdc_conn, &uuidarray, &req);
+        obd_disconnect(&mdc_conn);
+
         if (rc) {
                 CERROR("cannot get lov info %d\n", rc);
                 GOTO(out, rc);
         }
 
+
         if (lov->desc.ld_tgt_count > 1000) {
                 CERROR("configuration error: target count > 1000 (%d)\n",
                        lov->desc.ld_tgt_count);
index 48e416c..1b5d201 100644 (file)
@@ -9,8 +9,11 @@ MODULE = mdc
 modulefs_DATA = mdc.o
 EXTRA_PROGRAMS = mdc
 
-LINX=mds_updates.c ll_pack.c
+LINX=mds_updates.c ll_pack.c lov_pack.c
 mdc_SOURCES =  mdc_request.c mdc_reint.c $(LINX)
+lov_pack.c: 
+       test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
+
 ll_pack.c: 
        test -e ll_pack.c || ln -sf $(top_srcdir)/lib/ll_pack.c .
 
index 4ac843f..be73b40 100644 (file)
@@ -122,6 +122,53 @@ int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid,
         return rc;
 }
 
+int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
+                   uuid_t **uuids, struct ptlrpc_request **request)
+{
+        struct ptlrpc_request *req;
+        struct mds_status_req *streq;
+        struct lov_obd *lov = &obd->u.lov;
+        struct mdc_obd *mdc = &lov->mdcobd->u.mdc;
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
+        struct lov_desc *desc = &lov->desc;
+        int rc, size[2] = {sizeof(*streq)};
+        ENTRY;
+
+        mdc_con2cl(mdc_connh, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_LOVINFO, 1, size, NULL);
+        if (!req)
+                GOTO(out, rc = -ENOMEM);
+
+        *request = req;
+        streq = lustre_msg_buf(req->rq_reqmsg, 0);
+        streq->flags = HTON__u32(MDS_STATUS_LOV);
+        streq->repbuf = HTON__u32(8000);
+
+        /* prepare for reply */
+        req->rq_level = LUSTRE_CONN_CON;
+        size[0] = sizeof(*desc);
+        size[1] = 8000;
+        req->rq_replen = lustre_msg_size(2, size);
+
+        rc = ptlrpc_queue_wait(req);
+        rc = ptlrpc_check_status(req, rc);
+
+        if (!rc) {
+                memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
+                *uuids = lustre_msg_buf(req->rq_repmsg, 1);
+                lov_unpackdesc(desc);
+        }
+        mdc->mdc_max_mdsize = sizeof(*desc) +
+                desc->ld_tgt_count * sizeof(uuid_t);
+
+        EXIT;
+ out:
+        return rc;
+}
+
 
 int mdc_getattr(struct lustre_handle *conn,
                 obd_id ino, int type, unsigned long valid, size_t ea_size,
@@ -233,8 +280,9 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 break;
         case (IT_CREAT|IT_OPEN):
         case IT_CREAT:
+                it->it_mode |= S_IFREG; /* no break */
         case IT_MKNOD:
-                it->it_mode = (it->it_mode | S_IFREG) & ~current->fs->umask; 
+                it->it_mode &= ~current->fs->umask;
                 break;
         case IT_SYMLINK:
                 it->it_mode = (it->it_mode | S_IFLNK) & ~current->fs->umask; 
@@ -330,7 +378,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 RETURN(-1);
         }
 #warning FIXME: the data here needs to be different if a lock was granted for a different inode
-        rc = ldlm_cli_enqueue(cl, connection, NULL, req,
+        rc = ldlm_cli_enqueue(cl, connection, rconn, req,
                               obddev->obd_namespace, NULL, res_id, lock_type,
                               NULL, 0, lock_mode, &flags,
                               (void *)mdc_lock_callback, data, datalen, lockh);
@@ -831,6 +879,7 @@ MODULE_DESCRIPTION("Lustre Metadata Client v1.0");
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(mdc_getstatus);
+EXPORT_SYMBOL(mdc_getlovinfo);
 EXPORT_SYMBOL(mdc_enqueue);
 EXPORT_SYMBOL(mdc_getattr);
 EXPORT_SYMBOL(mdc_statfs);
index 51d525a..f41a621 100644 (file)
@@ -342,7 +342,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 break;
         }
         default:
-                CERROR("bad file type %d for create of %s\n",type,rec->ur_name);
+                CERROR("bad file type %o for create of %s\n",type,rec->ur_name);
                 GOTO(out_create_dchild, rc = -EINVAL);
         }