Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jan 2008 02:11:16 GMT
From:      Steve Wise <swise@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 133299 for review
Message-ID:  <200801150211.m0F2BGxS011728@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=133299

Change 133299 by swise@swise:vic10:iwarp on 2008/01/15 02:10:25

	YAGF - Yet Another Genpool Fix!
	
	wasn't rounding up the chunks correctly.

Affected files ...

.. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_hal.h#8 edit

Differences ...

==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cxio_hal.h#8 (text+ko) ====

@@ -249,7 +249,7 @@
 	int chunks;
 	daddr_t blkno; 
 
-	chunks = size >> gp->gen_chunk_shift;
+	chunks = (size + (1<<gp->gen_chunk_shift) - 1) >> gp->gen_chunk_shift;
 	blkno = blist_alloc(gp->gen_list, chunks);
 
 	if (blkno == SWAPBLK_NONE)
@@ -258,29 +258,13 @@
 	return (gp->gen_base + ((1 << gp->gen_chunk_shift) * blkno));
 }
 
-#define cxio_wait(ctx, lockp, cond) \
-({ \
-	int __ret = 0; \
-	mtx_lock_spin(lockp); \
-	while (!cond) { \
-                msleep_spin(ctx, lockp, "cxio_wait", hz); \
-                if (SIGPENDING(curthread)) { \
-			__ret = ERESTART; \
-                        break; \
-                } \
-	} \
-	mtx_unlock_spin(lockp); \
-	__ret; \
-}) 
-
-
 static __inline void
 gen_pool_free(struct gen_pool *gp, daddr_t address, int size)
 {
 	int chunks;
 	daddr_t blkno;
 	
-	chunks = size >> gp->gen_chunk_shift;
+	chunks = (size + (1<<gp->gen_chunk_shift) - 1) >> gp->gen_chunk_shift;
 	blkno = (address - gp->gen_base) / (1 << gp->gen_chunk_shift);
 	blist_free(gp->gen_list, blkno, chunks);
 }
@@ -292,4 +276,19 @@
 	free(gp, M_DEVBUF);
 }
 
+#define cxio_wait(ctx, lockp, cond) \
+({ \
+	int __ret = 0; \
+	mtx_lock_spin(lockp); \
+	while (!cond) { \
+                msleep_spin(ctx, lockp, "cxio_wait", hz); \
+                if (SIGPENDING(curthread)) { \
+			__ret = ERESTART; \
+                        break; \
+                } \
+	} \
+	mtx_unlock_spin(lockp); \
+	__ret; \
+}) 
+
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801150211.m0F2BGxS011728>