Whamcloud - gitweb
LU-8435 tests: slab alloc error does not LBUG 45/21745/6
authorAurelien Degremont <aurelien.degremont@cea.fr>
Tue, 30 May 2017 21:56:06 +0000 (23:56 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 31 Aug 2017 19:15:39 +0000 (19:15 +0000)
Under memory pressure, for instance using a memory cgroup
and kmem.limit_in_bytes enforced (SLURM does this),
osc_extent_alloc() could fail and error handling will
hit an LBUG.

Add a test for this.

Test-Parameters: trivial testlist=sanity,sanity,sanity

Signed-off-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Change-Id: I135f05ee4be14521522c949e50bd4c8deb1f099a
Reviewed-on: https://review.whamcloud.com/21745
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/tests/sanity.sh

index 7aa4bf6..97c6d0f 100755 (executable)
@@ -16380,6 +16380,36 @@ test_410()
 }
 run_test 410 "Test inode number returned from kernel thread"
 
+cleanup_test411_cgroup() {
+       trap 0
+       rmdir "$1"
+}
+
+test_411() {
+       local cg_basedir=/sys/fs/cgroup/memory
+       test -d "$cg_basedir" || { skip "no setup for cgroup"; return; }
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
+               error "test file creation failed"
+       cancel_lru_locks osc
+
+       # Create a very small memory cgroup to force a slab allocation error
+       local cgdir=$cg_basedir/osc_slab_alloc
+       mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
+       trap "cleanup_test411_cgroup $cgdir" EXIT
+       echo 2M > $cgdir/memory.kmem.limit_in_bytes
+       echo 1M > $cgdir/memory.limit_in_bytes
+
+       # Should not LBUG, just be killed by oom-killer
+       sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
+               error "fail to trigger a memory allocation error"
+
+       cleanup_test411_cgroup $cgdir
+
+       return 0
+}
+run_test 411 "Slab allocation error with cgroup does not LBUG"
+
 prep_801() {
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&