Wed Jul 3 11:50:59 2013 UTC ()
On growing a node that was recorded inside the (E)FE, don't forget to set the
size of the node to the NEW size. This was reported by the `t_io
udf_shrinkfile' testcase.

Fixes PR kern/47985


(reinoud)
diff -r1.32 -r1.33 src/sys/fs/udf/udf_allocation.c

cvs diff -r1.32 -r1.33 src/sys/fs/udf/udf_allocation.c (expand / switch to unified diff)

--- src/sys/fs/udf/udf_allocation.c 2011/06/16 09:21:02 1.32
+++ src/sys/fs/udf/udf_allocation.c 2013/07/03 11:50:59 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: udf_allocation.c,v 1.32 2011/06/16 09:21:02 hannken Exp $ */ 1/* $NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006, 2008 Reinoud Zandijk 4 * Copyright (c) 2006, 2008 Reinoud Zandijk
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *  26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30#ifndef lint 30#ifndef lint
31__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.32 2011/06/16 09:21:02 hannken Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $");
32#endif /* not lint */ 32#endif /* not lint */
33 33
34 34
35#if defined(_KERNEL_OPT) 35#if defined(_KERNEL_OPT)
36#include "opt_compat_netbsd.h" 36#include "opt_compat_netbsd.h"
37#endif 37#endif
38 38
39/* TODO strip */ 39/* TODO strip */
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/sysctl.h> 42#include <sys/sysctl.h>
43#include <sys/namei.h> 43#include <sys/namei.h>
44#include <sys/proc.h> 44#include <sys/proc.h>
@@ -2696,28 +2696,28 @@ udf_grow_node(struct udf_node *udf_node, @@ -2696,28 +2696,28 @@ udf_grow_node(struct udf_node *udf_node,
2696 if (fe) { 2696 if (fe) {
2697 fe->inf_len = udf_rw64(inflen); 2697 fe->inf_len = udf_rw64(inflen);
2698 fe->l_ad = udf_rw32(l_ad); 2698 fe->l_ad = udf_rw32(l_ad);
2699 fe->tag.desc_crc_len = udf_rw16(crclen); 2699 fe->tag.desc_crc_len = udf_rw16(crclen);
2700 } else { 2700 } else {
2701 efe->inf_len = udf_rw64(inflen); 2701 efe->inf_len = udf_rw64(inflen);
2702 efe->obj_size = udf_rw64(objsize); 2702 efe->obj_size = udf_rw64(objsize);
2703 efe->l_ad = udf_rw32(l_ad); 2703 efe->l_ad = udf_rw32(l_ad);
2704 efe->tag.desc_crc_len = udf_rw16(crclen); 2704 efe->tag.desc_crc_len = udf_rw16(crclen);
2705 } 2705 }
2706 error = 0; 2706 error = 0;
2707 2707
2708 /* set new size for uvm */ 2708 /* set new size for uvm */
2709 uvm_vnp_setsize(vp, old_size); 
2710 uvm_vnp_setwritesize(vp, new_size); 2709 uvm_vnp_setwritesize(vp, new_size);
 2710 uvm_vnp_setsize(vp, new_size);
2711 2711
2712#if 0 2712#if 0
2713 /* zero append space in buffer */ 2713 /* zero append space in buffer */
2714 ubc_zerorange(&vp->v_uobj, old_size, 2714 ubc_zerorange(&vp->v_uobj, old_size,
2715 new_size - old_size, UBC_UNMAP_FLAG(vp)); 2715 new_size - old_size, UBC_UNMAP_FLAG(vp));
2716#endif 2716#endif
2717  2717
2718 udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec); 2718 udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec);
2719 2719
2720 /* unlock */ 2720 /* unlock */
2721 UDF_UNLOCK_NODE(udf_node, 0); 2721 UDF_UNLOCK_NODE(udf_node, 0);
2722 2722
2723 KASSERT(new_inflen == orig_inflen + size_diff); 2723 KASSERT(new_inflen == orig_inflen + size_diff);