From owner-svn-src-all@freebsd.org Mon May 2 13:13:33 2016 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 75350B290A6; Mon, 2 May 2016 13:13:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 4182A1097; Mon, 2 May 2016 13:13:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u42DDWUl095371; Mon, 2 May 2016 13:13:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u42DDWXj095370; Mon, 2 May 2016 13:13:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201605021313.u42DDWXj095370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 2 May 2016 13:13:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298921 - 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.22 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: Mon, 02 May 2016 13:13:33 -0000 Author: kib Date: Mon May 2 13:13:32 2016 New Revision: 298921 URL: https://svnweb.freebsd.org/changeset/base/298921 Log: Fix reporting of NOTE_LINK when directory link count changes due to rename removing or adding subdirectory entry. Discussed with and tested by: Vladimir Kondratyev NetBSD PR: 48958 (http://gnats.netbsd.org/48958) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Mon May 2 05:46:47 2016 (r298920) +++ head/sys/kern/vfs_subr.c Mon May 2 13:13:32 2016 (r298921) @@ -4650,10 +4650,26 @@ void vop_rename_post(void *ap, int rc) { struct vop_rename_args *a = ap; + long hint; if (!rc) { - VFS_KNOTE_UNLOCKED(a->a_fdvp, NOTE_WRITE); - VFS_KNOTE_UNLOCKED(a->a_tdvp, NOTE_WRITE); + hint = NOTE_WRITE; + if (a->a_fdvp == a->a_tdvp) { + if (a->a_tvp != NULL && a->a_tvp->v_type == VDIR) + hint |= NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_fdvp, hint); + VFS_KNOTE_UNLOCKED(a->a_tdvp, hint); + } else { + if (a->a_fvp->v_type == VDIR) + hint |= NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_fdvp, hint); + + if (a->a_fvp->v_type == VDIR && a->a_tvp != NULL && + a->a_tvp->v_type == VDIR) + hint &= ~NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_tdvp, hint); + } + VFS_KNOTE_UNLOCKED(a->a_fvp, NOTE_RENAME); if (a->a_tvp) VFS_KNOTE_UNLOCKED(a->a_tvp, NOTE_DELETE);