[ext4:dev 41/46] fs/ext4/fast_commit.c:964 ext4_fc_commit_dentry_updates() error: double locked 'sbi->s_fc_lock' (orig line 955)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head:   1322181170bb01bce3c228b82ae3d5c6b793164f
commit: aa75f4d3daaeb1389b9cce9d6b84401eaf228d4e [41/46] ext4: main fast-commit commit path
config: x86_64-randconfig-m001-20201022 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
fs/ext4/fast_commit.c:964 ext4_fc_commit_dentry_updates() error: double locked 'sbi->s_fc_lock' (orig line 955)

vim +964 fs/ext4/fast_commit.c

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  890  static int ext4_fc_commit_dentry_updates(journal_t *journal, u32 *crc)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  891  {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  892  	struct super_block *sb = (struct super_block *)(journal->j_private);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  893  	struct ext4_sb_info *sbi = EXT4_SB(sb);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  894  	struct ext4_fc_dentry_update *fc_dentry;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  895  	struct inode *inode;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  896  	struct list_head *pos, *n, *fcd_pos, *fcd_n;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  897  	struct ext4_inode_info *ei;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  898  	int ret;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  899  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  900  	if (list_empty(&sbi->s_fc_dentry_q[FC_Q_MAIN]))
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  901  		return 0;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  902  	list_for_each_safe(fcd_pos, fcd_n, &sbi->s_fc_dentry_q[FC_Q_MAIN]) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  903  		fc_dentry = list_entry(fcd_pos, struct ext4_fc_dentry_update,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  904  					fcd_list);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  905  		if (fc_dentry->fcd_op != EXT4_FC_TAG_CREAT) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  906  			spin_unlock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  907  			if (!ext4_fc_add_dentry_tlv(
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  908  				sb, fc_dentry->fcd_op,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  909  				fc_dentry->fcd_parent, fc_dentry->fcd_ino,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  910  				fc_dentry->fcd_name.len,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  911  				fc_dentry->fcd_name.name, crc)) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  912  				ret = -ENOSPC;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  913  				goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  914  			}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  915  			spin_lock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  916  			continue;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  917  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  918  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  919  		inode = NULL;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  920  		list_for_each_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN]) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  921  			ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  922  			if (ei->vfs_inode.i_ino == fc_dentry->fcd_ino) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  923  				inode = &ei->vfs_inode;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  924  				break;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  925  			}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  926  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  927  		/*
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  928  		 * If we don't find inode in our list, then it was deleted,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  929  		 * in which case, we don't need to record it's create tag.
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  930  		 */
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  931  		if (!inode)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  932  			continue;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  933  		spin_unlock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  934  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  935  		/*
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  936  		 * We first write the inode and then the create dirent. This
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  937  		 * allows the recovery code to create an unnamed inode first
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  938  		 * and then link it to a directory entry. This allows us
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  939  		 * to use namei.c routines almost as is and simplifies
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  940  		 * the recovery code.
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  941  		 */
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  942  		ret = ext4_fc_write_inode(inode, crc);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  943  		if (ret)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  944  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  945  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  946  		ret = ext4_fc_write_inode_data(inode, crc);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  947  		if (ret)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  948  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  949  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  950  		if (!ext4_fc_add_dentry_tlv(
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  951  			sb, fc_dentry->fcd_op,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  952  			fc_dentry->fcd_parent, fc_dentry->fcd_ino,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  953  			fc_dentry->fcd_name.len,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  954  			fc_dentry->fcd_name.name, crc)) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15 @955  			spin_lock(&sbi->s_fc_lock);
                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Lock.

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  956  			ret = -ENOSPC;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  957  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  958  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  959  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  960  		spin_lock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  961  	}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  962  	return 0;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  963  lock_and_exit:
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15 @964  	spin_lock(&sbi->s_fc_lock);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Second lock.

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  965  	return ret;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  966  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux