From owner-p4-projects@FreeBSD.ORG Fri Oct 21 17:48:12 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CFFDE1065677; Fri, 21 Oct 2011 17:48:11 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92ABC106564A for ; Fri, 21 Oct 2011 17:48:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 7FD4D8FC14 for ; Fri, 21 Oct 2011 17:48:11 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p9LHmBn4041824 for ; Fri, 21 Oct 2011 17:48:11 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p9LHmBji041821 for perforce@freebsd.org; Fri, 21 Oct 2011 17:48:11 GMT (envelope-from jhb@freebsd.org) Date: Fri, 21 Oct 2011 17:48:11 GMT Message-Id: <201110211748.p9LHmBji041821@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 200534 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2011 17:48:12 -0000 http://p4web.freebsd.org/@@200534?ac=10 Change 200534 by jhb@jhb_jhbbsd on 2011/10/21 17:47:20 - A nit from mdf. - Rework FADV_DONTNEED. vm_object_sync() did not work because the buffer cache still had buffers holding onto the pages, so vm_object_page_remove() did not actually remove any pages. vinvalbuf() will flush all the open buffers (though it is a bit heavy-handed as it does all of the buffers and not just buffers for the requested range). Affected files ... .. //depot/projects/fadvise/sys/kern/vfs_syscalls.c#7 edit Differences ... ==== //depot/projects/fadvise/sys/kern/vfs_syscalls.c#7 (text+ko) ==== @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -4861,7 +4862,7 @@ int error, vfslocked; if (uap->offset < 0 || uap->len < 0 || - uap->offset + uap->len < uap->offset) + uap->offset > OFF_MAX - uap->len) return (EINVAL); switch (uap->advice) { case FADV_NORMAL: @@ -4959,12 +4960,24 @@ break; case FADV_DONTNEED: /* - * Invalidate pages from the backing VM object similar - * to msync(MS_INVALIDATE). + * Flush any open FS buffers and then remove pages + * from the backing VM object. */ - if (vp->v_object != NULL) - vm_object_sync(vp->v_object, uap->offset, end - uap->offset, - FALSE, TRUE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + if (vp->v_iflag & VI_DOOMED) { + VOP_UNLOCK(vp, 0); + break; + } + vinvalbuf(vp, V_NORMAL, 0, 0); + if (vp->v_object != NULL) { + start = trunc_page(uap->offset); + end = round_page(end); + VM_OBJECT_LOCK(vp->v_object); + vm_object_page_remove(vp->v_object, OFF_TO_IDX(start), + OFF_TO_IDX(end), OBJPR_CLEANONLY | OBJPR_DEBUG); + VM_OBJECT_UNLOCK(vp->v_object); + } + VOP_UNLOCK(vp, 0); break; } out: