Whamcloud - gitweb
LU-6091 llite: glimpse the inode before doing fiemap 80/13280/3
authorLi Dongyang <dongyang.li@anu.edu.au>
Thu, 8 Jan 2015 00:02:24 +0000 (11:02 +1100)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 16 Jan 2015 03:26:05 +0000 (03:26 +0000)
For a new inode, the i_size is 0 until a stat, which will yield
an empty fiemap result.
Fix the issue by glimpsing the size before doing fiemap.

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Change-Id: I072fd1f5e13c7fd127199a10b44366aed145b8e1
Reviewed-on: http://review.whamcloud.com/13280
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/file.c

index e4bed5d..9dd6906 100644 (file)
@@ -1794,6 +1794,12 @@ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
        fm_key.oa.o_oi = lsm->lsm_oi;
         fm_key.oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
        fm_key.oa.o_oi = lsm->lsm_oi;
         fm_key.oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
+       if (i_size_read(inode) == 0) {
+               rc = ll_glimpse_size(inode);
+               if (rc)
+                       GOTO(out, rc);
+       }
+
         obdo_from_inode(&fm_key.oa, inode, OBD_MD_FLSIZE);
         obdo_set_parent_fid(&fm_key.oa, &ll_i2info(inode)->lli_fid);
         /* If filesize is 0, then there would be no objects for mapping */
         obdo_from_inode(&fm_key.oa, inode, OBD_MD_FLSIZE);
         obdo_set_parent_fid(&fm_key.oa, &ll_i2info(inode)->lli_fid);
         /* If filesize is 0, then there would be no objects for mapping */