Mageia Bugzilla – Attachment 8881 Details for
Bug 20074
Partitions with Type: Empty corrupt the partition table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Patch to avoid race by not telling kernel about changes when it will automatically rescan the table
0002-Don-t-tell-the-kernel-about-partition-table-changes-.patch (text/plain), 3.68 KB, created by
Martin Whitaker
on 2017-01-22 01:56:15 CET
(
hide
)
Description:
Patch to avoid race by not telling kernel about changes when it will automatically rescan the table
Filename:
MIME Type:
Creator:
Martin Whitaker
Created:
2017-01-22 01:56:15 CET
Size:
3.68 KB
patch
obsolete
>From 02694fde878c07e7e2b249f714feb546d9baab3a Mon Sep 17 00:00:00 2001 >From: Martin Whitaker <mageia@martin-whitaker.me.uk> >Date: Sat, 21 Jan 2017 20:00:20 +0000 >Subject: [PATCH 2/4] Don't tell the kernel about partition table changes when > it rescans them automatically (mga#20074). > >When no partitions on a DOS-partitioned disk are mounted, the kernel >automatically rescans the partition table when it is written to disk. >We shouldn't then try to update the kernel's view of the partition >table, as the list of deltas we have recorded is relative to the >previous state of the partition table, not the newly rescanned state. > >The behaviour for other partition table types is unchanged. > >diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm >index 8a85e7d..64908d5 100644 >--- a/perl-install/partition_table.pm >+++ b/perl-install/partition_table.pm >@@ -446,7 +446,7 @@ sub write { > fs::dmraid::call_dmraid('-an'); > fs::dmraid::call_dmraid('-ay'); > } else { >- tell_kernel($hd, $tell_kernel); >+ tell_kernel($hd, $tell_kernel) if $hd->need_to_tell_kernel(); > } > } > # get major/minor again after writing the partition table so that we got them for dynamic devices >diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm >index 678de01..03a0a74 100644 >--- a/perl-install/partition_table/bsd.pm >+++ b/perl-install/partition_table/bsd.pm >@@ -126,6 +126,12 @@ sub end_write { > 1; > } > >+#- TODO does the kernel ever automatically reread a BSD partition table? >+sub need_to_tell_kernel { >+ my ($_hd) = @_; >+ 1; >+} >+ > sub info { > my ($hd) = @_; > my $dtype_scsi = 4; #- taken from fdisk, removed unused one, >diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm >index c56cdab..6833324 100644 >--- a/perl-install/partition_table/dos.pm >+++ b/perl-install/partition_table/dos.pm >@@ -278,6 +278,14 @@ sub end_write { > close $F; > } > >+sub need_to_tell_kernel { >+ my ($hd) = @_; >+ # If none of the partitions are mounted, the kernel will automatically rescan >+ # the partition table. If any partitions are mounted, this doesn't happen, so >+ # we need to tell the kernel what has changed. >+ return any { $_->{isMounted} } partition_table::get_normal_parts($hd); >+} >+ > sub empty_raw { { raw => [ ({}) x $nb_primary ] } } > > sub initialize { >diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm >index df591d5..789f539 100644 >--- a/perl-install/partition_table/gpt.pm >+++ b/perl-install/partition_table/gpt.pm >@@ -126,6 +126,12 @@ sub end_write { > 1; > } > >+#- TODO does the kernel ever automatically reread a GPT partition table? >+sub need_to_tell_kernel { >+ my ($_hd) = @_; >+ 1; >+} >+ > sub initialize { > my ($class, $hd) = @_; > # sync libparted view with diskdrake one in order to prevent overlapping errors when adding partitions: >diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm >index 450c803..986195f 100644 >--- a/perl-install/partition_table/mac.pm >+++ b/perl-install/partition_table/mac.pm >@@ -349,6 +349,12 @@ sub end_write { > 1; > } > >+#- TODO does the kernel ever automatically reread a Mac partition table? >+sub need_to_tell_kernel { >+ my ($_hd) = @_; >+ 1; >+} >+ > sub info { > my ($hd) = @_; > >diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm >index e476d09..8ad952c 100644 >--- a/perl-install/partition_table/sun.pm >+++ b/perl-install/partition_table/sun.pm >@@ -165,6 +165,12 @@ sub end_write { > 1; > } > >+#- TODO does the kernel ever automatically reread a Sun partition table? >+sub need_to_tell_kernel { >+ my ($_hd) = @_; >+ 1; >+} >+ > sub info { > my ($hd) = @_; > >-- >2.10.2
From 02694fde878c07e7e2b249f714feb546d9baab3a Mon Sep 17 00:00:00 2001 From: Martin Whitaker <mageia@martin-whitaker.me.uk> Date: Sat, 21 Jan 2017 20:00:20 +0000 Subject: [PATCH 2/4] Don't tell the kernel about partition table changes when it rescans them automatically (mga#20074). When no partitions on a DOS-partitioned disk are mounted, the kernel automatically rescans the partition table when it is written to disk. We shouldn't then try to update the kernel's view of the partition table, as the list of deltas we have recorded is relative to the previous state of the partition table, not the newly rescanned state. The behaviour for other partition table types is unchanged. diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 8a85e7d..64908d5 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -446,7 +446,7 @@ sub write { fs::dmraid::call_dmraid('-an'); fs::dmraid::call_dmraid('-ay'); } else { - tell_kernel($hd, $tell_kernel); + tell_kernel($hd, $tell_kernel) if $hd->need_to_tell_kernel(); } } # get major/minor again after writing the partition table so that we got them for dynamic devices diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm index 678de01..03a0a74 100644 --- a/perl-install/partition_table/bsd.pm +++ b/perl-install/partition_table/bsd.pm @@ -126,6 +126,12 @@ sub end_write { 1; } +#- TODO does the kernel ever automatically reread a BSD partition table? +sub need_to_tell_kernel { + my ($_hd) = @_; + 1; +} + sub info { my ($hd) = @_; my $dtype_scsi = 4; #- taken from fdisk, removed unused one, diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm index c56cdab..6833324 100644 --- a/perl-install/partition_table/dos.pm +++ b/perl-install/partition_table/dos.pm @@ -278,6 +278,14 @@ sub end_write { close $F; } +sub need_to_tell_kernel { + my ($hd) = @_; + # If none of the partitions are mounted, the kernel will automatically rescan + # the partition table. If any partitions are mounted, this doesn't happen, so + # we need to tell the kernel what has changed. + return any { $_->{isMounted} } partition_table::get_normal_parts($hd); +} + sub empty_raw { { raw => [ ({}) x $nb_primary ] } } sub initialize { diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm index df591d5..789f539 100644 --- a/perl-install/partition_table/gpt.pm +++ b/perl-install/partition_table/gpt.pm @@ -126,6 +126,12 @@ sub end_write { 1; } +#- TODO does the kernel ever automatically reread a GPT partition table? +sub need_to_tell_kernel { + my ($_hd) = @_; + 1; +} + sub initialize { my ($class, $hd) = @_; # sync libparted view with diskdrake one in order to prevent overlapping errors when adding partitions: diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm index 450c803..986195f 100644 --- a/perl-install/partition_table/mac.pm +++ b/perl-install/partition_table/mac.pm @@ -349,6 +349,12 @@ sub end_write { 1; } +#- TODO does the kernel ever automatically reread a Mac partition table? +sub need_to_tell_kernel { + my ($_hd) = @_; + 1; +} + sub info { my ($hd) = @_; diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm index e476d09..8ad952c 100644 --- a/perl-install/partition_table/sun.pm +++ b/perl-install/partition_table/sun.pm @@ -165,6 +165,12 @@ sub end_write { 1; } +#- TODO does the kernel ever automatically reread a Sun partition table? +sub need_to_tell_kernel { + my ($_hd) = @_; + 1; +} + sub info { my ($hd) = @_; -- 2.10.2
View Attachment As Raw
Actions:
View
Attachments on
bug 20074
:
8880
|
8881
|
8882
|
8883
|
8901
|
8906
|
8907
|
8908
|
8909
|
8926
|
8927
|
8972