+ 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);
+}
+
+static int lprocfs_rd_mdt_som(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+
+ return snprintf(page, count, "%sabled\n",
+ mdt->mdt_som_conf ? "en" : "dis");
+}
+
+static int lprocfs_wr_mdt_som(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_export *exp;
+ struct obd_device *obd = data;
+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+ char kernbuf[16];
+ unsigned long val = 0;
+
+ if (count > (sizeof(kernbuf) - 1))
+ return -EINVAL;
+
+ if (cfs_copy_from_user(kernbuf, buffer, count))
+ return -EFAULT;
+
+ kernbuf[count] = '\0';
+
+ if (!strcmp(kernbuf, "enabled"))
+ val = 1;
+ else if (strcmp(kernbuf, "disabled"))
+ return -EINVAL;
+
+ if (mdt->mdt_som_conf == val)
+ return count;
+
+ if (!obd->obd_process_conf) {
+ CERROR("Temporary SOM change is not supported, use lctl "
+ "conf_param for permanent setting\n");
+ return count;
+ }
+
+ /* 1 stands for self export. */
+ cfs_list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
+ if (exp == obd->obd_self_export)
+ continue;
+ if (exp->exp_connect_flags & OBD_CONNECT_MDS_MDS)
+ continue;
+ /* Some clients are already connected, skip the change */
+ LCONSOLE_INFO("%s is already connected, SOM will be %s on "
+ "the next mount\n", exp->exp_client_uuid.uuid,
+ val ? "enabled" : "disabled");
+ return count;
+ }
+
+ mdt->mdt_som_conf = val;
+ LCONSOLE_INFO("Enabling SOM\n");
+
+ return count;
+}
+
+/* Temporary; for testing purposes only */
+static int lprocfs_mdt_wr_mdc(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = data;
+ struct obd_export *exp = NULL;
+ struct obd_uuid uuid;
+ char tmpbuf[sizeof(struct obd_uuid)];
+
+ sscanf(buffer, "%40s", tmpbuf);
+
+ obd_str2uuid(&uuid, tmpbuf);
+ exp = cfs_hash_lookup(obd->obd_uuid_hash, &uuid);
+ if (exp == NULL) {
+ CERROR("%s: no export %s found\n",
+ obd->obd_name, obd_uuid2str(&uuid));
+ } else {
+ mdt_hsm_copytool_send(exp);
+ class_export_put(exp);
+ }
+
+ return count;