X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosc%2Flproc_osc.c;fp=lustre%2Fosc%2Flproc_osc.c;h=414d918e9f402308049b8f86c3f6197ab1b27a9b;hb=9b6b5e4798281eceb45699431bc871eda6d968c4;hp=b4c0e35a095d6b79f48457a7c3a90372db03a5b8;hpb=b09e63db24e5770b0a53ac6d68f91f08dc368be4;p=fs%2Flustre-release.git diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index b4c0e35..414d918 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -425,28 +425,34 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, int i; DECLARE_CKSUM_NAME; char kernbuf[10]; + int rc = -EINVAL; - if (obd == NULL) - return 0; + if (obd == NULL) + return 0; - if (count > sizeof(kernbuf) - 1) - return -EINVAL; + if (count > sizeof(kernbuf) - 1) + return -EINVAL; if (copy_from_user(kernbuf, buffer, count)) - return -EFAULT; - if (count > 0 && kernbuf[count - 1] == '\n') - kernbuf[count - 1] = '\0'; - else - kernbuf[count] = '\0'; - - for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { - if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0) - continue; - if (!strcmp(kernbuf, cksum_name[i])) { - obd->u.cli.cl_cksum_type = 1 << i; - return count; - } - } - return -EINVAL; + return -EFAULT; + + if (count > 0 && kernbuf[count - 1] == '\n') + kernbuf[count - 1] = '\0'; + else + kernbuf[count] = '\0'; + + for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { + if (strcmp(kernbuf, cksum_name[i]) == 0) { + obd->u.cli.cl_preferred_cksum_type = BIT(i); + if (obd->u.cli.cl_supp_cksum_types & BIT(i)) { + obd->u.cli.cl_cksum_type = BIT(i); + rc = count; + } else { + rc = -ENOTSUPP; + } + break; + } + } + return rc; } LPROC_SEQ_FOPS(osc_checksum_type);