mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
udf: Move udf_expand_dir_adinicb() to its callsite
[ Upstream commit a27b2923de ]
There is just one caller of udf_expand_dir_adinicb(). Move the function
to its caller into namei.c as it is more about directory handling than
anything else anyway.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5f503315e1
commit
0621e30fd8
@@ -325,88 +325,6 @@ int udf_expand_file_adinicb(struct inode *inode)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
|
|
||||||
udf_pblk_t *block, int *err)
|
|
||||||
{
|
|
||||||
udf_pblk_t newblock;
|
|
||||||
struct buffer_head *dbh = NULL;
|
|
||||||
struct kernel_lb_addr eloc;
|
|
||||||
struct extent_position epos;
|
|
||||||
uint8_t alloctype;
|
|
||||||
struct udf_inode_info *iinfo = UDF_I(inode);
|
|
||||||
struct udf_fileident_iter iter;
|
|
||||||
uint8_t *impuse;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
|
|
||||||
alloctype = ICBTAG_FLAG_AD_SHORT;
|
|
||||||
else
|
|
||||||
alloctype = ICBTAG_FLAG_AD_LONG;
|
|
||||||
|
|
||||||
if (!inode->i_size) {
|
|
||||||
iinfo->i_alloc_type = alloctype;
|
|
||||||
mark_inode_dirty(inode);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* alloc block, and copy data to it */
|
|
||||||
*block = udf_new_block(inode->i_sb, inode,
|
|
||||||
iinfo->i_location.partitionReferenceNum,
|
|
||||||
iinfo->i_location.logicalBlockNum, err);
|
|
||||||
if (!(*block))
|
|
||||||
return NULL;
|
|
||||||
newblock = udf_get_pblock(inode->i_sb, *block,
|
|
||||||
iinfo->i_location.partitionReferenceNum,
|
|
||||||
0);
|
|
||||||
if (!newblock)
|
|
||||||
return NULL;
|
|
||||||
dbh = udf_tgetblk(inode->i_sb, newblock);
|
|
||||||
if (!dbh)
|
|
||||||
return NULL;
|
|
||||||
lock_buffer(dbh);
|
|
||||||
memcpy(dbh->b_data, iinfo->i_data, inode->i_size);
|
|
||||||
memset(dbh->b_data + inode->i_size, 0,
|
|
||||||
inode->i_sb->s_blocksize - inode->i_size);
|
|
||||||
set_buffer_uptodate(dbh);
|
|
||||||
unlock_buffer(dbh);
|
|
||||||
|
|
||||||
/* Drop inline data, add block instead */
|
|
||||||
iinfo->i_alloc_type = alloctype;
|
|
||||||
memset(iinfo->i_data + iinfo->i_lenEAttr, 0, iinfo->i_lenAlloc);
|
|
||||||
iinfo->i_lenAlloc = 0;
|
|
||||||
eloc.logicalBlockNum = *block;
|
|
||||||
eloc.partitionReferenceNum =
|
|
||||||
iinfo->i_location.partitionReferenceNum;
|
|
||||||
iinfo->i_lenExtents = inode->i_size;
|
|
||||||
epos.bh = NULL;
|
|
||||||
epos.block = iinfo->i_location;
|
|
||||||
epos.offset = udf_file_entry_alloc_offset(inode);
|
|
||||||
udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
|
|
||||||
brelse(epos.bh);
|
|
||||||
mark_inode_dirty(inode);
|
|
||||||
|
|
||||||
/* Now fixup tags in moved directory entries */
|
|
||||||
for (ret = udf_fiiter_init(&iter, inode, 0);
|
|
||||||
!ret && iter.pos < inode->i_size;
|
|
||||||
ret = udf_fiiter_advance(&iter)) {
|
|
||||||
iter.fi.descTag.tagLocation = cpu_to_le32(*block);
|
|
||||||
if (iter.fi.lengthOfImpUse != cpu_to_le16(0))
|
|
||||||
impuse = dbh->b_data + iter.pos +
|
|
||||||
sizeof(struct fileIdentDesc);
|
|
||||||
else
|
|
||||||
impuse = NULL;
|
|
||||||
udf_fiiter_write_fi(&iter, impuse);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* We don't expect the iteration to fail as the directory has been
|
|
||||||
* already verified to be correct
|
|
||||||
*/
|
|
||||||
WARN_ON_ONCE(ret);
|
|
||||||
udf_fiiter_release(&iter);
|
|
||||||
|
|
||||||
return dbh;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int udf_get_block(struct inode *inode, sector_t block,
|
static int udf_get_block(struct inode *inode, sector_t block,
|
||||||
struct buffer_head *bh_result, int create)
|
struct buffer_head *bh_result, int create)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -326,6 +326,88 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
|
|||||||
return d_splice_alias(inode, dentry);
|
return d_splice_alias(inode, dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
|
||||||
|
udf_pblk_t *block, int *err)
|
||||||
|
{
|
||||||
|
udf_pblk_t newblock;
|
||||||
|
struct buffer_head *dbh = NULL;
|
||||||
|
struct kernel_lb_addr eloc;
|
||||||
|
struct extent_position epos;
|
||||||
|
uint8_t alloctype;
|
||||||
|
struct udf_inode_info *iinfo = UDF_I(inode);
|
||||||
|
struct udf_fileident_iter iter;
|
||||||
|
uint8_t *impuse;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
|
||||||
|
alloctype = ICBTAG_FLAG_AD_SHORT;
|
||||||
|
else
|
||||||
|
alloctype = ICBTAG_FLAG_AD_LONG;
|
||||||
|
|
||||||
|
if (!inode->i_size) {
|
||||||
|
iinfo->i_alloc_type = alloctype;
|
||||||
|
mark_inode_dirty(inode);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* alloc block, and copy data to it */
|
||||||
|
*block = udf_new_block(inode->i_sb, inode,
|
||||||
|
iinfo->i_location.partitionReferenceNum,
|
||||||
|
iinfo->i_location.logicalBlockNum, err);
|
||||||
|
if (!(*block))
|
||||||
|
return NULL;
|
||||||
|
newblock = udf_get_pblock(inode->i_sb, *block,
|
||||||
|
iinfo->i_location.partitionReferenceNum,
|
||||||
|
0);
|
||||||
|
if (!newblock)
|
||||||
|
return NULL;
|
||||||
|
dbh = udf_tgetblk(inode->i_sb, newblock);
|
||||||
|
if (!dbh)
|
||||||
|
return NULL;
|
||||||
|
lock_buffer(dbh);
|
||||||
|
memcpy(dbh->b_data, iinfo->i_data, inode->i_size);
|
||||||
|
memset(dbh->b_data + inode->i_size, 0,
|
||||||
|
inode->i_sb->s_blocksize - inode->i_size);
|
||||||
|
set_buffer_uptodate(dbh);
|
||||||
|
unlock_buffer(dbh);
|
||||||
|
|
||||||
|
/* Drop inline data, add block instead */
|
||||||
|
iinfo->i_alloc_type = alloctype;
|
||||||
|
memset(iinfo->i_data + iinfo->i_lenEAttr, 0, iinfo->i_lenAlloc);
|
||||||
|
iinfo->i_lenAlloc = 0;
|
||||||
|
eloc.logicalBlockNum = *block;
|
||||||
|
eloc.partitionReferenceNum =
|
||||||
|
iinfo->i_location.partitionReferenceNum;
|
||||||
|
iinfo->i_lenExtents = inode->i_size;
|
||||||
|
epos.bh = NULL;
|
||||||
|
epos.block = iinfo->i_location;
|
||||||
|
epos.offset = udf_file_entry_alloc_offset(inode);
|
||||||
|
udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
|
||||||
|
brelse(epos.bh);
|
||||||
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
|
/* Now fixup tags in moved directory entries */
|
||||||
|
for (ret = udf_fiiter_init(&iter, inode, 0);
|
||||||
|
!ret && iter.pos < inode->i_size;
|
||||||
|
ret = udf_fiiter_advance(&iter)) {
|
||||||
|
iter.fi.descTag.tagLocation = cpu_to_le32(*block);
|
||||||
|
if (iter.fi.lengthOfImpUse != cpu_to_le16(0))
|
||||||
|
impuse = dbh->b_data + iter.pos +
|
||||||
|
sizeof(struct fileIdentDesc);
|
||||||
|
else
|
||||||
|
impuse = NULL;
|
||||||
|
udf_fiiter_write_fi(&iter, impuse);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* We don't expect the iteration to fail as the directory has been
|
||||||
|
* already verified to be correct
|
||||||
|
*/
|
||||||
|
WARN_ON_ONCE(ret);
|
||||||
|
udf_fiiter_release(&iter);
|
||||||
|
|
||||||
|
return dbh;
|
||||||
|
}
|
||||||
|
|
||||||
static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
||||||
struct dentry *dentry,
|
struct dentry *dentry,
|
||||||
struct udf_fileident_bh *fibh,
|
struct udf_fileident_bh *fibh,
|
||||||
|
|||||||
@@ -169,8 +169,6 @@ static inline struct inode *udf_iget(struct super_block *sb,
|
|||||||
return __udf_iget(sb, ino, false);
|
return __udf_iget(sb, ino, false);
|
||||||
}
|
}
|
||||||
extern int udf_expand_file_adinicb(struct inode *);
|
extern int udf_expand_file_adinicb(struct inode *);
|
||||||
extern struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
|
|
||||||
udf_pblk_t *block, int *err);
|
|
||||||
extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,
|
extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,
|
||||||
int create, int *err);
|
int create, int *err);
|
||||||
extern int udf_setsize(struct inode *, loff_t);
|
extern int udf_setsize(struct inode *, loff_t);
|
||||||
|
|||||||
Reference in New Issue
Block a user