@@ -706,6 +706,8 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno,
706706 * it not only handles the fiemap for inlined files, but also deals
707707 * with the fast symlink, cause they have no difference for extent
708708 * mapping per se.
709+ *
710+ * Must be called with ip_alloc_sem semaphore held.
709711 */
710712static int ocfs2_fiemap_inline (struct inode * inode , struct buffer_head * di_bh ,
711713 struct fiemap_extent_info * fieinfo ,
@@ -717,6 +719,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
717719 u64 phys ;
718720 u32 flags = FIEMAP_EXTENT_DATA_INLINE |FIEMAP_EXTENT_LAST ;
719721 struct ocfs2_inode_info * oi = OCFS2_I (inode );
722+ lockdep_assert_held_read (& oi -> ip_alloc_sem );
720723
721724 di = (struct ocfs2_dinode * )di_bh -> b_data ;
722725 if (ocfs2_inode_is_fast_symlink (inode ))
@@ -732,8 +735,11 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
732735 phys += offsetof(struct ocfs2_dinode ,
733736 id2 .i_data .id_data );
734737
738+ /* Release the ip_alloc_sem to prevent deadlock on page fault */
739+ up_read (& OCFS2_I (inode )-> ip_alloc_sem );
735740 ret = fiemap_fill_next_extent (fieinfo , 0 , phys , id_count ,
736741 flags );
742+ down_read (& OCFS2_I (inode )-> ip_alloc_sem );
737743 if (ret < 0 )
738744 return ret ;
739745 }
@@ -802,9 +808,11 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
802808 len_bytes = (u64 )le16_to_cpu (rec .e_leaf_clusters ) << osb -> s_clustersize_bits ;
803809 phys_bytes = le64_to_cpu (rec .e_blkno ) << osb -> sb -> s_blocksize_bits ;
804810 virt_bytes = (u64 )le32_to_cpu (rec .e_cpos ) << osb -> s_clustersize_bits ;
805-
811+ /* Release the ip_alloc_sem to prevent deadlock on page fault */
812+ up_read (& OCFS2_I (inode )-> ip_alloc_sem );
806813 ret = fiemap_fill_next_extent (fieinfo , virt_bytes , phys_bytes ,
807814 len_bytes , fe_flags );
815+ down_read (& OCFS2_I (inode )-> ip_alloc_sem );
808816 if (ret )
809817 break ;
810818
0 commit comments