Skip to contentSkip to conversation

Bug in BLKBSZSET/GET ioctl ?

DISCUSSION Wanlong Gao 3 participants 7 messages Dec 29, 2011 VFS

lore
Share & tools
lore
#0 lore raw

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096

---

I'm not sure if it is related to write-back, but still CCed to Fengguang.

Thanks,
-Wanlong Gao

#1 lore raw
Quoted 3 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

The blockdev-get/setbsz in *libguestfs* is just a wraper of util-linux's *blockdev --get/setbsz*.

Quoted 23 lines

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096

---

I'm not sure if it is related to write-back, but still CCed to Fengguang.

Thanks,
-Wanlong Gao

#3 lore raw
In reply to Wanlong Gao
Quoted 9 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

Quoted 8 lines
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096

I think each blockdev invocation is working on a *new* bdev object. You'll get consistent results if somehow keep it referenced, for example, run a background copy task:

# cp /dev/sda6 /dev/null &
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6

Thanks,
Fengguang

#4 lore raw
Quoted 19 lines · Wu Fengguang
Quoted 9 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

Quoted 8 lines
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
Quoted 1 line

I think each blockdev invocation is working on a *new* bdev object.

But the address of *new* bdev is the same?
I did printk, and they all returned the same address.

Quoted 1 line

You'll get consistent results if somehow keep it referenced, for

But isn't it a bug? It seems that the setbsz has no effect?

Thanks,
-Wanlong

Quoted 11 lines

example, run a background copy task:

# cp /dev/sda6 /dev/null &
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6

Thanks,
Fengguang

#5 lore raw
Quoted 21 lines · Wanlong Gao
Quoted 19 lines · Wu Fengguang
Quoted 17 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
Quoted 5 lines
Quoted 1 line

I think each blockdev invocation is working on a *new* bdev object.

But the address of *new* bdev is the same?
I did printk, and they all returned the same address.

Then the block size value should be reset in one of the bd_set_size() calls in __blkdev_get().

Quoted 4 lines
Quoted 1 line

You'll get consistent results if somehow keep it referenced, for

But isn't it a bug? It seems that the setbsz has no effect?

Yeah, it does look like unexpected behavior to the end user..

Thanks,
Fengguang

#6 lore raw
Quoted 22 lines · Wu Fengguang
Quoted 21 lines · Wanlong Gao
Quoted 19 lines · Wu Fengguang
Quoted 17 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

Then, I looked into upstream util-linux and it seems nothing wrong. I'm not convinced that it's a kernel bug.

produce:

---

# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 2048 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
# ./util-linux/disk-utils/blockdev --setbsz 512 /dev/sda6
# ./util-linux/disk-utils/blockdev --getbsz /dev/sda6
4096
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I think each blockdev invocation is working on a *new* bdev object.

But the address of *new* bdev is the same?
I did printk, and they all returned the same address.

Then the block size value should be reset in one of the bd_set_size() calls in __blkdev_get().

Is the behaviour right that setting bd_block_size to the logical_block_size every time when __blkdev_get()?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

You'll get consistent results if somehow keep it referenced, for

But isn't it a bug? It seems that the setbsz has no effect?

Yeah, it does look like unexpected behavior to the end user..

And at least, the ioctl BLKBZSET seems useless.

Thanks
-Wanlong

Quoted 4 lines

Thanks,
Fengguang

#2 lore raw
In reply to Wanlong Gao
Quoted 8 lines · Wanlong Gao
Quoted 3 lines · Wanlong Gao

Hi all:

This is first reported to *libguestfs*: https://bugzilla.redhat.com/show_bug.cgi?id=624335

The blockdev-get/setbsz in *libguestfs* is just a wraper of util-linux's *blockdev --get/setbsz*.

Agreed.

I don't think libguestfs is anything to do with it, since those commands simply translate to running
/sbin/blockdev --{get,set}bsz /dev/sdX:

http://git.annexia.org/?p=libguestfs.git;a=blob;f=daemon/blockdev.c;h=d056abef1739de7b9e9aab118c138bae403e11e5;hb=HEAD#l106

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top