]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: account for snapshot items when deciding to split or merge a directory
authorVenky Shankar <vshankar@redhat.com>
Wed, 16 Nov 2022 10:03:08 +0000 (05:03 -0500)
committerVenky Shankar <vshankar@redhat.com>
Thu, 22 Dec 2022 14:31:02 +0000 (20:01 +0530)
Its easy to "overload" a directory object with large number of omap entries by
doing the following (one shot or over and over again):

      - touch dir/file{0..11000} ; create 11000 files (> mds_bal_split_size)
      - mkdir dir/.snap/snap_a
      - rm -f dir/file{0..11000}

End result - the directory object would have 11000 omap entries since the MDS
does not fragment directory snapshots. If the number of such entries exceed
`osd_deep_scrub_large_omap_object_key_threshold` (default: 200000), a cluster
health warning is generated:

       Large Omap objects found in pool...

CDir::should_merge() does not take into account COW'd inodes and the frags
get merged.

Fixes: http://tracker.ceph.com/issues/55215
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/mds/CDir.cc
src/mds/CDir.h

index d87ddbf63fe01c1a67817fa99a5f6ae09b698239..d7c5afd83dfc09f8efda17544f3960e8e8573450 100644 (file)
@@ -3794,7 +3794,7 @@ bool CDir::should_merge() const
       return false;
   }
 
-  return (int)get_frag_size() < g_conf()->mds_bal_merge_size;
+  return ((int)get_frag_size() + (int)get_num_snap_items()) < g_conf()->mds_bal_merge_size;
 }
 
 MEMPOOL_DEFINE_OBJECT_FACTORY(CDir, co_dir, mds_co);
index 6e69bc25b8e6c6365c01347893a9498d68395375..58507db970b4b3220dc1cc3c29f689de30d8a0bb 100644 (file)
@@ -404,7 +404,7 @@ public:
 
   bool should_split() const {
     return g_conf()->mds_bal_split_size > 0 &&
-           (int)get_frag_size() > g_conf()->mds_bal_split_size;
+      ((int)get_frag_size() + (int)get_num_snap_items()) > g_conf()->mds_bal_split_size;
   }
   bool should_split_fast() const;
   bool should_merge() const;