Whamcloud - gitweb
- a fix for Gary's directory read-back bug. You can now create lots
authorbraam <braam>
Mon, 16 Sep 2002 22:33:16 +0000 (22:33 +0000)
committerbraam <braam>
Mon, 16 Sep 2002 22:33:16 +0000 (22:33 +0000)
  of files and ls shows them. Fixes include updating the directory
  size during readdir by passing back the size in the readdir call.
  Every directory has at least one page, so this works.

lustre/llite/dir.c
lustre/mds/handler.c

index 9f12a25..456f6f1 100644 (file)
@@ -64,6 +64,7 @@ static int ll_dir_readpage(struct file *file, struct page *page)
         int rc = 0;
         struct ptlrpc_request *request;
         struct lustre_handle lockh;
+        struct mds_body *body;
         struct lookup_intent it = {IT_READDIR};
 
         ENTRY;
@@ -94,6 +95,11 @@ static int ll_dir_readpage(struct file *file, struct page *page)
         rc = mdc_readpage(&sbi->ll_mdc_conn, inode->i_ino,
                           S_IFDIR, offset, buf, &request);
         kunmap(page);
+        body = lustre_msg_buf(request->rq_repmsg, 0); 
+        if (!body) 
+                rc = -EINVAL;
+        if (body) 
+                inode->i_size = body->size;
         ptlrpc_free_req(request);
         EXIT;
 
@@ -374,6 +380,9 @@ int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
                 ext2_dirent *de;
                 struct page *page = ext2_get_page(inode, n);
 
+                /* size might have been updated by mdc_readpage */
+                npages = dir_pages(inode);
+
                 if (IS_ERR(page))
                         continue;
                 kaddr = page_address(page);
index fec6e2b..abfcfed 100644 (file)
@@ -790,7 +790,7 @@ static int mds_readpage(struct ptlrpc_request *req)
         struct vfsmount *mnt;
         struct dentry *de;
         struct file *file;
-        struct mds_body *body;
+        struct mds_body *body, *repbody;
         struct obd_run_ctxt saved;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -813,10 +813,15 @@ static int mds_readpage(struct ptlrpc_request *req)
         /* note: in case of an error, dentry_open puts dentry */
         if (IS_ERR(file))
                 GOTO(out_pop, rc = PTR_ERR(file));
+        
+        repbody = lustre_msg_buf(req->rq_repmsg, 0);
+        repbody->size = file->f_dentry->d_inode->i_size;
+        repbody->valid = OBD_MD_FLSIZE;
 
         /* to make this asynchronous make sure that the handling function
            doesn't send a reply when this function completes. Instead a
            callback function would send the reply */
+        /* note: in case of an error, dentry_open puts dentry */
         rc = mds_sendpage(req, file, body->size);
 
         filp_close(file, 0);