From 5b147e47de651f1c140f69314a2d6b56ff6b14d7 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Mon, 16 Jul 2018 17:09:15 -0700 Subject: [PATCH] LU-11115 lod: skip max_create_count=0 OST in QoS and RR algorithms While choosing OST to create object, both lod_alloc_qos() and lod_alloc_rr() functions use lod_statfs_and_check() function to check whether the OST is available for new OST objects or not. However, OST with max_create_count=0 is not checked in that function and just returned as an available OST. This patch fixes the above issue by detecting OST with max_create_count=0 in lod_statfs_and_check() and skip it. Change-Id: I04476a4b369e99133bd89c00155fd9f51bf0c930 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/32823 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Bobi Jam Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/uapi/linux/lustre/lustre_user.h | 1 + lustre/lod/lod_object.c | 3 ++- lustre/lod/lod_qos.c | 4 ++++ lustre/osp/osp_precreate.c | 7 +++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 81b0df2..9d1668d 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -119,6 +119,7 @@ typedef struct stat lstat_t; enum obd_statfs_state { OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */ OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */ + OS_STATE_NOPRECREATE = 0x00000004, /**< no object precreation */ OS_STATE_ENOSPC = 0x00000020, /**< not enough free space */ OS_STATE_ENOINO = 0x00000040, /**< not enough inodes */ }; diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 6eef5f0..7a5c0fb 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -5575,7 +5575,8 @@ static inline int lod_check_ost_avail(const struct lu_env *env, ost = OST_TGT(lod, idx); if (ost->ltd_statfs.os_state & - (OS_STATE_READONLY | OS_STATE_ENOSPC | OS_STATE_ENOINO) || + (OS_STATE_READONLY | OS_STATE_ENOSPC | OS_STATE_ENOINO | + OS_STATE_NOPRECREATE) || ost->ltd_active == 0) { CDEBUG(D_LAYOUT, DFID ": mirror %d OST%d unavail, rc = %d\n", PFID(lod_object_fid(lo)), index, idx, rc); diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 9eb1297..797f81c 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -216,6 +216,10 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, if (sfs->os_state & OS_STATE_READONLY) rc = -EROFS; + /* object precreation is skipped on the OST with max_create_count=0 */ + if (sfs->os_state & OS_STATE_NOPRECREATE) + rc = -ENOBUFS; + /* check whether device has changed state (active, inactive) */ if (rc != 0 && ost->ltd_active) { /* turned inactive? */ diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index bbcd7b3..ca07441 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -1038,6 +1038,13 @@ void osp_pre_update_status(struct osp_device *d, int rc) available, d->opd_reserved_mb_low, d->opd_pre_status, rc); } + + /* Object precreation is skipped on the OST with + * max_create_count=0. */ + if (d->opd_pre_max_create_count == 0) + msfs->os_state |= OS_STATE_NOPRECREATE; + else + msfs->os_state &= ~OS_STATE_NOPRECREATE; } out: wake_up(&d->opd_pre_user_waitq); -- 1.8.3.1