aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/truncate.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index cde328f16775..65e19b4f9424 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -179,6 +179,24 @@ void udf_discard_prealloc(struct inode *inode)
179 brelse(epos.bh); 179 brelse(epos.bh);
180} 180}
181 181
182static void udf_update_alloc_ext_desc(struct inode *inode,
183 struct extent_position *epos,
184 u32 lenalloc)
185{
186 struct super_block *sb = inode->i_sb;
187 struct udf_sb_info *sbi = UDF_SB(sb);
188
189 struct allocExtDesc *aed = (struct allocExtDesc *) (epos->bh->b_data);
190 int len = sizeof(struct allocExtDesc);
191
192 aed->lengthAllocDescs = cpu_to_le32(lenalloc);
193 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || sbi->s_udfrev >= 0x0201)
194 len += lenalloc;
195
196 udf_update_tag(epos->bh->b_data, len);
197 mark_buffer_dirty_inode(epos->bh, inode);
198}
199
182void udf_truncate_extents(struct inode *inode) 200void udf_truncate_extents(struct inode *inode)
183{ 201{
184 struct extent_position epos; 202 struct extent_position epos;
@@ -186,7 +204,6 @@ void udf_truncate_extents(struct inode *inode)
186 uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; 204 uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
187 int8_t etype; 205 int8_t etype;
188 struct super_block *sb = inode->i_sb; 206 struct super_block *sb = inode->i_sb;
189 struct udf_sb_info *sbi = UDF_SB(sb);
190 sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; 207 sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
191 loff_t byte_offset; 208 loff_t byte_offset;
192 int adsize; 209 int adsize;
@@ -229,24 +246,9 @@ void udf_truncate_extents(struct inode *inode)
229 } else if (!epos.bh) { 246 } else if (!epos.bh) {
230 iinfo->i_lenAlloc = lenalloc; 247 iinfo->i_lenAlloc = lenalloc;
231 mark_inode_dirty(inode); 248 mark_inode_dirty(inode);
232 } else { 249 } else
233 struct allocExtDesc *aed = 250 udf_update_alloc_ext_desc(inode,
234 (struct allocExtDesc *) 251 &epos, lenalloc);
235 (epos.bh->b_data);
236 int len = sizeof(struct allocExtDesc);
237
238 aed->lengthAllocDescs =
239 cpu_to_le32(lenalloc);
240 if (!UDF_QUERY_FLAG(sb,
241 UDF_FLAG_STRICT) ||
242 sbi->s_udfrev >= 0x0201)
243 len += lenalloc;
244
245 udf_update_tag(epos.bh->b_data,
246 len);
247 mark_buffer_dirty_inode(
248 epos.bh, inode);
249 }
250 brelse(epos.bh); 252 brelse(epos.bh);
251 epos.offset = sizeof(struct allocExtDesc); 253 epos.offset = sizeof(struct allocExtDesc);
252 epos.block = eloc; 254 epos.block = eloc;
@@ -272,20 +274,8 @@ void udf_truncate_extents(struct inode *inode)
272 } else if (!epos.bh) { 274 } else if (!epos.bh) {
273 iinfo->i_lenAlloc = lenalloc; 275 iinfo->i_lenAlloc = lenalloc;
274 mark_inode_dirty(inode); 276 mark_inode_dirty(inode);
275 } else { 277 } else
276 struct allocExtDesc *aed = 278 udf_update_alloc_ext_desc(inode, &epos, lenalloc);
277 (struct allocExtDesc *)(epos.bh->b_data);
278 aed->lengthAllocDescs = cpu_to_le32(lenalloc);
279 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
280 sbi->s_udfrev >= 0x0201)
281 udf_update_tag(epos.bh->b_data,
282 lenalloc +
283 sizeof(struct allocExtDesc));
284 else
285 udf_update_tag(epos.bh->b_data,
286 sizeof(struct allocExtDesc));
287 mark_buffer_dirty_inode(epos.bh, inode);
288 }
289 } else if (inode->i_size) { 279 } else if (inode->i_size) {
290 if (byte_offset) { 280 if (byte_offset) {
291 kernel_long_ad extent; 281 kernel_long_ad extent;