From owner-svn-src-all@freebsd.org Sat Jul 25 15:00:16 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C8FD9AA6E7; Sat, 25 Jul 2015 15:00:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.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 CCD4911E; Sat, 25 Jul 2015 15:00:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6PF0FtD079864; Sat, 25 Jul 2015 15:00:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6PF0F5J079863; Sat, 25 Jul 2015 15:00:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201507251500.t6PF0F5J079863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 25 Jul 2015 15:00:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285872 - head/sys/kern X-SVN-Group: head 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.20 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: Sat, 25 Jul 2015 15:00:16 -0000 Author: kib Date: Sat Jul 25 15:00:14 2015 New Revision: 285872 URL: https://svnweb.freebsd.org/changeset/base/285872 Log: With the removal of b_saveaddr in the r285819, b_data must be reset to b_kvabase when the buffer is reclaimed. Otherwise, if b_data for the mapped buffer was adjusted with the page-offset portion of b_offset, nothing would re-adjust the b_data, which breaks buffer management code which expects page-aligned b_data (see e.g. bpman_qenter(), which skips partial pages). Fix a minor issue with the GB_KVAALLOC requests, which could result in returning the mapped buffer if the reused buffer is mapped and have the right amount of KVA reserved. Improve assertion in the vfs_buf_check_mapped() to catch unmapped buffers which have their b_data incorrectly adjusted with offset. Reported and tested by: pho (previous version) Reviewed by: jeff (previous version) Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Sat Jul 25 14:06:32 2015 (r285871) +++ head/sys/kern/vfs_bio.c Sat Jul 25 15:00:14 2015 (r285872) @@ -956,6 +956,8 @@ vfs_buf_check_mapped(struct buf *bp) ("mapped buf: b_kvabase was not updated %p", bp)); KASSERT(bp->b_data != unmapped_buf, ("mapped buf: b_data was not updated %p", bp)); + KASSERT(bp->b_data < unmapped_buf || bp->b_data > unmapped_buf + + MAXPHYS, ("b_data + b_offset unmapped %p", bp)); } static inline void @@ -2241,6 +2243,7 @@ getnewbuf_reuse_bp(struct buf *bp, int q bp->b_dirtyoff = bp->b_dirtyend = 0; bp->b_bufobj = NULL; bp->b_pin_count = 0; + bp->b_data = bp->b_kvabase; bp->b_fsprivate1 = NULL; bp->b_fsprivate2 = NULL; bp->b_fsprivate3 = NULL; @@ -2528,6 +2531,10 @@ restart: bp->b_flags |= B_INVAL; brelse(bp); goto restart; + } else if ((gbflags & (GB_UNMAPPED | GB_KVAALLOC)) == + (GB_UNMAPPED | GB_KVAALLOC)) { + bp->b_data = unmapped_buf; + BUF_CHECK_UNMAPPED(bp); } atomic_add_int(&bufreusecnt, 1); }