From fdf3dec6c60c734fdbb7b5b8da0f3040c6b54748 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Tue, 16 Aug 2011 02:38:20 -0700 Subject: [PATCH] LU-592 1.8 <-> 2.1 interop: missing LMV on client When the cluster is upgraded from 1.8, client will not have LMV layer, and the "ll_md_exp" is pointing to MDC directly, so the code which assuming "ll_md_exp" as LMV need be revised: - ll_dir_ioctl(LL_IOC_GETOBDCOUNT) should return 1 for MDC case; - mdc_iocontrol() needs to handle the OBD_IOC_QUOTACTL as well when the "ll_md_exp" is MDC; Signed-off-by: Niu Yawei Change-Id: I3659a5f8076125c9b2012826521c44540e65a75e Reviewed-on: http://review.whamcloud.com/1236 Tested-by: Hudson Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/obd.h | 1 + lustre/llite/dir.c | 19 ++++++++++--------- lustre/lmv/lmv_obd.c | 3 +++ lustre/lov/lov_obd.c | 3 +++ lustre/mdc/mdc_request.c | 33 +++++++++++++++++++++++++++------ 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 91caaa6..fcee1b0 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1160,6 +1160,7 @@ enum obd_cleanup_stage { #define KEY_REGISTER_TARGET "register_target" #define KEY_REVIMP_UPD "revimp_update" #define KEY_SET_FS "set_fs" +#define KEY_TGT_COUNT "tgt_count" /* KEY_SET_INFO in lustre_idl.h */ #define KEY_SPTLRPC_CONF "sptlrpc_conf" #define KEY_CONNECT_FLAG "connect_flags" diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index b757927..1db1875 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1483,19 +1483,20 @@ out_free: } #endif case LL_IOC_GETOBDCOUNT: { - int count; + int count, vallen; + struct obd_export *exp; if (cfs_copy_from_user(&count, (int *)arg, sizeof(int))) RETURN(-EFAULT); - if (!count) { - /* get ost count */ - struct lov_obd *lov = &sbi->ll_dt_exp->exp_obd->u.lov; - count = lov->desc.ld_tgt_count; - } else { - /* get mdt count */ - struct lmv_obd *lmv = &sbi->ll_md_exp->exp_obd->u.lmv; - count = lmv->desc.ld_tgt_count; + /* get ost count when count is zero, get mdt count otherwise */ + exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; + vallen = sizeof(count); + rc = obd_get_info(exp, sizeof(KEY_TGT_COUNT), KEY_TGT_COUNT, + &vallen, &count, NULL); + if (rc) { + CERROR("get target count failed: %d\n", rc); + RETURN(rc); } if (cfs_copy_to_user((int *)arg, &count, sizeof(int))) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 6b6885e..e0d896d 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -2707,6 +2707,9 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, ((struct obd_connect_data *)val)->ocd_connect_flags; } RETURN(rc); + } else if (KEY_IS(KEY_TGT_COUNT)) { + *((int *)val) = lmv->desc.ld_tgt_count; + RETURN(0); } CDEBUG(D_IOCTL, "Invalid key\n"); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 4108530..3f1191f 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2650,6 +2650,9 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, *((__u64*)val) = tgt->ltd_exp->exp_connect_flags; GOTO(out, rc = 0); + } else if (KEY_IS(KEY_TGT_COUNT)) { + *((int *)val) = lov->desc.ld_tgt_count; + GOTO(out, rc = 0); } rc = -EINVAL; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 3abdd77..83eb2ae 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1427,10 +1427,11 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = ptlrpc_obd_ping(obd); GOTO(out, rc); /* - * Normally IOC_OBD_STATFS iocontrol is handled by LMV instead of MDC. - * But when the cluster is upgraded from 1.8, there'd be no LMV layer - * thus we might be called here. Eventually this code should be removed. - * bz20731. + * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by + * LMV instead of MDC. But when the cluster is upgraded from 1.8, + * there'd be no LMV layer thus we might be called here. Eventually + * this code should be removed. + * bz20731, LU-592. */ case IOC_OBD_STATFS: { struct obd_statfs stat_buf = {0}; @@ -1457,6 +1458,24 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc = 0); } + case OBD_IOC_QUOTACTL: { + struct if_quotactl *qctl = karg; + struct obd_quotactl *oqctl; + + OBD_ALLOC_PTR(oqctl); + if (!oqctl) + RETURN(-ENOMEM); + + QCTL_COPY(oqctl, qctl); + rc = obd_quotactl(exp, oqctl); + if (rc == 0) { + QCTL_COPY(qctl, oqctl); + qctl->qc_valid = QC_MDTIDX; + qctl->obd_uuid = obd->u.cli.cl_target_uuid; + } + OBD_FREE_PTR(oqctl); + break; + } case LL_IOC_GET_CONNECT_FLAGS: { if (cfs_copy_to_user(uarg, &exp->exp_connect_flags, sizeof(__u64))) @@ -1695,8 +1714,7 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key, max_easize = val; *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize; RETURN(0); - } - if (KEY_IS(KEY_CONN_DATA)) { + } else if (KEY_IS(KEY_CONN_DATA)) { struct obd_import *imp = class_exp2cliimp(exp); struct obd_connect_data *data = val; @@ -1705,6 +1723,9 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key, *data = imp->imp_connect_data; RETURN(0); + } else if (KEY_IS(KEY_TGT_COUNT)) { + *((int *)val) = 1; + RETURN(0); } rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val); -- 1.8.3.1