Skip to content
Commit 797f0b8e authored by Mike Fleetwood's avatar Mike Fleetwood Committed by Curtis Gedak
Browse files

Flush device after wiping a file system (#688882)

When just formatting an existing partition to "cleared", GParted just
uses wipefs to clear the file system signatures.  Afterwards parted/
libparted still detect the file system and GParted shows errors from the
file system specific tools reporting the file system doesn't exist.

    # wipefs /dev/sda7
    offset               type
    ----------------------------------------------------------------
    0x0                  xfs   [filesystem]
                         UUID:  28399a74-83a5-4ed7-aaf8-c76ac449fb57
    # wipefs -a /dev/sda7
    4 bytes were erased at offset 0x0 (xfs)
    they were: 58 46 53 42
    # parted /dev/sda print
    Model: ATA SAMSUNG HM500JI (scsi)
    Disk /dev/sda: 500GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type      File system     Flags
     1      1049kB  538MB   537MB   primary   ext4            boot
     2      538MB   5907MB  5369MB  primary   linux-swap(v1)
     3      5907MB  32.8GB  26.8GB  primary   ext4
     4      32.8GB  500GB   467GB   extended
     5      32.8GB  355GB   322GB   logical   ext3
     6      355GB   356GB   1074MB  logical
     7      356GB   357GB   1074MB  logical   xfs
    # xfs_db -c 'sb 0' -c 'print blocksize' -c 'print dblocks' -c 'print fdblocks' -r /dev/sda7
    xfs_db: /dev/sda7 is not a valid XFS filesystem (unexpected SB magic number 0x00000000)

Wipefs was run on the partition specific block device (/dev/sda7) where
as libparted reads the disk using the whole disk device (/dev/sda).
However as the Linux buffer cache does not provide cache coherency, the
xfs file system can still be found in the cache of /dev/sda.

Fix this by calling ped_device_sync() after wipefs as it guarantees
cache coherency.

(As documented in erase_filesystem_signatures() there are cases when
calling ped_device_sync() isn't necessary, but testing shows that the
whole processes takes at most 0.15 seconds.  As this is in the middle of
applying an operation, uses won't notice this extra time so just always
call ped_device_sync()).

Bug #688882 - Improve clearing of file system signatures
parent d4f68eb7
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment