Whamcloud - gitweb
A few more changes.
authorbraam <braam>
Fri, 31 Dec 1999 21:57:46 +0000 (21:57 +0000)
committerbraam <braam>
Fri, 31 Dec 1999 21:57:46 +0000 (21:57 +0000)
lustre/include/linux/obd_class.h
lustre/include/linux/obd_support.h
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/obdcontrol

index b50962d..22a2a9f 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 typedef uint64_t       obd_id;
+typedef uint64_t       obd_gr;
 typedef uint64_t       obd_time;
 typedef uint64_t       obd_size;
 typedef uint64_t       obd_off;
@@ -29,15 +30,15 @@ typedef uint32_t    obd_gid;
 typedef uint32_t       obd_flag;
 typedef uint32_t       obd_count;
 
-#define OBD_INLINESZ   60
-#define OBD_OBDMDSZ    64
-
 #define OBD_FL_INLINEDATA      (1UL)  
 #define OBD_FL_OBDMDEXISTS     (1UL << 1)
 
+#define OBD_INLINESZ   60
+#define OBD_OBDMDSZ    64
 /* Note: 64-bit types are 64-bit aligned in structure */
 struct obdo {
        obd_id                  o_id;
+       obd_gr                  o_gr;
        obd_time                o_atime;
        obd_time                o_mtime;
        obd_time                o_ctime;
@@ -123,6 +124,7 @@ struct obd_ops {
        int (*o_write)(struct obd_conn *, struct obdo *oa, char *buf, obd_size *count, obd_off offset);
        int (*o_brw)(int rw, struct obd_conn * conn, struct obdo *oa, char *buf, obd_size count, obd_off offset, obd_flag flags);
        int (*o_punch)(struct obd_conn *, struct obdo *tgt, obd_size count, obd_off offset);
+       int (*o_sync)(struct obd_conn *, struct obdo *tgt, obd_size count, obd_off offset);
        int (*o_migrate)(struct obd_conn *, struct obdo *dst, struct obdo *src, obd_size count, obd_off offset);
        int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst, struct obd_conn *srconn, struct obdo *src, obd_size count, obd_off offset);
        int (*o_iterate)(struct obd_conn *, int (*)(obd_id, void *), obd_id start, void *);
@@ -137,6 +139,7 @@ struct obd_ops {
  *  ======== OBD Metadata Support  ===========
  */
 
+extern int obd_init_obdo_cache(void);
 
 
 static inline int obdo_has_inline(struct obdo *obdo)
@@ -341,7 +344,8 @@ int gen_disconnect(struct obd_conn *conn);
 struct obd_client *gen_client(struct obd_conn *);
 int gen_cleanup(struct obd_device *obddev);
 int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
-                 struct obd_conn *src_conn, struct obdo *src);
+                 struct obd_conn *src_conn, struct obdo *src,
+                 obd_size count, obd_off offset);
 
 
 
index b270399..3104325 100644 (file)
@@ -118,43 +118,19 @@ do {                                                      \
 } while (0)
 
 
-
-static inline void inode_to_iattr(struct inode *inode, struct iattr *tmp)
+static inline struct page *addr_to_page(char *buf)
 {
-       tmp->ia_mode = inode->i_mode;
-       tmp->ia_uid = inode->i_uid;
-       tmp->ia_gid = inode->i_gid;
-       tmp->ia_size = inode->i_size;
-       tmp->ia_atime = inode->i_atime;
-       tmp->ia_mtime = inode->i_mtime;
-       tmp->ia_ctime = inode->i_ctime;
-       /*      tmp->ia_flags = inode->i_flags; */
-
-       tmp->ia_valid = ~0;
-}
-
-
-#define OBD_MAGIC_INL 0x77777770
+       unsigned long addr = (unsigned long)buf;
+        unsigned long map_nr;
 
-
-static inline void inode_cpy(struct inode *dest, struct inode *src)
-{
-       dest->i_mode = src->i_mode;
-       dest->i_uid = src->i_uid;
-       dest->i_gid = src->i_gid;
-       dest->i_size = src->i_size;
-       dest->i_atime = src->i_atime;
-       dest->i_mtime = src->i_mtime;
-       dest->i_ctime = src->i_ctime;
-       dest->i_flags = src->i_flags;
-       /* allocation of space */
-       dest->i_blocks = src->i_blocks;
-       if ( !src->i_blocks || 
-            OBD_MAGIC_INL == (OBD_MAGIC_INL & src->u.ext2_i.i_data[0])) {
-               CDEBUG(D_IOCTL, "copying inline data: ino %ld\n", dest->i_ino);
-               memcpy(&dest->u.ext2_i.i_data, &src->u.ext2_i.i_data, 
-                      sizeof(src->u.ext2_i.i_data));
-       }
+#ifdef CONFIG_DISCONTIGMEM
+        if (addr == 0) return;
+#endif
+        map_nr = MAP_NR(addr);
+        if (map_nr < max_mapnr)
+               return mem_map + map_nr;
+       else 
+               return 0;
 }
 
 
index 8560d6e..4fe3767 100644 (file)
@@ -846,7 +846,7 @@ int init_obd(void)
 {
        int i;
 
-       printk(KERN_INFO "OBD class driver  v0.002, braam@stelias.com\n");
+       printk(KERN_INFO "OBD class driver  v0.01, braam@stelias.com\n");
        
        INIT_LIST_HEAD(&obd_types);
        
@@ -863,6 +863,7 @@ int init_obd(void)
                INIT_LIST_HEAD(&obd_dev[i].obd_gen_clients);
        }
 
+       obd_init_obdo_cache();
        obd_sysctl_init();
        obd_init_magic = 0x11223344;
        return 0;
index be13204..d52106b 100644 (file)
@@ -229,7 +229,8 @@ void lck_page(struct page *page)
 
 /* XXX this should return errors correctly, so should migrate!!! */
 int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
-                 struct obd_conn *src_conn, struct obdo *src)
+                 struct obd_conn *src_conn, struct obdo *src,
+                 obd_size count, obd_off offset)
 {
        struct page *page;
        unsigned long index = 0;
index 15eb769..bc952e5 100755 (executable)
@@ -89,6 +89,133 @@ use Term::ReadLine;
 use IO::Handle;
 
 
+# NOTE long long are layed out in memory as follows:
+# u = 0xaaaabbbbccccdddd has ccccdddd at &u and aaaabbbb 4 bytes on
+# this may be different on other architectures
+
+# we use 32 bit integers for all 64 quantities in this program
+# #define OBD_INLINESZ 60
+# #define OBD_OBDMDSZ  64
+# /* Note: 64-bit types are 64-bit aligned in structure */
+# struct obdo {
+#      obd_id                  o_id;
+#      obd_gr                  o_gr;
+#      obd_time                o_atime;
+#      obd_time                o_mtime;
+#      obd_time                o_ctime;
+#      obd_size                o_size;
+#      obd_blocks              o_blocks;
+#      obd_blksize             o_blksize;
+#      obd_mode                o_mode;
+#      obd_uid                 o_uid;
+#      obd_gid                 o_gid;
+#      obd_flag                o_flags;
+#      obd_flag                o_obdflags;
+#      obd_count               o_nlink;
+#      obd_flag                o_valid;        /* hot fields in this obdo */
+#      char                    o_inline[OBD_INLINESZ];
+#      char                    o_obdmd[OBD_OBDMDSZ];
+#      struct list_head        o_list;
+#      struct obd_ops          *o_op;
+# };
+
+sub obdo_pack {
+    my $obdo = shift;
+    pack "LL LL LL LL LL LL LL L L L L L L L L 60c 64c L L L", 
+    $obdo->{id}, 0, 
+    $obdo->{gr}, 0, 
+    $obdo->{atime}, 0, 
+    $obdo->{mtime}, 0 ,
+    $obdo->{ctime}, 0, 
+    $obdo->{size}, 0, 
+    $obdo->{blocks}, 0, 
+    $obdo->{blksize},
+    $obdo->{mode},
+    $obdo->{uid},
+    $obdo->{gid},
+    $obdo->{flag},
+    $obdo->{obdoflags},
+    $obdo->{nlink},    
+    $obdo->{valid},    
+    $obdo->{inline},
+    $obdo->{obdmd},
+    0, 0, # struct list_head 
+    0;  #  struct obd_ops 
+}
+
+sub obdo_unpack {
+    my $buf = shift;
+    my $offset = shift;
+    my $obdo;
+    ($obdo->{id},
+    $obdo->{gr},
+    $obdo->{atime},
+    $obdo->{mtime},
+    $obdo->{ctime},
+    $obdo->{size},
+    $obdo->{blocks},
+    $obdo->{blksize},
+    $obdo->{mode},
+    $obdo->{uid},
+    $obdo->{gid},
+    $obdo->{flag},
+    $obdo->{obdoflags},
+    $obdo->{nlink},    
+    $obdo->{valid},    
+    $obdo->{inline},
+    $obdo->{obdmd}) = unpack $offset . "xL4x L4x L4x L4x L4x L4x L4x L L L L L L L L 60c 64c", $buf;
+}
+
+sub obdo_print {
+
+    printf "id: %d\ngrp: %d\natime: %s\natime: %s\nmtime: %s\nctime: %s\nsize: %d\nblocks: %d\nblksize: %d\nmode: %x\nuid: %d\ngid: %d\nflag: %x\nobdflag: %x\nnlink: %d\nvalid: %x\ninline: %s\obdmd: %s\n", 
+   $obdo->{id},
+    $obdo->{gr},
+    $obdo->{atime},
+    $obdo->{mtime},
+    $obdo->{ctime},
+    $obdo->{size},
+    $obdo->{blocks},
+    $obdo->{blksize},
+    $obdo->{mode},
+    $obdo->{uid},
+    $obdo->{gid},
+    $obdo->{flag},
+    $obdo->{obdoflags},
+    $obdo->{nlink},    
+    $obdo->{valid},    
+    $obdo->{inline},
+    $obdo->{obdmd};
+}
+
+
+# XXXXXXXXXXXXXXXXXX
+# test here
+
+   $obdo->{id}= 1;
+    $obdo->{gr}= 2;
+    $obdo->{atime}= 3;
+    $obdo->{mtime}= 4;
+    $obdo->{ctime}= 5;
+    $obdo->{size}= 6;
+    $obdo->{blocks}= 7;
+    $obdo->{blksize}= 8;
+    $obdo->{mode}= 9;
+    $obdo->{uid}= 10;
+    $obdo->{gid}= 11;
+    $obdo->{flag}= 12;
+    $obdo->{obdoflags}= ;
+    $obdo->{nlink}= ;  
+    $obdo->{valid}= ;  
+    $obdo->{inline}= ;
+    $obdo->{obdmd};
+
+# print, pack and unpack and print
+
+print "XXXXXXXX testing done\n";
+exit;
+
+
 my ($file);
 
 GetOptions("f!" => \$file, "device=s" => \$::device, ) || die "Getoptions";
@@ -917,24 +1044,17 @@ sub Getattr {
     }
 
     # see Setattr
-    my $packed = pack("ILsx2lLLLI", $::client_id, $inode, 0, 0, 0, 0, 0, 0, 0,
-                     0);
+    my $obdo;
+    $obdo->{id} = $inode;
+    my $packed = pack("L", $::client_id) . obdo_pack($obdo);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_GETATTR, $packed);
 
+    
     if (!defined $rc) {
        print STDERR "ioctl failed: $!\n";
     } elsif ($rc eq "0 but true") {
-       my ($valid, $mode, $uid, $gid, $size, $atime, $mtime, $ctime, $flags);
-       ($valid, $mode, $uid, $gid, $size, $atime, $mtime, $ctime, $flags) =
-         unpack("ISssx2lLLLI", $packed);
-
-       printf("Inode: %d  Mode:  %o\n", $inode, $mode);
-       printf("User: %6d   Group: %6d   Size: %d\n", $uid, $gid, $size);
-       printf("ctime: %08lx -- %s\n", $ctime, scalar(gmtime($ctime)));
-       printf("atime: %08lx -- %s\n", $atime, scalar(gmtime($atime)));
-       printf("mtime: %08lx -- %s\n", $mtime, scalar(gmtime($mtime)));
-       printf("flags: %08x\n", $flags);
-       print "Finished (success)\n";
+       $obdo = obdo_unpack($packed,  4); 
+       obdo_print($obdo);
     } else {
        print "ioctl returned error code $rc.\n";
     }