Bug 807905

Summary: mkfs blocksize option breaks when creating btrfs
Product: Red Hat Enterprise Linux 6 Reporter: Mohua Li <moli>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.3CC: leiwang, qguan, qwan, yuzhou
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.16.14-1.el6 Doc Type: Bug Fix
Doc Text:
No Documentation needed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 07:01:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mohua Li 2012-03-29 06:01:39 UTC
Description of problem:

for mkfs-opts, btrfs is different from ext3/ext4, "- b" doesn't mean blocksize but size in byte, so we need to split the below code for btrfs filesytem, 

//daemon/mkfs.c


136     else {
137       /* For all other filesystem types, try the -b option. */
138       snprintf (blocksize_str, sizeof blocksize_str, "%d", blocksize);
139       ADD_ARG (argv, i, "-b");
140       ADD_ARG (argv, i, blocksize_str);
141     }
142   }
143 

or mkfs-opts will fail with "File system size 4096 bytes is too small, 256M is required at least", which will treat the blocksize as filesystem size in byte, for more detail pls see below information, 



                                                                                                                                                                                                                                                                                                                                                   
--------fail to create btrfs with customize value blocksize

><fs> mkfs-opts btrfs blocksize:4096 /dev/vda
mkfs-opts: unknown optional argument "/dev/vda"
><fs> mkfs-opts btrfs /dev/vda blocksize:4096
libguestfs: send_to_daemon: 84 bytes: 00 00 00 50 | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 16 | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x50
mkfs -t btrfs -b 4096 /dev/vda
File system size 4096 bytes is too small, 256M is required at least
guestfsd: error: btrfs: /dev/vda: File system size 4096 bytes is too small, 256M is required at least
guestfsd: main_loop: proc 278 (mkfs_opts) took 0.00 seconds
libguestfs: recv_from_daemon: 132 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 16 | 00 00 00 01 | 00 12 34 0e | ...
libguestfs: error: mkfs_opts: btrfs: /dev/vda: File system size 4096 bytes is too small, 256M is required at least

--------could succeed with ext4 with customize value
><fs> mkfs-opts ext4  /dev/vda blocksize:4096
libguestfs: send_to_daemon: 80 bytes: 00 00 00 4c | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 16 | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x4c
mke2fs -t ext4 -F -b 4096 /dev/vda
mke2fs 1.41.12 (17-May-2010)
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 16 | 00 00 00 01 | 00 12 34 0f | ...

------could succeed with mkfs with the default value

><fs> mkfs btrfs /dev/vda
libguestfs: send_to_daemon: 68 bytes: 00 00 00 40 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 2a | 00 00 00 00 | ...
guestfsd: main_loop: proc 278 (mkfs_opts) took 2.27 seconds
guestfsd: main_loop: new request, len 0x40
mkfs -t btrfs /dev/vda



Version-Release number of selected component (if applicable):
libguestfs-1.16.12-1.el6.x86_64


How reproducible:
always

Steps to Reproduce:
1.mkfs-opts btrfs blocksize:4096 /dev/vda
2.
3.
  
Actual results:


Expected results:
mkfs-opts could create btrfs filesystem succeed with blocksize value, 



Additional info:

Comment 6 Richard W.M. Jones 2012-03-29 08:39:12 UTC
Putting back to 6.3.  As Mohua Li says, we need to fix this.

For a future feature, we should add a 'mkbtrfs' call which
contains all the specific parameters for btrfs (compare to
the various mke2fs calls:
http://libguestfs.org/guestfs.3.html#guestfs_mke2fs_J)

Comment 7 Richard W.M. Jones 2012-04-02 07:40:09 UTC
One-line reproducer:

$ guestfish -N disk mkfs-opts btrfs /dev/sda blocksize:1024
libguestfs: error: mkfs_opts: btrfs: /dev/vda: File system size 1024 bytes is too small, 256M is required at least

Comment 8 Richard W.M. Jones 2012-04-02 09:16:42 UTC
Patches posted:

https://www.redhat.com/archives/libguestfs/2012-April/msg00006.html

Only the first patch would be included in RHEL.

Comment 9 Richard W.M. Jones 2012-04-02 14:04:46 UTC
Fix is included in libguestfs-1.16.14-1.el6.

Comment 10 Mohua Li 2012-04-05 02:51:21 UTC
libguestfs-1.16.15-1.el6


as just included the first patch which just disallow the blocks option for btrfs filesystem, and i didn't see any side effect for other filesystem so far, 


[root@dhcp-93-131 RHEL-Server-6.0]# guestfish -N disk mkfs-opts btrfs /dev/sda blocksize:1024
libguestfs: error: mkfs_opts: blocksize cannot be set on btrfs filesystems
[root@dhcp-93-131 RHEL-Server-6.0]# guestfish -N disk mkfs-opts ext4 /dev/sda blocksize:1024

Comment 11 Richard W.M. Jones 2012-04-26 13:46:05 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed.

Comment 13 errata-xmlrpc 2012-06-20 07:01:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0774.html