From: lsy Date: Fri, 20 Oct 2006 03:36:57 +0000 (+0000) Subject: change capability config interface to 0/1/2/3 according to brian's advice. X-Git-Tag: v1_8_0_110~486^2~431 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fa4b92ad7c4d2fd794e1eef006d8fa2687c6dc67;p=fs%2Flustre-release.git change capability config interface to 0/1/2/3 according to brian's advice. --- diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index df102ee..941fd80 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -540,26 +540,28 @@ static int lprocfs_wr_capa(struct file *file, const char *buffer, { struct obd_device *obd = data; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - char mode[3] = ""; - - if (count > 3) { - CERROR("invalid capability mode, only m/o/mo/x is accepted.\n" - " m: enable MDS fid capability\n" - " o: enable OSS fid capability\n" - " mo: enable both MDS and OSS fid capability\n" - " x: disable fid capability\n"); + int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + + if (val < 0 || val > 3) { + CERROR("invalid capability mode, only 0/1/2/3 is accepted.\n" + " 0: disable fid capability\n" + " 1: enable OSS fid capability\n" + " 2: enable MDS fid capability\n" + " 3: enable both MDS and OSS fid capability\n"); return -EINVAL; } - if (copy_from_user(mode, buffer, min(2UL, count))) - return -EFAULT; + /* OSS fid capability needs enable both MDS and OSS fid capability on + * MDS */ + if (val == 1) + val = 3; - mdt->mdt_opts.mo_mds_capa = 0; - mdt->mdt_opts.mo_oss_capa = 0; - if (strchr(mode, 'm')) - mdt->mdt_opts.mo_mds_capa = 1; - if (strchr(mode, 'o')) - mdt->mdt_opts.mo_oss_capa = 1; + mdt->mdt_opts.mo_oss_capa = (val & 0x1); + mdt->mdt_opts.mo_mds_capa = !!(val & 0x2); mdt->mdt_capa_conf = 1; return count; } diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c index 71727fe..f3ea9fb 100644 --- a/lustre/obdfilter/lproc_obdfilter.c +++ b/lustre/obdfilter/lproc_obdfilter.c @@ -320,23 +320,20 @@ static int lprocfs_filter_wr_capa(struct file *file, const char *buffer, unsigned long count, void *data) { struct obd_device *obd = data; - char mode[2] = ""; + int val, rc; - if (count > 2) { - CERROR("invalid capability mode, only o/x are accepted.\n" - " o: enable oss fid capability\n" - " x: disable oss fid capability\n"); + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + + if (val & ~0x1) { + CERROR("invalid capability mode, only 0/1 are accepted.\n" + " 1: enable oss fid capability\n" + " 0: disable oss fid capability\n"); return -EINVAL; } - if (copy_from_user(mode, buffer, min(1UL, count))) - return -EFAULT; - - if (strchr(mode, 'o')) - obd->u.filter.fo_fl_oss_capa = 1; - else - obd->u.filter.fo_fl_oss_capa = 0; - + obd->u.filter.fo_fl_oss_capa = val; return count; }