]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/btrfs/extent_io.c
btrfs: Remove false alert when fiemap range is smaller than on-disk extent
[mirror_ubuntu-bionic-kernel.git] / fs / btrfs / extent_io.c
index 29a6111a68d2814a47d1364894f9a67a5ba8b8e0..2e6f69908303311128554c951e573f2596022669 100644 (file)
@@ -4438,29 +4438,25 @@ try_submit_last:
 }
 
 /*
- * Sanity check for fiemap cache
+ * Emit last fiemap cache
  *
- * All fiemap cache should be submitted by emit_fiemap_extent()
- * Iteration should be terminated either by last fiemap extent or
- * fieinfo->fi_extents_max.
- * So no cached fiemap should exist.
+ * The last fiemap cache may still be cached in the following case:
+ * 0                 4k                    8k
+ * |<- Fiemap range ->|
+ * |<------------  First extent ----------->|
+ *
+ * In this case, the first extent range will be cached but not emitted.
+ * So we must emit it before ending extent_fiemap().
  */
-static int check_fiemap_cache(struct btrfs_fs_info *fs_info,
-                              struct fiemap_extent_info *fieinfo,
-                              struct fiemap_cache *cache)
+static int emit_last_fiemap_cache(struct btrfs_fs_info *fs_info,
+                                 struct fiemap_extent_info *fieinfo,
+                                 struct fiemap_cache *cache)
 {
        int ret;
 
        if (!cache->cached)
                return 0;
 
-       /* Small and recoverbale problem, only to info developer */
-#ifdef CONFIG_BTRFS_DEBUG
-       WARN_ON(1);
-#endif
-       btrfs_warn(fs_info,
-                  "unhandled fiemap cache detected: offset=%llu phys=%llu len=%llu flags=0x%x",
-                  cache->offset, cache->phys, cache->len, cache->flags);
        ret = fiemap_fill_next_extent(fieinfo, cache->offset, cache->phys,
                                      cache->len, cache->flags);
        cache->cached = false;
@@ -4676,7 +4672,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        }
 out_free:
        if (!ret)
-               ret = check_fiemap_cache(root->fs_info, fieinfo, &cache);
+               ret = emit_last_fiemap_cache(root->fs_info, fieinfo, &cache);
        free_extent_map(em);
 out:
        btrfs_free_path(path);