Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Dec 2015 03:38:35 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r291741 - head/sys/geom
Message-ID:  <201512040338.tB43cZY1053263@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ken
Date: Fri Dec  4 03:38:35 2015
New Revision: 291741
URL: https://svnweb.freebsd.org/changeset/base/291741

Log:
  Fix g_disk_vlist_limit() to work properly with deletes.
  
  Add a new bp argument to g_disk_maxsegs(), and add a new function,
  g_disk_maxsize() tha will properly determine the maximum I/O size for a
  delete or non-delete bio.
  
  Submitted by:	will
  MFC after:	1 week
  Sponsored by:	Spectra Logic

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==============================================================================
--- head/sys/geom/geom_disk.c	Fri Dec  4 03:18:02 2015	(r291740)
+++ head/sys/geom/geom_disk.c	Fri Dec  4 03:38:35 2015	(r291741)
@@ -253,10 +253,18 @@ g_disk_ioctl(struct g_provider *pp, u_lo
 	return (error);
 }
 
+static off_t
+g_disk_maxsize(struct disk *dp, struct bio *bp)
+{
+	if (bp->bio_cmd == BIO_DELETE)
+		return (dp->d_delmaxsize);
+	return (dp->d_maxsize);
+}
+
 static int
-g_disk_maxsegs(struct disk *dp)
+g_disk_maxsegs(struct disk *dp, struct bio *bp)
 {
-	return ((dp->d_maxsize / PAGE_SIZE) + 1);
+	return ((g_disk_maxsize(dp, bp) / PAGE_SIZE) + 1);
 }
 
 static void
@@ -334,7 +342,7 @@ g_disk_vlist_limit(struct disk *dp, stru
 	end = (bus_dma_segment_t *)bp->bio_data + bp->bio_ma_n;
 	residual = bp->bio_length;
 	offset = bp->bio_ma_offset;
-	pages = g_disk_maxsegs(dp);
+	pages = g_disk_maxsegs(dp, bp);
 	while (residual != 0 && pages != 0) {
 		KASSERT((seg != end),
 		    ("vlist limit runs off the end"));
@@ -350,10 +358,7 @@ static bool
 g_disk_limit(struct disk *dp, struct bio *bp)
 {
 	bool limited = false;
-	off_t d_maxsize;
-
-	d_maxsize = (bp->bio_cmd == BIO_DELETE) ?
-	    dp->d_delmaxsize : dp->d_maxsize;
+	off_t maxsz = g_disk_maxsize(dp, bp);
 
 	/*
 	 * XXX: If we have a stripesize we should really use it here.
@@ -361,8 +366,8 @@ g_disk_limit(struct disk *dp, struct bio
 	 *      as deletes can be very sensitive to size given how they
 	 *      are processed.
 	 */
-	if (bp->bio_length > d_maxsize) {
-		bp->bio_length = d_maxsize;
+	if (bp->bio_length > maxsz) {
+		bp->bio_length = maxsz;
 		limited = true;
 	}
 



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