forked from Minki/linux
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>
This commit is contained in:
parent
9de90b76eb
commit
456390de46
@ -179,6 +179,24 @@ void udf_discard_prealloc(struct inode *inode)
|
|||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void udf_update_alloc_ext_desc(struct inode *inode,
|
||||||
|
struct extent_position *epos,
|
||||||
|
u32 lenalloc)
|
||||||
|
{
|
||||||
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct udf_sb_info *sbi = UDF_SB(sb);
|
||||||
|
|
||||||
|
struct allocExtDesc *aed = (struct allocExtDesc *) (epos->bh->b_data);
|
||||||
|
int len = sizeof(struct allocExtDesc);
|
||||||
|
|
||||||
|
aed->lengthAllocDescs = cpu_to_le32(lenalloc);
|
||||||
|
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || sbi->s_udfrev >= 0x0201)
|
||||||
|
len += lenalloc;
|
||||||
|
|
||||||
|
udf_update_tag(epos->bh->b_data, len);
|
||||||
|
mark_buffer_dirty_inode(epos->bh, inode);
|
||||||
|
}
|
||||||
|
|
||||||
void udf_truncate_extents(struct inode *inode)
|
void udf_truncate_extents(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct extent_position epos;
|
struct extent_position epos;
|
||||||
@ -186,7 +204,6 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
|
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
|
||||||
int8_t etype;
|
int8_t etype;
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
struct udf_sb_info *sbi = UDF_SB(sb);
|
|
||||||
sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
|
sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
|
||||||
loff_t byte_offset;
|
loff_t byte_offset;
|
||||||
int adsize;
|
int adsize;
|
||||||
@ -229,24 +246,9 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
} else if (!epos.bh) {
|
} else if (!epos.bh) {
|
||||||
iinfo->i_lenAlloc = lenalloc;
|
iinfo->i_lenAlloc = lenalloc;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
} else {
|
} else
|
||||||
struct allocExtDesc *aed =
|
udf_update_alloc_ext_desc(inode,
|
||||||
(struct allocExtDesc *)
|
&epos, lenalloc);
|
||||||
(epos.bh->b_data);
|
|
||||||
int len = sizeof(struct allocExtDesc);
|
|
||||||
|
|
||||||
aed->lengthAllocDescs =
|
|
||||||
cpu_to_le32(lenalloc);
|
|
||||||
if (!UDF_QUERY_FLAG(sb,
|
|
||||||
UDF_FLAG_STRICT) ||
|
|
||||||
sbi->s_udfrev >= 0x0201)
|
|
||||||
len += lenalloc;
|
|
||||||
|
|
||||||
udf_update_tag(epos.bh->b_data,
|
|
||||||
len);
|
|
||||||
mark_buffer_dirty_inode(
|
|
||||||
epos.bh, inode);
|
|
||||||
}
|
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
epos.offset = sizeof(struct allocExtDesc);
|
epos.offset = sizeof(struct allocExtDesc);
|
||||||
epos.block = eloc;
|
epos.block = eloc;
|
||||||
@ -272,20 +274,8 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
} else if (!epos.bh) {
|
} else if (!epos.bh) {
|
||||||
iinfo->i_lenAlloc = lenalloc;
|
iinfo->i_lenAlloc = lenalloc;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
} else {
|
} else
|
||||||
struct allocExtDesc *aed =
|
udf_update_alloc_ext_desc(inode, &epos, lenalloc);
|
||||||
(struct allocExtDesc *)(epos.bh->b_data);
|
|
||||||
aed->lengthAllocDescs = cpu_to_le32(lenalloc);
|
|
||||||
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
|
|
||||||
sbi->s_udfrev >= 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);
|
|
||||||
}
|
|
||||||
} else if (inode->i_size) {
|
} else if (inode->i_size) {
|
||||||
if (byte_offset) {
|
if (byte_offset) {
|
||||||
kernel_long_ad extent;
|
kernel_long_ad extent;
|
||||||
|
Loading…
Reference in New Issue
Block a user