Whamcloud - gitweb
- remainder of rmdir changes
authorbraam <braam>
Sun, 23 Jun 2002 04:37:10 +0000 (04:37 +0000)
committerbraam <braam>
Sun, 23 Jun 2002 04:37:10 +0000 (04:37 +0000)
lustre/ldlm/ldlm_lock.c
lustre/llite/file.c
lustre/llite/namei.c
lustre/mdc/mdc_request.c

index 31a6f4b..2d24340 100644 (file)
@@ -83,6 +83,9 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                         bufcount = 2;
                         size[1] = sizeof(struct obdo); 
                         break;
+                case IT_RMDIR:
+                        bufcount = 1;
+                        break;
                 default:
                         LBUG();
                 }
@@ -107,6 +110,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                 case IT_MKNOD:
                 case IT_LINK:
                 case IT_UNLINK:
+                case IT_RMDIR:
                 case IT_RENAME2:
                         if (mds_reint_p == NULL)
                                 mds_reint_p =
index 1382b9c..740d4b9 100644 (file)
@@ -64,7 +64,8 @@ static int ll_file_open(struct inode *inode, struct file *file)
                 GOTO(out, rc = -ENOMEM);
         memset(fd, 0, sizeof(*fd));
 
-        rc = mdc_open(&sbi->ll_mdc_conn, inode->i_ino, S_IFREG, file->f_flags,
+        rc = mdc_open(&sbi->ll_mdc_conn, inode->i_ino, S_IFREG | inode->i_mode,
+                      file->f_flags,
                       oa, (__u64)(unsigned long)file, &fd->fd_mdshandle, &req);
         fd->fd_req = req;
         ptlrpc_req_finished(req);
index 34bcdcd..e367bbc 100644 (file)
@@ -105,7 +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_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK))
+        else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK |
+                              IT_RMDIR))
                 err = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_MDSINTENT,
                                   it, LCK_PR, dir, dentry, lockh, 0, NULL, 0,
                                   dir, sizeof(*dir));
@@ -159,7 +160,7 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
              it->it_disposition && !it->it_status)
                 GOTO(negative, NULL);
 
-        if ( (it->it_op & (IT_GETATTR | IT_UNLINK)) &&
+        if ( (it->it_op & (IT_GETATTR | IT_UNLINK | IT_RMDIR)) &&
              it->it_disposition && it->it_status)
                 GOTO(negative, NULL);
 
@@ -192,6 +193,14 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
                 inode->i_mode= S_IFREG;
                 inode->i_nlink = 1;
                 GOTO(out_req, 0);
+        } else if (it->it_op == IT_RMDIR) { 
+                inode = new_inode(dir->i_sb);
+                if (!inode) 
+                        GOTO(out_req, -ENOMEM);
+                ll_i2info(inode)->lli_obdo = NULL;
+                inode->i_mode= S_IFDIR;
+                inode->i_nlink = 1;
+                GOTO(out_req, 0);
         } else {
                 struct mds_body *body;
 
@@ -565,17 +574,21 @@ out:
 static int ll_rmdir(struct inode * dir, struct dentry *dentry)
 {
         struct inode * inode = dentry->d_inode;
-        int err = -ENOTEMPTY;
+        int err = 0;
+        int intent_did = dentry->d_it && dentry->d_it->it_disposition;
+
+        if (!intent_did) { 
+                if (!ext2_empty_dir(inode))
+                LBUG();
 
-        if (ext2_empty_dir(inode)) {
                 err = ll_unlink(dir, dentry);
-                if (!err) {
-                        inode->i_size = 0;
-                        ext2_dec_count(inode);
-                        ext2_dec_count(dir);
-                }
+                if (err) 
+                        RETURN(err);
         }
-        return err;
+        inode->i_size = 0;
+        ext2_dec_count(inode);
+        ext2_dec_count(dir);
+        RETURN(err);
 }
 
 static int ll_rename (struct inode * old_dir, struct dentry * old_dentry,
index db2dbd6..de7ad89 100644 (file)
@@ -259,8 +259,25 @@ int mdc_enqueue(struct obd_conn *conn, int lock_type, struct lookup_intent *it,
                 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 ) {
+                size[2] = sizeof(struct mds_rec_unlink);
+                size[3] = de->d_name.len + 1;
+                req = ptlrpc_prep_req(mdc->mdc_ldlm_client, mdc->mdc_conn,
+                                      LDLM_ENQUEUE, 4, size, NULL);
+                if (!req)
+                        RETURN(-ENOMEM);
+
+                /* pack the intent */
+                lit = lustre_msg_buf(req->rq_reqmsg, 1);
+                lit->opc = NTOH__u64((__u64)it->it_op);
+
+                /* pack the intended request */
+                mds_unlink_pack(req, 2, dir, NULL, de->d_name.name, 
+                                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 ) {
+                     it->it_op == IT_OPEN ) {
                 size[2] = sizeof(struct mds_body);
                 size[3] = de->d_name.len + 1;