Whamcloud - gitweb
Another slightly less rough cut at XML based configuration. There
[fs/lustre-release.git] / lustre / llite / dir.c
index 3d91ae6..0262b05 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
 #include <linux/lustre_lite.h>
+#include <linux/lustre_dlm.h>
 
 typedef struct ext2_dir_entry_2 ext2_dirent;
 
@@ -62,6 +63,8 @@ static int ll_dir_readpage(struct file *file, struct page *page)
         __u64 offset;
         int rc = 0;
         struct ptlrpc_request *request = NULL;
+        struct lustre_handle lockh; 
+        struct lookup_intent it = {IT_READDIR }; 
 
         ENTRY;
 
@@ -72,6 +75,11 @@ static int ll_dir_readpage(struct file *file, struct page *page)
                 goto readpage_out;
         }
 
+        rc = ll_lock(inode, NULL, &it, &lockh);
+        if (rc != ELDLM_OK)
+                CERROR("lock enqueue: err: %d\n", rc);
+        ldlm_lock_dump((void *)(unsigned long)lockh.addr);
+
         if (Page_Uptodate(page)) {
                 CERROR("Explain this please?\n");
                 EXIT;
@@ -80,7 +88,7 @@ static int ll_dir_readpage(struct file *file, struct page *page)
 
         offset = page->index << PAGE_SHIFT; 
         buf = kmap(page);
-        rc = mdc_readpage(&sbi->ll_mds_client, sbi->ll_mds_conn, inode->i_ino,
+        rc = mdc_readpage(&sbi->ll_mdc_conn, inode->i_ino,
                           S_IFDIR, offset, buf, &request);
         kunmap(page); 
         ptlrpc_free_req(request);
@@ -91,6 +99,9 @@ static int ll_dir_readpage(struct file *file, struct page *page)
                 SetPageUptodate(page);
 
         UnlockPage(page);
+        rc = ll_unlock(LCK_PR, &lockh);
+        if (rc != ELDLM_OK)
+                CERROR("ll_unlock: err: %d\n", rc);
         return rc;
 } /* ll_dir_readpage */
 
@@ -336,7 +347,7 @@ static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
 }
 
 int
-new_ll_readdir (struct file * filp, void * dirent, filldir_t filldir)
+ll_readdir (struct file * filp, void * dirent, filldir_t filldir)
 {
         loff_t pos = filp->f_pos;
         struct inode *inode = filp->f_dentry->d_inode;
@@ -624,12 +635,14 @@ int ext2_make_empty(struct inode *inode, struct inode *parent)
 
         if (!page)
                 return -ENOMEM;
+        base = kmap(page);
+        if (!base) 
+                return -ENOMEM;
+
         err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size);
         if (err)
                 goto fail;
 
-        base = page_address(page);
-
         de = (struct ext2_dir_entry_2 *) base;
         de->name_len = 1;
         de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1));
@@ -646,6 +659,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent)
 
         err = ext2_commit_chunk(page, 0, chunk_size);
 fail:
+        kunmap(page);
         UnlockPage(page);
         page_cache_release(page);
         ENTRY;
@@ -699,5 +713,5 @@ not_empty:
 
 struct file_operations ll_dir_operations = {
         read: generic_read_dir,
-        readdir: new_ll_readdir
+        readdir: ll_readdir
 };