From nobody@FreeBSD.org  Mon Apr  1 08:38:35 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 884A3B27
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Apr 2013 08:38:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 79D2D934
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Apr 2013 08:38:35 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r318cX85024431
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 1 Apr 2013 08:38:33 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r318cXsQ024430;
	Mon, 1 Apr 2013 08:38:33 GMT
	(envelope-from nobody)
Message-Id: <201304010838.r318cXsQ024430@red.freebsd.org>
Date: Mon, 1 Apr 2013 08:38:33 GMT
From: "Ralf Wenk <"<iz-rpi03@hs-karlsruhe.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: tunefs(8) and mount(8) can not access a newfs(8)'d filesystem (clang, EABI).
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177538
>Category:       arm
>Synopsis:       tunefs(8) and mount(8) can not access a newfs(8)'d filesystem (clang, EABI).
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 01 08:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Thu Aug  8 00:10:00 UTC 2013
>Originator:     Ralf Wenk
>Release:        FreeBSD 10.0-CURRENT arm
>Organization:
Hochschule Karlsruhe, University of Applied Sciences
>Environment:
FreeBSD raspberry-pi 10.0-CURRENT FreeBSD 10.0-CURRENT #2 r248943: Sun Mar 31 15:30:18 CEST 2013     root@home:/usr/obj/arm.armv6/home/rpi/src/sys/RPI-Bsc  arm
>Description:
It looks like there is a reproduceable problem with geom when creating/accessing
a ufs using clang and EABI.

newfs(8) creates a filesystem, but tunefs(8) and mount(8) can not use it.

The problem shows up as:
# tunefs -n enable /dev/mmcsd0s3a
tunefs: /dev/mmcsd0s3a: could not read superblock to fill out disk
# mount /dev/mmcsd0s3a /mnt
mount: /dev/mmcsd0s3a: Invalid argument

Kernel and world are at the same revision.
>How-To-Repeat:
Kernel and world are build on a i386 9.1-STABLE revision 248678 with:

make -C $SRCROOT -DWITH_ARM_EABI kernel-toolchain
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes -DWITH_ARM_EABI buildkernel
make -C $SRCROOT MALLOC_PRODUCTION=yes -DWITH_ARM_EABI buildworld

KERNCONF is RPI-B with serial console enabled (RPI-Bsc).

Initial SD-card layout:
# gpart show
=>      1  7788543  mmcsd0  MBR  (3.7G)
        1       62          - free -  (31k)
       63    65520       1  !12  [active]  (32M)
    65583  2031561       2  freebsd  (992M)
  2097144  5691400          - free -  (2.7G)

=>      0  2031561  mmcsd0s2  BSD  (992M)
        0  2031561         1  freebsd-ufs  (992M)


Now I add a new MBR slice, create a BSD disklabel on it and add a
partition on that. After that I create a new ufs filesystem and try
tunefs(8) and mount(8) on it.

# gpart add -t freebsd mmcsd0
mmcsd0s3 added, but partition is not aligned on 65536 bytes

The alignment warning is caused by the stripesize[1].

# gpart create -s BSD mmcsd0s3
mmcsd0s3 created
# gpart add -t freebsd-ufs mmcsd0s3
mmcsd0s3a added
# newfs /dev/mmcsd0s3a
/dev/mmcsd0s3a: 2778.8MB (5691008 sectors) block size 32768, fragment size 4096
        using 5 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
super-block backups (for fsck -b #) at:
 192, 1282432, 2564672, 3846912, 5129152
# tunefs -n enable /dev/mmcsd0s3a
tunefs: /dev/mmcsd0s3a: could not read superblock to fill out disk
# mount /dev/mmcsd0s3a /mnt
mount: /dev/mmcsd0s3a: Invalid argument

Resulting SD-card layout:
# gpart show
=>      1  7788543  mmcsd0  MBR  (3.7G)
        1       62          - free -  (31k)
       63    65520       1  !12  [active]  (32M)
    65583  2031561       2  freebsd  (992M)
  2097144       63          - free -  (31k)
  2097207  5691168       3  freebsd  (2.7G)
  7788375      169          - free -  (84k)

=>      0  2031561  mmcsd0s2  BSD  (992M)
        0  2031561         1  freebsd-ufs  (992M)

=>      0  5691168  mmcsd0s3  BSD  (2.7G)
        0       73            - free -  (36k)
       73  5691008         1  freebsd-ufs  (2.7G)
  5691081       87            - free -  (43k)


Creating the ufs on the i386 system results in a mountable filesystem on the
pi.

[1] # diskinfo -v mmcsd0
mmcsd0
        512             # sectorsize
        3987734528      # mediasize in bytes (3.7G)
        7788544         # mediasize in sectors
        65536           # stripesize
        0               # stripeoffset
                        # Disk ident.
>Fix:


>Release-Note:
>Audit-Trail:

From: Andreas Schwarz <freebsd.asc@strcmp.org>
To: bug-followup@FreeBSD.org, iz-rpi03@hs-karlsruhe.de
Cc:  
Subject: Re: arm/177538: tunefs(8) and mount(8) can not access a
 newfs(8)&#39;d filesystem (clang, EABI).
Date: Thu, 08 Aug 2013 02:02:33 +0200 (CEST)

 The problem is still existing with current head (r254005), seems that newfs is 
 not working correctly. Tunefs and mount can't work with a corrupt ufs structure.
 When doing the newfs at my separate pc, all is fine.
 
>Unformatted:
