- struct obd_device *obd = data;
- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- int rc;
- char *kernbuf, *errmsg;
- cfs_list_t tmp;
- ENTRY;
-
- OBD_ALLOC(kernbuf, count + 1);
- if (kernbuf == NULL) {
- errmsg = "no memory";
- GOTO(failed, rc = -ENOMEM);
- }
- if (cfs_copy_from_user(kernbuf, buffer, count)) {
- errmsg = "bad address";
- GOTO(failed, rc = -EFAULT);
- }
- kernbuf[count] = '\0';
-
- if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
- /* empty string is special case */
- cfs_down_write(&mdt->mdt_squash_sem);
- if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
- cfs_free_nidlist(&mdt->mdt_nosquash_nids);
- OBD_FREE(mdt->mdt_nosquash_str,
- mdt->mdt_nosquash_strlen);
- mdt->mdt_nosquash_str = NULL;
- mdt->mdt_nosquash_strlen = 0;
- }
- cfs_up_write(&mdt->mdt_squash_sem);
- LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
- obd->obd_name);
- OBD_FREE(kernbuf, count + 1);
- RETURN(count);
- }
-
- CFS_INIT_LIST_HEAD(&tmp);
- if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
- errmsg = "can't parse";
- GOTO(failed, rc = -EINVAL);
- }
-
- cfs_down_write(&mdt->mdt_squash_sem);
- if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
- cfs_free_nidlist(&mdt->mdt_nosquash_nids);
- OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
- }
- mdt->mdt_nosquash_str = kernbuf;
- mdt->mdt_nosquash_strlen = count + 1;
- cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
-
- LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
- obd->obd_name, kernbuf);
- cfs_up_write(&mdt->mdt_squash_sem);
- RETURN(count);
-
- failed:
- CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
- obd->obd_name, kernbuf, errmsg, rc);
- if (kernbuf)
- OBD_FREE(kernbuf, count + 1);
- RETURN(rc);
+ struct obd_device *obd = data;
+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+ int rc;
+ char *kernbuf, *errmsg;
+ cfs_list_t tmp;
+ ENTRY;
+
+ OBD_ALLOC(kernbuf, count + 1);
+ if (kernbuf == NULL) {
+ errmsg = "no memory";
+ GOTO(failed, rc = -ENOMEM);
+ }
+ if (cfs_copy_from_user(kernbuf, buffer, count)) {
+ errmsg = "bad address";
+ GOTO(failed, rc = -EFAULT);
+ }
+ kernbuf[count] = '\0';
+
+ if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
+ /* empty string is special case */
+ down_write(&mdt->mdt_squash_sem);
+ if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
+ cfs_free_nidlist(&mdt->mdt_nosquash_nids);
+ OBD_FREE(mdt->mdt_nosquash_str,
+ mdt->mdt_nosquash_strlen);
+ mdt->mdt_nosquash_str = NULL;
+ mdt->mdt_nosquash_strlen = 0;
+ }
+ up_write(&mdt->mdt_squash_sem);
+ LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
+ mdt_obd_name(mdt));
+ OBD_FREE(kernbuf, count + 1);
+ RETURN(count);
+ }
+
+ CFS_INIT_LIST_HEAD(&tmp);
+ if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
+ errmsg = "can't parse";
+ GOTO(failed, rc = -EINVAL);
+ }
+
+ down_write(&mdt->mdt_squash_sem);
+ if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
+ cfs_free_nidlist(&mdt->mdt_nosquash_nids);
+ OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
+ }
+ mdt->mdt_nosquash_str = kernbuf;
+ mdt->mdt_nosquash_strlen = count + 1;
+ cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
+
+ LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
+ mdt_obd_name(mdt), kernbuf);
+ up_write(&mdt->mdt_squash_sem);
+ RETURN(count);
+
+failed:
+ CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
+ mdt_obd_name(mdt), kernbuf, errmsg, rc);
+ if (kernbuf)
+ OBD_FREE(kernbuf, count + 1);
+ RETURN(rc);