From owner-svn-src-all@FreeBSD.ORG Tue Jun 17 07:58:53 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A2DDCE71; Tue, 17 Jun 2014 07:58:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E89A2049; Tue, 17 Jun 2014 07:58:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5H7wrpk026068; Tue, 17 Jun 2014 07:58:53 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5H7wrMB026067; Tue, 17 Jun 2014 07:58:53 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201406170758.s5H7wrMB026067@svn.freebsd.org> From: Xin LI Date: Tue, 17 Jun 2014 07:58:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r267569 - vendor-sys/illumos/dist/uts/common/fs/zfs X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jun 2014 07:58:53 -0000 Author: delphij Date: Tue Jun 17 07:58:53 2014 New Revision: 267569 URL: http://svnweb.freebsd.org/changeset/base/267569 Log: 4897 Space accounting mismatch in L2ARC/zpool Reviewed by: Matthew Ahrens Reviewed by: Boris Protopopov Approved by: Dan McDonald illumos/illumos-dist@3038a2b421b40dc5ac11cd88423696618584f85a Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c Tue Jun 17 07:51:55 2014 (r267568) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c Tue Jun 17 07:58:53 2014 (r267569) @@ -23,7 +23,7 @@ * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2014 by Saso Kiselkov. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ /* @@ -1592,6 +1592,8 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr) list_remove(l2hdr->b_dev->l2ad_buflist, hdr); ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size); ARCSTAT_INCR(arcstat_l2_asize, -l2hdr->b_asize); + vdev_space_update(l2hdr->b_dev->l2ad_vdev, + -l2hdr->b_asize, 0, 0); kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t)); if (hdr->b_state == arc_l2c_only) l2arc_hdr_stat_remove(); @@ -3445,6 +3447,8 @@ arc_release(arc_buf_t *buf, void *tag) if (l2hdr) { ARCSTAT_INCR(arcstat_l2_asize, -l2hdr->b_asize); + vdev_space_update(l2hdr->b_dev->l2ad_vdev, + -l2hdr->b_asize, 0, 0); kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t)); ARCSTAT_INCR(arcstat_l2_size, -buf_size); mutex_exit(&l2arc_buflist_mtx); @@ -4241,6 +4245,7 @@ l2arc_write_done(zio_t *zio) arc_buf_hdr_t *head, *ab, *ab_prev; l2arc_buf_hdr_t *abl2; kmutex_t *hash_lock; + int64_t bytes_dropped = 0; cb = zio->io_private; ASSERT(cb != NULL); @@ -4288,6 +4293,7 @@ l2arc_write_done(zio_t *zio) */ list_remove(buflist, ab); ARCSTAT_INCR(arcstat_l2_asize, -abl2->b_asize); + bytes_dropped += abl2->b_asize; ab->b_l2hdr = NULL; kmem_free(abl2, sizeof (l2arc_buf_hdr_t)); ARCSTAT_INCR(arcstat_l2_size, -ab->b_size); @@ -4306,6 +4312,8 @@ l2arc_write_done(zio_t *zio) kmem_cache_free(hdr_cache, head); mutex_exit(&l2arc_buflist_mtx); + vdev_space_update(dev->l2ad_vdev, -bytes_dropped, 0, 0); + l2arc_do_free_on_write(); kmem_free(cb, sizeof (l2arc_write_callback_t)); @@ -4444,6 +4452,7 @@ l2arc_evict(l2arc_dev_t *dev, uint64_t d arc_buf_hdr_t *ab, *ab_prev; kmutex_t *hash_lock; uint64_t taddr; + int64_t bytes_evicted = 0; buflist = dev->l2ad_buflist; @@ -4542,6 +4551,7 @@ top: if (ab->b_l2hdr != NULL) { abl2 = ab->b_l2hdr; ARCSTAT_INCR(arcstat_l2_asize, -abl2->b_asize); + bytes_evicted += abl2->b_asize; ab->b_l2hdr = NULL; kmem_free(abl2, sizeof (l2arc_buf_hdr_t)); ARCSTAT_INCR(arcstat_l2_size, -ab->b_size); @@ -4558,7 +4568,7 @@ top: } mutex_exit(&l2arc_buflist_mtx); - vdev_space_update(dev->l2ad_vdev, -(taddr - dev->l2ad_evict), 0, 0); + vdev_space_update(dev->l2ad_vdev, -bytes_evicted, 0, 0); dev->l2ad_evict = taddr; } @@ -4801,15 +4811,13 @@ l2arc_write_buffers(spa_t *spa, l2arc_de ARCSTAT_INCR(arcstat_l2_write_bytes, write_asize); ARCSTAT_INCR(arcstat_l2_size, write_sz); ARCSTAT_INCR(arcstat_l2_asize, write_asize); - vdev_space_update(dev->l2ad_vdev, write_psize, 0, 0); + vdev_space_update(dev->l2ad_vdev, write_asize, 0, 0); /* * Bump device hand to the device start if it is approaching the end. * l2arc_evict() will already have evicted ahead for this case. */ if (dev->l2ad_hand >= (dev->l2ad_end - target_sz)) { - vdev_space_update(dev->l2ad_vdev, - dev->l2ad_end - dev->l2ad_hand, 0, 0); dev->l2ad_hand = dev->l2ad_start; dev->l2ad_evict = dev->l2ad_start; dev->l2ad_first = B_FALSE;