Whamcloud - gitweb
Items of note:
authorpschwan <pschwan>
Fri, 5 Jul 2002 18:56:59 +0000 (18:56 +0000)
committerpschwan <pschwan>
Fri, 5 Jul 2002 18:56:59 +0000 (18:56 +0000)
* Fixes rename
* Allows for symlinks larger than LL_INLINESZ (of course, intent-based symlink
  code isn't written yet)

Items of lesser note, although their importance is not diminished by the mere
inclusion in this seemingly unimportant list:
- We were ignoring reint errors in ldlm_intent_policy.  No more!
- ll_dir_readpage error "handling" led directly to a panic.  Hopefully that's
  fixed now.

lustre/ldlm/ldlm_lock.c
lustre/llite/dir.c
lustre/llite/namei.c
lustre/llite/symlink.c
lustre/mdc/mdc_request.c
lustre/mds/mds_reint.c

index c43240e..9ad2c51 100644 (file)
@@ -288,14 +288,12 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                 case IT_RENAME:
                         bufcount = 3;
                         break;
-                case IT_RENAME2:
-                        bufcount = 5;
-                        break;
                 case IT_UNLINK:
                         bufcount = 2;
                         size[1] = sizeof(struct obdo);
                         break;
                 case IT_RMDIR:
+                case IT_RENAME2:
                         bufcount = 1;
                         break;
                 default:
@@ -335,8 +333,10 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                                 RETURN(-EINVAL);
                         }
                         rc = mds_reint_p(2, req);
-                        if (rc)
-                                LBUG();
+                        if (rc || req->rq_status != 0) {
+                                rep->lock_policy_res2 = req->rq_status;
+                                RETURN(ELDLM_LOCK_ABORTED);
+                        }
                         break;
                 case IT_GETATTR:
                 case IT_READDIR:
@@ -357,7 +357,6 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                          * set req->rq_status, who should return negative and
                          * positive return values, and what they all mean. */
                         if (rc || req->rq_status != 0) {
-                                mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
                                 rep->lock_policy_res2 = req->rq_status;
                                 RETURN(ELDLM_LOCK_ABORTED);
                         }
@@ -374,8 +373,8 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                     it->opc == IT_RENAME || it->opc == IT_RENAME2)
                         RETURN(ELDLM_LOCK_ABORTED);
 
-                mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
                 rep->lock_policy_res2 = req->rq_status;
+                mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
                 new_resid[0] = NTOH__u32(mds_rep->ino);
                 if (new_resid[0] == 0)
                         LBUG();
index 8e3141c..526bc1c 100644 (file)
@@ -77,11 +77,13 @@ static int ll_dir_readpage(struct file *file, struct page *page)
         rc = ll_lock(inode, NULL, &it, &lockh);
         request = (struct ptlrpc_request *)it.it_data;
         ptlrpc_free_req(request);
-        if (rc != ELDLM_OK)
+        if (rc != ELDLM_OK) {
                 CERROR("lock enqueue: err: %d\n", rc);
+                UnlockPage(page);
+                RETURN(rc);
+        }
         ldlm_lock_dump((void *)(unsigned long)lockh.addr);
 
-
         if (Page_Uptodate(page)) {
                 CERROR("Explain this please?\n");
                 GOTO(readpage_out, rc);
index 463357b..c7906af 100644 (file)
@@ -105,8 +105,8 @@ int ll_lock(struct inode *dir, struct dentry *dentry,
                 err = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT,
                                   it, LCK_PW, dir, dentry, lockh, 0, NULL, 0,
                                   dir, sizeof(*dir));
-        else if (it->it_op & (IT_RENAME| IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK |
-                              IT_RMDIR | IT_RENAME2))
+        else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK |
+                              IT_RMDIR | IT_RENAME | IT_RENAME2))
                 err = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT,
                                   it, LCK_PR, dir, dentry, lockh, 0, NULL, 0,
                                   dir, sizeof(*dir));
@@ -152,14 +152,19 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
                 RETURN(ERR_PTR(-ENAMETOOLONG));
 
         err = ll_lock(dir, dentry, it, &lockh);
+        if (err < 0) {
+                /* FIXME: Mike handle EINTR here */
+                LBUG();
+                RETURN(ERR_PTR(err));
+        }
         memcpy(it->it_lock_handle, &lockh, sizeof(lockh));
 
-        if ( (it->it_op & (IT_RENAME |IT_CREAT | IT_MKDIR | IT_SYMLINK | IT_MKNOD)) &&
-             it->it_disposition && !it->it_status)
+        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_GETATTR | IT_UNLINK | IT_RMDIR)) &&
-             it->it_disposition && it->it_status)
+        if ((it->it_op & (IT_RENAME | IT_GETATTR | IT_UNLINK | IT_RMDIR)) &&
+            it->it_disposition && it->it_status)
                 GOTO(negative, NULL);
 
         request = (struct ptlrpc_request *)it->it_data;
@@ -188,7 +193,7 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
 
                 if (!inode)
                         GOTO(out_req, -ENOMEM);
-                inode->i_mode= S_IFREG;
+                inode->i_mode = S_IFREG;
                 inode->i_nlink = 1;
                 GOTO(out_req, 0);
         } else if (it->it_op == IT_RMDIR) {
@@ -196,10 +201,10 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
                 if (!inode)
                         GOTO(out_req, -ENOMEM);
                 ll_i2info(inode)->lli_obdo = NULL;
-                inode->i_mode= S_IFDIR;
+                inode->i_mode = S_IFDIR;
                 inode->i_nlink = 1;
                 GOTO(out_req, 0);
-        } else {
+        } else if (it->it_op != IT_RENAME2) {
                 struct mds_body *body;
 
                 offset = 1;
@@ -218,7 +223,8 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
         } else
                 md.obdo = NULL;
 
-        md.body = lustre_msg_buf(request->rq_repmsg, offset);
+        if (!(it->it_op & IT_RENAME2))
+                md.body = lustre_msg_buf(request->rq_repmsg, offset);
 
         inode = iget4(dir->i_sb, ino, ll_find_inode, &md);
 
@@ -438,9 +444,6 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
         struct inode * inode;
         struct ll_inode_info *oinfo;
 
-        if (l > LL_INLINESZ)
-                return err;
-
         inode = ll_create_node(dir, dentry->d_name.name,
                                dentry->d_name.len, symname, l,
                                S_IFLNK | S_IRWXUGO, 0, dentry->d_it, NULL);
@@ -450,8 +453,9 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry,
 
         oinfo = ll_i2info(inode);
 
-        memcpy(oinfo->lli_inline, symname, l);
-        inode->i_size = l-1;
+        OBD_ALLOC(oinfo->lli_symlink_name, l + 1);
+        memcpy(oinfo->lli_symlink_name, symname, l + 1);
+        inode->i_size = l;
 
         err = ext2_add_nondir(dentry, inode);
 
@@ -599,7 +603,7 @@ static int ll_rename(struct inode * old_dir, struct dentry * old_dentry,
         struct ext2_dir_entry_2 * old_de;
         int err = -ENOENT;
 
-        if (new_dentry->d_it)
+        if (new_dentry->d_it && new_dentry->d_it->it_disposition)
                 GOTO(out, err = new_dentry->d_it->it_status);
 
         err = ll_mdc_rename(old_dir, new_dir, old_dentry, new_dentry);
index 1b307d6..35941a8 100644 (file)
@@ -35,8 +35,7 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen)
         int rc, size;
         ENTRY;
 
-        rc = mdc_getattr(&sbi->ll_mdc_conn,
-                         dentry->d_inode->i_ino, S_IFLNK,
+        rc = mdc_getattr(&sbi->ll_mdc_conn, dentry->d_inode->i_ino, S_IFLNK,
                          OBD_MD_LINKNAME, dentry->d_inode->i_size, &request);
         if (rc) {
                 CERROR("failure %d inode %ld\n", rc,
index 00d6a39..9fb9fca 100644 (file)
@@ -91,7 +91,7 @@ int mdc_getattr(struct lustre_handle *conn,
         ENTRY;
 
         req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_GETATTR, 1, size, NULL);
+                               MDS_GETATTR, 1, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
@@ -200,8 +200,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[3] = de->d_name.len + 1;
                 size[4] = tgtlen + 1;
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                       &mdc->mdc_connh, 
-                                       LDLM_ENQUEUE, 5, size, NULL);
+                                       &mdc->mdc_connh, LDLM_ENQUEUE, 5, size,
+                                       NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -218,14 +218,15 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[1] = sizeof(struct mds_body);
                 size[2] = sizeof(struct obdo);
                 req->rq_replen = lustre_msg_size(3, size);
-        } else if ( it->it_op == IT_RENAME2 ) {
+        } else if (it->it_op == IT_RENAME2) {
                 struct dentry *old_de = it->it_data;
 
                 size[2] = sizeof(struct mds_rec_rename);
                 size[3] = old_de->d_name.len + 1;
                 size[4] = de->d_name.len + 1;
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                      &mdc->mdc_connh, LDLM_ENQUEUE, 5, size, NULL);
+                                       &mdc->mdc_connh, LDLM_ENQUEUE, 5, size,
+                                       NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -234,15 +235,13 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 lit->opc = NTOH__u64((__u64)it->it_op);
 
                 /* pack the intended request */
-                mds_rename_pack(req, 2, old_de->d_inode, dir,
-                                old_de->d_parent->d_name.name,
-                                old_de->d_parent->d_name.len,
+                mds_rename_pack(req, 2, old_de->d_parent->d_inode, dir,
+                                old_de->d_name.name, old_de->d_name.len,
                                 de->d_name.name, de->d_name.len);
 
                 size[0] = sizeof(struct ldlm_reply);
-                size[1] = sizeof(struct mds_body);
-                req->rq_replen = lustre_msg_size(2, size);
-        } else if ( it->it_op == IT_UNLINK ) {
+                req->rq_replen = lustre_msg_size(1, size);
+        } else if (it->it_op == IT_UNLINK) {
                 size[2] = sizeof(struct mds_rec_unlink);
                 size[3] = de->d_name.len + 1;
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
@@ -260,11 +259,12 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[0] = sizeof(struct ldlm_reply);
                 size[1] = sizeof(struct obdo);
                 req->rq_replen = lustre_msg_size(2, size);
-        } else if ( it->it_op == IT_RMDIR ) {
+        } else if (it->it_op == IT_RMDIR) {
                 size[2] = sizeof(struct mds_rec_unlink);
                 size[3] = de->d_name.len + 1;
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                      &mdc->mdc_connh, LDLM_ENQUEUE, 4, size, NULL);
+                                       &mdc->mdc_connh, LDLM_ENQUEUE, 4, size,
+                                       NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -277,8 +277,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                                 de->d_name.len);
                 size[0] = sizeof(struct ldlm_reply);
                 req->rq_replen = lustre_msg_size(1, size);
-        } else if ( it->it_op == IT_GETATTR || it->it_op == IT_RENAME ||
-                    it->it_op == IT_OPEN ) {
+        } else if (it->it_op == IT_GETATTR || it->it_op == IT_RENAME ||
+                   it->it_op == IT_OPEN) {
                 size[2] = sizeof(struct mds_body);
                 size[3] = de->d_name.len + 1;
 
@@ -300,11 +300,12 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[1] = sizeof(struct mds_body);
                 size[2] = sizeof(struct obdo);
                 req->rq_replen = lustre_msg_size(3, size);
-        } else if ( it->it_op == IT_SETATTR) {
+        } else if (it->it_op == IT_SETATTR) {
                 size[2] = sizeof(struct mds_rec_setattr);
                 size[3] = de->d_name.len + 1;
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                &mdc->mdc_connh, LDLM_ENQUEUE, 5, size, NULL);
+                                       &mdc->mdc_connh, LDLM_ENQUEUE, 5, size,
+                                       NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -319,7 +320,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[0] = sizeof(struct ldlm_reply);
                 size[1] = sizeof(struct mds_body);
                 req->rq_replen = lustre_msg_size(2, size);
-        } else if ( it->it_op == IT_READDIR ) {
+        } else if (it->it_op == IT_READDIR) {
                 req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
                                 &mdc->mdc_connh, LDLM_ENQUEUE, 1, size, NULL);
                 if (!req)
@@ -333,8 +334,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(mdc->mdc_ldlm_client, mdc->mdc_conn, 
-                              NULL, req,
+        rc = ldlm_cli_enqueue(mdc->mdc_ldlm_client, mdc->mdc_conn, NULL, req,
                               obddev->obd_namespace, NULL, res_id, lock_type,
                               NULL, 0, lock_mode, &flags,
                               (void *)mdc_lock_callback, data, datalen, lockh);
@@ -371,7 +371,7 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
         }
 
         req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_OPEN, bufcount, size, NULL);
+                               MDS_OPEN, bufcount, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
@@ -412,7 +412,7 @@ int mdc_close(struct lustre_handle *conn,
         struct ptlrpc_request *req;
 
         req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_CLOSE, 1, &size, NULL);
+                               MDS_CLOSE, 1, &size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
@@ -450,7 +450,7 @@ int mdc_readpage(struct lustre_handle *conn, obd_id ino, int type, __u64 offset,
                 GOTO(out, rc = -ENOMEM);
 
         req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_READPAGE, 1, &size, NULL);
+                               MDS_READPAGE, 1, &size, NULL);
         if (!req)
                 GOTO(out2, rc = -ENOMEM);
 
@@ -501,7 +501,7 @@ int mdc_statfs(struct lustre_handle *conn, struct statfs *sfs,
         ENTRY;
 
         req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_STATFS, 0, NULL, NULL);
+                               MDS_STATFS, 0, NULL, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
         req->rq_replen = lustre_msg_size(1, &size);
index aebd988..a25d074 100644 (file)
@@ -619,19 +619,15 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         struct dentry *de_old = NULL;
         struct dentry *de_new = NULL;
         struct mds_obd *mds = mds_req2mds(req);
-        __u64 res_id[3] = {0};
         struct lustre_handle tgtlockh, srclockh, oldhandle;
-        int lock_mode;
+        int flags, lock_mode, rc = 0, err;
         void *handle;
-        int flags;
-        int rc = 0;
-        int err;
+        __u64 res_id[3] = {0};
         ENTRY;
 
         de_srcdir = mds_fid2dentry(mds, rec->ur_fid1, NULL);
-        if (IS_ERR(de_srcdir)) {
+        if (IS_ERR(de_srcdir))
                 GOTO(out_rename, rc = -ESTALE);
-        }
 
         lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
         res_id[0] = de_srcdir->d_inode->i_ino;
@@ -653,11 +649,9 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         } else
                 ldlm_lock_dump((void *)(unsigned long)srclockh.addr);
 
-
         de_tgtdir = mds_fid2dentry(mds, rec->ur_fid2, NULL);
-        if (IS_ERR(de_tgtdir)) {
+        if (IS_ERR(de_tgtdir))
                 GOTO(out_rename_srcdir, rc = -ESTALE);
-        }
 
         lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
         res_id[0] = de_tgtdir->d_inode->i_ino;
@@ -683,14 +677,16 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
 
         de_old = lookup_one_len(rec->ur_name, de_srcdir, rec->ur_namelen - 1);
         if (IS_ERR(de_old)) {
-                CERROR("old child lookup error %ld\n", PTR_ERR(de_old));
-                GOTO(out_rename_tgtdir, rc = -ESTALE);
+                CERROR("old child lookup error (%*s): %ld\n",
+                       rec->ur_namelen - 1, rec->ur_name, PTR_ERR(de_old));
+                GOTO(out_rename_tgtdir, rc = -ENOENT);
         }
 
         de_new = lookup_one_len(rec->ur_tgt, de_tgtdir, rec->ur_tgtlen - 1);
         if (IS_ERR(de_new)) {
-                CERROR("new child lookup error %ld\n", PTR_ERR(de_new));
-                GOTO(out_rename_deold, rc = -ESTALE);
+                CERROR("new child lookup error (%*s): %ld\n",
+                       rec->ur_tgtlen - 1, rec->ur_tgt, PTR_ERR(de_new));
+                GOTO(out_rename_deold, rc = -ENOENT);
         }
 
         OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE,