git: 513e1bbc7392 - main - ufs_rename(): revert the bump of fvp nlink count in case of EMLINK for tdvp

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 06 Jul 2022 12:35:20 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=513e1bbc739239c9479367b15e5f863a5f891d66

commit 513e1bbc739239c9479367b15e5f863a5f891d66
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-07-04 10:28:49 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-07-06 12:34:36 +0000

    ufs_rename(): revert the bump of fvp nlink count in case of EMLINK for tdvp
    
    Reported and tested by: pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/ufs/ufs/ufs_vnops.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 976bc31841dd..918b1e7ab29c 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1576,17 +1576,17 @@ relock:
 			 * .. is rewritten below.
 			 */
 			if (tdp->i_nlink >= UFS_LINK_MAX) {
-				if (!DOINGSOFTDEP(tdvp) ||
-				    tdp->i_effnlink >= UFS_LINK_MAX) {
-					error = EMLINK;
-					goto unlockout;
-				}
 				fip->i_effnlink--;
 				fip->i_nlink--;
 				DIP_SET(fip, i_nlink, fip->i_nlink);
 				UFS_INODE_SET_FLAG(fip, IN_CHANGE);
 				if (DOINGSOFTDEP(fvp))
 					softdep_revert_link(tdp, fip);
+				if (!DOINGSOFTDEP(tdvp) ||
+				    tdp->i_effnlink >= UFS_LINK_MAX) {
+					error = EMLINK;
+					goto unlockout;
+				}
 				MPASS(want_seqc_end);
 				if (tvp != NULL)
 					vn_seqc_write_end(tvp);