Whamcloud - gitweb
Changes for file creation and small fixes.
authorbraam <braam>
Mon, 28 Jan 2002 19:06:15 +0000 (19:06 +0000)
committerbraam <braam>
Mon, 28 Jan 2002 19:06:15 +0000 (19:06 +0000)
15 files changed:
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_light.h
lustre/include/linux/lustre_mds.h
lustre/lib/mds_updates.c
lustre/llite/dir.c
lustre/llite/namei.c
lustre/llite/super.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_reint.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/tests/mdcreq.sh
lustre/tests/ostreq.sh

index f1d966d..e7f74f6 100644 (file)
@@ -137,6 +137,7 @@ struct obdo {
 #define OBD_MD_FLGENER  (0x00004000UL)
 #define OBD_MD_FLINLINE (0x00008000UL)
 #define OBD_MD_FLOBDMD  (0x00010000UL)
+#define OBD_MD_FLOBJID  (0x00020000UL)
 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS))
 
 /* request structure for OST's */
@@ -246,6 +247,7 @@ struct mds_req_packed {
         __u32                       ino;
         __u32                       nlink;
         __u32                       generation;
+        __u64                       objid;
 };
 
 struct mds_rep_packed {
@@ -267,6 +269,7 @@ struct mds_rep_packed {
         __u32                       ino;
         __u32                       nlink;
         __u32                       generation;
+        __u64                       objid;
 };
 
 
index 77244d2..fe95c0f 100644 (file)
@@ -19,8 +19,7 @@
 
 struct ll_inode_info {
         int              lli_flags;
-        struct list_head lli_inodes;
-        struct list_head lli_pages;
+       __u64            lli_objid; 
         char             lli_inline[OBD_INLINESZ];
 };
 
@@ -69,56 +68,7 @@ static void inline ll_from_inode(struct obdo *oa, struct inode *inode)
         }
 } /* ll_from_inode */
 
-static __inline__ void mds_rep_to_inode(struct inode *dst, struct mds_rep *rep)
-{
-
-        if ( rep->valid & OBD_MD_FLID )
-                dst->i_ino = rep->ino;
-        if ( rep->valid & OBD_MD_FLATIME ) 
-                dst->i_atime = rep->atime;
-        if ( rep->valid & OBD_MD_FLMTIME ) 
-                dst->i_mtime = rep->mtime;
-        if ( rep->valid & OBD_MD_FLCTIME ) 
-                dst->i_ctime = rep->ctime;
-        if ( rep->valid & OBD_MD_FLSIZE ) 
-                dst->i_size = rep->size;
-        if ( rep->valid & OBD_MD_FLMODE ) 
-                dst->i_mode = rep->mode;
-        if ( rep->valid & OBD_MD_FLUID ) 
-                dst->i_uid = rep->uid;
-        if ( rep->valid & OBD_MD_FLGID ) 
-                dst->i_gid = rep->gid;
-        if ( rep->valid & OBD_MD_FLFLAGS ) 
-                dst->i_flags = rep->flags;
-        if ( rep->valid & OBD_MD_FLNLINK )
-                dst->i_nlink = rep->nlink;
-        if ( rep->valid & OBD_MD_FLGENER )
-                dst->i_generation = rep->generation;
-}
 
-static void inline ll_to_inode(struct inode *inode, struct mds_rep *rep)
-{
-        CDEBUG(D_INFO, "src obdo %d valid 0x%08x, dst inode %ld\n",
-               rep->ino, rep->valid, inode->i_ino);
-
-        mds_rep_to_inode(inode, rep);
-
-#if 0
-        if (obdo_has_inline(oa)) {
-               if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
-                   S_ISFIFO(inode->i_mode)) {
-                       obd_rdev rdev = *((obd_rdev *)oa->o_inline);
-                       CDEBUG(D_INODE,
-                              "copying device %x from obdo to inode\n", rdev);
-                       init_special_inode(inode, inode->i_mode, rdev);
-               } else {
-                       CDEBUG(D_INFO, "copying inline from obdo to inode\n");
-                       memcpy(oinfo->lli_inline, oa->o_inline, OBD_INLINESZ);
-               }
-                oinfo->lli_flags |= OBD_FL_INLINEDATA;
-        }
-#endif 
-} /* ll_to_inode */
 
 
 
@@ -229,19 +179,6 @@ static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
         return (struct ll_sb_info *) &(inode->i_sb->u.generic_sbp);
 }
 
-static inline struct list_head *ll_iplist(struct inode *inode) 
-{
-        struct ll_inode_info *info = ll_i2info(inode);
-
-        return &info->lli_pages;
-}
-
-static inline struct list_head *ll_islist(struct inode *inode) 
-{
-        struct ll_inode_info *info = ll_i2info(inode);
-
-        return &info->lli_inodes;
-}
 
 static inline struct list_head *ll_slist(struct inode *inode) 
 {
@@ -284,29 +221,5 @@ static void inline ll_set_size (struct inode *inode, obd_size size)
 #define OBDAddCachePage(page)   test_and_set_bit(PG_obdcache, &(page)->flags)
 #define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags)
 
-static inline void ll_print_plist(struct inode *inode) 
-{
-        struct list_head *page_list = ll_iplist(inode);
-        struct list_head *tmp;
-
-        CDEBUG(D_INFO, "inode %ld: page", inode->i_ino);
-        /* obd_down(&ll_i2sbi(inode)->ll_list_mutex); */
-        if (list_empty(page_list)) {
-                CDEBUG(D_INFO, " list empty\n");
-                obd_up(&ll_i2sbi(inode)->ll_list_mutex);
-                return;
-        }
-
-        tmp = page_list;
-        while ( (tmp = tmp->next) != page_list) {
-                struct ll_pgrq *pgrq;
-                pgrq = list_entry(tmp, struct ll_pgrq, rq_plist);
-                CDEBUG(D_INFO, " %p", pgrq->rq_page);
-        }
-        CDEBUG(D_INFO, "\n");
-        /* obd_up(&ll_i2sbi(inode)->ll_list_mutex); */
-}
-#include <linux/obdo.h>
-
 #endif
 
index 1ee99b5..a7fb923 100644 (file)
@@ -99,6 +99,7 @@ struct mds_req {
         __u32                       ino;
         __u32                       nlink;
         __u32                       generation;
+        __u64                       objid;
 };
 
 /* more or less identical to the packed structure, except for the pointers */
@@ -121,6 +122,7 @@ struct mds_rep {
         __u32                       ino;
         __u32                       nlink;
         __u32                       generation;
+        __u64                       objid;
 };
 
 struct mds_update_record { 
@@ -154,12 +156,11 @@ int mds_reint_rec(struct mds_update_record *r, struct mds_request *req);
 int mds_update_unpack(char *buf, int len, struct mds_update_record *r); 
 
 void mds_setattr_pack(struct mds_rec_setattr *rec, struct inode *inode, struct iattr *iattr);
-void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, char *name, __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time);
+void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, const char *name, int namelen, __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time);
 
 /* mds/handler.c */
 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt);
 
-
 /* llight/request.c */
 int mdc_getattr(ino_t ino, int type, int valid, 
                struct mds_rep  **mds_reply, struct mds_rep_hdr **hdr);
@@ -167,12 +168,11 @@ int mdc_setattr(struct inode *inode, struct iattr *iattr,
                struct mds_rep  **mds_reply, struct mds_rep_hdr **hdr);
 int mdc_readpage(ino_t ino, int type, __u64 offset, char *addr, 
                  struct mds_rep  **rep, struct mds_rep_hdr **hdr);
-int mdc_create(struct inode *dir, char *name, int mode, __u64 id, 
-               __u32 uid, __u32 gid, __u64 time, 
+int mdc_create(struct inode *dir, const char *name, 
+               int namelen, int mode, __u64 id, __u32 uid, 
+               __u32 gid, __u64 time, 
                struct mds_rep **rep, struct mds_rep_hdr **hdr);
 
-
-
 /* ioctls for trying requests */
 #define IOC_REQUEST_TYPE                   'f'
 #define IOC_REQUEST_MIN_NR                 30
index 802e909..ad48e5c 100644 (file)
 
 /* packing of MDS records */
 
-void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, char *name, __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time)
+void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, const char *name, int namelen, __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time)
 {
        char *tmp = (char *)rec + sizeof(*rec); 
        /* XXX do something about time, uid, gid */
        rec->cr_reclen = 
-               HTON__u32(sizeof(*rec)) + size_round(strlen(name) + 1);
+               HTON__u32(sizeof(*rec) + size_round(namelen + 1));
        rec->cr_opcode = HTON__u32(REINT_CREATE);
 
        ll_inode2fid(&rec->cr_fid, inode); 
@@ -49,8 +49,9 @@ void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, char *name
        rec->cr_uid = HTON__u32(uid);
        rec->cr_gid = HTON__u32(gid);
        rec->cr_time = HTON__u64(time);
-       rec->cr_namelen = strlen(name);
-       LOGL(name, rec->cr_namelen + 1, tmp); 
+       rec->cr_namelen = namelen;
+       LOGL(name, namelen, tmp); 
+       *tmp = '\0';
 }
 
 
@@ -79,7 +80,7 @@ static int mds_update_hdr_unpack(char *buf, int len, struct mds_update_record *r
        
        r->ur_reclen = NTOH__u32(hdr->ur_reclen);
        if (len < sizeof(*hdr) || len != r->ur_reclen) { 
-               printk(__FUNCTION__ "invalid buffer length\n"); 
+               printk(__FUNCTION__ "invalid buffer length\n"); 
                return -EFAULT;
        }
        r->ur_opcode = NTOH__u32(hdr->ur_opcode); 
index ebc68e9..9265dac 100644 (file)
@@ -1,5 +1,4 @@
 /*
- *  linux/fs/ext2/dir.c
  *
  * Copyright (C) 1992, 1993, 1994, 1995
  * Remy Card (card@masi.ibp.fr)
@@ -9,6 +8,7 @@
  *  from
  *
  *  linux/fs/minix/dir.c
+ *  linux/fs/ext2/dir.c
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
  *
  *  Big-endian to little-endian byte-swapping/bitmaps by
  *        David S. Miller (davem@caip.rutgers.edu), 1995
  *
- * All code that works with directory layout had been switched to pagecache
- * and moved here. AV
+ *  All code that works with directory layout had been switched to pagecache
+ *  and moved here. AV
+ *   
+ *  Adapted for Lustre Light
+ *  Copyright (C) 2002, Cluster File Systems, Inc.
+ * 
  */
 
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
 #include <linux/pagemap.h>
+#include <linux/mm.h>
 #include <linux/obd_support.h>
 #include <linux/locks.h>
 
@@ -32,9 +37,6 @@ typedef struct ext2_dir_entry_2 ext2_dirent;
 #define PageChecked(page)        test_bit(PG_checked, &(page)->flags)
 #define SetPageChecked(page)     set_bit(PG_checked, &(page)->flags)
 
-
-
-
 int waitfor_one_page(struct page *page)
 {
        int error = 0;
@@ -70,14 +72,19 @@ static inline unsigned long dir_pages(struct inode *inode)
        return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
 }
 
+extern void set_page_clean(struct page *page); 
+
 static int ext2_commit_chunk(struct page *page, unsigned from, unsigned to)
 {
        struct inode *dir = page->mapping->host;
        int err = 0;
        dir->i_version = ++event;
-       page->mapping->a_ops->commit_write(NULL, page, from, to);
-       if (IS_SYNC(dir))
-               err = waitfor_one_page(page);
+       SetPageUptodate(page);
+       set_page_clean(page);
+
+       //page->mapping->a_ops->commit_write(NULL, page, from, to);
+       //if (IS_SYNC(dir))
+       //      err = waitfor_one_page(page);
        return err;
 }
 
@@ -421,7 +428,7 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
 /*
  *     Parent is locked.
  */
-int ext2_add_link (struct dentry *dentry, struct inode *inode)
+int ll_add_link (struct dentry *dentry, struct inode *inode)
 {
        struct inode *dir = dentry->d_parent->d_inode;
        const char *name = dentry->d_name.name;
@@ -470,9 +477,9 @@ got_it:
        from = (char*)de - (char*)page_address(page);
        to = from + rec_len;
        lock_page(page);
-       err = page->mapping->a_ops->prepare_write(NULL, page, from, to);
-       if (err)
-               goto out_unlock;
+       //err = page->mapping->a_ops->prepare_write(NULL, page, from, to);
+       //if (err)
+       //      goto out_unlock;
        if (de->inode) {
                ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len);
                de1->rec_len = cpu_to_le16(rec_len - name_len);
index 408ff33..097f486 100644 (file)
@@ -38,7 +38,7 @@ extern void ll_change_inode(struct inode *inode);
 extern int ll_setattr(struct dentry *de, struct iattr *attr);
 
 /* from dir.c */
-extern int ext2_add_link (struct dentry *dentry, struct inode *inode);
+extern int ll_add_link (struct dentry *dentry, struct inode *inode);
 ino_t ll_inode_by_name(struct inode * dir, struct dentry *dentry, int *typ);
 int ext2_make_empty(struct inode *inode, struct inode *parent);
 struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
@@ -66,7 +66,7 @@ static inline void ext2_dec_count(struct inode *inode)
 static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
 {
        int err;
-       err = ext2_add_link(dentry, inode);
+       err = ll_add_link(dentry, inode);
        if (!err) {
                d_instantiate(dentry, inode);
                return 0;
@@ -130,52 +130,47 @@ static inline int ext2_match (int len, const char * const name,
         return !memcmp(name, de->name, len);
 }
 
-static struct inode *ll_new_inode(struct inode *dir, int mode)
+static struct inode *ll_create_node(struct inode *dir, const char *name, 
+                                   int namelen, int mode, __u64 id)
 {
-        struct obdo *oa;
         struct inode *inode;
+       struct mds_rep *rep;
+       struct mds_rep_hdr *hdr;
         int err;
 
         ENTRY;
 
-        oa = obdo_alloc();
-        if (!oa) {
+       err = mdc_create(dir, name, namelen, mode, id,
+                        current->uid, current->gid, CURRENT_TIME, 
+                        &rep, &hdr); 
+       if (err) { 
                 EXIT;
-                return ERR_PTR(-ENOMEM);
-        }
-
-        /* Send a hint to the create method on the type of file to create */
-        oa->o_mode = mode;
-        oa->o_valid |= OBD_MD_FLMODE;
-       CDEBUG(D_INODE, "\n");
-        err = obd_create(IID(dir), oa);
-       CDEBUG(D_INODE, "\n");
-
-        if ( err ) {
-                printk("new_inode - fatal: err %d\n", err);
-                obdo_free(oa);
-                EXIT;
-                return ERR_PTR(err);
-        }
-       CDEBUG(D_INODE, "obdo mode %o\n", oa->o_mode);
-
-        inode = iget4(dir->i_sb, (ino_t)oa->o_id, NULL, oa);
-       CDEBUG(D_INODE, "\n");
-        obdo_free(oa);
-
-        if (!inode) {
-                printk("new_inode -fatal:  %ld\n", (long)oa->o_id);
-                obd_destroy(IID(dir), oa);
+               return ERR_PTR(err);
+       }
+       if ( hdr->status) {
+               EXIT;
+               return ERR_PTR(hdr->status);
+       }
+       rep->valid = OBD_MD_FLNOTOBD;
+
+       rep->objid = id; 
+       rep->nlink = 1;
+       rep->mode = mode;
+       printk("-- new_inode: objid %lld, ino %d, mode %o\n", 
+              rep->objid, rep->ino, rep->mode); 
+
+        inode = iget4(dir->i_sb, rep->ino, NULL, rep);
+        if (IS_ERR(inode)) {
+                printk(__FUNCTION__ ": new_inode -fatal:  %ld\n", 
+                      PTR_ERR(inode));
                 EXIT;
                 return ERR_PTR(-EIO);
         }
 
         if (!list_empty(&inode->i_dentry)) {
-                printk("new_inode -fatal: aliases %ld, ct %d lnk %d\n", 
-                      (long)oa->o_id,
-                      atomic_read(&inode->i_count), 
+                printk("new_inode -fatal: aliases %d, ct %d lnk %d\n", 
+                      rep->ino, atomic_read(&inode->i_count), 
                       inode->i_nlink);
-                obd_destroy(IID(dir), oa);
                 iput(inode);
                 EXIT;
                 return ERR_PTR(-EIO);
@@ -196,21 +191,38 @@ static struct inode *ll_new_inode(struct inode *dir, int mode)
  */
 static int ll_create (struct inode * dir, struct dentry * dentry, int mode)
 {
-       struct inode * inode = ll_new_inode (dir, mode);
-       int err = PTR_ERR(inode);
+       int err; 
+       struct obdo oa;
+       struct inode * inode;
+
+       err = obd_create(IID(dir), &oa);  
+       if (err) { 
+               EXIT; 
+               return err;
+       }
+
+       mode = mode | S_IFREG;
+       printk("ll_create: name %s mode %o\n", dentry->d_name.name, mode);
+       inode = ll_create_node(dir, dentry->d_name.name, 
+                              dentry->d_name.len, 
+                              mode, oa.o_id);
+       err = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
+               // XXX clean up the object
                inode->i_op = &ll_file_inode_operations;
                inode->i_fop = &ll_file_operations;
                inode->i_mapping->a_ops = &ll_aops;
                err = ext2_add_nondir(dentry, inode);
        }
+       EXIT;
        return err;
 } /* ll_create */
 
 
 static int ll_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev)
 {
-       struct inode * inode = ll_new_inode (dir, mode);
+       struct inode * inode = ll_create_node(dir, dentry->d_name.name, 
+                                             dentry->d_name.len, mode, 0);
        int err = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
                init_special_inode(inode, mode, rdev);
@@ -231,7 +243,9 @@ static int ll_symlink (struct inode * dir, struct dentry * dentry,
        if (l > sb->s_blocksize)
                goto out;
 
-       inode = ll_new_inode (dir, S_IFLNK | S_IRWXUGO);
+       inode = ll_create_node(dir, dentry->d_name.name, 
+                              dentry->d_name.len, 
+                              S_IFLNK | S_IRWXUGO, 0);
        err = PTR_ERR(inode);
        if (IS_ERR(inode))
                goto out;
@@ -293,7 +307,9 @@ static int ll_mkdir(struct inode * dir, struct dentry * dentry, int mode)
 
        ext2_inc_count(dir);
 
-       inode = ll_new_inode (dir, S_IFDIR | mode);
+       inode = ll_create_node (dir, dentry->d_name.name, 
+                               dentry->d_name.len,
+                               S_IFDIR | mode, 0);
        err = PTR_ERR(inode);
        if (IS_ERR(inode))
                goto out_dir;
@@ -308,7 +324,7 @@ static int ll_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        if (err)
                goto out_fail;
 
-       err = ext2_add_link(dentry, inode);
+       err = ll_add_link(dentry, inode);
        if (err)
                goto out_fail;
 
@@ -414,7 +430,7 @@ static int ll_rename (struct inode * old_dir, struct dentry * old_dentry,
                                goto out_dir;
                }
                ext2_inc_count(old_inode);
-               err = ext2_add_link(new_dentry, old_inode);
+               err = ll_add_link(new_dentry, old_inode);
                if (err) {
                        ext2_dec_count(old_inode);
                        goto out_dir;
index 357be67..3b33fa4 100644 (file)
@@ -274,6 +274,56 @@ static int ll_statfs(struct super_block *sb, struct statfs *buf)
         return err; 
 }
 
+static void inline ll_to_inode(struct inode *dst, struct mds_rep *rep)
+{
+       struct ll_inode_info *ii = 
+               (struct ll_inode_info *) &dst->u.generic_ip;
+
+       /* core attributes first */
+        if ( rep->valid & OBD_MD_FLID )
+                dst->i_ino = rep->ino;
+        if ( rep->valid & OBD_MD_FLATIME ) 
+                dst->i_atime = rep->atime;
+        if ( rep->valid & OBD_MD_FLMTIME ) 
+                dst->i_mtime = rep->mtime;
+        if ( rep->valid & OBD_MD_FLCTIME ) 
+                dst->i_ctime = rep->ctime;
+        if ( rep->valid & OBD_MD_FLSIZE ) 
+                dst->i_size = rep->size;
+        if ( rep->valid & OBD_MD_FLMODE ) 
+                dst->i_mode = rep->mode;
+        if ( rep->valid & OBD_MD_FLUID ) 
+                dst->i_uid = rep->uid;
+        if ( rep->valid & OBD_MD_FLGID ) 
+                dst->i_gid = rep->gid;
+        if ( rep->valid & OBD_MD_FLFLAGS ) 
+                dst->i_flags = rep->flags;
+        if ( rep->valid & OBD_MD_FLNLINK )
+                dst->i_nlink = rep->nlink;
+        if ( rep->valid & OBD_MD_FLGENER )
+                dst->i_generation = rep->generation;
+
+       /* this will become more elaborate for striping etc */ 
+       if (rep->valid & OBD_MD_FLOBJID) 
+               ii->lli_objid = rep->objid;
+#if 0
+
+        if (obdo_has_inline(oa)) {
+               if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+                   S_ISFIFO(inode->i_mode)) {
+                       obd_rdev rdev = *((obd_rdev *)oa->o_inline);
+                       CDEBUG(D_INODE,
+                              "copying device %x from obdo to inode\n", rdev);
+                       init_special_inode(inode, inode->i_mode, rdev);
+               } else {
+                       CDEBUG(D_INFO, "copying inline from obdo to inode\n");
+                       memcpy(oinfo->lli_inline, oa->o_inline, OBD_INLINESZ);
+               }
+                oinfo->lli_flags |= OBD_FL_INLINEDATA;
+        }
+#endif 
+} /* ll_to_inode */
+
 static inline void ll_read_inode2(struct inode *inode, void *opaque)
 {
        struct mds_rep *rep = opaque; 
@@ -281,9 +331,6 @@ static inline void ll_read_inode2(struct inode *inode, void *opaque)
        ENTRY;
        ll_to_inode(inode, rep); 
 
-        INIT_LIST_HEAD(ll_iplist(inode)); /* list of dirty pages on inode */
-        INIT_LIST_HEAD(ll_islist(inode)); /* list of inodes in superblock */
-
         /* OIDEBUG(inode); */
 
         if (S_ISREG(inode->i_mode)) {
index 734ccad..9f67163 100644 (file)
@@ -64,8 +64,8 @@ int mdc_setattr(struct inode *inode, struct iattr *iattr,
        return rc;
 }
 
-int mdc_create(struct inode *dir, char *name, int mode, __u64 id
-              __u32 uid, __u32 gid, __u64 time, 
+int mdc_create(struct inode *dir, const char *name, int namelen
+              int mode, __u64 id, __u32 uid, __u32 gid, __u64 time, 
                struct mds_rep **rep, struct mds_rep_hdr **hdr)
 {
        int rc; 
@@ -73,7 +73,7 @@ int mdc_create(struct inode *dir, char *name, int mode, __u64 id,
        struct mds_rec_create *rec;
 
        request = mds_prep_req(MDS_REINT, 0, NULL, 
-                              sizeof(*rec) + size_round(strlen(name)), 
+                              sizeof(*rec) + size_round(namelen + 1), 
                               NULL);
        if (!request) { 
                printk("mdc_create: cannot pack\n");
@@ -81,7 +81,7 @@ int mdc_create(struct inode *dir, char *name, int mode, __u64 id,
        }
 
        rec = mds_req_tgt(request->rq_req);
-       mds_create_pack(rec, dir, name, mode, id, uid, gid, time); 
+       mds_create_pack(rec, dir, name, namelen, mode, id, uid, gid, time); 
 
        rc = mdc_reint(request);
 
index 1eee16c..688196e 100644 (file)
@@ -276,7 +276,8 @@ static int request_ioctl(struct inode *inode, struct file *file,
                iattr.ia_atime = 0;
                iattr.ia_valid = ATTR_MODE | ATTR_ATIME;
 
-               err = mdc_create(&inode, "foofile", 0100707, 47114711, 
+               err = mdc_create(&inode, "foofile", strlen("foofile"), 
+                                0100707, 47114711, 
                                 11, 47, 0, NULL, &hdr);
                printk("-- done err %d\n", err);
                if (!err) { 
index c66f26c..fe93fd7 100644 (file)
@@ -75,9 +75,12 @@ int mds_sendpage(struct mds_request *req, struct file *file,
                    __u64 offset, struct niobuf *dst)
 {
        int rc; 
-
+       mm_segment_t oldfs = get_fs();
+       /* dst->addr is a user address, but in a different task! */
+       set_fs(KERNEL_DS); 
        rc = generic_file_read(file, (char *)(long)dst->addr, 
                              PAGE_SIZE, &offset); 
+       set_fs(oldfs);
 
        if (rc != PAGE_SIZE) 
                return -EIO;
@@ -193,6 +196,11 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vf
        return result;
 }
 
+static inline void mds_get_objid(struct inode *inode, __u64 *id)
+{
+       memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
+}
+
 int mds_getattr(struct mds_request *req)
 {
        struct dentry *de = mds_fid2dentry(req->rq_obd, &req->rq_req->fid1, 
@@ -228,8 +236,9 @@ int mds_getattr(struct mds_request *req)
        rep->gid = inode->i_gid;
        rep->size = inode->i_size;
        rep->mode = inode->i_mode;
+       rep->nlink = inode->i_nlink;
        rep->valid = ~0;
-
+       mds_get_objid(inode, &rep->objid);
        dput(de); 
        return 0;
 }
index d51e669..eea758e 100644 (file)
@@ -52,12 +52,23 @@ static int mds_reint_setattr(struct mds_update_record *rec, struct mds_request *
        return 0;
 }
 
+/* 
+   XXX nasty hack: store the object id in the first two
+   direct block spots 
+*/
+static inline void mds_store_objid(struct inode *inode, __u64 *id)
+{
+       memcpy(&inode->u.ext2_i.i_data, id, sizeof(*id));
+}
+
+
 static int mds_reint_create(struct mds_update_record *rec, 
                            struct mds_request *req)
 {
        struct vfsmount *mnt;
        int type = rec->ur_mode & S_IFMT;
        struct dentry *de;
+       struct mds_rep *rep = req->rq_rep;
        struct dentry *dchild; 
        int rc;
 
@@ -88,6 +99,16 @@ static int mds_reint_create(struct mds_update_record *rec,
        switch (type) {
        case S_IFREG: { 
                rc = vfs_create(de->d_inode, dchild, rec->ur_mode);
+               
+               if (!rc) { 
+                       mds_store_objid(dchild->d_inode, &rec->ur_id); 
+                       dchild->d_inode->i_atime = rec->ur_time;
+                       dchild->d_inode->i_ctime = rec->ur_time;
+                       dchild->d_inode->i_mtime = rec->ur_time;
+                       dchild->d_inode->i_uid = rec->ur_uid;
+                       dchild->d_inode->i_gid = rec->ur_gid;
+                       rep->ino = dchild->d_inode->i_ino;
+               }
                break;
        }
        case S_IFDIR: { 
index ae12729..da8a9ad 100644 (file)
@@ -128,6 +128,30 @@ int osc_connect(struct obd_conn *conn)
        return rc;
 }
 
+int osc_disconnect(struct obd_conn *conn)
+{
+       struct ost_request *request;
+       int rc; 
+       ENTRY;
+       
+       request = osc_prep_req(sizeof(*request), OST_DISCONNECT);
+       if (!request) { 
+               printk("osc_connect: cannot pack req!\n"); 
+               return -ENOMEM;
+       }
+
+       rc = osc_queue_wait(conn, request);
+       if (rc) { 
+               EXIT;
+               goto out;
+       }
+ out:
+       osc_free_req(request);
+       EXIT;
+       return rc;
+}
+
+
 int osc_getattr(struct obd_conn *conn, struct obdo *oa)
 {
        struct ost_request *request;
@@ -158,6 +182,35 @@ int osc_getattr(struct obd_conn *conn, struct obdo *oa)
        return 0;
 }
 
+int osc_create(struct obd_conn *conn, struct obdo *oa)
+{
+       struct ost_request *request;
+       int rc; 
+
+       if (!oa) { 
+               printk(__FUNCTION__ ": oa NULL\n"); 
+       }
+       request = osc_prep_req(sizeof(*request), OST_CREATE);
+       if (!request) { 
+               printk("osc_connect: cannot pack req!\n"); 
+               return -ENOMEM;
+       }
+       
+       memcpy(&request->rq_req->oa, oa, sizeof(*oa));
+       request->rq_req->oa.o_valid = ~0;
+       
+       rc = osc_queue_wait(conn, request);
+       if (rc) { 
+               EXIT;
+               goto out;
+       }
+       memcpy(oa, &request->rq_rep->oa, sizeof(*oa));
+
+ out:
+       osc_free_req(request);
+       return 0;
+}
+
 
 /* mount the file system (secretly) */
 static int osc_setup(struct obd_device *obddev, obd_count len,
@@ -207,8 +260,10 @@ static int osc_cleanup(struct obd_device * obddev)
 struct obd_ops osc_obd_ops = { 
        o_setup:   osc_setup,
        o_cleanup: osc_cleanup, 
+       o_create: osc_create,
        o_getattr: osc_getattr,
-       o_connect: osc_connect
+       o_connect: osc_connect,
+       o_disconnect: osc_disconnect
 };
 
 static int __init osc_init(void)
index 4e7b04f..3da3ec3 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *  linux/mds/handler.c
+ *  ost/ost_handler.c
+ *  Storage Target Handling functions
  *  
  *  Lustre Object Server Module (OST)
  * 
index 4625991..411a147 100644 (file)
@@ -2,8 +2,6 @@
 
 R=/r
 
-
-insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
 insmod $R/usr/src/obd/class/obdclass.o 
 insmod $R/usr/src/obd/ext2obd/obdext2.o
 insmod $R/usr/src/obd/ost/ost.o
index 634f443..bebc73a 100644 (file)
@@ -2,11 +2,15 @@
 
 R=/r
 
-insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
+insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o
 insmod $R/usr/src/obd/class/obdclass.o 
 insmod $R/usr/src/obd/ext2obd/obdext2.o
 insmod $R/usr/src/obd/ost/ost.o
 insmod $R/usr/src/obd/osc/osc.o
+insmod $R/usr/src/obd/mds/mds.o
+insmod $R/usr/src/obd/mdc/mdc.o
+insmod $R/usr/src/obd/llight/llight.o
+
 
 dd if=/dev/zero of=/tmp/fs bs=1024 count=10000
 mke2fs -F /tmp/fs