From 57a5f895de635c50c25ea54f0eb909e91293351d Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 18 Jan 2000 21:29:12 +0000 Subject: [PATCH] Changed _brw methods in ext2obd, obdfs, snap to allow an array of I/Os with one call. Updated obdspec to reflect new method parameters. Work in progress. --- lustre/include/linux/obd_class.h | 45 ++++++++++++++++++++++------------------ lustre/obdclass/genops.c | 27 ++++++++++++++++-------- lustre/obdfs/namei.c | 29 ++++++++++++++------------ lustre/obdfs/rw.c | 15 +++++++++----- 4 files changed, 69 insertions(+), 47 deletions(-) diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 34389ce..ff45419 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -30,8 +30,8 @@ typedef uint32_t obd_gid; typedef uint32_t obd_flag; typedef uint32_t obd_count; -#define OBD_FL_INLINEDATA (1UL) -#define OBD_FL_OBDMDEXISTS (1UL << 1) +#define OBD_FL_INLINEDATA (0x00000001UL) +#define OBD_FL_OBDMDEXISTS (0x00000002UL) #define OBD_INLINESZ 60 #define OBD_OBDMDSZ 60 @@ -60,22 +60,22 @@ struct obdo { }; #define OBD_MD_FLALL (~0UL) -#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) +#define OBD_MD_FLID (0x00000001UL) +#define OBD_MD_FLATIME (0x00000002UL) +#define OBD_MD_FLMTIME (0x00000004UL) +#define OBD_MD_FLCTIME (0x00000008UL) +#define OBD_MD_FLSIZE (0x00000010UL) +#define OBD_MD_FLBLOCKS (0x00000020UL) +#define OBD_MD_FLBLKSZ (0x00000040UL) +#define OBD_MD_FLMODE (0x00000080UL) +#define OBD_MD_FLUID (0x00000100UL) +#define OBD_MD_FLGID (0x00000200UL) +#define OBD_MD_FLFLAGS (0x00000400UL) +#define OBD_MD_FLOBDFLG (0x00000800UL) +#define OBD_MD_FLNLINK (0x00001000UL) +#define OBD_MD_FLGENER (0x00002000UL) +#define OBD_MD_FLINLINE (0x00004000UL) +#define OBD_MD_FLOBDMD (0x00008000UL) #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG)) /* @@ -123,6 +123,10 @@ struct obd_device { * ======== OBD Operations Declarations =========== */ +#define OBD_BRW_READ (READ) +#define OBD_BRW_WRITE (WRITE) +#define OBD_BRW_RWMASK (READ | WRITE) +#define OBD_BRW_CREATE (0x00000010UL) struct obd_ops { int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg, @@ -147,8 +151,9 @@ struct obd_ops { obd_size *count, obd_off offset); int (*o_write)(struct obd_conn *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_brw)(int rw, struct obd_conn *conn, obd_count *num_io, + struct obdo **oa, char **buf, obd_size **count, + obd_off *offset, obd_flag *flags); int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count, obd_off offset); int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count, diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index ada4632..6940a95 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -264,15 +264,24 @@ int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst, lck_page(page); + /* XXX with brw vector I/O, we could batch up reads and writes here, + * all we need to do is allocate multiple pages to handle the I/Os + * and arrays to handle the request parameters. + */ while (index < ((src->o_size + PAGE_SIZE - 1) >> PAGE_SHIFT)) { - obd_size brw_count; + obd_count num = 1; + char *buf; + obd_size brw_size = PAGE_SIZE; + obd_size *brw_count = &brw_size; + obd_off brw_offset = (page->index) << PAGE_SHIFT; + obd_flag flagr = 0; + obd_flag flagw = OBD_BRW_CREATE; - brw_count = PAGE_SIZE; - page->index = index; - err = OBP(src_conn->oc_dev, brw) - (READ, src_conn, src, (char *)page_address(page), - &brw_count, (page->index) << PAGE_SHIFT, 0); + buf = (char *)page_address(page); + err = OBP(src_conn->oc_dev, brw)(READ, src_conn, &num, &src, + &buf, &brw_count, &brw_offset, + &flagr); if ( err ) { EXIT; @@ -280,9 +289,9 @@ int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst, } CDEBUG(D_INODE, "Read page %ld ...\n", page->index); - err = OBP(dst_conn->oc_dev, brw) - (WRITE, dst_conn, dst, (char *)page_address(page), - &brw_count, (page->index) << PAGE_SHIFT, 1); + err = OBP(dst_conn->oc_dev, brw)(WRITE, dst_conn, &num, &dst, + &buf, &brw_count, &brw_offset, + &flagw); /* XXX should handle dst->o_size, dst->o_blocks here */ if ( err ) { diff --git a/lustre/obdfs/namei.c b/lustre/obdfs/namei.c index 0b91c0f..7b44ec0 100644 --- a/lustre/obdfs/namei.c +++ b/lustre/obdfs/namei.c @@ -244,14 +244,16 @@ static struct page *obdfs_add_entry (struct inode * dir, return NULL; } rec_len = EXT2_DIR_REC_LEN(namelen); - CDEBUG(D_INODE, "reclen: %d\n", rec_len); + /* CDEBUG(D_INODE, "reclen: %d\n", rec_len); */ PDEBUG(page, "starting search"); offset = 0; de = (struct ext2_dir_entry_2 *) page_address(page); *err = -ENOSPC; while (1) { - CDEBUG(D_INODE, "Considering entry at %p, (page at %#lx - %#lx), offset %ld\n", - de, page_address(page), page_address(page) + PAGE_SIZE, offset); + /* CDEBUG(D_INODE, + "Entry at %p, (page at %#lx - %#lx), offset %ld\n", + de, page_address(page), page_address(page) + PAGE_SIZE, + offset); */ if ((char *)de >= PAGE_SIZE + (char *)page_address(page)) { UnlockPage(page); page_cache_release(page); @@ -283,7 +285,6 @@ static struct page *obdfs_add_entry (struct inode * dir, de = (struct ext2_dir_entry_2 *) page_address(page); } } - CDEBUG(D_INODE, "\n"); if (!obdfs_check_dir_entry ("ext2_add_entry", dir, de, page, offset)) { *err = -ENOENT; @@ -300,27 +301,32 @@ static struct page *obdfs_add_entry (struct inode * dir, EXIT; return NULL; } - CDEBUG(D_INODE, "Testing for enough space at de %p\n", de); + /* CDEBUG(D_INODE, "Testing for enough space at de %p\n", de);*/ if ( (le32_to_cpu(de->inode) == 0 && le16_to_cpu(de->rec_len) >= rec_len) || (le16_to_cpu(de->rec_len) >= EXT2_DIR_REC_LEN(de->name_len) + rec_len)) { offset += le16_to_cpu(de->rec_len); - CDEBUG(D_INODE, "Found enough space de %p, offset %#lx\n", de, offset); + /* CDEBUG(D_INODE, + "Found enough space de %p, offset %#lx\n", + de, offset); */ if (le32_to_cpu(de->inode)) { - CDEBUG(D_INODE, "Inserting new in %p\n", de); + /*CDEBUG(D_INODE, "Insert new in %p\n", de);*/ de1 = (struct ext2_dir_entry_2 *) ((char *) de + EXT2_DIR_REC_LEN(de->name_len)); - CDEBUG(D_INODE, "-- de1 at %p\n", de1); + /*CDEBUG(D_INODE, "-- de1 at %p\n", de1);*/ de1->rec_len = cpu_to_le16(le16_to_cpu(de->rec_len) - EXT2_DIR_REC_LEN(de->name_len)); de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(de->name_len)); de = de1; } - CDEBUG(D_INODE, "Reclen adjusted; copy %d bytes to %p, page at %#lx EOP at %#lx\n", namelen, de->name, page_address(page), page_address(page) + PAGE_SIZE); + /* CDEBUG(D_INODE, + "Reclen adjusted; copy %d bytes to %p, " + "page at %#lx EOP at %#lx\n", + namelen, de->name, page_address(page), + page_address(page) + PAGE_SIZE); */ de->inode = 0; de->name_len = namelen; de->file_type = 0; memcpy (de->name, name, namelen); - CDEBUG(D_INODE, "Copy done\n"); /* * XXX shouldn't update any times until successful * completion of syscall, but too many callers depend @@ -339,16 +345,13 @@ static struct page *obdfs_add_entry (struct inode * dir, *res_dir = de; *err = 0; PDEBUG(page, "add_entry"); - CDEBUG(D_INODE, "Regular exit from add_entry"); EXIT; return page; } - CDEBUG(D_INODE, "\n"); offset += le16_to_cpu(de->rec_len); de = (struct ext2_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len)); } - CDEBUG(D_INODE, "\n"); UnlockPage(page); page_cache_release(page); diff --git a/lustre/obdfs/rw.c b/lustre/obdfs/rw.c index fa6ce07..cdb7bd6 100644 --- a/lustre/obdfs/rw.c +++ b/lustre/obdfs/rw.c @@ -38,9 +38,14 @@ int console_loglevel; /* SYNCHRONOUS I/O for an inode */ static int obdfs_brw(int rw, struct inode *inode, struct page *page, int create) { - struct obdo *oa; - obd_size count = PAGE_SIZE; - int err; + obd_count num_io = 1; + struct obdo *oa; + char *buf = (char *)page_address(page); + obd_size size = PAGE_SIZE; + obd_size *count = &size; + obd_off offset = ((obd_off)page->index) << PAGE_SHIFT; + obd_flag flags = create ? OBD_BRW_CREATE : 0; + int err; ENTRY; oa = obdo_fromid(IID(inode), inode->i_ino, OBD_MD_FLNOTOBD); @@ -50,8 +55,8 @@ static int obdfs_brw(int rw, struct inode *inode, struct page *page, int create) } obdfs_from_inode(oa, inode); - err = IOPS(inode, brw)(rw, IID(inode), oa, (char *)page_address(page), - &count, (page->index) >> PAGE_SHIFT, create); + err = IOPS(inode, brw)(rw, IID(inode), &num_io, &oa, &buf, &count, + &offset, &flags); if ( !err ) obdfs_to_inode(inode, oa); /* copy o_blocks to i_blocks */ -- 1.8.3.1