svn commit: r200461 - user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Kip Macy kmacy at FreeBSD.org
Sun Dec 13 02:00:41 UTC 2009


Author: kmacy
Date: Sun Dec 13 02:00:41 2009
New Revision: 200461
URL: http://svn.freebsd.org/changeset/base/200461

Log:
  simplify initial version and reduce ARC churn by assuming that the block address is
  never available at getblk time

Modified:
  user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Sun Dec 13 01:20:32 2009	(r200460)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Sun Dec 13 02:00:41 2009	(r200461)
@@ -258,7 +258,6 @@ static arc_state_t ARC_mfu_ghost;
 static arc_state_t ARC_l2c_only;
 
 typedef struct arc_stats {
-	kstat_named_t arcstat_page_cache_hits;
 	kstat_named_t arcstat_hits;
 	kstat_named_t arcstat_misses;
 	kstat_named_t arcstat_demand_data_hits;
@@ -309,7 +308,6 @@ typedef struct arc_stats {
 
 static arc_stats_t arc_stats = {
 	{ "hits",			KSTAT_DATA_UINT64 },
-	{ "page_cache_hits",		KSTAT_DATA_UINT64 },
 	{ "misses",			KSTAT_DATA_UINT64 },
 	{ "demand_data_hits",		KSTAT_DATA_UINT64 },
 	{ "demand_data_misses",		KSTAT_DATA_UINT64 },
@@ -451,7 +449,6 @@ struct arc_write_callback {
 /*
  * Keep initial ordering in-sync with zbio_buf_hdr
  */
-
 struct arc_buf_hdr {
 	/* protected by hash lock */
 	dva_t			b_dva;
@@ -646,6 +643,8 @@ typedef struct l2arc_data_free {
 	list_node_t	l2df_list_node;
 } l2arc_data_free_t;
 
+extern int zfs_page_cache_disable;
+
 static kmutex_t l2arc_feed_thr_lock;
 static kcondvar_t l2arc_feed_thr_cv;
 static uint8_t l2arc_thread_exit;
@@ -1198,9 +1197,8 @@ arc_data_buf_free(void *buf, uint64_t si
 	atomic_add_64(&arc_size, -size);
 }
 
-static arc_buf_t *
-_arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type,
-	blkptr_t *bp)
+arc_buf_t *
+arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type)
 {
 	arc_buf_hdr_t *hdr;
 	arc_buf_t *buf;
@@ -1210,14 +1208,6 @@ _arc_buf_alloc(spa_t *spa, int size, voi
 	ASSERT(BUF_EMPTY(hdr));
 	hdr->b_size = size;
 	hdr->b_type = type;
-	if (bp != NULL) {
-		hdr->b_dva = *BP_IDENTITY(bp);
-		hdr->b_birth = bp->blk_birth;
-	} else {
-		hdr->b_dva.dva_word[0] = 0;
-		hdr->b_dva.dva_word[1] = 0;
-		hdr->b_birth = 0;
-	}
 	hdr->b_spa = spa;
 	hdr->b_state = arc_anon;
 	hdr->b_arc_access = 0;
@@ -1237,13 +1227,6 @@ _arc_buf_alloc(spa_t *spa, int size, voi
 	return (buf);
 }
 
-arc_buf_t *
-arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type)
-{
-
-	return (_arc_buf_alloc(spa, size, tag, type, NULL));
-}
-
 static arc_buf_t *
 arc_buf_clone(arc_buf_t *from)
 {
@@ -1564,7 +1547,7 @@ arc_evict(arc_state_t *state, spa_t *spa
 	 * don't recycle page cache bufs
 	 *
 	 */
-	if (recycle && (bytes >= PAGE_SIZE))
+	if (recycle && ((bytes & PAGE_MASK) != 0) && !zfs_page_cache_disable)
 		recycle = FALSE;
 #endif
 	if (type == ARC_BUFC_METADATA) {
@@ -2339,7 +2322,7 @@ arc_get_data_buf(arc_buf_t *buf)
 			zbio_data_getblk(buf);
 			atomic_add_64(&arc_size, size);
 		}
-		if (size < PAGE_SIZE)
+		if (size & PAGE_MASK)
 			ARCSTAT_BUMP(arcstat_recycle_miss);
 	}
 	ASSERT(buf->b_data != NULL);
@@ -2768,8 +2751,10 @@ top:
 			/* this block is not in the cache */
 			arc_buf_hdr_t	*exists;
 			arc_buf_contents_t type = BP_GET_BUFC_TYPE(bp);
-			buf = _arc_buf_alloc(spa, size, private, type, bp);
+			buf = arc_buf_alloc(spa, size, private, type);
 			hdr = buf->b_hdr;
+			hdr->b_dva = *BP_IDENTITY(bp);
+			hdr->b_birth = bp->blk_birth;
 			hdr->b_cksum0 = bp->blk_cksum.zc_word[0];
 			exists = buf_hash_insert(hdr, &hash_lock);
 			if (exists) {
@@ -4021,6 +4006,7 @@ l2arc_do_free_on_write()
 
 	for (df = list_tail(buflist); df; df = df_prev) {
 		df_prev = list_prev(buflist, df);
+		ASSERT(df->l2df_buf != NULL);
 		ASSERT(df->l2df_func != NULL);
 		df->l2df_func(df->l2df_buf, df->l2df_size);
 		list_remove(buflist, df);

Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c
==============================================================================
--- user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c	Sun Dec 13 01:20:32 2009	(r200460)
+++ user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_bio.c	Sun Dec 13 02:00:41 2009	(r200461)
@@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$");
 	(buf)->b_birth == 0)
 
 SYSCTL_DECL(_vfs_zfs);
-static int zfs_page_cache_disable = 1;
+int zfs_page_cache_disable = 1;
 TUNABLE_INT("vfs.zfs.page_cache_disable", &zfs_page_cache_disable);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, page_cache_disable, CTLFLAG_RDTUN,
     &zfs_page_cache_disable, 0, "Disable backing ARC with page cache ");
@@ -759,16 +759,6 @@ _zbio_getblk_malloc(zbio_buf_hdr_t *hdr,
 	newbp->b_data = data;
 	newbp->b_flags = (B_MALLOC|B_INVAL);
 	newbp->b_bcount = size;
-	if (!BUF_EMPTY(hdr) && !(hdr->b_flags & ZBIO_BUF_CLONING)) {
-		blkno = hdr->b_dva.dva_word[1] & ~(1ULL<<63);
-		zbio_buf_evict_overlap(blkno, size, state, txg, ZB_EVICT_BUFFERED);
-		newbp->b_blkno = blkno;
-		/*
-		 * Copy in from the page cache if found & valid
-		 * and mark B_CACHE
-		 */
-		zbio_buf_vm_object_copyin(newbp);
-	}
 
 	if (hdr->b_flags & ZBIO_BUF_CLONING) {
 		newbp->b_flags |= B_CLONED;
@@ -781,31 +771,13 @@ static buf_t *
 _zbio_getblk_vmio(zbio_buf_hdr_t *hdr, int flags)
 {
 	buf_t 		*newbp;
-	daddr_t 	blkno;
 	uint64_t	size = hdr->b_size;
 	spa_t		*spa = hdr->b_spa;
 	zbio_state_t	*state = spa_get_bio_state(spa);
-	struct vnode 	*vp = spa_get_vnode(spa);
-	struct bufobj	*bo = &vp->v_bufobj;
 
-	if (BUF_EMPTY(hdr)) {
-		newbp = geteblk(size, flags);
-		zbio_buf_va_insert(newbp, state);
-	} else {
-		blkno = hdr->b_dva.dva_word[1] & ~(1ULL<<63);
-		zbio_buf_evict_overlap(blkno, size, state, NO_TXG, ZB_EVICT_BUFFERED);
-
-		while (newbp == NULL)
-			newbp = getblk(vp, blkno, size, 0, 0, flags | GB_LOCK_NOWAIT);
-		brelvp(newbp);
-		newbp->b_flags |= B_ASSIGNED;
-		zbio_buf_blkno_insert(newbp, state);
-	}
-	newbp->b_bufobj = bo;
+	newbp = geteblk(size, flags);
+	zbio_buf_va_insert(newbp, state);
 	BUF_KERNPROC(newbp);
-	CTR4(KTR_SPARE2, "arc_getblk() bp=%p flags %X "
-	    "blkno %ld npages %d",
-	    newbp, newbp->b_flags, blkno, newbp->b_npages);
 
 	return (newbp);
 }
@@ -876,7 +848,8 @@ zbio_relse(arc_buf_t *buf, size_t size)
 }
 
 int
-zbio_sync_cache(spa_t *spa, blkptr_t *blkp, uint64_t txg, void *data, uint64_t size, int bio_op)
+zbio_sync_cache(spa_t *spa, blkptr_t *blkp, uint64_t txg, void *data,
+    uint64_t size, int bio_op)
 {
 	buf_t		*bp;
 	zbio_state_t 	*state = spa_get_bio_state(spa);
@@ -917,11 +890,13 @@ zbio_sync_cache(spa_t *spa, blkptr_t *bl
 				zbio_buf_vm_object_copyout(bp);
 			}
 		} else {
+			zbio_buf_va_remove(bp);
 			VM_OBJECT_LOCK(object);
 			zbio_buf_evict_overlap_locked(blkno, size, state, NO_TXG,
 			    ZB_EVICT_ALL, object);
 			bp->b_blkno = bp->b_lblkno = blkno;
 			bp->b_flags |= (B_VMIO|B_ASSIGNED);
+			zbio_buf_blkno_insert(bp, state);
 			zbio_buf_vm_object_insert_locked(bp, vp, object, bio_op == BIO_WRITE);
 			VM_OBJECT_UNLOCK(object);
 		}


More information about the svn-src-user mailing list