Linux Device Mapper development
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Bart Van Assche <Bart.VanAssche@sandisk.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v3 07/10] (lib)mpathpersist: use O_RDONLY file descriptors
Date: Sun, 24 Jun 2018 21:09:41 +0200	[thread overview]
Message-ID: <20180624190944.27158-8-mwilck@suse.com> (raw)
In-Reply-To: <20180624190944.27158-1-mwilck@suse.com>

udevd catches close-after-write inotify events and generates "change"
uvents for such devices, which may cause extra unnecessary and unwanted
udev activity.

Therefore use O_RDONLY file descriptors for PRIN and PROUT commands. This
works just as well as O_WRONLY. sg_persist has supported the --readonly option
for years.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmpathpersist/mpath_pr_ioctl.c | 4 ++--
 mpathpersist/main.c              | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmpathpersist/mpath_pr_ioctl.c b/libmpathpersist/mpath_pr_ioctl.c
index 8416a3bf..a222b1e1 100644
--- a/libmpathpersist/mpath_pr_ioctl.c
+++ b/libmpathpersist/mpath_pr_ioctl.c
@@ -52,7 +52,7 @@ int prout_do_scsi_ioctl(char * dev, int rq_servact, int rq_scope,
 	int fd = -1;
 
 	snprintf(devname, FILE_NAME_SIZE, "/dev/%s",dev);
-	fd = open(devname, O_WRONLY);
+	fd = open(devname, O_RDONLY);
 	if(fd < 0){
 		condlog (1, "%s: unable to open device.", dev);
 		return MPATH_PR_FILE_ERROR;
@@ -308,7 +308,7 @@ int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int
 	{MPATH_PRIN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 	snprintf(devname, FILE_NAME_SIZE, "/dev/%s",dev);
-	fd = open(devname, O_WRONLY);
+	fd = open(devname, O_RDONLY);
 	if(fd < 0){
 		condlog(0, "%s: Unable to open device ", dev);
 		return MPATH_PR_FILE_ERROR;
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 5b37f3ae..34caa16c 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -380,7 +380,7 @@ int main (int argc, char * argv[])
 	}
 
 	/* open device */
-	if ((fd = open (device_name, O_WRONLY)) < 0)
+	if ((fd = open (device_name, O_RDONLY)) < 0)
 	{
 		fprintf (stderr, "%s: error opening file (rw) fd=%d\n",
 				device_name, fd);
-- 
2.17.1

  parent reply	other threads:[~2018-06-24 19:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-24 19:09 [PATCH v3 00/10] libmpathpersist fixes and some more Martin Wilck
2018-06-24 19:09 ` [PATCH v3 01/10] libmpathpersist: remove duplicate test in readfullstatus Martin Wilck
2018-06-24 19:09 ` [PATCH v3 02/10] libmpathpersist: fix typo in mpath_format_readfullstatus Martin Wilck
2018-06-24 19:09 ` [PATCH v3 03/10] libmpathpersist: fix stack overflow in mpath_format_readfullstatus() Martin Wilck
2018-06-24 19:09 ` [PATCH v3 04/10] libmultipath: add (get|put)_unaligned_be64 Martin Wilck
2018-06-24 19:09 ` [PATCH v3 05/10] multipath-tools/tests: add tests for get_unaligned_beXX Martin Wilck
2018-06-24 19:09 ` [PATCH v3 06/10] libmpathpersist: fix byte swapping for big endian systems Martin Wilck
2018-06-24 19:09 ` Martin Wilck [this message]
2018-06-24 19:09 ` [PATCH v3 08/10] libmultipath: fix gcc 8.1 "truncated output" warnings Martin Wilck
2018-06-24 19:09 ` [PATCH v3 09/10] multipathd: fix buffer size in cli_getprkey() Martin Wilck
2018-06-24 19:09 ` [PATCH v3 10/10] libmultipath: avoid error messages from RDAC check Martin Wilck
2018-06-25 22:32 ` [PATCH v3 00/10] libmpathpersist fixes and some more Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180624190944.27158-8-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox