git: 2d20a3178a72 - stable/13 - Remove a partial UFS/FFS snapshot if it fails to build successfully.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 20 Aug 2023 04:28:24 UTC
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=2d20a3178a72c84eb83816a3c6c98629bcb84c72 commit 2d20a3178a72c84eb83816a3c6c98629bcb84c72 Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2023-08-09 23:43:41 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> CommitDate: 2023-08-20 04:27:38 +0000 Remove a partial UFS/FFS snapshot if it fails to build successfully. Reported-by: Peter Holm Tested-by: Peter Holm Sponsored-by: The FreeBSD Foundation (cherry picked from commit c52b5d16ccf29ad0e999a1f5f813ed6472aa3771) --- sys/ufs/ffs/ffs_snapshot.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index b606c64241e3..5ceca72fd44f 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -851,7 +851,6 @@ done: free(copy_fs, M_UFSMNT); copy_fs = NULL; out: - NDFREE(&nd, NDF_ONLY_PNBUF); if (saved_nice > 0) { struct proc *p; @@ -869,14 +868,30 @@ out: MNT_ILOCK(mp); mp->mnt_flag = (mp->mnt_flag & MNT_QUOTA) | (flag & ~MNT_QUOTA); MNT_IUNLOCK(mp); - if (error) - (void) ffs_truncate(vp, (off_t)0, 0, NOCRED); - (void) ffs_syncvnode(vp, MNT_WAIT, 0); - if (error) - vput(vp); - else - VOP_UNLOCK(vp); + NDFREE_PNBUF(&nd); vrele(nd.ni_dvp); + if (error == 0) { + (void) ffs_syncvnode(vp, MNT_WAIT, 0); + VOP_UNLOCK(vp); + } else if (VN_IS_DOOMED(vp)) { + vput(vp); + } else { + int rmerr; + + /* Remove snapshot as its creation has failed. */ + vput(vp); + NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_SYSSPACE, + snapfile, td); + if ((rmerr = namei(&nd)) != 0 || + (rmerr = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd)) != 0) + printf("Delete of %s failed with error %d\n", + nd.ni_dirp, rmerr); + NDFREE_PNBUF(&nd); + if (nd.ni_dvp != NULL) + vput(nd.ni_dvp); + if (nd.ni_vp != NULL) + vput(nd.ni_vp); + } vn_finished_write(wrtmp); process_deferred_inactive(mp); return (error);