From 659c81ca4bfbbc536260ff15bb31da84d9366791 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 20 Nov 2015 22:51:15 -0700 Subject: [PATCH] LU-4825 ofd: fix OBD_FAIL_OST_ENOINO/ENOSPC behaviour Fix the OBD_FAIL_OST_ENOINO and OBD_FAIL_OST_ENOSPC behaviour so that they also reduce the total number of inodes or blocks when setting the number of free inodes/blocks to zero. This allows "lfs df [-i]" to still report the correct number of blocks and inodes used on the OST. Signed-off-by: Andreas Dilger Change-Id: Ia746273e19aed22a0926708899de009b8d5cab07 Reviewed-on: https://review.whamcloud.com/20163 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_obd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 2c492f2..9092ca8 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -856,8 +856,11 @@ int ofd_statfs(const struct lu_env *env, struct obd_export *exp, osfs->os_files, osfs->os_ffree, osfs->os_state); if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOINO, - ofd->ofd_lut.lut_lsd.lsd_osd_index)) - osfs->os_ffree = 0; + ofd->ofd_lut.lut_lsd.lsd_osd_index)) { + /* Reduce free inode count to zero, but keep "used" intact */ + osfs->os_files -= osfs->os_ffree; + osfs->os_ffree -= osfs->os_ffree; + } /* OS_STATE_READONLY can be set by OSD already */ if (ofd->ofd_raid_degraded) @@ -877,8 +880,12 @@ int ofd_statfs(const struct lu_env *env, struct obd_export *exp, } if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOSPC, - ofd->ofd_lut.lut_lsd.lsd_osd_index)) - osfs->os_bfree = osfs->os_bavail = 2; + ofd->ofd_lut.lut_lsd.lsd_osd_index)) { + /* Reduce free blocks count near zero, but keep "used" intact */ + osfs->os_bavail -= osfs->os_bavail - 2; + osfs->os_blocks -= osfs->os_bfree - 2; + osfs->os_bfree -= osfs->os_bfree - 2; + } EXIT; out: -- 1.8.3.1