From fd30f6fd77b232b2da9b9bbecfcf92b8973d15f5 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 7 Mar 2000 20:58:16 +0000 Subject: [PATCH] obdfs/flushd.c: added constant for nr_free_buffer_pages() function call as this isn't available from the kernel. Will figure out later. obdfs/rw.c: added bit on page flags to indicate if page is in obdfs page cache, to avoid searching list when inserting pages to page cache --- lustre/include/linux/obdfs.h | 18 ++++++++++++++++++ lustre/obdclass/obdcontrol | 2 +- lustre/obdfs/flushd.c | 8 +++++--- lustre/obdfs/rw.c | 17 ++++++++++------- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lustre/include/linux/obdfs.h b/lustre/include/linux/obdfs.h index 0ce8157..2359995 100644 --- a/lustre/include/linux/obdfs.h +++ b/lustre/include/linux/obdfs.h @@ -145,6 +145,14 @@ static inline struct list_head *obdfs_slist(struct inode *inode) /* CDEBUG(D_INFO, "free lock\n"); */ \ } +/* We track if a page has been added to the OBD page cache by stting a + * flag on the page. We have chosen a bit that will hopefully not be + * used for a while. + */ +#define PG_obdcache 29 +#define OBDAddCachePage(page) test_and_set_bit(PG_obdcache, &(page)->flags) +#define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags) + static inline void obdfs_print_plist(struct inode *inode) { struct list_head *page_list = obdfs_iplist(inode); @@ -194,6 +202,16 @@ static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa) CDEBUG(D_INFO, "src obdo %ld valid 0x%08x, dst inode %ld\n", (long)oa->o_id, oa->o_valid, inode->i_ino); + /* If the inode is dirty, we won't overwrite the data there, as it + * is newer than the data on the disk. The ext2obd side only will + * change the block count, so we are guaranteed that is safe. + */ + if (inode->i_state & I_DIRTY) { + CDEBUG(D_INODE, "dirty inode %ld, only copying blocks\n", + inode->i_ino); + oa->o_valid = OBD_MD_FLBLOCKS; + } + obdo_to_inode(inode, oa); if (obdo_has_inline(oa)) { diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index 0e11f78..59dda5a 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -1290,7 +1290,7 @@ sub Punch { return; } - print("Punching $count bytes starting at byte $start in object $id...\n"); + print("Punching $count bytes starting at byte $start from object $id...\n"); my $obdo; $obdo->{id} = $id; diff --git a/lustre/obdfs/flushd.c b/lustre/obdfs/flushd.c index f13952c..638dd54 100644 --- a/lustre/obdfs/flushd.c +++ b/lustre/obdfs/flushd.c @@ -17,6 +17,11 @@ #include +/* XXX temporary until the real function is available from kernel + * XXX set this to memory size in pages for max page cache size + */ +#define nr_free_buffer_pages() 32768 + struct { int nfract; /* Percentage of buffer cache dirty to activate bdflush */ @@ -366,10 +371,7 @@ static int pupdate(void *unused) /* asynchronous setattr etc for the future ... obdfs_flush_dirty_inodes(jiffies - pupd_prm.age_super); */ - /* XXX for debugging dirty_limit = nr_free_buffer_pages() * pupd_prm.nfract / 100; - * XXX */ - dirty_limit = 16384 * pupd_prm.nfract / 100; CDEBUG(D_CACHE, "dirty_limit %ld, cache_count %ld, wrote %d\n", dirty_limit, obdfs_cache_count, wrote); diff --git a/lustre/obdfs/rw.c b/lustre/obdfs/rw.c index be52f79..7a2dab7 100644 --- a/lustre/obdfs/rw.c +++ b/lustre/obdfs/rw.c @@ -121,6 +121,7 @@ inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq) --obdfs_cache_count; CDEBUG(D_INFO, "deleting page %p from list [count %ld]\n", pgrq->rq_page, obdfs_cache_count); + OBDClearCachePage(pgrq->rq_page); list_del(&pgrq->rq_plist); kmem_cache_free(obdfs_pgrq_cachep, pgrq); } @@ -143,12 +144,13 @@ void obdfs_cleanup_pgrqcache(void) /* - * 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. + * See whether a specific page in the page cache. * Called with the list lock held. */ -static struct obdfs_pgrq * -obdfs_find_in_page_list(struct inode *inode, struct page *page) +#ifdef PG_obdcache +#define obdfs_find_in_page_list(inode, page) OBDAddCachePage(page) +#else +static int obdfs_find_in_page_list(struct inode *inode, struct page *page) { struct list_head *page_list = obdfs_iplist(inode); struct list_head *tmp; @@ -161,7 +163,7 @@ obdfs_find_in_page_list(struct inode *inode, struct page *page) if (list_empty(page_list)) { CDEBUG(D_INFO, "empty list\n"); EXIT; - return NULL; + return 0; } tmp = page_list; while ( (tmp = tmp->next) != page_list ) { @@ -171,13 +173,14 @@ obdfs_find_in_page_list(struct inode *inode, struct page *page) if (pgrq->rq_page == page) { CDEBUG(D_INFO, "found page %p in list\n", page); EXIT; - return pgrq; + return 1; } } EXIT; - return NULL; + return 0; } /* obdfs_find_in_page_list */ +#endif /* called with the list lock held */ -- 1.8.3.1