summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-10-28 08:00:28 +0000
committermav <mav@FreeBSD.org>2014-10-28 08:00:28 +0000
commit928386888ba740d10d5891223be7757b5099e310 (patch)
tree6e9d0c02593ee1e606cce9c9a43e7f0d5e3ab879 /sys/geom
parent1c649cc8f3b5376126d2ea329e6f4badebe7f008 (diff)
downloadFreeBSD-src-928386888ba740d10d5891223be7757b5099e310.zip
FreeBSD-src-928386888ba740d10d5891223be7757b5099e310.tar.gz
MFC r273638:
Revert somewhat hackish geom_disk optimization, committed as part of r256880, and the following r273143 commit, supposed to workaround introduced issue by quite innocent-looking change. While there is no clear understanding why, but r273143 is accused in data corruption in some environments with high I/O load. I personally don't see any problem in that commit, and possibly it is just a trigger to some other bug somewhere, but better safe then sorry for now. Requested by: scottl@
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_disk.c59
1 files changed, 16 insertions, 43 deletions
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 2c6b00b..9319b97 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -255,25 +255,6 @@ g_disk_done(struct bio *bp)
g_destroy_bio(bp);
}
-static void
-g_disk_done_single(struct bio *bp)
-{
- struct bintime now;
- struct g_disk_softc *sc;
-
- bp->bio_completed = bp->bio_length - bp->bio_resid;
- bp->bio_done = (void *)bp->bio_to;
- bp->bio_to = LIST_FIRST(&bp->bio_disk->d_geom->provider);
- if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE|BIO_FLUSH)) != 0) {
- binuptime(&now);
- sc = bp->bio_to->private;
- mtx_lock(&sc->done_mtx);
- devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now);
- mtx_unlock(&sc->done_mtx);
- }
- g_io_deliver(bp, bp->bio_error);
-}
-
static int
g_disk_ioctl(struct g_provider *pp, u_long cmd, void * data, int fflag, struct thread *td)
{
@@ -299,7 +280,7 @@ g_disk_start(struct bio *bp)
struct disk *dp;
struct g_disk_softc *sc;
int error;
- off_t d_maxsize, off;
+ off_t off;
sc = bp->bio_to->private;
if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
@@ -316,22 +297,6 @@ g_disk_start(struct bio *bp)
/* fall-through */
case BIO_READ:
case BIO_WRITE:
- d_maxsize = (bp->bio_cmd == BIO_DELETE) ?
- dp->d_delmaxsize : dp->d_maxsize;
- if (bp->bio_length <= d_maxsize) {
- bp->bio_disk = dp;
- bp->bio_to = (void *)bp->bio_done;
- bp->bio_done = g_disk_done_single;
- bp->bio_pblkno = bp->bio_offset / dp->d_sectorsize;
- bp->bio_bcount = bp->bio_length;
- mtx_lock(&sc->start_mtx);
- devstat_start_transaction_bio(dp->d_devstat, bp);
- mtx_unlock(&sc->start_mtx);
- g_disk_lock_giant(dp);
- dp->d_strategy(bp);
- g_disk_unlock_giant(dp);
- break;
- }
off = 0;
bp3 = NULL;
bp2 = g_clone_bio(bp);
@@ -340,6 +305,10 @@ g_disk_start(struct bio *bp)
break;
}
do {
+ off_t d_maxsize;
+
+ d_maxsize = (bp->bio_cmd == BIO_DELETE) ?
+ dp->d_delmaxsize : dp->d_maxsize;
bp2->bio_offset += off;
bp2->bio_length -= off;
if ((bp->bio_flags & BIO_UNMAPPED) == 0) {
@@ -447,14 +416,18 @@ g_disk_start(struct bio *bp)
error = EOPNOTSUPP;
break;
}
- bp->bio_disk = dp;
- bp->bio_to = (void *)bp->bio_done;
- bp->bio_done = g_disk_done_single;
- mtx_lock(&sc->start_mtx);
- devstat_start_transaction_bio(dp->d_devstat, bp);
- mtx_unlock(&sc->start_mtx);
+ bp2 = g_clone_bio(bp);
+ if (bp2 == NULL) {
+ g_io_deliver(bp, ENOMEM);
+ return;
+ }
+ bp2->bio_done = g_disk_done;
+ bp2->bio_disk = dp;
+ mtx_lock(&sc->start_mtx);
+ devstat_start_transaction_bio(dp->d_devstat, bp2);
+ mtx_unlock(&sc->start_mtx);
g_disk_lock_giant(dp);
- dp->d_strategy(bp);
+ dp->d_strategy(bp2);
g_disk_unlock_giant(dp);
break;
default:
OpenPOWER on IntegriCloud