Commit 05343c4f authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

udf: fix adding entry to a directory

When adding directory entry to a directory, we have to properly increase
length of the last extent.  Handle this similarly as extending regular files -
make extents always have size multiple of block size (it will be truncated
down to proper size in udf_clear_inode()).
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent af793295
...@@ -289,7 +289,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, ...@@ -289,7 +289,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
eloc.logicalBlockNum = *block; eloc.logicalBlockNum = *block;
eloc.partitionReferenceNum = eloc.partitionReferenceNum =
iinfo->i_location.partitionReferenceNum; iinfo->i_location.partitionReferenceNum;
elen = inode->i_size; elen = inode->i_sb->s_blocksize;
iinfo->i_lenExtents = elen; iinfo->i_lenExtents = elen;
epos.bh = NULL; epos.bh = NULL;
epos.block = iinfo->i_location; epos.block = iinfo->i_location;
......
...@@ -395,7 +395,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -395,7 +395,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
} }
block = dinfo->i_location.logicalBlockNum; block = dinfo->i_location.logicalBlockNum;
} else { } else {
block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0); block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0);
fibh->sbh = fibh->ebh = NULL; fibh->sbh = fibh->ebh = NULL;
...@@ -474,6 +473,14 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -474,6 +473,14 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
} }
add: add:
if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(short_ad);
else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
epos.offset -= sizeof(long_ad);
udf_write_aext(dir, &epos, eloc, elen, 1);
}
f_pos += nfidlen; f_pos += nfidlen;
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
...@@ -491,15 +498,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -491,15 +498,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
if (!fibh->sbh) if (!fibh->sbh)
return NULL; return NULL;
epos.block = dinfo->i_location; epos.block = dinfo->i_location;
eloc.logicalBlockNum = block;
eloc.partitionReferenceNum =
dinfo->i_location.partitionReferenceNum;
elen = dir->i_sb->s_blocksize;
epos.offset = udf_file_entry_alloc_offset(dir); epos.offset = udf_file_entry_alloc_offset(dir);
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) /* Load extent udf_expand_dir_adinicb() has created */
epos.offset += sizeof(short_ad); udf_current_aext(dir, &epos, &eloc, &elen, 1);
else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
epos.offset += sizeof(long_ad);
} }
if (sb->s_blocksize - fibh->eoffset >= nfidlen) { if (sb->s_blocksize - fibh->eoffset >= nfidlen) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment