Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Artem Pogartsev <artem.pogartsev@activecloud.com>
To: <drbd-dev@lists.linbit.com>
Subject: [Drbd-dev] [PATCH] drbdmeta: Fix drbdmeta to support old kernels
Date: Thu, 17 Aug 2017 04:57:12 +0300	[thread overview]
Message-ID: <a1c1b596-8259-a2cf-3b1b-6461761bbca4@activecloud.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

Hello,

RedHat 6.9
kernel-2.6.32-431.11.2
drbd-utils-9.0.0
drbd-8.4.10

Problem:

drbdmeta 0 v08 /dev/sda internal create-md
initializing activity log
initializing bitmap (30524 KB) to all zero
ioctl(/dev/sda) failed: Invalid argument

Reason:

Wrong check of the return error code into zeroout_bitmap function 
(user/shared/drbdmeta.c):

err = ioctl(cfg->md_fd, BLKZEROOUT, &range);
if (!err)
         return;
if (errno == ENOTTY) {
         do pwrite stuff;
}

We must check if errno == EINVAL (request code or argp is not valid). We 
will get ENOTTY if the block device doesnt has ioctl into fops structure 
(look at the __blkdev_driver_ioctl into block/ioctl.c) - not out case. 
And we will get EINVAL if the request code is wrong for this type of the 
device (old kernels doesnt have BLKZEROOUT) - our case.

Possible patch is attached.

But maybe better change logic and make ioctl with BLKZEROOUT only if 
BLKZEROOUT was defined in kernel headers (if we dont have BLKZEROOUT 
macro in kernel tree then 100% ioctl with _IO(0x12,127) will fail).


[-- Attachment #2: drbd-utils-9.0.0-blkzeroout.patch --]
[-- Type: text/plain, Size: 462 bytes --]

diff -Nru a/user/shared/drbdmeta.c b/user/shared/drbdmeta.c
--- a/user/shared/drbdmeta.c	2017-04-20 10:35:02.000000000 +0300
+++ b/user/shared/drbdmeta.c	2017-08-17 04:26:35.509000784 +0300
@@ -1716,7 +1716,7 @@
 	if (!err)
 		return;
 
-	if (errno == ENOTTY) {
+	if (errno == EINVAL) {
 		/* need to sector-align this for O_DIRECT.
 		 * "sector" here means hard-sect size, which may be != 512.
 		 * Note that even though ALIGN does round up, for sector sizes

             reply	other threads:[~2017-08-17  9:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17  1:57 Artem Pogartsev [this message]
2017-08-17  9:59 ` [Drbd-dev] [PATCH] drbdmeta: Fix drbdmeta to support old kernels Lars Ellenberg

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=a1c1b596-8259-a2cf-3b1b-6461761bbca4@activecloud.com \
    --to=artem.pogartsev@activecloud.com \
    --cc=drbd-dev@lists.linbit.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