Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Oct 2011 19:29:00 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 200664 for review
Message-ID:  <201110241929.p9OJT0FL097998@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@200664?ac=10

Change 200664 by jhb@jhb_jhbbsd on 2011/10/24 19:28:32

	Merge existing non-standard regions when possible.

Affected files ...

.. //depot/projects/fadvise/sys/kern/vfs_syscalls.c#9 edit

Differences ...

==== //depot/projects/fadvise/sys/kern/vfs_syscalls.c#9 (text+ko) ====

@@ -4904,9 +4904,23 @@
 	case FADV_RANDOM:
 	case FADV_NOREUSE:
 		mtx_pool_lock(mtxpool_sleep, fp);
-		fp->f_advice = uap->advice;
-		fp->f_advstart = uap->offset;
-		fp->f_advend = end;
+		/*
+		 * See if we can merge with the existing non-standard
+		 * region.
+		 */
+		if (fp->f_advice == uap->advice &&
+		    ((fp->f_advstart <= end && fp->f_advend >= uap->offset) ||
+		    (fp->f_advstart != 0 && fp->f_advstart == end + 1) ||
+		    (uap->offset != 0 && fp->f_advend + 1 == uap->offset))) {
+			if (uap->offset < fp->f_advstart)
+				fp->f_advstart = uap->offset;
+			if (end > fp->f_advend)
+				fp->f_advend = end;
+		} else {
+			fp->f_advice = uap->advice;
+			fp->f_advstart = uap->offset;
+			fp->f_advend = end;
+		}
 		mtx_pool_unlock(mtxpool_sleep, fp);
 		break;
 	case FADV_NORMAL:



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