Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * truncate.c |
| 3 | * |
| 4 | * PURPOSE |
| 5 | * Truncate handling routines for the OSTA-UDF(tm) filesystem. |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * COPYRIGHT |
| 8 | * This file is distributed under the terms of the GNU General Public |
| 9 | * License (GPL). Copies of the GPL can be obtained from: |
| 10 | * ftp://prep.ai.mit.edu/pub/gnu/GPL |
| 11 | * Each contributing author retains all rights to their own work. |
| 12 | * |
| 13 | * (C) 1999-2004 Ben Fennema |
| 14 | * (C) 1999 Stelias Computing Inc |
| 15 | * |
| 16 | * HISTORY |
| 17 | * |
| 18 | * 02/24/99 blf Created. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include "udfdecl.h" |
| 23 | #include <linux/fs.h> |
| 24 | #include <linux/mm.h> |
| 25 | #include <linux/udf_fs.h> |
| 26 | #include <linux/buffer_head.h> |
| 27 | |
| 28 | #include "udf_i.h" |
| 29 | #include "udf_sb.h" |
| 30 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 31 | static void extent_trunc(struct inode * inode, struct extent_position *epos, |
| 32 | kernel_lb_addr eloc, int8_t etype, uint32_t elen, uint32_t nelen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | { |
| 34 | kernel_lb_addr neloc = { 0, 0 }; |
| 35 | int last_block = (elen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; |
| 36 | int first_block = (nelen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; |
| 37 | |
| 38 | if (nelen) |
| 39 | { |
| 40 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
| 41 | { |
| 42 | udf_free_blocks(inode->i_sb, inode, eloc, 0, last_block); |
| 43 | etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30); |
| 44 | } |
| 45 | else |
| 46 | neloc = eloc; |
| 47 | nelen = (etype << 30) | nelen; |
| 48 | } |
| 49 | |
| 50 | if (elen != nelen) |
| 51 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 52 | udf_write_aext(inode, epos, neloc, nelen, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | if (last_block - first_block > 0) |
| 54 | { |
| 55 | if (etype == (EXT_RECORDED_ALLOCATED >> 30)) |
| 56 | mark_inode_dirty(inode); |
| 57 | |
| 58 | if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
| 59 | udf_free_blocks(inode->i_sb, inode, eloc, first_block, last_block - first_block); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void udf_discard_prealloc(struct inode * inode) |
| 65 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 66 | struct extent_position epos = { NULL, 0, {0, 0}}; |
| 67 | kernel_lb_addr eloc; |
| 68 | uint32_t elen, nelen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | uint64_t lbcount = 0; |
| 70 | int8_t etype = -1, netype; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | int adsize; |
| 72 | |
| 73 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB || |
| 74 | inode->i_size == UDF_I_LENEXTENTS(inode)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) |
| 78 | adsize = sizeof(short_ad); |
| 79 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) |
| 80 | adsize = sizeof(long_ad); |
| 81 | else |
| 82 | adsize = 0; |
| 83 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 84 | epos.block = UDF_I_LOCATION(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 86 | /* Find the last extent in the file */ |
| 87 | while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
| 89 | etype = netype; |
| 90 | lbcount += elen; |
| 91 | if (lbcount > inode->i_size && lbcount - inode->i_size < inode->i_sb->s_blocksize) |
| 92 | { |
| 93 | nelen = elen - (lbcount - inode->i_size); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 94 | epos.offset -= adsize; |
| 95 | extent_trunc(inode, &epos, eloc, etype, elen, nelen); |
| 96 | epos.offset += adsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | lbcount = inode->i_size; |
| 98 | } |
| 99 | } |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 100 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
| 101 | epos.offset -= adsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | lbcount -= elen; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 103 | extent_trunc(inode, &epos, eloc, etype, elen, 0); |
| 104 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 106 | UDF_I_LENALLOC(inode) = epos.offset - udf_file_entry_alloc_offset(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | mark_inode_dirty(inode); |
| 108 | } |
| 109 | else |
| 110 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 111 | struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data); |
| 112 | aed->lengthAllocDescs = cpu_to_le32(epos.offset - sizeof(struct allocExtDesc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 114 | udf_update_tag(epos.bh->b_data, epos.offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 116 | udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc)); |
| 117 | mark_buffer_dirty_inode(epos.bh, inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | UDF_I_LENEXTENTS(inode) = lbcount; |
| 121 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 122 | udf_release_data(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | void udf_truncate_extents(struct inode * inode) |
| 126 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 127 | struct extent_position epos; |
| 128 | kernel_lb_addr eloc, neloc = { 0, 0 }; |
| 129 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | int8_t etype; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 131 | sector_t first_block = inode->i_size >> inode->i_sb->s_blocksize_bits, offset; |
| 132 | loff_t byte_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | int adsize; |
| 134 | |
| 135 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) |
| 136 | adsize = sizeof(short_ad); |
| 137 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) |
| 138 | adsize = sizeof(long_ad); |
| 139 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 140 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 142 | etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 143 | byte_offset = (offset << inode->i_sb->s_blocksize_bits) + (inode->i_size & (inode->i_sb->s_blocksize-1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | if (etype != -1) |
| 145 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 146 | epos.offset -= adsize; |
| 147 | extent_trunc(inode, &epos, eloc, etype, elen, byte_offset); |
| 148 | epos.offset += adsize; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 149 | if (byte_offset) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 150 | lenalloc = epos.offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 152 | lenalloc = epos.offset - adsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 154 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | lenalloc -= udf_file_entry_alloc_offset(inode); |
| 156 | else |
| 157 | lenalloc -= sizeof(struct allocExtDesc); |
| 158 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 159 | while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | { |
| 161 | if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) |
| 162 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 163 | udf_write_aext(inode, &epos, neloc, nelen, 0); |
| 164 | if (indirect_ext_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 166 | /* We managed to free all extents in the |
| 167 | * indirect extent - free it too */ |
| 168 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | BUG(); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 170 | udf_free_blocks(inode->i_sb, inode, epos.block, 0, indirect_ext_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } |
| 172 | else |
| 173 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 174 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { |
| 176 | UDF_I_LENALLOC(inode) = lenalloc; |
| 177 | mark_inode_dirty(inode); |
| 178 | } |
| 179 | else |
| 180 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 181 | struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); |
| 183 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 184 | udf_update_tag(epos.bh->b_data, lenalloc + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | sizeof(struct allocExtDesc)); |
| 186 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 187 | udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc)); |
| 188 | mark_buffer_dirty_inode(epos.bh, inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 191 | brelse(epos.bh); |
| 192 | epos.offset = sizeof(struct allocExtDesc); |
| 193 | epos.block = eloc; |
| 194 | epos.bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, eloc, 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | if (elen) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 196 | indirect_ext_len = (elen + |
| 197 | inode->i_sb->s_blocksize - 1) >> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | inode->i_sb->s_blocksize_bits; |
| 199 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 200 | indirect_ext_len = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } |
| 202 | else |
| 203 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 204 | extent_trunc(inode, &epos, eloc, etype, elen, 0); |
| 205 | epos.offset += adsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 209 | if (indirect_ext_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 211 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | BUG(); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 213 | udf_free_blocks(inode->i_sb, inode, epos.block, 0, indirect_ext_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } |
| 215 | else |
| 216 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 217 | if (!epos.bh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | { |
| 219 | UDF_I_LENALLOC(inode) = lenalloc; |
| 220 | mark_inode_dirty(inode); |
| 221 | } |
| 222 | else |
| 223 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 224 | struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); |
| 226 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 227 | udf_update_tag(epos.bh->b_data, lenalloc + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | sizeof(struct allocExtDesc)); |
| 229 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 230 | udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc)); |
| 231 | mark_buffer_dirty_inode(epos.bh, inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | } |
| 235 | else if (inode->i_size) |
| 236 | { |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 237 | if (byte_offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 239 | /* |
| 240 | * OK, there is not extent covering inode->i_size and |
| 241 | * no extent above inode->i_size => truncate is |
| 242 | * extending the file by 'offset'. |
| 243 | */ |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 244 | if ((!epos.bh && epos.offset == udf_file_entry_alloc_offset(inode)) || |
| 245 | (epos.bh && epos.offset == sizeof(struct allocExtDesc))) { |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 246 | /* File has no extents at all! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 248 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | byte_offset; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 249 | udf_add_aext(inode, &epos, eloc, elen, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | } |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 251 | else { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 252 | epos.offset -= adsize; |
| 253 | etype = udf_next_aext(inode, &epos, &eloc, &elen, 1); |
| 254 | |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 255 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
| 256 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 257 | epos.offset -= adsize; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 258 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + byte_offset); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 259 | udf_write_aext(inode, &epos, eloc, elen, 0); |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 260 | } |
| 261 | else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
| 262 | { |
| 263 | kernel_lb_addr neloc = { 0, 0 }; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 264 | epos.offset -= adsize; |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 265 | nelen = EXT_NOT_RECORDED_NOT_ALLOCATED | |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 266 | ((elen + byte_offset + inode->i_sb->s_blocksize - 1) & |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 267 | ~(inode->i_sb->s_blocksize - 1)); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 268 | udf_write_aext(inode, &epos, neloc, nelen, 1); |
| 269 | udf_add_aext(inode, &epos, eloc, (etype << 30) | elen, 1); |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 270 | } |
| 271 | else |
| 272 | { |
| 273 | if (elen & (inode->i_sb->s_blocksize - 1)) |
| 274 | { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 275 | epos.offset -= adsize; |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 276 | elen = EXT_RECORDED_ALLOCATED | |
| 277 | ((elen + inode->i_sb->s_blocksize - 1) & |
| 278 | ~(inode->i_sb->s_blocksize - 1)); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 279 | udf_write_aext(inode, &epos, eloc, elen, 1); |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 280 | } |
| 281 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 282 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | byte_offset; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 283 | udf_add_aext(inode, &epos, eloc, elen, 1); |
Jan Kara | 00a2b0f | 2006-08-15 13:56:26 +0200 | [diff] [blame] | 284 | } |
| 285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | UDF_I_LENEXTENTS(inode) = inode->i_size; |
| 289 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame^] | 290 | udf_release_data(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |