summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a231148)
Starting with 4.15 kernels any sysfs read only is limited to
root access only. To retain the ability for non root users
to detect if a remote server is alive using the 'ping' sysfs
file we need to change it to writable. Retain the read ability
so older tools will work.
Change-Id: I6560c119328d723a20a2b32e1fa8c68dce5d407a
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/33776
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
#endif
ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
const char *buffer, size_t count);
#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);
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_ATTR(mds_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
{
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_ATTR(mgs_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
static struct attribute *mgc_attrs[] = {
&lustre_attr_mgs_conn_uuid.attr,
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_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
LUSTRE_RO_ATTR(conn_uuid);
static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
{
static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
{
}
EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
}
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);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
- RETURN(rc >= 0 ? count : 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,
/* 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"
[ $RUNAS_ID -eq $UID ] &&
skip_env "RUNAS_ID = UID = $UID -- skipping"
denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
grep "Permission denied" | wc -l)))
if [ $denied_cnt -ne 0 ]; then
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 llapi_ping(char *obd_type, char *obd_name)
{
+ int flags = O_RDONLY;
+ char buf[1] = { 0 };
int rc, fd;
rc = cfs_get_param_paths(&path, "%s/%s/ping",
obd_type, obd_name);
if (rc != 0)
return -errno;
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 (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;
}
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);
if (rc < 0)
rc = -errno;
close(fd);