udf: Reduce repeated dereferences

Replace repeated dereferences like dir->i_sb by storing superblock
pointer in a variable and using that.

Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Jan Kara 2014-12-18 22:49:12 +01:00
parent e237ec37ec
commit 3ee3039c5b
2 changed files with 25 additions and 25 deletions

View file

@ -57,6 +57,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
sector_t offset; sector_t offset;
int i, num, ret = 0; int i, num, ret = 0;
struct extent_position epos = { NULL, 0, {0, 0} }; struct extent_position epos = { NULL, 0, {0, 0} };
struct super_block *sb = dir->i_sb;
if (ctx->pos == 0) { if (ctx->pos == 0) {
if (!dir_emit_dot(file, ctx)) if (!dir_emit_dot(file, ctx))
@ -76,16 +77,16 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
if (nf_pos == 0) if (nf_pos == 0)
nf_pos = udf_ext0_offset(dir); nf_pos = udf_ext0_offset(dir);
fibh.soffset = fibh.eoffset = nf_pos & (dir->i_sb->s_blocksize - 1); fibh.soffset = fibh.eoffset = nf_pos & (sb->s_blocksize - 1);
if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
if (inode_bmap(dir, nf_pos >> dir->i_sb->s_blocksize_bits, if (inode_bmap(dir, nf_pos >> sb->s_blocksize_bits,
&epos, &eloc, &elen, &offset) &epos, &eloc, &elen, &offset)
!= (EXT_RECORDED_ALLOCATED >> 30)) { != (EXT_RECORDED_ALLOCATED >> 30)) {
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
} }
block = udf_get_lb_pblock(dir->i_sb, &eloc, offset); block = udf_get_lb_pblock(sb, &eloc, offset);
if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { if ((++offset << sb->s_blocksize_bits) < elen) {
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(struct short_ad); epos.offset -= sizeof(struct short_ad);
else if (iinfo->i_alloc_type == else if (iinfo->i_alloc_type ==
@ -95,18 +96,18 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
offset = 0; offset = 0;
} }
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { if (!(fibh.sbh = fibh.ebh = udf_tread(sb, block))) {
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { if (!(offset & ((16 >> (sb->s_blocksize_bits - 9)) - 1))) {
i = 16 >> (dir->i_sb->s_blocksize_bits - 9); i = 16 >> (sb->s_blocksize_bits - 9);
if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) if (i + offset > (elen >> sb->s_blocksize_bits))
i = (elen >> dir->i_sb->s_blocksize_bits) - offset; i = (elen >> sb->s_blocksize_bits) - offset;
for (num = 0; i > 0; i--) { for (num = 0; i > 0; i--) {
block = udf_get_lb_pblock(dir->i_sb, &eloc, offset + i); block = udf_get_lb_pblock(sb, &eloc, offset + i);
tmp = udf_tgetblk(dir->i_sb, block); tmp = udf_tgetblk(sb, block);
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
else else
@ -152,12 +153,12 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
} }
if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE))
continue; continue;
} }
if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) { if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE))
continue; continue;
} }
@ -167,13 +168,12 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
continue; continue;
} }
flen = udf_get_filename(dir->i_sb, nameptr, lfi, fname, flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
UDF_NAME_LEN);
if (!flen) if (!flen)
continue; continue;
tloc = lelb_to_cpu(cfi.icb.extLocation); tloc = lelb_to_cpu(cfi.icb.extLocation);
iblock = udf_get_lb_pblock(dir->i_sb, &tloc, 0); iblock = udf_get_lb_pblock(sb, &tloc, 0);
if (!dir_emit(ctx, fname, flen, iblock, DT_UNKNOWN)) if (!dir_emit(ctx, fname, flen, iblock, DT_UNKNOWN))
goto out; goto out;
} /* end while */ } /* end while */

View file

@ -159,18 +159,19 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
struct udf_inode_info *dinfo = UDF_I(dir); struct udf_inode_info *dinfo = UDF_I(dir);
int isdotdot = child->len == 2 && int isdotdot = child->len == 2 &&
child->name[0] == '.' && child->name[1] == '.'; child->name[0] == '.' && child->name[1] == '.';
struct super_block *sb = dir->i_sb;
size = udf_ext0_offset(dir) + dir->i_size; size = udf_ext0_offset(dir) + dir->i_size;
f_pos = udf_ext0_offset(dir); f_pos = udf_ext0_offset(dir);
fibh->sbh = fibh->ebh = NULL; fibh->sbh = fibh->ebh = NULL;
fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); fibh->soffset = fibh->eoffset = f_pos & (sb->s_blocksize - 1);
if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, &epos, if (inode_bmap(dir, f_pos >> sb->s_blocksize_bits, &epos,
&eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30)) &eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30))
goto out_err; goto out_err;
block = udf_get_lb_pblock(dir->i_sb, &eloc, offset); block = udf_get_lb_pblock(sb, &eloc, offset);
if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { if ((++offset << sb->s_blocksize_bits) < elen) {
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(struct short_ad); epos.offset -= sizeof(struct short_ad);
else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
@ -178,7 +179,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
} else } else
offset = 0; offset = 0;
fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); fibh->sbh = fibh->ebh = udf_tread(sb, block);
if (!fibh->sbh) if (!fibh->sbh)
goto out_err; goto out_err;
} }
@ -217,12 +218,12 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
} }
if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE))
continue; continue;
} }
if ((cfi->fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) { if ((cfi->fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE))
continue; continue;
} }
@ -233,8 +234,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
if (!lfi) if (!lfi)
continue; continue;
flen = udf_get_filename(dir->i_sb, nameptr, lfi, fname, flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
UDF_NAME_LEN);
if (flen && udf_match(flen, fname, child->len, child->name)) if (flen && udf_match(flen, fname, child->len, child->name))
goto out_ok; goto out_ok;
} }