From c227004555dd3485504b72e6d17ad3bb1bde744f Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 4 Jan 2000 23:27:50 +0000 Subject: [PATCH 1/1] Pass inline data from filesystem through obdo to VFS. --- lustre/demos/baseclean.sh | 3 +-- lustre/demos/basesetup.sh | 5 +++-- lustre/include/linux/obd_class.h | 34 +++++++++++++++++----------------- lustre/include/linux/obd_support.h | 2 +- lustre/include/linux/obdfs.h | 7 ++++++- lustre/obdclass/class_obd.c | 2 +- lustre/obdfs/namei.c | 12 +++++++++--- lustre/obdfs/rw.c | 9 +++++++++ lustre/obdfs/super.c | 36 ++++++++++++++++++++++++++++++++++-- 9 files changed, 81 insertions(+), 29 deletions(-) diff --git a/lustre/demos/baseclean.sh b/lustre/demos/baseclean.sh index f7ad227..0daf84b 100755 --- a/lustre/demos/baseclean.sh +++ b/lustre/demos/baseclean.sh @@ -28,7 +28,6 @@ rmmod loop > /dev/null 2>&1 if [ "$TMPFILE" -a -f "$TMPFILE" ]; then echo -n "Remove $TMPFILE [N/y]? " - read ANS - [ "`echo $ANS | cut -c1 | tr A-Z a-z`" = "y" ] && rm $TMPFILE + rm -i $TMPFILE fi diff --git a/lustre/demos/basesetup.sh b/lustre/demos/basesetup.sh index 263e252..be60196 100755 --- a/lustre/demos/basesetup.sh +++ b/lustre/demos/basesetup.sh @@ -12,8 +12,9 @@ OBDDIR="`dirname $0`/.." # temp file if [ "$TMPFILE" -a -f $TMPFILE ]; then - echo "$TMPFILE exists; I'm unwilling to overwrite it." 1>&2 - exit 1 + echo "$TMPFILE exists; I'm unwilling to overwrite it. Remove [N/y]?" 1>&2 + rm -i $TMPFILE + [ -f $TMPFILE ] && exit 1 fi [ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=10k diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 596e0be..14b5625 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -60,22 +60,22 @@ struct obdo { }; #define OBD_MD_FLALL (~0UL) -#define OBD_MD_FLID (1UL) -#define OBD_MD_FLATIME (1UL<<1) -#define OBD_MD_FLMTIME (1UL<<2) -#define OBD_MD_FLCTIME (1UL<<3) -#define OBD_MD_FLSIZE (1UL<<4) -#define OBD_MD_FLBLOCKS (1UL<<5) -#define OBD_MD_FLBLKSZ (1UL<<6) -#define OBD_MD_FLMODE (1UL<<7) -#define OBD_MD_FLUID (1UL<<8) -#define OBD_MD_FLGID (1UL<<9) -#define OBD_MD_FLFLAGS (1UL<<10) -#define OBD_MD_FLOBDFLG (1UL<<11) -#define OBD_MD_FLNLINK (1UL<<12) -#define OBD_MD_FLGENER (1UL<<13) -#define OBD_MD_FLINLINE (1UL<<14) -#define OBD_MD_FLOBDMD (1UL<<15) +#define OBD_MD_FLID (0x0001UL) +#define OBD_MD_FLATIME (0x0002UL) +#define OBD_MD_FLMTIME (0x0004UL) +#define OBD_MD_FLCTIME (0x0008UL) +#define OBD_MD_FLSIZE (0x0010UL) +#define OBD_MD_FLBLOCKS (0x0020UL) +#define OBD_MD_FLBLKSZ (0x0040UL) +#define OBD_MD_FLMODE (0x0080UL) +#define OBD_MD_FLUID (0x0100UL) +#define OBD_MD_FLGID (0x0200UL) +#define OBD_MD_FLFLAGS (0x0400UL) +#define OBD_MD_FLOBDFLG (0x0800UL) +#define OBD_MD_FLNLINK (0x1000UL) +#define OBD_MD_FLGENER (0x2000UL) +#define OBD_MD_FLINLINE (0x4000UL) +#define OBD_MD_FLOBDMD (0x8000UL) /* * ======== OBD Device Declarations =========== @@ -254,7 +254,7 @@ static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr) static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src) { - CDEBUG(D_INODE, "flags %x\n", src->o_valid); + CDEBUG(D_INODE, "flags 0x%x\n", src->o_valid); if ( src->o_valid & OBD_MD_FLATIME ) dst->o_atime = src->o_atime; if ( src->o_valid & OBD_MD_FLMTIME ) diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index f33c0c3..5521428 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 %0x, obdflg %0x, nlnk %d, valid %0x\n", \ + printk("]]%s line %d[[ mode %o, uid %d, gid %d, flg 0x%0x, obdflg 0x%0x, nlnk %d, valid 0x%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/include/linux/obdfs.h b/lustre/include/linux/obdfs.h index 6800db6..7ff6874 100644 --- a/lustre/include/linux/obdfs.h +++ b/lustre/include/linux/obdfs.h @@ -24,6 +24,7 @@ int flushd_init(void); /* rw.c */ int obdfs_do_writepage(struct inode *, struct page *, int sync); int obdfs_init_wreqcache(void); +void obdfs_cleanup_wreqcache(void); int obdfs_readpage(struct dentry *dentry, struct page *page); int obdfs_writepage(struct dentry *dentry, struct page *page); struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create, int locked); @@ -69,6 +70,11 @@ struct obdfs_sb_info { struct list_head osi_list; /* linked list of inodes to write */ }; +struct obdfs_inode_info { + int oi_flags; + struct list_head oi_list; + char *oi_inline; +}; #define WB_NEXT(req) ((struct obdfs_wreq *) ((req)->wb_list.next)) /* XXX page list should go on each inode instead of supberblock */ @@ -78,7 +84,6 @@ struct obdfs_sb_info { void obdfs_sysctl_init(void); void obdfs_sysctl_clean(void); - extern struct file_operations obdfs_file_operations; extern struct inode_operations obdfs_file_inode_operations; extern struct inode_operations obdfs_dir_inode_operations; diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 4a19570..24cadd0 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -913,8 +913,8 @@ void cleanup_module(void) } } - obd_cleanup_obdo_cache(); obd_sysctl_clean(); + obd_cleanup_obdo_cache(); obd_init_magic = 0; EXIT; } diff --git a/lustre/obdfs/namei.c b/lustre/obdfs/namei.c index dfb3c00..6b80666 100644 --- a/lustre/obdfs/namei.c +++ b/lustre/obdfs/namei.c @@ -447,6 +447,7 @@ struct inode *obdfs_new_inode(struct inode *dir) { struct obdo *obdo; struct inode *inode; + struct obdfs_inode_info *oinfo; int err; obdo = obdo_alloc(); @@ -474,8 +475,10 @@ struct inode *obdfs_new_inode(struct inode *dir) return ERR_PTR(-EIO); } - obdo_free(obdo); + + oinfo = inode->u.generic_ip; + INIT_LIST_HEAD(&oinfo->oi_list); EXIT; return inode; } @@ -835,6 +838,7 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry, const char * symna { struct ext2_dir_entry_2 * de; struct inode * inode; + struct obdfs_inode_info *oinfo; struct page* page = NULL, * name_page = NULL; char * link; int i, l, err = -EIO; @@ -842,6 +846,7 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry, const char * symna ENTRY; inode = obdfs_new_inode(dir); + oinfo = inode->u.generic_ip; if ( IS_ERR(inode) ) { EXIT; return PTR_ERR(inode); @@ -853,7 +858,7 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry, const char * symna symname [l]; l++) ; - if (l >= sizeof (inode->u.ext2_i.i_data)) { + if (l >= sizeof (oinfo->oi_inline)) { CDEBUG(D_INODE, "l=%d, normal symlink\n", l); name_page = obdfs_getpage(inode, 0, 1, LOCKED); @@ -866,7 +871,8 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry, const char * symna } link = (char *)page_address(name_page); } else { - link = (char *) inode->u.ext2_i.i_data; + link = oinfo->oi_inline; + oinfo->oi_flags |= OBD_FL_INLINEDATA; CDEBUG(D_INODE, "l=%d, fast symlink\n", l); diff --git a/lustre/obdfs/rw.c b/lustre/obdfs/rw.c index 465b5de..b0f70fa 100644 --- a/lustre/obdfs/rw.c +++ b/lustre/obdfs/rw.c @@ -99,6 +99,15 @@ int obdfs_init_wreqcache(void) return 0; } +void obdfs_cleanup_wreqcache(void) +{ + if (obdfs_wreq_cachep != NULL) + kmem_cache_destroy(obdfs_wreq_cachep); + + obdfs_wreq_cachep = NULL; +} + + /* * Find a specific page in the page cache. If it is found, we return * the write request struct associated with it, if not found return NULL. diff --git a/lustre/obdfs/super.c b/lustre/obdfs/super.c index 14109c8..6e571f5 100644 --- a/lustre/obdfs/super.c +++ b/lustre/obdfs/super.c @@ -292,6 +292,35 @@ static void obdfs_put_super(struct super_block *sb) EXIT; } +inline int obdfs_has_inline(struct inode *inode) +{ + struct obdfs_inode_info *oinfo = inode->u.generic_ip; + + return (oinfo->oi_flags & OBD_FL_INLINEDATA); +} + +void inline obdfs_from_inode(struct obdo *oa, struct inode *inode) +{ + struct obdfs_inode_info *oinfo = inode->u.generic_ip; + + obdo_from_inode(oa, inode); + if (obdfs_has_inline(inode)) { + memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ); + oa->o_flags |= OBD_FL_INLINEDATA; + } +} + +void inline obdfs_to_inode(struct inode *inode, struct obdo *oa) +{ + struct obdfs_inode_info *oinfo = inode->u.generic_ip; + + obdo_to_inode(inode, oa); + if (obdo_has_inline(oa)) { + memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ); + oinfo->oi_flags |= OBD_FL_INLINEDATA; + } +} + /* all filling in of inodes postponed until lookup */ void obdfs_read_inode(struct inode *inode) { @@ -316,7 +345,7 @@ void obdfs_read_inode(struct inode *inode) } ODEBUG(oa); - obdo_to_inode(inode, oa); + obdfs_to_inode(inode, oa); obdo_free(oa); IDEBUG(inode); @@ -339,7 +368,7 @@ static void obdfs_write_inode(struct inode *inode) oa = obdo_alloc(); oa->o_valid = OBD_MD_FLALL; - obdo_from_inode(oa, inode); + obdfs_from_inode(oa, inode); err = IOPS(inode, setattr)(IID(inode), oa); obdo_free(oa); @@ -391,6 +420,8 @@ static int obdfs_notify_change(struct dentry *de, struct iattr *attr) oa->o_id = inode->i_ino; obdo_from_iattr(oa, attr); err = IOPS(inode, setattr)(IID(inode), oa); + obdo_free(oa); + if ( err ) { printk("obdfs_notify_change: obd_setattr fails (%d)\n", err); return err; @@ -459,6 +490,7 @@ void cleanup_module(void) ENTRY; obdfs_sysctl_clean(); + obdfs_cleanup_wreqcache(); unregister_filesystem(&obdfs_fs_type); } -- 1.8.3.1