Whamcloud - gitweb
- fixed some NTOH/HTON mixups
[fs/lustre-release.git] / lustre / llite / dir.c
index 83305e8..fe6aff8 100644 (file)
@@ -35,6 +35,7 @@
 #define DEBUG_SUBSYSTEM S_LLIGHT
 
 #include <linux/obd_support.h>
+#include <linux/obd_class.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
@@ -59,43 +60,37 @@ static int ll_dir_readpage(struct file *file, struct page *page)
        char *buf;
        __u64 offset;
         int rc = 0;
-       struct ptlrep_hdr *hdr;
+       struct ptlrpc_request *request;
 
         ENTRY;
 
-       if ( ((inode->i_size + PAGE_CACHE_SIZE -1)>>PAGE_SHIFT) 
-            <= page->index) {
+       if ( ((inode->i_size + PAGE_CACHE_SIZE -1)>>PAGE_SHIFT)
+             <= page->index) {
                memset(kmap(page), 0, PAGE_CACHE_SIZE);
                kunmap(page);
+                EXIT;
                goto readpage_out;
        }
 
        if (Page_Uptodate(page)) {
+                CERROR("Explain this please?\n");
                EXIT;
                goto readpage_out;
        }
 
        offset = page->index << PAGE_SHIFT; 
        buf = kmap(page);
-        rc = mdc_readpage(sbi->ll_peer_ptr, inode->i_ino, S_IFDIR, offset, buf,
-                         NULL, &hdr);
+        rc = mdc_readpage(&sbi->ll_mds_client, inode->i_ino, S_IFDIR, offset, 
+                         buf, &request);
        kunmap(page); 
-        if ( rc ) {
-               EXIT; 
-               goto readpage_out;
-        } 
-
-       if ((rc = hdr->status)) {
-               EXIT;
-               goto readpage_out;
-       }
-
-        /* PDEBUG(page, "READ"); */
+        ptlrpc_free_req(request);
+        EXIT;
 
-       SetPageUptodate(page);
  readpage_out:
-       obd_unlock_page(page);
-        EXIT;
+        if ( !rc )
+                SetPageUptodate(page);
+
+       UnlockPage(page);
         return rc;
 } /* ll_dir_readpage */
 
@@ -170,8 +165,11 @@ static void ext2_check_page(struct page *page)
 
        if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
                limit = dir->i_size & ~PAGE_CACHE_MASK;
-               if (limit & (chunk_size - 1))
+               if (limit & (chunk_size - 1)) {
+                       CERROR("limit %d dir size %lld index %ld\n", 
+                                       limit, dir->i_size, page->index); 
                        goto Ebadsize;
+               }
                for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
                        ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
                        p->rec_len = cpu_to_le16(chunk_size);
@@ -203,8 +201,8 @@ out:
        /* Too bad, we had an error */
 
 Ebadsize:
-       printk("ext2_check_page"
-               "size of directory #%lu is not a multiple of chunk size",
+       CERROR("ext2_check_page"
+               "size of directory #%lu is not a multiple of chunk size\n",
                dir->i_ino
        );
        goto fail;
@@ -223,7 +221,7 @@ Espan:
        //Einumber:
        // error = "inode out of bounds";
 bad_entry:
-       printk("ext2_check_page: bad entry in directory #%lu: %s - "
+       CERROR("ext2_check_page: bad entry in directory #%lu: %s - "
                "offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
                dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs,
                (unsigned long) le32_to_cpu(p->inode),
@@ -231,7 +229,7 @@ bad_entry:
        goto fail;
 Eend:
        p = (ext2_dirent *)(kaddr + offs);
-       printk("ext2_check_page"
+       CERROR("ext2_check_page"
                "entry in directory #%lu spans the page boundary"
                "offset=%lu, inode=%lu",
                dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
@@ -239,6 +237,7 @@ Eend:
 fail:
        SetPageChecked(page);
        SetPageError(page);
+        BUG();
 }
 
 static struct page * ext2_get_page(struct inode *dir, unsigned long n)
@@ -528,7 +527,7 @@ int ll_add_link (struct dentry *dentry, struct inode *inode)
                        name_len = EXT2_DIR_REC_LEN(de->name_len);
                        rec_len = le16_to_cpu(de->rec_len);
                        if ( n==npages && rec_len == 0) {
-                               printk("Fatal dir behaviour\n");
+                               CERROR("Fatal dir behaviour\n");
                                goto out_page;
                        }
                        if (!de->inode && rec_len >= reclen)