diff options
author | marcin.slusarz@gmail.com <marcin.slusarz@gmail.com> | 2008-01-30 16:03:56 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2008-04-17 08:22:28 -0400 |
commit | 456390de465e5a19c84bca5d78e2550971ab5a96 (patch) | |
tree | 0d15823a458067f3c36c5b8420c35180f90fabaa /fs/udf/truncate.c | |
parent | 9de90b76eb96e7cdeac8b8dbe7d3db948b070f4d (diff) |
udf: truncate: create function for updating of Allocation Ext Descriptor
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/truncate.c')
-rw-r--r-- | fs/udf/truncate.c | 56 |
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 | ||
182 | static 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 | |||
182 | void udf_truncate_extents(struct inode *inode) | 200 | void 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; |