Module Name: src Committed By: jdolecek Date: Thu Oct 20 20:17:46 UTC 2016
Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.140 src/sys/ufs/ffs/ffs_snapshot.c:1.141 --- src/sys/ufs/ffs/ffs_snapshot.c:1.140 Sun Jun 28 10:04:32 2015 +++ src/sys/ufs/ffs/ffs_snapshot.c Thu Oct 20 20:17:46 2016 @@ -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 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 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);