linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Heinz Mauelshagen <heinzm@redhat.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.de>,
	linux-raid@vger.kernel.org, Neil Brown <neilb@suse.com>,
	Hannes Reinecke <hare@suse.de>
Subject: [PATCH] dmraid: remove partitions with O_RDONLY
Date: Thu, 26 Oct 2017 22:47:22 +0200	[thread overview]
Message-ID: <20171026204722.9150-1-mwilck@suse.com> (raw)

It's not necessary to use O_RDWR to use BLKPG_DEL_PARTITION.
It's actually harmful, because closing the device will cause
an IN_CLOSE_WRITE inotify event, which will trigger a BLKRRPART
from systemd, which will reinstate all partitions just deleted.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 lib/device/partition.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/device/partition.c b/lib/device/partition.c
index 9352b0437694..a01cc3583514 100644
--- a/lib/device/partition.c
+++ b/lib/device/partition.c
@@ -22,7 +22,7 @@ _remove_subset_partitions(struct lib_context *lc, struct raid_set *rs)
 	};
 
 	list_for_each_entry(rd, &rs->devs, devs) {
-		int fd = open(rd->di->path, O_RDWR);
+		int fd = open(rd->di->path, O_RDONLY);
 		if (fd < 0)
 			LOG_ERR(lc, 0, "opening %s: %s\n", rd->di->path,
 				strerror(errno));
-- 
2.14.2


                 reply	other threads:[~2017-10-26 20:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20171026204722.9150-1-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    --cc=heinzm@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mwilck@suse.de \
    --cc=neilb@suse.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;
as well as URLs for NNTP newsgroup(s).