allow also the snapshot_setup()'s call to ffs_truncate() fail, the code

should simply reuse the file blocks in that case; also make sure the
ffs_truncate() call is run within transaction if log is on
This commit is contained in:
jdolecek 2016-10-20 20:17:46 +00:00
parent 7470816b2a
commit e1aea9a285
1 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_snapshot.c,v 1.140 2015/06/28 10:04:32 maxv Exp $ */
/* $NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $ */
/*
* Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.140 2015/06/28 10:04:32 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -402,6 +402,10 @@ out:
}
if (error) {
if (UFS_WAPBL_BEGIN(mp) == 0) {
/*
* This is okay to fail, we'll simply reuse the blocks
* later.
*/
(void) ffs_truncate(vp, (off_t)0, 0, NOCRED);
UFS_WAPBL_END(mp);
}
@ -437,9 +441,13 @@ snapshot_setup(struct mount *mp, struct vnode *vp)
return EACCES;
if (vp->v_size != 0) {
error = ffs_truncate(vp, 0, 0, NOCRED);
if (error)
return error;
if (UFS_WAPBL_BEGIN(mp) == 0) {
/*
* This is okay to fail, we'll simply reuse the blocks
*/
(void) ffs_truncate(vp, 0, 0, NOCRED);
UFS_WAPBL_END(mp);
}
}
/* Change inode to snapshot type file. */
@ -448,6 +456,7 @@ snapshot_setup(struct mount *mp, struct vnode *vp)
return error;
#if defined(QUOTA) || defined(QUOTA2)
/* shapshot inodes are not accounted in quotas */
chkdq(ip, -DIP(ip, blocks), l->l_cred, 0);
chkiq(ip, -1, l->l_cred, 0);
#endif
ip->i_flags |= (SF_SNAPSHOT | SF_SNAPINVAL);