Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1387047

[PATCH] block: partitions: efi: Always check for alternative GPT at end of drive

From Julius Werner <jwerner@chromium.org>
Newsgroups linux.kernel
Subject [PATCH] block: partitions: efi: Always check for alternative GPT at end of drive
Date 2016-04-26 03:10 +0200
Message-ID <rrZFM-7e1-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The GUID Partiton Table layout maintains two synonymous partition tables
on a block device, one starting in sector 1 and one in the very last
sectors of the block device. This is useful if one of the tables gets
accidentally corrupted (e.g. through a partial write because of an
unexpected power loss).

Linux normally only boots if the primary GPT is valid. It will not even
try to find the alternative GPT to an invalid primary one unless the
"gpt" command line option forces more aggressive detection. This doesn't
really make any sense... if the "gpt" option is not set, the code
validates the protective or hybrid MBR in sector 0 anyway before it even
starts looking for the actual GPTs. If we get to the point where a valid
proctective or hybrid MBR was found but the primary GPT was not found
(valid), checking the alternative GPT is our best bet: we know that this
block device is meant to use GPT (because any other partitioning system
would've presumably overwritten sector 0), and we know that if the
alternative GPT is valid it should contain more accurate information
than parsing the protective/hybrid MBR with msdos_partition() would
yield (which would otherwise be what happens next).

Signed-off-by: Julius Werner <jwerner@chromium.org>
---
 block/partitions/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 26cb624..0d4ca8e 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -625,7 +625,7 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
 		good_agpt = is_gpt_valid(state,
 					 le64_to_cpu(pgpt->alternate_lba),
 					 &agpt, &aptes);
-        if (!good_agpt && force_gpt)
+        if (!good_agpt)
                 good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
 
         /* The obviously unsuccessful case */
-- 
2.1.2

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] block: partitions: efi: Always check for alternative GPT at end of drive Julius Werner <jwerner@chromium.org> - 2016-04-26 03:10 +0200
  Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Karel Zak <kzak@redhat.com> - 2016-04-26 12:30 +0200
    Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Davidlohr Bueso <dave@stgolabs.net> - 2016-04-26 20:40 +0200
      Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Julius Werner <jwerner@chromium.org> - 2016-04-26 22:20 +0200
      RE: [PATCH] block: partitions: efi: Always check for alternative  GPT at end of drive "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2016-04-26 22:40 +0200
        Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Davidlohr Bueso <dave@stgolabs.net> - 2016-04-26 23:20 +0200
          Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Gwendal Grignou <gwendal@chromium.org> - 2016-04-27 00:00 +0200
            Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Karel Zak <kzak@redhat.com> - 2016-04-27 17:10 +0200
              Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Doug Anderson <dianders@chromium.org> - 2016-04-27 17:50 +0200
              Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Julius Werner <jwerner@chromium.org> - 2016-04-27 23:50 +0200
        Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-27 08:10 +0200
          Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-04-27 15:10 +0200
  Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-04-26 16:40 +0200
    Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive Davidlohr Bueso <dave@stgolabs.net> - 2016-04-26 20:20 +0200
      Re: [PATCH] block: partitions: efi: Always check for alternative GPT  at end of drive "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-04-26 21:30 +0200

csiph-web