Whamcloud - gitweb
- Set valid flags in llite and not OSC. It does not make sense for the OSC
authoradilger <adilger>
Thu, 1 Aug 2002 00:11:06 +0000 (00:11 +0000)
committeradilger <adilger>
Thu, 1 Aug 2002 00:11:06 +0000 (00:11 +0000)
  layer to be needed for llite->OBD operations to work properly.
- Set LOV EA size in mds_reint_unlink, so we use the EA data to unlink object.
- Remove extNisms from MDS code (mds_fs_get_md()) will return status if
  there is an available EA, and what size it is.
- Handle error on open intent, to avoid spurious actions on non-existent file.
- Rename OBD_MD_FLOBJID to OBD_MD_FLEASIZE to more accurately name it.

lustre/include/linux/lustre_idl.h
lustre/lib/mds_updates.c
lustre/llite/file.c
lustre/llite/namei.c
lustre/llite/rw.c
lustre/llite/super.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_reint.c
lustre/osc/osc_request.c

index 5fa091e..4e14155 100644 (file)
@@ -121,8 +121,8 @@ struct lustre_msg {
         __u64 last_committed;
         __u64 transno;
         __u32 status;
-        __u32   bufcount;
-        __u32   buflens[0];
+        __u32 bufcount;
+        __u32 buflens[0];
 };
 
 #define CONNMGR_REPLY  0
@@ -168,7 +168,7 @@ typedef uint32_t        obd_count;
 #define OBD_FL_CREATEONOPEN     (0x00000004)
 
 #define OBD_INLINESZ    60
-#define OBD_OBDMDSZ     60
+
 /* Note: 64-bit types are 64-bit aligned in structure */
 struct obdo {
         obd_id                  o_id;
@@ -188,7 +188,7 @@ struct obdo {
         obd_count               o_generation;
         obd_flag                o_valid;        /* hot fields in this obdo */
         obd_flag                o_obdflags;
-        __u32                   o_easize; 
+        __u32                   o_easize;
         char                    o_inline[OBD_INLINESZ];
 };
 
@@ -227,7 +227,7 @@ struct lov_stripe_md {
 #define OBD_MD_FLGENER  (0x00004000)
 #define OBD_MD_FLINLINE (0x00008000)
 #define OBD_MD_FLRDEV   (0x00010000)
-#define OBD_MD_FLOBJID  (0x00020000)
+#define OBD_MD_FLEASIZE (0x00020000)
 #define OBD_MD_LINKNAME (0x00040000)
 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME))
 
index e7f192c..2fb2d3e 100644 (file)
@@ -46,18 +46,20 @@ void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
 
 void mds_pack_inode2body(struct mds_body *b, struct inode *inode)
 {
-        b->valid = OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLNLINK | OBD_MD_FLGENER | OBD_MD_FLSIZE | OBD_MD_FLOBJID;
-        b->size = HTON__u64(inode->i_size);
+        b->valid = OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLMTIME |
+                OBD_MD_FLCTIME | OBD_MD_FLMODE | OBD_MD_FLSIZE | OBD_MD_FLUID |
+                OBD_MD_FLGID | OBD_MD_FLNLINK | OBD_MD_FLGENER;
+        b->ino = HTON__u32(inode->i_ino);
+        b->atime = HTON__u32(inode->i_atime);
+        b->mtime = HTON__u32(inode->i_mtime);
+        b->ctime = HTON__u32(inode->i_ctime);
         b->mode = HTON__u32(inode->i_mode);
+        b->size = HTON__u64(inode->i_size);
         b->uid = HTON__u32(inode->i_uid);
         b->gid = HTON__u32(inode->i_gid);
-        b->mtime = HTON__u32(inode->i_mtime);
-        b->ctime = HTON__u32(inode->i_ctime);
-        b->atime = HTON__u32(inode->i_atime);
         b->flags = HTON__u32(inode->i_flags);
         //b->major = HTON__u32(inode->i_major);
         //b->minor = HTON__u32(inode->i_minor);
-        b->ino = HTON__u32(inode->i_ino);
         b->nlink = HTON__u32(inode->i_nlink);
         b->generation = HTON__u32(inode->i_generation);
 }
index 41ff0b8..22c198a 100644 (file)
@@ -57,9 +57,9 @@ static int ll_file_open(struct inode *inode, struct file *file)
                 if (!oa) { 
                         RETURN(-ENOMEM);
                 }
-                oa->o_valid = OBD_MD_FLMODE;
                 oa->o_mode = S_IFREG | 0600;
                 oa->o_easize = mdc->cl_max_mdsize;
+                oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLEASIZE;
                 rc = obd_create(ll_i2obdconn(inode), oa, &lli->lli_smd);
                 if (rc)
                         RETURN(rc);
@@ -86,13 +86,12 @@ static int ll_file_open(struct inode *inode, struct file *file)
         if (!fd->fd_mdshandle)
                 CERROR("mdc_open didn't assign fd_mdshandle\n");
 
-        if (oa == NULL) {
-                oa =  obdo_alloc();
-                if (!oa)
-                        GOTO(out_mdc, rc = -EINVAL);
-        }
+        if (oa == NULL && (oa = obdo_alloc()) == NULL)
+                GOTO(out_mdc, rc = -EINVAL);
+
         oa->o_id = lli->lli_smd->lmd_object_id;
         oa->o_mode = S_IFREG | inode->i_mode;
+        oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLID;
         rc = obd_open(ll_i2obdconn(inode), oa, lli->lli_smd);
         obdo_free(oa);
         oa = NULL;
@@ -111,8 +110,7 @@ out_mdc:
 out_req:
         ptlrpc_free_req(req);
 //out_fd:
-        if (oa)
-                obdo_free(oa);
+        obdo_free(oa);
         kmem_cache_free(ll_file_data_slab, fd);
         file->private_data = NULL;
 out:
@@ -141,8 +139,11 @@ static int ll_file_release(struct inode *inode, struct file *file)
                 LBUG();
                 GOTO(out_fd, rc = -ENOENT);
         }
+        oa->o_id = lli->lli_smd->lmd_object_id;
+        oa->o_mode = S_IFREG;
+        oa->o_valid = (OBD_MD_FLMODE | OBD_MD_FLID);
         rc = obd_close(ll_i2obdconn(inode), oa, lli->lli_smd);
-        obdo_free(oa); 
+        obdo_free(oa);
         if (rc)
                 GOTO(out_fd, abs(rc));
 
index e8a8ee9..1ff092c 100644 (file)
@@ -110,9 +110,10 @@ int ll_lock(struct inode *dir, struct dentry *dentry,
                 lock_mode = LCK_CR;
         else {
                 LBUG();
-                RETURN(-1);
+                RETURN(-EINVAL);
         }
 
+#warning FIXME: add symlink tgt to intent and as a parameter here
         err = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT, it, lock_mode, dir,
                           dentry, lockh, 0, NULL, 0, dir, sizeof(*dir));
 
@@ -158,36 +159,45 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
                 RETURN(ERR_PTR(err));
         memcpy(it->it_lock_handle, &lockh, sizeof(lockh));
 
-        if ((it->it_op & (IT_CREAT | IT_MKDIR | IT_SYMLINK | IT_MKNOD)) &&
-            it->it_disposition && !it->it_status)
-                GOTO(negative, NULL);
-
-        if ((it->it_op & (IT_RENAME | IT_GETATTR | IT_UNLINK | IT_RMDIR |
-                          IT_SETATTR | IT_LOOKUP)) &&
-            it->it_disposition && it->it_status)
-                GOTO(negative, NULL);
-
-        request = (struct ptlrpc_request *)it->it_data;
-        if (!it->it_disposition) {
+        if (it->it_disposition) {
+                offset = 1;
+                if (it->it_op & (IT_CREAT | IT_MKDIR | IT_SYMLINK | IT_MKNOD)) {
+                        /* For create ops, we want the lookup to be negative */
+                        request = (struct ptlrpc_request *)it->it_data;
+                        if (!it->it_status)
+                                GOTO(negative, NULL);
+                        //else
+                        //        GOTO(err, it->it_status);
+                } else if (it->it_op & (IT_RENAME | IT_GETATTR | IT_UNLINK |
+                                        IT_RMDIR | IT_SETATTR | IT_LOOKUP |
+                                        IT_OPEN)) {
+                        /* For remove/check, we want the lookup to succeed */
+                        request = (struct ptlrpc_request *)it->it_data;
+                        if (it->it_status)
+                                GOTO(negative, NULL);
+                        //else
+                        //        GOTO(err, it->it_status);
+                } else if (it->it_op == IT_RENAME2) {
+                        /* Set below to be a dentry from the IT_RENAME op */
+                        inode = ((struct dentry *)(it->it_data))->d_inode;
+                        GOTO(out_req, NULL);
+                }
+        } else {
                 struct ll_inode_info *lli = ll_i2info(dir);
+                request = (struct ptlrpc_request *)it->it_data;
                 memcpy(&lli->lli_intent_lock_handle, &lockh, sizeof(lockh));
+                offset = 0;
 
                 ino = ll_inode_by_name(dir, dentry, &type);
 #warning FIXME: handle negative inode case (see old ll_lookup)
 
                 err = mdc_getattr(&sbi->ll_mdc_conn, ino, type,
-                                  OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
+                                  OBD_MD_FLNOTOBD|OBD_MD_FLEASIZE, 0, &request);
                 if (err) {
                         CERROR("failure %d inode %Ld\n", err, (long long)ino);
                         ptlrpc_free_req(request);
                         RETURN(ERR_PTR(-abs(err)));
                 }
-                offset = 0;
-        } else if (it->it_op == IT_RENAME2) {
-                inode = ((struct dentry *)(it->it_data))->d_inode;
-                GOTO(out_req, NULL);
-        } else {
-                offset = 1;
         }
 
         md.body = lustre_msg_buf(request->rq_repmsg, offset);
@@ -205,6 +215,7 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
 
  out_req:
         ptlrpc_free_req(request);
+        request = NULL;
         if (!inode || IS_ERR(inode)) {
                 ll_intent_release(dentry);
                 RETURN(ERR_PTR(-ENOMEM));
@@ -213,8 +224,10 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
  negative:
         dentry->d_op = &ll_d_ops;
         d_add(dentry, inode);
-        if (it->it_op == IT_LOOKUP)
+        if (it->it_op == IT_LOOKUP || (it->it_op == IT_OPEN && it->it_status)) {
                 ll_intent_release(dentry);
+                ptlrpc_free_req(request);
+        }
 
         return NULL;
 }
@@ -357,18 +370,19 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
         struct inode *inode;
         struct lov_stripe_md *smd;
         struct ll_inode_info *ii = NULL;
+        ENTRY;
 
         if (dentry->d_it->it_disposition == 0) {
                 memset(&oa, 0, sizeof(oa));
                 oa.o_valid = OBD_MD_FLMODE;
                 oa.o_mode = S_IFREG | 0600;
                 rc = obd_create(ll_i2obdconn(dir), &oa, &smd);
+                CDEBUG(D_DENTRY, "name %s mode %o o_id %lld: rc = %d\n",
+                       dentry->d_name.name, mode, (long long)oa.o_id, rc);
                 if (rc)
                         RETURN(rc);
         }
 
-        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,
                                NULL, 0, mode, 0, dentry->d_it, smd);
 
@@ -395,6 +409,7 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
         RETURN(rc);
 
 out_destroy:
+#warning FIXME: what about ii???
         oa.o_easize = ii->lli_smd->lmd_easize;
         err = obd_destroy(ll_i2obdconn(dir), &oa, ii->lli_smd);
         if (err)
index 5ce6087..0200ca6 100644 (file)
@@ -201,12 +201,11 @@ void ll_truncate(struct inode *inode)
         CDEBUG(D_INFO, "calling punch for %ld (all bytes after %Ld)\n",
                (long)oa.o_id, (unsigned long long)oa.o_size);
 
-        oa.o_size = inode->i_size;
         oa.o_id = md->lmd_object_id;
         oa.o_valid = OBD_MD_FLID;
         /* truncate == punch to/from start from/to end:
            set end to -1 for that. */
-        err = obd_punch(ll_i2obdconn(inode), &oa, md, oa.o_size, 
+        err = obd_punch(ll_i2obdconn(inode), &oa, md, inode->i_size,
                         0xffffffffffffffff);
         if (err)
                 CERROR("obd_truncate fails (%d)\n", err);
index 4e22cdc..315c2d3 100644 (file)
@@ -149,24 +149,27 @@ static struct super_block * ll_read_super(struct super_block *sb,
         /* XXX: need to store the last_* values somewhere */
         err = mdc_getstatus(&sbi->ll_mdc_conn, &rootfid, &last_committed,
                             &last_rcvd, &last_xid, &request);
+        ptlrpc_req_finished(request);
         if (err) {
-                CERROR("cannot mdc_connect: rc = %d\n", err);
-                GOTO(out_request, sb = NULL);
+                CERROR("cannot mds_connect: rc = %d\n", err);
+                GOTO(out_mdc, sb = NULL);
         }
         CDEBUG(D_SUPER, "rootfid %Ld\n", (unsigned long long)rootfid.id);
         sbi->ll_rootino = rootfid.id;
 
         memset(&sfs, 0, sizeof(sfs));
+        request = NULL;
         err = mdc_statfs(&sbi->ll_mdc_conn, &sfs, &request);
+        ptlrpc_req_finished(request);
         sb->s_blocksize = sfs.f_bsize;
         sb->s_blocksize_bits = log2(sfs.f_bsize);
         sb->s_magic = LL_SUPER_MAGIC;
         sb->s_maxbytes = (1ULL << (32 + 9)) - sfs.f_bsize;
-        ptlrpc_req_finished(request);
 
         sb->s_op = &ll_super_operations;
 
         /* make root inode */
+        request = NULL;
         err = mdc_getattr(&sbi->ll_mdc_conn, sbi->ll_rootino, S_IFDIR,
                           OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
         if (err) {
@@ -196,7 +199,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
                 GOTO(out_cdb, sb = NULL);
         }
 
-        ptlrpc_free_req(request);
+        ptlrpc_req_finished(request);
 
 out_dev:
         if (mdc)
@@ -209,7 +212,7 @@ out_dev:
 out_cdb:
         ll_commitcbd_cleanup(sbi);
 out_request:
-        ptlrpc_free_req(request);
+        ptlrpc_req_finished(request);
         obd_disconnect(&sbi->ll_osc_conn);
 out_mdc:
         obd_disconnect(&sbi->ll_mdc_conn);
@@ -255,21 +258,29 @@ static void ll_delete_inode(struct inode *inode)
 {
         if (S_ISREG(inode->i_mode)) {
                 int err;
-                struct obdo oa;
+                struct obdo *oa;
                 struct lov_stripe_md *md = ll_i2info(inode)->lli_smd;
 
-               if (!md)
+                if (!md)
                         GOTO(out, -EINVAL);
 
-                oa.o_id = md->lmd_object_id;
-                oa.o_easize = md->lmd_easize;
-                if (oa.o_id == 0) {
+                if (md->lmd_object_id == 0) {
                         CERROR("This really happens\n");
                         /* No obdo was ever created */
                         GOTO(out, 0);
                 }
 
-                err = obd_destroy(ll_i2obdconn(inode), &oa, md);
+                oa = obdo_alloc();
+                if (oa == NULL)
+                        GOTO(out, -ENOMEM);
+
+                oa->o_id = md->lmd_object_id;
+                oa->o_easize = md->lmd_easize;
+                oa->o_mode = inode->i_mode;
+                oa->o_valid = OBD_MD_FLID | OBD_MD_FLEASIZE | OBD_MD_FLMODE;
+
+                err = obd_destroy(ll_i2obdconn(inode), oa, md);
+                obdo_free(oa);
                 CDEBUG(D_SUPER, "obd destroy of %Ld error %d\n",
                        md->lmd_object_id, err);
         }
@@ -416,6 +427,7 @@ static void ll_to_inode(struct inode *dst, struct ll_inode_md *md)
                 dst->i_generation = body->generation;
         if (body->valid & OBD_MD_FLRDEV)
                 dst->i_rdev = body->extra;
+        //if (body->valid & OBD_MD_FLEASIZE)
         if (md && md->md && md->md->lmd_stripe_count) { 
                 struct lov_stripe_md *smd = md->md;
                 int size = ll_stripe_md_size(dst->i_sb);
index b81e961..15afc64 100644 (file)
@@ -203,6 +203,7 @@ static int mdc_lock_callback(struct lustre_handle *lockh,
                 CERROR("data_len should be %d, but is %d\n", sizeof(*inode),
                        data_len);
                 LBUG();
+                RETURN(-EINVAL);
         }
 
         /* FIXME: do something better than throwing away everything */
@@ -335,7 +336,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 req->rq_replen = lustre_msg_size(1, repsize);
         } else {
                 LBUG();
-                RETURN(-1);
+                RETURN(-EINVAL);
         }
 #warning FIXME: the data here needs to be different if a lock was granted for a different inode
         rc = ldlm_cli_enqueue(conn, req, obddev->obd_namespace, NULL, res_id, lock_type,
@@ -344,6 +345,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
         if (rc == -ENOENT || rc == ELDLM_LOCK_ABORTED) {
                 lock_mode = 0;
                 memset(lockh, 0, sizeof(*lockh));
+                /* rc = 0 */
         } else if (rc != 0) {
                 CERROR("ldlm_cli_enqueue: %d\n", rc);
                 RETURN(rc);
index dfc469b..58bb545 100644 (file)
@@ -520,7 +520,10 @@ static int mds_getattr(int offset, struct ptlrpc_request *req)
         body->size = inode->i_size;
         body->mode = inode->i_mode;
         body->nlink = inode->i_nlink;
-        body->valid = ~0; /* FIXME: should be more selective */
+        body->valid = (OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLCTIME |
+                       OBD_MD_FLMTIME | OBD_MD_FLSIZE | OBD_MD_FLUID |
+                       OBD_MD_FLGID | OBD_MD_FLNLINK | OBD_MD_FLGENER |
+                       OBD_MD_FLMODE);
 
         if (S_ISREG(inode->i_mode)) {
                 rc = mds_fs_get_md(mds, inode,
@@ -529,7 +532,10 @@ static int mds_getattr(int offset, struct ptlrpc_request *req)
                         CERROR("mds_fs_get_md failed: %d\n", rc);
                         GOTO(out, rc);
                 }
-        }
+                body->valid |= OBD_MD_FLEASIZE;
+        } else if (S_ISLNK(inode->i_mode))
+                body->valid |= OBD_MD_LINKNAME;
+
 out:
         l_dput(de);
 out_pop:
@@ -791,8 +797,7 @@ int mds_handle(struct ptlrpc_request *req)
                 GOTO(out, rc = -EINVAL);
         }
 
-        if (req->rq_reqmsg->opc != MDS_CONNECT &&
-            req->rq_export == NULL)
+        if (req->rq_reqmsg->opc != MDS_CONNECT && req->rq_export == NULL)
                 GOTO(out, rc = -ENOTCONN);
 
         if (strcmp(req->rq_obd->obd_type->typ_name, "mds") != 0)
@@ -857,7 +862,7 @@ int mds_handle(struct ptlrpc_request *req)
                 rc = mds_reint(0, req);
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET_REP, 0);
                 break;
-        }
+                }
 
         case MDS_OPEN:
                 CDEBUG(D_INODE, "open\n");
index f35a9bf..60b74a0 100644 (file)
@@ -116,10 +116,9 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 /* a name was supplied by the client; fid1 is the directory */
                 dir = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PR,
                                             &dir_lockh);
-                if (!dir || IS_ERR(dir)) {
-                        l_dput(dir);
+                if (IS_ERR(dir)) {
                         LBUG();
-                        GOTO(out_setattr, rc = -ESTALE);
+                        GOTO(out_setattr, rc = PTR_ERR(dir));
                 }
 
                 name = lustre_msg_buf(req->rq_reqmsg, offset + 1);
@@ -127,9 +126,9 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 de = mds_name2locked_dentry(obd, dir, NULL, name, namelen,
                                             0, &child_lockh, LCK_PR);
                 l_dput(dir);
-                if (!de || IS_ERR(de)) {
+                if (IS_ERR(de)) {
                         LBUG();
-                        GOTO(out_setattr_de, rc = -ESTALE);
+                        GOTO(out_setattr_de, rc = PTR_ERR(de));
                 }
         } else {
                 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
@@ -228,8 +227,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         struct inode *dir;
         void *handle;
         struct lustre_handle lockh;
-        int rc = 0, err, flags, lock_mode, type = rec->ur_mode & S_IFMT;
-        __u64 res_id[3] = {0,0,0};
+        int rc = 0, err, lock_mode, type = rec->ur_mode & S_IFMT;
         ENTRY;
 
         /* requests were at offset 2, replies go back at 1 */
@@ -239,40 +237,30 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         if (strcmp(req->rq_export->exp_obd->obd_type->typ_name, "mds") != 0)
                 LBUG();
 
-        de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
-        if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) {
+        lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
+
+        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
+                GOTO(out_create, rc = -ESTALE);
+
+        de = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, lock_mode, &lockh);
+        if (IS_ERR(de)) {
+                rc = PTR_ERR(de);
+                CERROR("parent lookup error %d\n", rc);
                 LBUG();
-                GOTO(out_create_de, rc = -ESTALE);
+                GOTO(out_create, rc);
         }
         dir = de->d_inode;
         CDEBUG(D_INODE, "parent ino %ld name %s mode %o\n",
                dir->i_ino, rec->ur_name, rec->ur_mode);
 
-        lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
-        res_id[0] = dir->i_ino;
-
-        rc = ldlm_lock_match(obd->obd_namespace, res_id, LDLM_PLAIN,
-                             NULL, 0, lock_mode, &lockh);
-        if (rc == 0) {
-                LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
-                rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
-                                      res_id, LDLM_PLAIN, NULL, 0, lock_mode,
-                                      &flags, ldlm_completion_ast, (void *)mds_lock_callback, NULL,
-                                      0, &lockh);
-                if (rc != ELDLM_OK) {
-                        CERROR("lock enqueue: err: %d\n", rc);
-                        GOTO(out_create_de, rc = -EIO);
-                }
-        }
         ldlm_lock_dump((void *)(unsigned long)lockh.addr);
 
         down(&dir->i_sem);
         dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1);
         if (IS_ERR(dchild)) {
                 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
-                up(&dir->i_sem);
                 LBUG();
-                GOTO(out_create_dchild, rc = -ESTALE);
+                GOTO(out_create_de, rc = -ESTALE);
         }
 
         if (dchild->d_inode) {
@@ -285,12 +273,12 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 body = lustre_msg_buf(req->rq_repmsg, offset);
                 mds_pack_inode2fid(&body->fid1, inode);
                 mds_pack_inode2body(body, inode);
-#warning FIXME: This ext3/N-specific code does not belong here
-                /* If i_file_acl is set, this inode has an EA */
-                if (S_ISREG(inode->i_mode) && inode->u.ext3_i.i_file_acl) {
+                if (S_ISREG(inode->i_mode)) {
                         md = lustre_msg_buf(req->rq_repmsg, offset + 1);
                         md->lmd_easize = mds->mds_max_mdsize;
-                        mds_fs_get_md(mds, inode, md);
+
+                        if (mds_fs_get_md(mds, inode, md) < 0)
+                                memset(md, 0, md->lmd_easize);
                 }
                 /* now a normal case for intent locking */
                 GOTO(out_create_dchild, rc = -EEXIST);
@@ -362,7 +350,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         md = lustre_msg_buf(req->rq_reqmsg, 2);
                         rc = mds_fs_set_md(mds, inode, handle, md);
                         if (rc) {
-                                CERROR("error %d setting obdo for %ld\n",
+                                CERROR("error %d setting LOV MD for %ld\n",
                                        rc, inode->i_ino);
                                 GOTO(out_create_unlink, rc);
                         }
@@ -391,6 +379,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 body = lustre_msg_buf(req->rq_repmsg, offset);
                 body->ino = inode->i_ino;
                 body->generation = inode->i_generation;
+                body->valid = OBD_MD_FLID | OBD_MD_FLGENER;
         }
         EXIT;
 out_create_commit:
@@ -402,10 +391,11 @@ out_create_commit:
         }
 out_create_dchild:
         l_dput(dchild);
-        up(&dir->i_sem);
         ldlm_lock_decref(&lockh, lock_mode);
 out_create_de:
+        up(&dir->i_sem);
         l_dput(de);
+out_create:
         req->rq_status = rc;
         return 0;
 
@@ -455,7 +445,6 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                 RETURN(PTR_ERR(de));
         }
 
-
         name = lustre_msg_buf(req->rq_reqmsg, offset + 1);
         namelen = req->rq_reqmsg->buflens[offset + 1] - 1;
         dchild = mds_name2locked_dentry(obd, de, NULL, name, namelen,
@@ -483,6 +472,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
 
         OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dir->i_sb->s_dev);
 
+#warning FIXME: the file type needs to match the original requested operation
         switch (inode->i_mode & S_IFMT) {
         case S_IFDIR:
                 handle = mds_fs_start(mds, dir, MDS_FSOP_RMDIR);
@@ -491,16 +481,18 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                 rc = vfs_rmdir(dir, dchild);
                 break;
         case S_IFREG:
-                if (inode->u.ext3_i.i_file_acl && offset) {
+                if (offset) {
                         struct lov_stripe_md *md;
-                        md = lustre_msg_buf(req->rq_repmsg, 2); 
-                        rc = mds_fs_get_md(mds, inode, md);
-                        if (rc < 0) { 
-                                CDEBUG(D_INFO, "No md for ino %ld err %d\n",
+
+                        md = lustre_msg_buf(req->rq_repmsg, 2);
+                        md->lmd_easize = mds->mds_max_mdsize;
+                        if ((rc = mds_fs_get_md(mds, inode, md)) < 0) {
+                                CDEBUG(D_INFO, "No md for ino %ld: rc = %d\n",
                                        inode->i_ino, rc);
-                                memset(md, 0, md->lmd_easize); 
+                                memset(md, 0, md->lmd_easize);
                         }
                 }
+                /* No break */
         default:
                 handle = mds_fs_start(mds, dir, MDS_FSOP_UNLINK);
                 if (!handle)
index 006b745..4ebefc5 100644 (file)
@@ -41,8 +41,8 @@ static int osc_getattr(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(request->rq_reqmsg, 0);
+#warning FIXME: pack only valid fields instead of memcpy, endianness
         memcpy(&body->oa, oa, sizeof(*oa));
-        body->oa.o_valid = ~0;
 
         request->rq_replen = lustre_msg_size(1, &size);
 
@@ -77,8 +77,8 @@ static int osc_open(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(request->rq_reqmsg, 0);
+#warning FIXME: pack only valid fields instead of memcpy, endianness
         memcpy(&body->oa, oa, sizeof(*oa));
-        body->oa.o_valid = (OBD_MD_FLMODE | OBD_MD_FLID);
 
         request->rq_replen = lustre_msg_size(1, &size);
 
@@ -110,10 +110,8 @@ static int osc_close(struct lustre_handle *conn, struct obdo *oa,
         if (!request)
                 RETURN(-ENOMEM);
 
-        oa->o_id = md->lmd_object_id;
-        oa->o_mode = S_IFREG;
-        oa->o_valid = (OBD_MD_FLMODE | OBD_MD_FLID);
         body = lustre_msg_buf(request->rq_reqmsg, 0);
+#warning FIXME: pack only valid fields instead of memcpy, endianness
         memcpy(&body->oa, oa, sizeof(*oa));
 
         request->rq_replen = lustre_msg_size(1, &size);
@@ -228,9 +226,11 @@ static int osc_punch(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(request->rq_reqmsg, 0);
+#warning FIXME: pack only valid fields instead of memcpy, endianness, valid
         memcpy(&body->oa, oa, sizeof(*oa));
 
         /* overload the blocks and size fields in the oa with start/end */ 
+#warning FIXME: endianness, size=start, blocks=end?
         body->oa.o_blocks = start;
         body->oa.o_size = end;
         body->oa.o_valid |= OBD_MD_FLBLOCKS | OBD_MD_FLSIZE;
@@ -268,8 +268,8 @@ static int osc_destroy(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(request->rq_reqmsg, 0);
+#warning FIXME: pack only valid fields instead of memcpy, endianness
         memcpy(&body->oa, oa, sizeof(*oa));
-        body->oa.o_valid = ~0;
 
         request->rq_replen = lustre_msg_size(1, &size);