From cddc16981097f8f6c6ad9b4b638f741f1d278bc6 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 4 Jan 2000 20:52:06 +0000 Subject: [PATCH] Generation added to obdo --- lustre/include/linux/obd.h | 2 ++ lustre/include/linux/obd_class.h | 23 ++++++++++++++++++----- lustre/include/linux/obd_support.h | 2 +- lustre/obdclass/class_obd.c | 8 ++++++-- lustre/obdclass/genops.c | 20 ++++++++++++++++++-- lustre/obdclass/obdcontrol | 21 ++++++++++++--------- lustre/obdfs/super.c | 2 ++ lustre/scripts/maketags.sh | 4 ++-- 8 files changed, 61 insertions(+), 21 deletions(-) diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 03add50..b3b9e7f 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -13,6 +13,8 @@ struct obd_type { int typ_refcnt; }; +#define OBD_MAGIC 0xffff0000 +#define OBD_MAGIC_MASK 0xffff0000 diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index cd85152..596e0be 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -34,7 +34,7 @@ typedef uint32_t obd_count; #define OBD_FL_OBDMDEXISTS (1UL << 1) #define OBD_INLINESZ 60 -#define OBD_OBDMDSZ 64 +#define OBD_OBDMDSZ 60 /* Note: 64-bit types are 64-bit aligned in structure */ struct obdo { obd_id o_id; @@ -51,6 +51,7 @@ struct obdo { obd_flag o_flags; obd_flag o_obdflags; obd_count o_nlink; + obd_count o_generation; obd_flag o_valid; /* hot fields in this obdo */ char o_inline[OBD_INLINESZ]; char o_obdmd[OBD_OBDMDSZ]; @@ -72,8 +73,9 @@ struct obdo { #define OBD_MD_FLFLAGS (1UL<<10) #define OBD_MD_FLOBDFLG (1UL<<11) #define OBD_MD_FLNLINK (1UL<<12) -#define OBD_MD_FLINLINE (1UL<<13) -#define OBD_MD_FLOBDMD (1UL<<14) +#define OBD_MD_FLGENER (1UL<<13) +#define OBD_MD_FLINLINE (1UL<<14) +#define OBD_MD_FLOBDMD (1UL<<15) /* * ======== OBD Device Declarations =========== @@ -157,6 +159,7 @@ struct obd_ops { */ extern int obd_init_obdo_cache(void); +extern void obd_cleanup_obdo_cache(void); static inline int obdo_has_inline(struct obdo *obdo) @@ -276,6 +279,8 @@ static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src) dst->o_obdflags = src->o_obdflags; if ( src->o_valid & OBD_MD_FLNLINK ) dst->o_nlink = src->o_nlink; + if ( src->o_valid & OBD_MD_FLGENER ) + dst->o_generation = src->o_generation; if ( src->o_valid & OBD_MD_FLINLINE ) memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline)); if ( src->o_valid & OBD_MD_FLOBDMD ) @@ -309,6 +314,10 @@ static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src) dst->o_gid = src->i_gid; if ( dst->o_valid & OBD_MD_FLFLAGS ) dst->o_flags = src->i_flags; + if ( dst->o_valid & OBD_MD_FLNLINK ) + dst->o_nlink = src->i_nlink; + if ( dst->o_valid & OBD_MD_FLGENER ) + dst->o_generation = src->i_generation; } static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src) @@ -323,6 +332,8 @@ static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src) dst->i_mtime = src->o_mtime; if ( src->o_valid & OBD_MD_FLCTIME ) dst->i_ctime = src->o_ctime; + if ( src->o_valid & OBD_MD_FLSIZE ) + dst->i_size = src->o_size; if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ dst->i_blocks = src->o_blocks; if ( src->o_valid & OBD_MD_FLBLKSZ ) @@ -333,10 +344,12 @@ static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src) dst->i_uid = src->o_uid; if ( src->o_valid & OBD_MD_FLGID ) dst->i_gid = src->o_gid; - if ( src->o_valid & OBD_MD_FLSIZE ) - dst->i_size = src->o_size; if ( src->o_valid & OBD_MD_FLFLAGS ) dst->i_flags = src->o_flags; + if ( src->o_valid & OBD_MD_FLNLINK ) + dst->i_nlink = src->o_nlink; + if ( src->o_valid & OBD_MD_FLGENER ) + dst->i_generation = src->o_generation; } static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src) diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index 153002f..f33c0c3 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -78,7 +78,7 @@ extern int obd_print_entry; __FUNCTION__ , __LINE__, \ obdo->o_id, obdo->o_atime, obdo->o_mtime,\ obdo->o_ctime, obdo->o_size, obdo->o_blocks);\ - printk("]]%s line %d[[ mode %o, uid %d, gid %d, flg %0xld, obdflg %0xld, nlnk %d, valid %0xld\n", \ + printk("]]%s line %d[[ mode %o, uid %d, gid %d, flg %0x, obdflg %0x, nlnk %d, valid %0x\n", \ __FUNCTION__ , __LINE__, \ obdo->o_mode, obdo->o_uid, obdo->o_gid,\ obdo->o_flags, obdo->o_obdflags, obdo->o_nlink,\ diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index a64e9ef..4a19570 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -844,6 +844,7 @@ static struct file_operations obd_psdev_fops = { int init_obd(void) { + int err; int i; printk(KERN_INFO "OBD class driver v0.01, braam@stelias.com\n"); @@ -863,7 +864,9 @@ int init_obd(void) INIT_LIST_HEAD(&obd_dev[i].obd_gen_clients); } - obd_init_obdo_cache(); + err = obd_init_obdo_cache(); + if (err) + return err; obd_sysctl_init(); obd_init_magic = 0x11223344; return 0; @@ -910,8 +913,9 @@ void cleanup_module(void) } } - + obd_cleanup_obdo_cache(); obd_sysctl_clean(); obd_init_magic = 0; + EXIT; } #endif diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index d52106b..37e795c 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -32,12 +32,18 @@ extern struct obd_device obd_dev[MAX_OBD_DEVICES]; -kmem_cache_t *obdo_cachep; +kmem_cache_t *obdo_cachep = NULL; int obd_init_obdo_cache(void) { - /* XXX need to free this somewhere? */ ENTRY; + if (obdo_cachep != NULL) { + printk(KERN_INFO "obdo_cache already exists\n"); + EXIT; + /* XXX maybe this shoul be an error return? */ + return 0; + } + obdo_cachep = kmem_cache_create("obdo_cache", sizeof(struct obdo), 0, SLAB_HWCACHE_ALIGN, @@ -50,6 +56,16 @@ int obd_init_obdo_cache(void) return 0; } +void obd_cleanup_obdo_cache(void) +{ + ENTRY; + if (obdo_cachep != NULL) + kmem_cache_destroy(obdo_cachep); + + obdo_cachep = NULL; + EXIT; +} + /* map connection to client */ struct obd_client *gen_client(struct obd_conn *conn) diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index f8fbfc9..642bed6 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -95,8 +95,8 @@ use IO::Handle; # this may be different on other architectures # we use 32-bit integers for all 64-bit quantities in this program -# #define OBD_INLINESZ 64 -# #define OBD_OBDMDSZ 64 +# #define OBD_INLINESZ 60 +# #define OBD_OBDMDSZ 60 # /* Note: 64-bit types are 64-bit aligned in structure */ # struct obdo { # obd_id o_id; @@ -113,16 +113,17 @@ use IO::Handle; # obd_flag o_flags; # obd_flag o_obdflags; # obd_count o_nlink; +# obd_count o_generation; # obd_flag o_valid; /* hot fields in this obdo */ -# char o_inline[OBD_INLINESZ]; -# char o_obdmd[OBD_OBDMDSZ]; +# char o_inline[60]; +# char o_obdmd[60]; # 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 a60 a64 L L L", + pack "LL LL LL LL LL LL LL L L L L L L L L L a60 a60 L L L", $obdo->{id}, 0, $obdo->{gr}, 0, $obdo->{atime}, 0, @@ -137,6 +138,7 @@ sub obdo_pack { $obdo->{flags}, $obdo->{obdflags}, $obdo->{nlink}, + $obdo->{generation}, $obdo->{valid}, $obdo->{inline}, $obdo->{obdmd}, @@ -161,10 +163,11 @@ sub obdo_unpack { $obdo->{gid}, $obdo->{flags}, $obdo->{obdflags}, - $obdo->{nlink}, - $obdo->{valid}, + $obdo->{nlink}, + $obdo->{generation}, + $obdo->{valid}, $obdo->{inline}, - $obdo->{obdmd}) = unpack "x${offset}Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 L L L L L L L L a60 a64", $buf; + $obdo->{obdmd}) = unpack "x${offset}Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 L L L L L L L L L a60 a60", $buf; $obdo; } @@ -841,7 +844,7 @@ sub Setup { # XXX we need a getinfo ioctl to validate parameters # by type here - if ($arg && !defined($::st = stat($arg))) { + if ($arg && !defined($::st = stat($arg))) { print "$arg is not a valid device\n"; return; } diff --git a/lustre/obdfs/super.c b/lustre/obdfs/super.c index c48a9e3..14109c8 100644 --- a/lustre/obdfs/super.c +++ b/lustre/obdfs/super.c @@ -440,7 +440,9 @@ int init_obdfs(void) if (err) return err; + /* XXX flushd_init(); + */ return register_filesystem(&obdfs_fs_type); } diff --git a/lustre/scripts/maketags.sh b/lustre/scripts/maketags.sh index 39994a8..7f3a793 100755 --- a/lustre/scripts/maketags.sh +++ b/lustre/scripts/maketags.sh @@ -1,4 +1,4 @@ #!/bin/sh - +set -vx rm -f TAGS ; find . -name '*.h' -or -name '*.c' | xargs etags -rm -f tags ; ctags -R * +rm -f ctags; find . -name '*.h' -or -name '*.c' | xargs ctags -- 1.8.3.1