From: Bob Peterson Date: Tue, 5 Apr 2016 10:14:27 -0400 (EDT) Subject: [Cluster-devel] [PATCH 2/2] mkfs.gfs2: Open the target device with O_EXCL In-Reply-To: <1459865009-14109-2-git-send-email-anprice@redhat.com> References: <1459865009-14109-1-git-send-email-anprice@redhat.com> <1459865009-14109-2-git-send-email-anprice@redhat.com> Message-ID: <2126126528.47807026.1459865667265.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ----- Original Message ----- > O_EXCL will let local mounters know that the device is busy while > mkfs.gfs2 is running so that they don't try to access it. > > Before: > # mount /dev/vdc /mnt/test > mount: /dev/vdc: can't read superblock > > With O_EXCL: > # mount /dev/vdc /mnt/test > mount: /dev/vdc is already mounted or /mnt/test busy > > Signed-off-by: Andrew Price > --- > gfs2/mkfs/main_mkfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c > index 107d3cc..4436f93 100644 > --- a/gfs2/mkfs/main_mkfs.c > +++ b/gfs2/mkfs/main_mkfs.c > @@ -854,7 +854,7 @@ static void open_dev(struct mkfs_dev *dev) > { > int error; > > - dev->fd = open(dev->path, O_RDWR | O_CLOEXEC); > + dev->fd = open(dev->path, O_RDWR|O_CLOEXEC|O_EXCL); > if (dev->fd < 0) { > perror(dev->path); > exit(1); > -- > 2.4.11 > > Hi Andy, In fact, we used to have O_EXCL: https://git.fedorahosted.org/cgit/cluster.git/commit/gfs2/mkfs/main_mkfs.c?h=RHEL6&id=b0db0bad3e6a8996fcaecbb93bfe9f8de97b7508 I remember Ryan doing this, but I'm not sure why or how it disappeared. We need to chase down why O_EXCL was removed last time; whether it was just an oversight/mistake or whether it caused problems elsewhere. Regards, Bob Peterson Red Hat File Systems