>From FreeBSD. FFS2 inodes have unsigned block counts, so we have to
perform the underflow test before the substraction.
Index: ffs_inode.c
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/ffs_inode.c,v
retrieving revision 1.62
diff -u -p -r1.62 ffs_inode.c
--- ffs_inode.c 16 Jan 2013 22:41:47 -0000 1.62
+++ ffs_inode.c 21 Apr 2013 20:06:39 -0000
@@ -436,8 +436,9 @@ done:
* Put back the real size.
*/
DIP_ASSIGN(oip, size, length);
- DIP_ADD(oip, blocks, -blocksreleased);
- if (DIP(oip, blocks) < 0) /* Sanity */
+ if (DIP(oip, blocks) >= blocksreleased)
+ DIP_ADD(oip, blocks, -blocksreleased);
+ else /* sanity */
DIP_ASSIGN(oip, blocks, 0);
oip->i_flag |= IN_CHANGE;
(void)ufs_quota_free_blocks(oip, blocksreleased, NOCRED);