summaryrefslogtreecommitdiff
path: root/fs/udf/truncate.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/truncate.c')
-rw-r--r--fs/udf/truncate.c113
1 files changed, 39 insertions, 74 deletions
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index b2002da0a5c..7fc3912885a 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
kernel_lb_addr eloc, int8_t etype, uint32_t elen,
uint32_t nelen)
{
- kernel_lb_addr neloc = { 0, 0 };
- int last_block =
- (elen + inode->i_sb->s_blocksize -
- 1) >> inode->i_sb->s_blocksize_bits;
- int first_block =
- (nelen + inode->i_sb->s_blocksize -
- 1) >> inode->i_sb->s_blocksize_bits;
+ kernel_lb_addr neloc = {};
+ int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
+ inode->i_sb->s_blocksize_bits;
+ int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
+ inode->i_sb->s_blocksize_bits;
if (nelen) {
if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
@@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
*/
void udf_truncate_tail_extent(struct inode *inode)
{
- struct extent_position epos = { NULL, 0, {0, 0} };
+ struct extent_position epos = {};
kernel_lb_addr eloc;
uint32_t elen, nelen;
uint64_t lbcount = 0;
@@ -156,16 +154,16 @@ void udf_discard_prealloc(struct inode *inode)
extent_trunc(inode, &epos, eloc, etype, elen, 0);
if (!epos.bh) {
UDF_I_LENALLOC(inode) =
- epos.offset - udf_file_entry_alloc_offset(inode);
+ epos.offset - udf_file_entry_alloc_offset(inode);
mark_inode_dirty(inode);
} else {
struct allocExtDesc *aed =
- (struct allocExtDesc *)(epos.bh->b_data);
+ (struct allocExtDesc *)(epos.bh->b_data);
aed->lengthAllocDescs =
- cpu_to_le32(epos.offset -
- sizeof(struct allocExtDesc));
- if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)
- || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+ cpu_to_le32(epos.offset -
+ sizeof(struct allocExtDesc));
+ if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
+ UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
udf_update_tag(epos.bh->b_data, epos.offset);
else
udf_update_tag(epos.bh->b_data,
@@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode)
void udf_truncate_extents(struct inode *inode)
{
struct extent_position epos;
- kernel_lb_addr eloc, neloc = { 0, 0 };
+ kernel_lb_addr eloc, neloc = {};
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
int8_t etype;
struct super_block *sb = inode->i_sb;
@@ -198,9 +196,8 @@ void udf_truncate_extents(struct inode *inode)
BUG();
etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
- byte_offset =
- (offset << sb->s_blocksize_bits) +
- (inode->i_size & (sb->s_blocksize - 1));
+ byte_offset = (offset << sb->s_blocksize_bits) +
+ (inode->i_size & (sb->s_blocksize - 1));
if (etype != -1) {
epos.offset -= adsize;
extent_trunc(inode, &epos, eloc, etype, elen, byte_offset);
@@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode)
else
lenalloc -= sizeof(struct allocExtDesc);
- while ((etype =
- udf_current_aext(inode, &epos, &eloc, &elen,
- 0)) != -1) {
+ while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) {
if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
udf_write_aext(inode, &epos, neloc, nelen, 0);
if (indirect_ext_len) {
@@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode)
0, indirect_ext_len);
} else {
if (!epos.bh) {
- UDF_I_LENALLOC(inode) =
- lenalloc;
+ UDF_I_LENALLOC(inode) = lenalloc;
mark_inode_dirty(inode);
} else {
struct allocExtDesc *aed =
- (struct allocExtDesc
- *)(epos.bh->b_data);
+ (struct allocExtDesc *)(epos.bh->b_data);
aed->lengthAllocDescs =
cpu_to_le32(lenalloc);
- if (!UDF_QUERY_FLAG
- (sb, UDF_FLAG_STRICT)
- || UDF_SB_UDFREV(sb) >=
- 0x0201)
- udf_update_tag(epos.bh->
- b_data,
- lenalloc
- +
- sizeof
- (struct
- allocExtDesc));
+ if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
+ UDF_SB_UDFREV(sb) >= 0x0201)
+ udf_update_tag(epos.bh->b_data,
+ lenalloc +
+ sizeof(struct allocExtDesc));
else
- udf_update_tag(epos.bh->
- b_data,
- sizeof
- (struct
- allocExtDesc));
- mark_buffer_dirty_inode(epos.bh,
- inode);
+ udf_update_tag(epos.bh->b_data,
+ sizeof(struct allocExtDesc));
+ mark_buffer_dirty_inode(epos.bh, inode);
}
}
brelse(epos.bh);
epos.offset = sizeof(struct allocExtDesc);
epos.block = eloc;
- epos.bh =
- udf_tread(sb,
- udf_get_lb_pblock(sb, eloc, 0));
+ epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0));
if (elen)
- indirect_ext_len = (elen +
- sb->s_blocksize -
- 1) >> sb->
- s_blocksize_bits;
+ indirect_ext_len = (elen + sb->s_blocksize -1) >>
+ sb->s_blocksize_bits;
else
indirect_ext_len = 1;
} else {
- extent_trunc(inode, &epos, eloc, etype, elen,
- 0);
+ extent_trunc(inode, &epos, eloc, etype, elen, 0);
epos.offset += adsize;
}
}
@@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode)
struct allocExtDesc *aed =
(struct allocExtDesc *)(epos.bh->b_data);
aed->lengthAllocDescs = cpu_to_le32(lenalloc);
- if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)
- || UDF_SB_UDFREV(sb) >= 0x0201)
+ if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
+ UDF_SB_UDFREV(sb) >= 0x0201)
udf_update_tag(epos.bh->b_data,
- lenalloc +
- sizeof(struct
- allocExtDesc));
+ lenalloc + sizeof(struct allocExtDesc));
else
udf_update_tag(epos.bh->b_data,
- sizeof(struct
- allocExtDesc));
+ sizeof(struct allocExtDesc));
mark_buffer_dirty_inode(epos.bh, inode);
}
}
@@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode)
* no extent above inode->i_size => truncate is
* extending the file by 'offset' blocks.
*/
- if ((!epos.bh
- && epos.offset ==
- udf_file_entry_alloc_offset(inode)) || (epos.bh
- && epos.
- offset ==
- sizeof
- (struct
- allocExtDesc)))
- {
+ if ((!epos.bh &&
+ epos.offset == udf_file_entry_alloc_offset(inode)) ||
+ (epos.bh && epos.offset == sizeof(struct allocExtDesc))) {
/* File has no extents at all or has empty last
* indirect extent! Create a fake extent... */
extent.extLocation.logicalBlockNum = 0;
extent.extLocation.partitionReferenceNum = 0;
- extent.extLength =
- EXT_NOT_RECORDED_NOT_ALLOCATED;
+ extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
} else {
epos.offset -= adsize;
etype = udf_next_aext(inode, &epos,
@@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode)
extent.extLength |= etype << 30;
}
udf_extend_file(inode, &epos, &extent,
- offset +
- ((inode->
- i_size & (sb->s_blocksize - 1)) !=
- 0));
+ offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0));
}
}
UDF_I_LENEXTENTS(inode) = inode->i_size;