From: Jan Kara <jack@xxxxxxx> [ Upstream commit afb525f466f9fdc140b975221cb43fbb5c59314e ] Convert empty_dir() to new directory iteration code. Signed-off-by: Jan Kara <jack@xxxxxxx> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/udf/namei.c | 68 +++++++-------------------------------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -879,69 +879,19 @@ out: static int empty_dir(struct inode *dir) { - struct fileIdentDesc *fi, cfi; - struct udf_fileident_bh fibh; - loff_t f_pos; - loff_t size = udf_ext0_offset(dir) + dir->i_size; - udf_pblk_t block; - struct kernel_lb_addr eloc; - uint32_t elen; - sector_t offset; - struct extent_position epos = {}; - struct udf_inode_info *dinfo = UDF_I(dir); + struct udf_fileident_iter iter; + int ret; - f_pos = udf_ext0_offset(dir); - fibh.soffset = fibh.eoffset = f_pos & (dir->i_sb->s_blocksize - 1); - - if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) - fibh.sbh = fibh.ebh = NULL; - else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, - &epos, &eloc, &elen, &offset) == - (EXT_RECORDED_ALLOCATED >> 30)) { - block = udf_get_lb_pblock(dir->i_sb, &eloc, offset); - if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { - if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) - epos.offset -= sizeof(struct short_ad); - else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) - epos.offset -= sizeof(struct long_ad); - } else - offset = 0; - - fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block); - if (!fibh.sbh) { - brelse(epos.bh); - return 0; - } - } else { - brelse(epos.bh); - return 0; - } - - while (f_pos < size) { - fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, - &elen, &offset); - if (!fi) { - if (fibh.sbh != fibh.ebh) - brelse(fibh.ebh); - brelse(fibh.sbh); - brelse(epos.bh); - return 0; - } - - if (cfi.lengthFileIdent && - (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { - if (fibh.sbh != fibh.ebh) - brelse(fibh.ebh); - brelse(fibh.sbh); - brelse(epos.bh); + for (ret = udf_fiiter_init(&iter, dir, 0); + !ret && iter.pos < dir->i_size; + ret = udf_fiiter_advance(&iter)) { + if (iter.fi.lengthFileIdent && + !(iter.fi.fileCharacteristics & FID_FILE_CHAR_DELETED)) { + udf_fiiter_release(&iter); return 0; } } - - if (fibh.sbh != fibh.ebh) - brelse(fibh.ebh); - brelse(fibh.sbh); - brelse(epos.bh); + udf_fiiter_release(&iter); return 1; } Patches currently in stable-queue which might be from cascardo@xxxxxxxxxx are queue-6.1/udf-handle-error-when-expanding-directory.patch queue-6.1/udf-convert-empty_dir-to-new-directory-iteration-code.patch queue-6.1/udf-convert-udf_expand_dir_adinicb-to-new-directory-iteration.patch queue-6.1/udf-convert-udf_unlink-to-new-directory-iteration-code.patch queue-6.1/udf-convert-udf_add_nondir-to-new-directory-iteration.patch queue-6.1/udf-convert-udf_link-to-new-directory-iteration-code.patch queue-6.1/udf-remove-old-directory-iteration-code.patch queue-6.1/udf-don-t-return-bh-from-udf_expand_dir_adinicb.patch queue-6.1/udf-new-directory-iteration-code.patch queue-6.1/udf-convert-udf_rmdir-to-new-directory-iteration-code.patch queue-6.1/udf-move-udf_expand_dir_adinicb-to-its-callsite.patch queue-6.1/udf-convert-udf_readdir-to-new-directory-iteration.patch queue-6.1/udf-convert-udf_mkdir-to-new-directory-iteration-code.patch queue-6.1/udf-provide-function-to-mark-entry-as-deleted-using-new-directory-iteration-code.patch queue-6.1/udf-convert-udf_lookup-to-use-new-directory-iteration-code.patch queue-6.1/udf-implement-adding-of-dir-entries-using-new-iteration-code.patch queue-6.1/udf-convert-udf_rename-to-new-directory-iteration-code.patch queue-6.1/udf-convert-udf_get_parent-to-new-directory-iteration-code.patch queue-6.1/udf-implement-searching-for-directory-entry-using-new-iteration-code.patch