From 5a922d30001ba50ce799b9ca6fb6a96992788585 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 7 Mar 2000 07:44:28 +0000 Subject: [PATCH] obdfs,ext2_obd,class/*.c: added truncate/punch method/ioctl --- lustre/demos/obdfsclean.sh | 8 ++-- lustre/include/linux/obd_class.h | 3 +- lustre/include/linux/obd_ext2.h | 5 +- lustre/include/linux/obd_support.h | 96 +++++++++++++++++++++++++------------- lustre/include/linux/obdfs.h | 9 +++- lustre/obdclass/class_obd.c | 30 +++++++++++- 6 files changed, 109 insertions(+), 42 deletions(-) diff --git a/lustre/demos/obdfsclean.sh b/lustre/demos/obdfsclean.sh index b153ed8..6a888a7 100755 --- a/lustre/demos/obdfsclean.sh +++ b/lustre/demos/obdfsclean.sh @@ -4,8 +4,8 @@ OBDDIR="`dirname $0`/.." . $OBDDIR/demos/config.sh plog umount $MNTOBD -killall pupdated # stop the OBDFS flush daemon -rmmod obdfs +#killall pupdated # stop the OBDFS flush daemon +plog rmmod obdfs plog log "CLEANUP/DETACH" $OBDDIR/class/obdcontrol -f << EOF @@ -14,7 +14,7 @@ detach quit EOF -rmmod obdext2 -rmmod obdclass +plog rmmod obdext2 +plog rmmod obdclass $OBDDIR/demos/baseclean.sh diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 5bc5049..114095d 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -525,7 +525,7 @@ struct oic_range_s { #define OBD_IOC_CONNECT _IOR ('f', 13, long) #define OBD_IOC_DISCONNECT _IOW ('f', 14, long) #define OBD_IOC_STATFS _IOWR('f', 15, long) -#define OBD_IOC_SYNC _IOR ('f', 16, long) +#define OBD_IOC_SYNC _IOR ('f', 16, long) #define OBD_IOC_READ2 _IOWR('f', 17, long) #define OBD_IOC_FORMAT _IOWR('f', 18, long) #define OBD_IOC_PARTITION _IOWR('f', 19, long) @@ -533,6 +533,7 @@ struct oic_range_s { #define OBD_IOC_DETACH _IOWR('f', 21, long) #define OBD_IOC_COPY _IOWR('f', 22, long) #define OBD_IOC_MIGR _IOWR('f', 23, long) +#define OBD_IOC_PUNCH _IOWR('f', 24, long) #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 32 ) diff --git a/lustre/include/linux/obd_ext2.h b/lustre/include/linux/obd_ext2.h index 270364a..bc58ca0 100644 --- a/lustre/include/linux/obd_ext2.h +++ b/lustre/include/linux/obd_ext2.h @@ -78,8 +78,9 @@ int obd_remount (struct super_block * sb, int * flags, char * data); struct super_block * ext2_read_super (struct super_block * sb, void * data, int silent); -/* truncate.c */ -void obd_truncate (struct inode * inode); +/* punch.c */ +void ext2_truncate (struct inode * inode); +int ext2_punch (struct inode * inode, loff_t start, size_t count); static inline struct page *addr_to_page(char *buf) { diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index abb64d2..84c5b11 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -12,6 +12,9 @@ /* global variables */ extern int obd_debug_level; extern int obd_print_entry; +extern int obd_inodes; +extern int obd_pages; +extern long obd_memory; #define EXT2_OBD_DEBUG @@ -19,19 +22,20 @@ extern int obd_print_entry; #define CMD(cmd) (( cmd == READ ) ? "read" : "write") /* debugging masks */ -#define D_PSDEV 1 /* debug information from psdev.c */ -#define D_INODE 2 -#define D_SUPER 4 -#define D_SNAP 8 -#define D_UNUSED 16 -#define D_WARNING 32 /* misc warnings */ -#define D_EXT2 64 /* anything from ext2_debug */ -#define D_MALLOC 128 /* print malloc, free information */ -#define D_CACHE 256 /* cache-related items */ -#define D_INFO 512 /* general information, especially from interface.c */ -#define D_IOCTL 1024 /* ioctl related information */ -#define D_BLOCKS 2048 /* ext2 block allocation */ -#define D_RPC 4096 /* rpc communications */ +#define D_PSDEV 0x001 /* debug information from psdev.c */ +#define D_INODE 0x002 +#define D_SUPER 0x004 +#define D_SNAP 0x008 +#define D_UNUSED4 0x010 +#define D_WARNING 0x020 /* misc warnings */ +#define D_EXT2 0x040 /* anything from ext2_debug */ +#define D_MALLOC 0x080 /* print malloc, free information */ +#define D_CACHE 0x100 /* cache-related items */ +#define D_INFO 0x200 /* general information, especially from interface.c */ +#define D_IOCTL 0x400 /* ioctl related information */ +#define D_BLOCKS 0x800 /* ext2 block allocation */ +#define D_RPC 0x1000 /* rpc communications */ +#define D_PUNCH 0x2000 #define CDEBUG(mask, format, a...) \ do { \ @@ -41,12 +45,11 @@ extern int obd_print_entry; } while (0) #define ENTRY if (obd_print_entry) \ - printk(KERN_INFO "Process %d entered %s\n",\ - current->pid, __FUNCTION__) + printk(KERN_INFO "Process %d entered %s\n", current->pid, __FUNCTION__) #define EXIT if (obd_print_entry) \ - printk(KERN_INFO "Process %d leaving %s [%d]\n",\ - current->pid, __FUNCTION__, __LINE__) + printk(KERN_INFO "Process %d leaving %s [%d]\n", current->pid,\ + __FUNCTION__, __LINE__) /* Inode common information printed out (used by obdfs and ext2obd inodes) */ #define ICDEBUG(inode) { \ @@ -90,20 +93,46 @@ extern int obd_print_entry; } -#define PDEBUG(page,cmd) { \ +#define PDEBUG(page,msg) { \ if (page){\ - char *uptodate = (Page_Uptodate(page)) ? "yes" : "no";\ - char *locked = (PageLocked(page)) ? "yes" : "no";\ - int count = page->count.counter;\ + char *uptodate = (Page_Uptodate(page)) ? "upto" : "outof";\ + char *locked = (PageLocked(page)) ? "" : "un";\ + char *buffer = page->buffers ? "buffer" : "";\ + int count = page_count(page);\ long index = page->index;\ - CDEBUG(D_CACHE, " ** %s, cmd: %s, off %ld, uptodate: %s, "\ - "locked: %s, cnt %d page %p pages %ld** \n",\ - __FUNCTION__, cmd, index, uptodate, locked, count, \ - page, (!page->mapping) ? -1 : page->mapping->nrpages);\ + CDEBUG(D_CACHE, "%s: ** off %ld, %sdate, %slocked, flag %ld,"\ + " cnt %d page 0x%p pages %ld virt %lx %s**\n",\ + msg, index, uptodate, locked, page->flags, count,\ + page, page->mapping ? page->mapping->nrpages : -1,\ + page->virtual, buffer);\ } else \ - CDEBUG(D_CACHE, "** %s, no page\n", __FUNCTION__);\ + CDEBUG(D_CACHE, "** %s: no page\n", msg);\ } +#if 0 +#define iget(sb, ino) obd_iget(sb, ino) +#define iput(sb, ino) obd_iput(sb, ino) + +static inline struct inode *obd_iget(struct super_block *sb, unsigned long ino) +{ + struct inode *inode; + + if ((inode = iget(sb, ino)) == NULL) + CDEBUG(D_INODE, "NULL in iget for %ld\n", ino); + else + obd_inodes++; + return inode; +} + +static inline void obd_iput(struct inode *inode) +{ + if (inode == NULL) + CDEBUG(D_INODE, "NULL in iput\n"); + else + obd_inodes--; +} +#endif + #else /* EXT2_OBD_DEBUG */ #define CDEBUG(mask, format, a...) {} @@ -121,32 +150,35 @@ extern int obd_print_entry; #define OBD_ALLOC(ptr, cast, size) \ do { \ if (size <= 4096) { \ - ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \ - CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", \ + ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \ + CDEBUG(D_MALLOC, "kmalloced: %d at %x.\n", \ (int) size, (int) ptr); \ } else { \ ptr = (cast)vmalloc((unsigned long) size); \ - CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", \ + CDEBUG(D_MALLOC, "vmalloced: %d at %x.\n", \ (int) size, (int) ptr); \ } \ if (ptr == 0) { \ printk("kernel malloc returns 0 at %s:%d\n", \ __FILE__, __LINE__); \ + } else { \ + memset(ptr, 0, size); \ + obd_memory += size; \ } \ - memset(ptr, 0, size); \ } while (0) #define OBD_FREE(ptr,size) \ do { \ if (size <= 4096) { \ kfree_s((ptr), (size)); \ - CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \ + CDEBUG(D_MALLOC, "kfreed: %d at %x.\n", \ (int) size, (int) ptr); \ } else { \ vfree((ptr)); \ - CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \ + CDEBUG(D_MALLOC, "vfreed: %d at %x.\n", \ (int) size, (int) ptr); \ } \ + obd_memory -= size; \ } while (0) diff --git a/lustre/include/linux/obdfs.h b/lustre/include/linux/obdfs.h index ca61554..0ce8157 100644 --- a/lustre/include/linux/obdfs.h +++ b/lustre/include/linux/obdfs.h @@ -31,6 +31,7 @@ struct obdfs_sb_info { ino_t osi_rootino; /* number of root inode */ int osi_minor; /* minor of /dev/obdX */ struct list_head osi_inodes; /* list of dirty inodes */ + unsigned long osi_cache_count; struct semaphore osi_list_mutex; }; @@ -53,10 +54,11 @@ extern struct file_operations obdfs_file_operations; extern struct inode_operations obdfs_file_inode_operations; /* flush.c */ +void obdfs_dequeue_pages(struct inode *inode); int obdfs_flushd_init(void); int obdfs_flushd_cleanup(void); -int obdfs_flush_reqs(struct list_head *inode_list, int check_time); -void obdfs_flush_dirty_pages(int check_time); +int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time); +int obdfs_flush_dirty_pages(unsigned long check_time); /* namei.c */ struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry); @@ -88,10 +90,13 @@ int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa, struct obdo **obdos, obd_count *oa_bufs, struct page **pages, char **bufs, obd_size *counts, obd_off *offsets, obd_flag *flags); +void obdfs_truncate(struct inode *inode); /* super.c */ +extern long obdfs_cache_count; /* symlink.c */ +extern struct inode_operations obdfs_fast_symlink_inode_operations; extern struct inode_operations obdfs_symlink_inode_operations; /* sysctl.c */ diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 51904f8..6d42ddd 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -59,7 +59,7 @@ static int obd_init_magic; int obd_print_entry = 0; -int obd_debug_level = D_IOCTL|D_INODE|D_SUPER|D_WARNING|D_MALLOC|D_CACHE; +int obd_debug_level = ~D_INFO; long obd_memory = 0; struct obd_device obd_dev[MAX_OBD_DEVICES]; struct list_head obd_types; @@ -760,6 +760,34 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, return err; } + case OBD_IOC_PUNCH: { + struct oic_rw_s *rw_s = tmp_buf; /* read, write ioctl str */ + + err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s)); + if ( err ) { + EXIT; + return err; + } + + conn.oc_id = rw_s->conn_id; + + if ( !OBT(obddev) || !OBP(obddev, punch) ) { + err = -EOPNOTSUPP; + return err; + } + + CDEBUG(D_INFO, "PUNCH: conn %d, count %Ld, offset %Ld\n", + rw_s->conn_id, rw_s->count, rw_s->offset); + err = OBP(obddev, punch)(&conn, &rw_s->obdo, rw_s->count, + rw_s->offset); + ODEBUG(&rw_s->obdo); + if ( err ) { + EXIT; + return err; + } + EXIT; + return err; + } default: { struct obd_type *type; -- 1.8.3.1