Whamcloud - gitweb
LU-5933 fiemap: set FIEMAP_EXTENT_LAST correctly 81/12781/2
authorBobi Jam <bobijam.xu@intel.com>
Wed, 19 Nov 2014 05:47:58 +0000 (13:47 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 5 Dec 2014 13:40:59 +0000 (13:40 +0000)
When we've collected enough extents as user requested, we'd check one
further to decide whether we've reached the last extent of the file.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: Ic4c4710adf98552626d87d54c893ba9fa18ef7b8
Reviewed-on: http://review.whamcloud.com/12781
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lov/lov_obd.c

index 2ef90db..1d9fe20 100644 (file)
@@ -1678,6 +1678,8 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
        obd_size fm_start, fm_end, fm_length, fm_end_offset;
         obd_size curr_loc;
         int current_extent = 0, rc = 0, i;
+       /* Whether have we collected enough extents */
+       bool enough = false;
         int ost_eof = 0; /* EOF for object */
         int ost_done = 0; /* done with required mapping for this OST? */
         int last_stripe;
@@ -1800,9 +1802,9 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
                         lun_start += len_mapped_single_call;
                         fm_local->fm_length = req_fm_len - len_mapped_single_call;
                         req_fm_len = fm_local->fm_length;
-                        fm_local->fm_extent_count = count_local;
-                        fm_local->fm_mapped_extents = 0;
-                        fm_local->fm_flags = fiemap->fm_flags;
+                       fm_local->fm_extent_count = enough ? 1 : count_local;
+                       fm_local->fm_mapped_extents = 0;
+                       fm_local->fm_flags = fiemap->fm_flags;
 
                        fm_key->oa.o_oi = lsm->lsm_oinfo[cur_stripe]->loi_oi;
                         ost_index = lsm->lsm_oinfo[cur_stripe]->loi_ost_idx;
@@ -1844,7 +1846,13 @@ inactive_tgt:
                                         goto finish;
                                 }
                                 break;
-                        }
+                       } else if (enough) {
+                               /*
+                                * We've collected enough extents and there are
+                                * more extents after it.
+                                */
+                               goto finish;
+                       }
 
                         /* If we just need num of extents then go to next device */
                         if (get_num_extents) {
@@ -1878,9 +1886,9 @@ inactive_tgt:
 
                         current_extent += ext_count;
 
-                        /* Ran out of available extents? */
-                        if (current_extent >= fiemap->fm_extent_count)
-                                goto finish;
+                       /* Ran out of available extents? */
+                       if (current_extent >= fiemap->fm_extent_count)
+                               enough = true;
                 } while (ost_done == 0 && ost_eof == 0);
 
                 if (cur_stripe_wrap == last_stripe)