MFC: Detect the snapshot file being prematurely unlinked.
This commit is contained in:
parent
24528b3490
commit
c83e05380e
@ -405,6 +405,11 @@ ffs_snapshot(mp, snapfile)
|
||||
vn_start_write(NULL, &wrtmp, V_WAIT);
|
||||
}
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if (ip->i_effnlink == 0) {
|
||||
error = ENOENT; /* Snapshot file unlinked */
|
||||
sn = NULL;
|
||||
goto out1;
|
||||
}
|
||||
if (collectsnapstats)
|
||||
nanotime(&starttime);
|
||||
/*
|
||||
@ -763,12 +768,17 @@ ffs_snapshot(mp, snapfile)
|
||||
* the inode for this snapshot then a deadlock can occur. Drop
|
||||
* the snapshot lock until the buffer has been written.
|
||||
*/
|
||||
VREF(vp); /* Protect against ffs_snapgone() */
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
(void) bread(ip->i_devvp,
|
||||
fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
|
||||
(int) fs->fs_bsize, NOCRED, &nbp);
|
||||
brelse(nbp);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if (ip->i_effnlink == 0)
|
||||
error = ENOENT; /* Snapshot file unlinked */
|
||||
else
|
||||
vrele(vp); /* Drop extra reference */
|
||||
done:
|
||||
FREE(copy_fs->fs_csp, M_UFSMNT);
|
||||
bawrite(sbp);
|
||||
|
Loading…
Reference in New Issue
Block a user