#endif
ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
const char *buffer, size_t count);
-extern ssize_t
-lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
+ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
+ char *buffer);
+
extern ssize_t
lprocfs_import_seq_write(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
LUSTRE_ATTR(mds_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
-LUSTRE_WO_ATTR(ping);
+LUSTRE_RW_ATTR(ping);
static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
{
LUSTRE_ATTR(mgs_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
-LUSTRE_WO_ATTR(ping);
+LUSTRE_RW_ATTR(ping);
static struct attribute *mgc_attrs[] = {
&lustre_attr_mgs_conn_uuid.attr,
LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
-LUSTRE_WO_ATTR(ping);
+LUSTRE_RW_ATTR(ping);
static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
{
}
EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
-ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
- const char *buffer, size_t count)
+ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
+ char *buffer)
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
- RETURN(rc >= 0 ? count : rc);
+ RETURN(rc);
}
-EXPORT_SYMBOL(ping_store);
+EXPORT_SYMBOL(ping_show);
-ssize_t
-lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+/* kept for older verison of tools. */
+ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
- struct ptlrpc_request *req;
- int rc;
- ENTRY;
-
- LPROCFS_CLIMP_CHECK(obd);
- req = ptlrpc_prep_ping(obd->u.cli.cl_import);
- LPROCFS_CLIMP_EXIT(obd);
- if (req == NULL)
- RETURN(-ENOMEM);
-
- req->rq_send_state = LUSTRE_IMP_FULL;
-
- rc = ptlrpc_queue_wait(req);
-
- ptlrpc_req_finished(req);
- if (rc >= 0)
- RETURN(count);
- RETURN(rc);
+ return ping_show(kobj, attr, (char *)buffer);
}
-EXPORT_SYMBOL(lprocfs_ping_seq_write);
+EXPORT_SYMBOL(ping_store);
/* Write the connection UUID to this file to attempt to connect to that node.
* The connection UUID is a node's primary NID. For example,
[ $RUNAS_ID -eq $UID ] &&
skip_env "RUNAS_ID = UID = $UID -- skipping"
- chmod 666 /dev/obd
denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
grep "Permission denied" | wc -l)))
if [ $denied_cnt -ne 0 ]; then
int llapi_ping(char *obd_type, char *obd_name)
{
+ int flags = O_RDONLY;
+ char buf[1] = { 0 };
glob_t path;
- char buf[1];
int rc, fd;
rc = cfs_get_param_paths(&path, "%s/%s/ping",
obd_type, obd_name);
if (rc != 0)
return -errno;
-
- fd = open(path.gl_pathv[0], O_WRONLY);
+retry_open:
+ fd = open(path.gl_pathv[0], flags);
if (fd < 0) {
+ if (errno == EACCES && flags == O_RDONLY) {
+ flags = O_WRONLY;
+ goto retry_open;
+ }
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc, "error opening %s",
path.gl_pathv[0]);
goto failed;
}
- /* The purpose is to send a byte as a ping, whatever this byte is. */
- /* coverity[uninit_use_in_call] */
- rc = write(fd, buf, 1);
+ if (flags == O_RDONLY)
+ rc = read(fd, buf, sizeof(buf));
+ else
+ rc = write(fd, buf, sizeof(buf));
if (rc < 0)
rc = -errno;
close(fd);