2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
/* lvm.c - module to read Logical Volumes. */
|
|
|
|
|
/*
|
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
2011-11-12 22:16:48 +00:00
|
|
|
|
* Copyright (C) 2006,2007,2008,2009,2011 Free Software Foundation, Inc.
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-21 23:32:33 +00:00
|
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <grub/dl.h>
|
|
|
|
|
#include <grub/disk.h>
|
|
|
|
|
#include <grub/mm.h>
|
|
|
|
|
#include <grub/err.h>
|
|
|
|
|
#include <grub/misc.h>
|
|
|
|
|
#include <grub/lvm.h>
|
2011-10-28 13:52:15 +00:00
|
|
|
|
#include <grub/partition.h>
|
2011-11-11 20:44:56 +00:00
|
|
|
|
#include <grub/i18n.h>
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2010-04-17 16:58:56 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2010-04-27 15:25:12 +00:00
|
|
|
|
#include <grub/emu/misc.h>
|
2011-04-22 00:46:36 +00:00
|
|
|
|
#include <grub/emu/hostdisk.h>
|
2010-04-17 16:58:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-11 21:01:51 +00:00
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
|
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
struct cache_lv
|
|
|
|
|
{
|
|
|
|
|
struct grub_diskfilter_lv *lv;
|
|
|
|
|
char *cache_pool;
|
|
|
|
|
char *origin;
|
|
|
|
|
struct cache_lv *next;
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
|
|
|
|
/* Go the string STR and return the number after STR. *P will point
|
2008-04-13 12:22:22 +00:00
|
|
|
|
at the number. In case STR is not found, *P will be NULL and the
|
|
|
|
|
return value will be 0. */
|
2012-06-25 15:52:20 +00:00
|
|
|
|
static grub_uint64_t
|
misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.
The typical declarations of these functions follow this pattern:
long
strtol(const char * restrict nptr, char ** restrict endptr, int base);
Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change. (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)
The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.
This patch changes these declarations to follow this pattern instead:
long
strtol(const char * restrict nptr,
const char ** const restrict endptr,
int base);
This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error. (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)
It also means the typical use case changes to:
char *s = ...;
const char *end;
long l;
l = strtol(s, &end, 10);
Or even:
const char *p = str;
while (p && *p) {
long l = strtol(p, &p, 10);
...
}
This fixes 26 places where we discard our attempts at treating the data
safely by doing:
const char *p = str;
long l;
l = strtol(p, (char **)&ptr, 10);
It also adds 5 places where we do:
char *p = str;
while (p && *p) {
long l = strtol(p, (const char ** const)&p, 10);
...
/* more calls that need p not to be pointer-to-const */
}
While moderately distasteful, this is a better problem to have.
With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.
Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions. This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.
The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later). strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.
The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type. Quoting from C99, the
syntax is:
declarator:
pointer[opt] direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
...
direct-declarator [ type-qualifier-list[opt] * ]
...
pointer:
* type-qualifier-list[opt]
* type-qualifier-list[opt] pointer
type-qualifier-list:
type-qualifier
type-qualifier-list type-qualifier
...
type-qualifier:
const
restrict
volatile
So the examples go like:
const char foo; // immutable object
const char *foo; // mutable pointer to object
char * const foo; // immutable pointer to mutable object
const char * const foo; // immutable pointer to immutable object
const char const * const foo; // XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
// pointer to immutable object
const char ** const foo; // immutable pointer to mutable pointer
// to immutable object
Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way. I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.
Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-21 21:39:33 +00:00
|
|
|
|
grub_lvm_getvalue (const char ** const p, const char *str)
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
{
|
2008-04-13 12:22:22 +00:00
|
|
|
|
*p = grub_strstr (*p, str);
|
|
|
|
|
if (! *p)
|
|
|
|
|
return 0;
|
|
|
|
|
*p += grub_strlen (str);
|
2012-06-25 15:52:20 +00:00
|
|
|
|
return grub_strtoull (*p, p, 10);
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-29 17:47:34 +00:00
|
|
|
|
#if 0
|
2010-07-01 21:19:11 +00:00
|
|
|
|
static int
|
|
|
|
|
grub_lvm_checkvalue (char **p, char *str, char *tmpl)
|
|
|
|
|
{
|
|
|
|
|
int tmpllen = grub_strlen (tmpl);
|
|
|
|
|
*p = grub_strstr (*p, str);
|
|
|
|
|
if (! *p)
|
|
|
|
|
return 0;
|
|
|
|
|
*p += grub_strlen (str);
|
|
|
|
|
if (**p != '"')
|
|
|
|
|
return 0;
|
|
|
|
|
return (grub_memcmp (*p + 1, tmpl, tmpllen) == 0 && (*p)[tmpllen + 1] == '"');
|
|
|
|
|
}
|
2011-03-29 17:47:34 +00:00
|
|
|
|
#endif
|
2010-07-01 21:19:11 +00:00
|
|
|
|
|
|
|
|
|
static int
|
misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.
The typical declarations of these functions follow this pattern:
long
strtol(const char * restrict nptr, char ** restrict endptr, int base);
Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change. (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)
The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.
This patch changes these declarations to follow this pattern instead:
long
strtol(const char * restrict nptr,
const char ** const restrict endptr,
int base);
This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error. (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)
It also means the typical use case changes to:
char *s = ...;
const char *end;
long l;
l = strtol(s, &end, 10);
Or even:
const char *p = str;
while (p && *p) {
long l = strtol(p, &p, 10);
...
}
This fixes 26 places where we discard our attempts at treating the data
safely by doing:
const char *p = str;
long l;
l = strtol(p, (char **)&ptr, 10);
It also adds 5 places where we do:
char *p = str;
while (p && *p) {
long l = strtol(p, (const char ** const)&p, 10);
...
/* more calls that need p not to be pointer-to-const */
}
While moderately distasteful, this is a better problem to have.
With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.
Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions. This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.
The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later). strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.
The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type. Quoting from C99, the
syntax is:
declarator:
pointer[opt] direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
...
direct-declarator [ type-qualifier-list[opt] * ]
...
pointer:
* type-qualifier-list[opt]
* type-qualifier-list[opt] pointer
type-qualifier-list:
type-qualifier
type-qualifier-list type-qualifier
...
type-qualifier:
const
restrict
volatile
So the examples go like:
const char foo; // immutable object
const char *foo; // mutable pointer to object
char * const foo; // immutable pointer to mutable object
const char * const foo; // immutable pointer to immutable object
const char const * const foo; // XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
// pointer to immutable object
const char ** const foo; // immutable pointer to mutable pointer
// to immutable object
Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way. I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.
Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-21 21:39:33 +00:00
|
|
|
|
grub_lvm_check_flag (const char *p, const char *str, const char *flag)
|
2010-07-01 21:19:11 +00:00
|
|
|
|
{
|
2013-12-21 13:15:04 +00:00
|
|
|
|
grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag);
|
2010-07-01 21:19:11 +00:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.
The typical declarations of these functions follow this pattern:
long
strtol(const char * restrict nptr, char ** restrict endptr, int base);
Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change. (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)
The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.
This patch changes these declarations to follow this pattern instead:
long
strtol(const char * restrict nptr,
const char ** const restrict endptr,
int base);
This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error. (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)
It also means the typical use case changes to:
char *s = ...;
const char *end;
long l;
l = strtol(s, &end, 10);
Or even:
const char *p = str;
while (p && *p) {
long l = strtol(p, &p, 10);
...
}
This fixes 26 places where we discard our attempts at treating the data
safely by doing:
const char *p = str;
long l;
l = strtol(p, (char **)&ptr, 10);
It also adds 5 places where we do:
char *p = str;
while (p && *p) {
long l = strtol(p, (const char ** const)&p, 10);
...
/* more calls that need p not to be pointer-to-const */
}
While moderately distasteful, this is a better problem to have.
With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.
Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions. This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.
The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later). strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.
The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type. Quoting from C99, the
syntax is:
declarator:
pointer[opt] direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
...
direct-declarator [ type-qualifier-list[opt] * ]
...
pointer:
* type-qualifier-list[opt]
* type-qualifier-list[opt] pointer
type-qualifier-list:
type-qualifier
type-qualifier-list type-qualifier
...
type-qualifier:
const
restrict
volatile
So the examples go like:
const char foo; // immutable object
const char *foo; // mutable pointer to object
char * const foo; // immutable pointer to mutable object
const char * const foo; // immutable pointer to immutable object
const char const * const foo; // XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
// pointer to immutable object
const char ** const foo; // immutable pointer to mutable pointer
// to immutable object
Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way. I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.
Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-21 21:39:33 +00:00
|
|
|
|
const char *q;
|
2010-07-01 21:19:11 +00:00
|
|
|
|
p = grub_strstr (p, str);
|
|
|
|
|
if (! p)
|
|
|
|
|
return 0;
|
|
|
|
|
p += len_str;
|
|
|
|
|
if (grub_memcmp (p, " = [", sizeof (" = [") - 1) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
q = p + sizeof (" = [") - 1;
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
while (grub_isspace (*q))
|
|
|
|
|
q++;
|
|
|
|
|
if (*q != '"')
|
|
|
|
|
return 0;
|
|
|
|
|
q++;
|
|
|
|
|
if (grub_memcmp (q, flag, len_flag) == 0 && q[len_flag] == '"')
|
|
|
|
|
return 1;
|
|
|
|
|
while (*q != '"')
|
|
|
|
|
q++;
|
|
|
|
|
q++;
|
|
|
|
|
if (*q == ']')
|
|
|
|
|
return 0;
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
static void
|
|
|
|
|
grub_lvm_free_cache_lvs (struct cache_lv *cache_lvs)
|
|
|
|
|
{
|
|
|
|
|
struct cache_lv *cache;
|
|
|
|
|
|
|
|
|
|
while ((cache = cache_lvs))
|
|
|
|
|
{
|
|
|
|
|
cache_lvs = cache_lvs->next;
|
|
|
|
|
|
|
|
|
|
if (cache->lv)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < cache->lv->segment_count; ++i)
|
|
|
|
|
if (cache->lv->segments)
|
|
|
|
|
grub_free (cache->lv->segments[i].nodes);
|
|
|
|
|
grub_free (cache->lv->segments);
|
|
|
|
|
grub_free (cache->lv->fullname);
|
|
|
|
|
grub_free (cache->lv->idname);
|
|
|
|
|
grub_free (cache->lv->name);
|
|
|
|
|
}
|
|
|
|
|
grub_free (cache->lv);
|
|
|
|
|
grub_free (cache->origin);
|
|
|
|
|
grub_free (cache->cache_pool);
|
|
|
|
|
grub_free (cache);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
static struct grub_diskfilter_vg *
|
|
|
|
|
grub_lvm_detect (grub_disk_t disk,
|
|
|
|
|
struct grub_diskfilter_pv_id *id,
|
|
|
|
|
grub_disk_addr_t *start_sector)
|
2011-07-07 21:21:59 +00:00
|
|
|
|
{
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_err_t err;
|
|
|
|
|
grub_uint64_t mda_offset, mda_size;
|
|
|
|
|
char buf[GRUB_LVM_LABEL_SIZE];
|
|
|
|
|
char vg_id[GRUB_LVM_ID_STRLEN+1];
|
|
|
|
|
char pv_id[GRUB_LVM_ID_STRLEN+1];
|
misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.
The typical declarations of these functions follow this pattern:
long
strtol(const char * restrict nptr, char ** restrict endptr, int base);
Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change. (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)
The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.
This patch changes these declarations to follow this pattern instead:
long
strtol(const char * restrict nptr,
const char ** const restrict endptr,
int base);
This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error. (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)
It also means the typical use case changes to:
char *s = ...;
const char *end;
long l;
l = strtol(s, &end, 10);
Or even:
const char *p = str;
while (p && *p) {
long l = strtol(p, &p, 10);
...
}
This fixes 26 places where we discard our attempts at treating the data
safely by doing:
const char *p = str;
long l;
l = strtol(p, (char **)&ptr, 10);
It also adds 5 places where we do:
char *p = str;
while (p && *p) {
long l = strtol(p, (const char ** const)&p, 10);
...
/* more calls that need p not to be pointer-to-const */
}
While moderately distasteful, this is a better problem to have.
With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.
Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions. This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.
The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later). strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.
The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type. Quoting from C99, the
syntax is:
declarator:
pointer[opt] direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
...
direct-declarator [ type-qualifier-list[opt] * ]
...
pointer:
* type-qualifier-list[opt]
* type-qualifier-list[opt] pointer
type-qualifier-list:
type-qualifier
type-qualifier-list type-qualifier
...
type-qualifier:
const
restrict
volatile
So the examples go like:
const char foo; // immutable object
const char *foo; // mutable pointer to object
char * const foo; // immutable pointer to mutable object
const char * const foo; // immutable pointer to immutable object
const char const * const foo; // XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
// pointer to immutable object
const char ** const foo; // immutable pointer to mutable pointer
// to immutable object
Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way. I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.
Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-21 21:39:33 +00:00
|
|
|
|
char *metadatabuf, *vgname;
|
|
|
|
|
const char *p, *q;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf;
|
|
|
|
|
struct grub_lvm_pv_header *pvh;
|
|
|
|
|
struct grub_lvm_disk_locn *dlocn;
|
|
|
|
|
struct grub_lvm_mda_header *mdah;
|
|
|
|
|
struct grub_lvm_raw_locn *rlocn;
|
2013-12-21 13:15:04 +00:00
|
|
|
|
unsigned int i, j;
|
|
|
|
|
grub_size_t vgname_len;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
struct grub_diskfilter_vg *vg;
|
|
|
|
|
struct grub_diskfilter_pv *pv;
|
|
|
|
|
|
|
|
|
|
/* Search for label. */
|
|
|
|
|
for (i = 0; i < GRUB_LVM_LABEL_SCAN_SECTORS; i++)
|
2011-07-07 21:21:59 +00:00
|
|
|
|
{
|
2012-01-29 13:28:01 +00:00
|
|
|
|
err = grub_disk_read (disk, i, 0, sizeof(buf), buf);
|
|
|
|
|
if (err)
|
|
|
|
|
goto fail;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if ((! grub_strncmp ((char *)lh->id, GRUB_LVM_LABEL_ID,
|
|
|
|
|
sizeof (lh->id)))
|
|
|
|
|
&& (! grub_strncmp ((char *)lh->type, GRUB_LVM_LVM2_LABEL,
|
|
|
|
|
sizeof (lh->type))))
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* Return if we didn't find a label. */
|
|
|
|
|
if (i == GRUB_LVM_LABEL_SCAN_SECTORS)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_util_info ("no LVM signature found");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
pvh = (struct grub_lvm_pv_header *) (buf + grub_le_to_cpu32(lh->offset_xl));
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
for (i = 0, j = 0; i < GRUB_LVM_ID_LEN; i++)
|
|
|
|
|
{
|
|
|
|
|
pv_id[j++] = pvh->pv_uuid[i];
|
|
|
|
|
if ((i != 1) && (i != 29) && (i % 4 == 1))
|
|
|
|
|
pv_id[j++] = '-';
|
|
|
|
|
}
|
|
|
|
|
pv_id[j] = '\0';
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
dlocn = pvh->disk_areas_xl;
|
|
|
|
|
|
|
|
|
|
dlocn++;
|
|
|
|
|
/* Is it possible to have multiple data/metadata areas? I haven't
|
|
|
|
|
seen devices that have it. */
|
|
|
|
|
if (dlocn->offset)
|
|
|
|
|
{
|
|
|
|
|
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
|
|
|
|
"we don't support multiple LVM data areas");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("we don't support multiple LVM data areas");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
dlocn++;
|
|
|
|
|
mda_offset = grub_le_to_cpu64 (dlocn->offset);
|
|
|
|
|
mda_size = grub_le_to_cpu64 (dlocn->size);
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* It's possible to have multiple copies of metadata areas, we just use the
|
|
|
|
|
first one. */
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* Allocate buffer space for the circular worst-case scenario. */
|
2020-06-15 16:26:01 +00:00
|
|
|
|
metadatabuf = grub_calloc (2, mda_size);
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (! metadatabuf)
|
|
|
|
|
goto fail;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
err = grub_disk_read (disk, 0, mda_offset, mda_size, metadatabuf);
|
|
|
|
|
if (err)
|
|
|
|
|
goto fail2;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
mdah = (struct grub_lvm_mda_header *) metadatabuf;
|
|
|
|
|
if ((grub_strncmp ((char *)mdah->magic, GRUB_LVM_FMTT_MAGIC,
|
|
|
|
|
sizeof (mdah->magic)))
|
|
|
|
|
|| (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION))
|
|
|
|
|
{
|
|
|
|
|
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
|
|
|
|
"unknown LVM metadata header");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown LVM metadata header");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail2;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
rlocn = mdah->raw_locns;
|
|
|
|
|
if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) >
|
|
|
|
|
grub_le_to_cpu64 (mdah->size))
|
|
|
|
|
{
|
|
|
|
|
/* Metadata is circular. Copy the wrap in place. */
|
|
|
|
|
grub_memcpy (metadatabuf + mda_size,
|
|
|
|
|
metadatabuf + GRUB_LVM_MDA_HEADER_SIZE,
|
|
|
|
|
grub_le_to_cpu64 (rlocn->offset) +
|
|
|
|
|
grub_le_to_cpu64 (rlocn->size) -
|
|
|
|
|
grub_le_to_cpu64 (mdah->size));
|
|
|
|
|
}
|
|
|
|
|
p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset);
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
while (*q != ' ' && q < metadatabuf + mda_size)
|
|
|
|
|
q++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (q == metadatabuf + mda_size)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("error parsing metadata");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail2;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
vgname_len = q - p;
|
|
|
|
|
vgname = grub_malloc (vgname_len + 1);
|
|
|
|
|
if (!vgname)
|
|
|
|
|
goto fail2;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_memcpy (vgname, p, vgname_len);
|
|
|
|
|
vgname[vgname_len] = '\0';
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (q, "id = \"");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("couldn't find ID");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail3;
|
|
|
|
|
}
|
|
|
|
|
p += sizeof ("id = \"") - 1;
|
|
|
|
|
grub_memcpy (vg_id, p, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
vg_id[GRUB_LVM_ID_STRLEN] = '\0';
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
vg = grub_diskfilter_get_vg_by_uuid (GRUB_LVM_ID_STRLEN, vg_id);
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (! vg)
|
|
|
|
|
{
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
struct cache_lv *cache_lvs = NULL;
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* First time we see this volume group. We've to create the
|
|
|
|
|
whole volume group structure. */
|
|
|
|
|
vg = grub_malloc (sizeof (*vg));
|
|
|
|
|
if (! vg)
|
2011-07-07 21:21:59 +00:00
|
|
|
|
goto fail3;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
vg->name = vgname;
|
|
|
|
|
vg->uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
|
|
|
|
|
if (! vg->uuid)
|
|
|
|
|
goto fail3;
|
|
|
|
|
grub_memcpy (vg->uuid, vg_id, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
vg->uuid_len = GRUB_LVM_ID_STRLEN;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
vg->extent_size = grub_lvm_getvalue (&p, "extent_size = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown extent size");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
vg->lvs = NULL;
|
|
|
|
|
vg->pvs = NULL;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "physical_volumes {");
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
p += sizeof ("physical_volumes {") - 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* Add all the pvs to the volume group. */
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2013-12-21 13:15:04 +00:00
|
|
|
|
grub_ssize_t s;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
while (grub_isspace (*p))
|
|
|
|
|
p++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (*p == '}')
|
|
|
|
|
break;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
pv = grub_zalloc (sizeof (*pv));
|
|
|
|
|
q = p;
|
|
|
|
|
while (*q != ' ')
|
|
|
|
|
q++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
s = q - p;
|
|
|
|
|
pv->name = grub_malloc (s + 1);
|
|
|
|
|
grub_memcpy (pv->name, p, s);
|
|
|
|
|
pv->name[s] = '\0';
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "id = \"");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
goto pvs_fail;
|
|
|
|
|
p += sizeof("id = \"") - 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
pv->id.uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
|
|
|
|
|
if (!pv->id.uuid)
|
|
|
|
|
goto pvs_fail;
|
|
|
|
|
grub_memcpy (pv->id.uuid, p, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
pv->id.uuidlen = GRUB_LVM_ID_STRLEN;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
pv->start_sector = grub_lvm_getvalue (&p, "pe_start = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown pe_start");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto pvs_fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strchr (p, '}');
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("error parsing pe_start");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto pvs_fail;
|
|
|
|
|
}
|
|
|
|
|
p++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
pv->disk = NULL;
|
|
|
|
|
pv->next = vg->pvs;
|
|
|
|
|
vg->pvs = pv;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
continue;
|
|
|
|
|
pvs_fail:
|
|
|
|
|
grub_free (pv->name);
|
|
|
|
|
grub_free (pv);
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2014-04-10 13:42:41 +00:00
|
|
|
|
p = grub_strstr (p, "logical_volumes {");
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (p)
|
|
|
|
|
{
|
2014-04-10 13:42:41 +00:00
|
|
|
|
p += sizeof ("logical_volumes {") - 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* And add all the lvs to the volume group. */
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2013-12-21 13:15:04 +00:00
|
|
|
|
grub_ssize_t s;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
int skip_lv = 0;
|
|
|
|
|
struct grub_diskfilter_lv *lv;
|
|
|
|
|
struct grub_diskfilter_segment *seg;
|
|
|
|
|
int is_pvmove;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
while (grub_isspace (*p))
|
|
|
|
|
p++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (*p == '}')
|
|
|
|
|
break;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv = grub_zalloc (sizeof (*lv));
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
q = p;
|
|
|
|
|
while (*q != ' ')
|
|
|
|
|
q++;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
s = q - p;
|
|
|
|
|
lv->name = grub_strndup (p, s);
|
|
|
|
|
if (!lv->name)
|
|
|
|
|
goto lvs_fail;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const char *iptr;
|
|
|
|
|
char *optr;
|
|
|
|
|
lv->fullname = grub_malloc (sizeof ("lvm/") - 1 + 2 * vgname_len
|
|
|
|
|
+ 1 + 2 * s + 1);
|
|
|
|
|
if (!lv->fullname)
|
2011-07-07 21:21:59 +00:00
|
|
|
|
goto lvs_fail;
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_memcpy (lv->fullname, "lvm/", sizeof ("lvm/") - 1);
|
|
|
|
|
optr = lv->fullname + sizeof ("lvm/") - 1;
|
|
|
|
|
for (iptr = vgname; iptr < vgname + vgname_len; iptr++)
|
|
|
|
|
{
|
|
|
|
|
*optr++ = *iptr;
|
|
|
|
|
if (*iptr == '-')
|
|
|
|
|
*optr++ = '-';
|
|
|
|
|
}
|
|
|
|
|
*optr++ = '-';
|
|
|
|
|
for (iptr = p; iptr < p + s; iptr++)
|
|
|
|
|
{
|
|
|
|
|
*optr++ = *iptr;
|
|
|
|
|
if (*iptr == '-')
|
|
|
|
|
*optr++ = '-';
|
|
|
|
|
}
|
|
|
|
|
*optr++ = 0;
|
2013-09-20 18:37:03 +00:00
|
|
|
|
lv->idname = grub_malloc (sizeof ("lvmid/")
|
|
|
|
|
+ 2 * GRUB_LVM_ID_STRLEN + 1);
|
|
|
|
|
if (!lv->idname)
|
|
|
|
|
goto lvs_fail;
|
|
|
|
|
grub_memcpy (lv->idname, "lvmid/",
|
|
|
|
|
sizeof ("lvmid/") - 1);
|
|
|
|
|
grub_memcpy (lv->idname + sizeof ("lvmid/") - 1,
|
|
|
|
|
vg_id, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
lv->idname[sizeof ("lvmid/") - 1 + GRUB_LVM_ID_STRLEN] = '/';
|
|
|
|
|
|
|
|
|
|
p = grub_strstr (q, "id = \"");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("couldn't find ID");
|
2013-09-20 18:37:03 +00:00
|
|
|
|
#endif
|
|
|
|
|
goto lvs_fail;
|
|
|
|
|
}
|
|
|
|
|
p += sizeof ("id = \"") - 1;
|
|
|
|
|
grub_memcpy (lv->idname + sizeof ("lvmid/") - 1
|
|
|
|
|
+ GRUB_LVM_ID_STRLEN + 1,
|
|
|
|
|
p, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
lv->idname[sizeof ("lvmid/") - 1 + 2 * GRUB_LVM_ID_STRLEN + 1] = '\0';
|
2012-01-29 13:28:01 +00:00
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv->size = 0;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv->visible = grub_lvm_check_flag (p, "status", "VISIBLE");
|
|
|
|
|
is_pvmove = grub_lvm_check_flag (p, "status", "PVMOVE");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv->segment_count = grub_lvm_getvalue (&p, "segment_count = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown segment_count");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_fail;
|
|
|
|
|
}
|
2020-06-15 16:26:01 +00:00
|
|
|
|
lv->segments = grub_calloc (lv->segment_count, sizeof (*seg));
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg = lv->segments;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
for (i = 0; i < lv->segment_count; i++)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "segment");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown segment");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg->start_extent = grub_lvm_getvalue (&p, "start_extent = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown start_extent");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
|
|
|
|
seg->extent_count = grub_lvm_getvalue (&p, "extent_count = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown extent_count");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
|
|
|
|
goto lvs_segment_fail;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "type = \"");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
p += sizeof("type = \"") - 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv->size += seg->extent_count * vg->extent_size;
|
|
|
|
|
|
|
|
|
|
if (grub_memcmp (p, "striped\"",
|
|
|
|
|
sizeof ("striped\"") - 1) == 0)
|
|
|
|
|
{
|
|
|
|
|
struct grub_diskfilter_node *stripe;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg->type = GRUB_DISKFILTER_STRIPED;
|
|
|
|
|
seg->node_count = grub_lvm_getvalue (&p, "stripe_count = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown stripe_count");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (seg->node_count != 1)
|
|
|
|
|
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2020-06-15 16:26:01 +00:00
|
|
|
|
seg->nodes = grub_calloc (seg->node_count,
|
|
|
|
|
sizeof (*stripe));
|
2012-01-29 13:28:01 +00:00
|
|
|
|
stripe = seg->nodes;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "stripes = [");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown stripes");
|
2011-07-07 21:21:59 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_segment_fail2;
|
|
|
|
|
}
|
|
|
|
|
p += sizeof("stripes = [") - 1;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < seg->node_count; j++)
|
|
|
|
|
{
|
|
|
|
|
p = grub_strchr (p, '"');
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
q = ++p;
|
|
|
|
|
while (*q != '"')
|
|
|
|
|
q++;
|
|
|
|
|
|
|
|
|
|
s = q - p;
|
|
|
|
|
|
|
|
|
|
stripe->name = grub_malloc (s + 1);
|
|
|
|
|
if (stripe->name == NULL)
|
2011-07-07 21:21:59 +00:00
|
|
|
|
goto lvs_segment_fail2;
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_memcpy (stripe->name, p, s);
|
|
|
|
|
stripe->name[s] = '\0';
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = q + 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
stripe->start = grub_lvm_getvalue (&p, ",")
|
|
|
|
|
* vg->extent_size;
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
stripe++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (grub_memcmp (p, "mirror\"", sizeof ("mirror\"") - 1)
|
|
|
|
|
== 0)
|
|
|
|
|
{
|
|
|
|
|
seg->type = GRUB_DISKFILTER_MIRROR;
|
|
|
|
|
seg->node_count = grub_lvm_getvalue (&p, "mirror_count = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown mirror_count");
|
2012-01-29 13:28:01 +00:00
|
|
|
|
#endif
|
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
|
|
|
|
|
* seg->node_count);
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "mirrors = [");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown mirrors");
|
2012-01-29 13:28:01 +00:00
|
|
|
|
#endif
|
|
|
|
|
goto lvs_segment_fail2;
|
|
|
|
|
}
|
|
|
|
|
p += sizeof("mirrors = [") - 1;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
for (j = 0; j < seg->node_count; j++)
|
|
|
|
|
{
|
|
|
|
|
char *lvname;
|
2011-07-07 21:21:59 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strchr (p, '"');
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
q = ++p;
|
|
|
|
|
while (*q != '"')
|
|
|
|
|
q++;
|
2011-04-21 22:09:07 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
s = q - p;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lvname = grub_malloc (s + 1);
|
|
|
|
|
if (lvname == NULL)
|
|
|
|
|
goto lvs_segment_fail2;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_memcpy (lvname, p, s);
|
|
|
|
|
lvname[s] = '\0';
|
|
|
|
|
seg->nodes[j].name = lvname;
|
|
|
|
|
p = q + 1;
|
|
|
|
|
}
|
|
|
|
|
/* Only first (original) is ok with in progress pvmove. */
|
|
|
|
|
if (is_pvmove)
|
|
|
|
|
seg->node_count = 1;
|
|
|
|
|
}
|
2015-03-19 18:30:27 +00:00
|
|
|
|
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
|
|
|
|
|
&& ((p[sizeof ("raid") - 1] >= '4'
|
|
|
|
|
&& p[sizeof ("raid") - 1] <= '6')
|
|
|
|
|
|| p[sizeof ("raid") - 1] == '1')
|
2012-01-29 13:28:01 +00:00
|
|
|
|
&& p[sizeof ("raidX") - 1] == '"')
|
|
|
|
|
{
|
|
|
|
|
switch (p[sizeof ("raid") - 1])
|
|
|
|
|
{
|
2015-03-19 18:30:27 +00:00
|
|
|
|
case '1':
|
|
|
|
|
seg->type = GRUB_DISKFILTER_MIRROR;
|
|
|
|
|
break;
|
2012-01-29 13:28:01 +00:00
|
|
|
|
case '4':
|
|
|
|
|
seg->type = GRUB_DISKFILTER_RAID4;
|
|
|
|
|
seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
|
|
|
|
|
break;
|
|
|
|
|
case '5':
|
|
|
|
|
seg->type = GRUB_DISKFILTER_RAID5;
|
|
|
|
|
seg->layout = GRUB_RAID_LAYOUT_LEFT_SYMMETRIC;
|
|
|
|
|
break;
|
|
|
|
|
case '6':
|
|
|
|
|
seg->type = GRUB_DISKFILTER_RAID6;
|
|
|
|
|
seg->layout = (GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC
|
|
|
|
|
| GRUB_RAID_LAYOUT_MUL_FROM_POS);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
seg->node_count = grub_lvm_getvalue (&p, "device_count = ");
|
|
|
|
|
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2008-02-09 10:49:29 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown device_count");
|
2008-02-09 10:49:29 +00:00
|
|
|
|
#endif
|
2012-01-29 13:28:01 +00:00
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
2008-02-09 10:49:29 +00:00
|
|
|
|
|
2015-03-19 18:30:27 +00:00
|
|
|
|
if (seg->type != GRUB_DISKFILTER_MIRROR)
|
2012-01-29 13:28:01 +00:00
|
|
|
|
{
|
2015-03-19 18:30:27 +00:00
|
|
|
|
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
2012-01-29 13:28:01 +00:00
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown stripe_size");
|
2012-01-29 13:28:01 +00:00
|
|
|
|
#endif
|
2015-03-19 18:30:27 +00:00
|
|
|
|
goto lvs_segment_fail;
|
|
|
|
|
}
|
2012-01-29 13:28:01 +00:00
|
|
|
|
}
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
|
|
|
|
|
* seg->node_count);
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
p = grub_strstr (p, "raids = [");
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GRUB_UTIL
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown raids");
|
2012-01-29 13:28:01 +00:00
|
|
|
|
#endif
|
|
|
|
|
goto lvs_segment_fail2;
|
|
|
|
|
}
|
|
|
|
|
p += sizeof("raids = [") - 1;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < seg->node_count; j++)
|
|
|
|
|
{
|
|
|
|
|
char *lvname;
|
|
|
|
|
|
|
|
|
|
p = grub_strchr (p, '"');
|
|
|
|
|
p = p ? grub_strchr (p + 1, '"') : 0;
|
|
|
|
|
p = p ? grub_strchr (p + 1, '"') : 0;
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
q = ++p;
|
|
|
|
|
while (*q != '"')
|
|
|
|
|
q++;
|
|
|
|
|
|
|
|
|
|
s = q - p;
|
|
|
|
|
|
|
|
|
|
lvname = grub_malloc (s + 1);
|
|
|
|
|
if (lvname == NULL)
|
|
|
|
|
goto lvs_segment_fail2;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_memcpy (lvname, p, s);
|
|
|
|
|
lvname[s] = '\0';
|
|
|
|
|
seg->nodes[j].name = lvname;
|
|
|
|
|
p = q + 1;
|
|
|
|
|
}
|
|
|
|
|
if (seg->type == GRUB_DISKFILTER_RAID4)
|
|
|
|
|
{
|
|
|
|
|
char *tmp;
|
|
|
|
|
tmp = seg->nodes[0].name;
|
|
|
|
|
grub_memmove (seg->nodes, seg->nodes + 1,
|
|
|
|
|
sizeof (seg->nodes[0])
|
|
|
|
|
* (seg->node_count - 1));
|
|
|
|
|
seg->nodes[seg->node_count - 1].name = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
else if (grub_memcmp (p, "cache\"",
|
|
|
|
|
sizeof ("cache\"") - 1) == 0)
|
|
|
|
|
{
|
|
|
|
|
struct cache_lv *cache = NULL;
|
|
|
|
|
|
|
|
|
|
char *p2, *p3;
|
|
|
|
|
grub_size_t sz;
|
|
|
|
|
|
|
|
|
|
cache = grub_zalloc (sizeof (*cache));
|
|
|
|
|
if (!cache)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
cache->lv = grub_zalloc (sizeof (*cache->lv));
|
|
|
|
|
if (!cache->lv)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
grub_memcpy (cache->lv, lv, sizeof (*cache->lv));
|
|
|
|
|
|
|
|
|
|
if (lv->fullname)
|
|
|
|
|
{
|
|
|
|
|
cache->lv->fullname = grub_strdup (lv->fullname);
|
|
|
|
|
if (!cache->lv->fullname)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
}
|
|
|
|
|
if (lv->idname)
|
|
|
|
|
{
|
|
|
|
|
cache->lv->idname = grub_strdup (lv->idname);
|
|
|
|
|
if (!cache->lv->idname)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
}
|
|
|
|
|
if (lv->name)
|
|
|
|
|
{
|
|
|
|
|
cache->lv->name = grub_strdup (lv->name);
|
|
|
|
|
if (!cache->lv->name)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skip_lv = 1;
|
|
|
|
|
|
|
|
|
|
p2 = grub_strstr (p, "cache_pool = \"");
|
|
|
|
|
if (!p2)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
p2 = grub_strchr (p2, '"');
|
|
|
|
|
if (!p2)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
p3 = ++p2;
|
|
|
|
|
p3 = grub_strchr (p3, '"');
|
|
|
|
|
if (!p3)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
sz = p3 - p2;
|
|
|
|
|
|
|
|
|
|
cache->cache_pool = grub_malloc (sz + 1);
|
|
|
|
|
if (!cache->cache_pool)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
grub_memcpy (cache->cache_pool, p2, sz);
|
|
|
|
|
cache->cache_pool[sz] = '\0';
|
|
|
|
|
|
|
|
|
|
p2 = grub_strstr (p, "origin = \"");
|
|
|
|
|
if (!p2)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
p2 = grub_strchr (p2, '"');
|
|
|
|
|
if (!p2)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
p3 = ++p2;
|
|
|
|
|
p3 = grub_strchr (p3, '"');
|
|
|
|
|
if (!p3)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
|
|
|
|
|
sz = p3 - p2;
|
|
|
|
|
|
|
|
|
|
cache->origin = grub_malloc (sz + 1);
|
|
|
|
|
if (!cache->origin)
|
|
|
|
|
goto cache_lv_fail;
|
|
|
|
|
grub_memcpy (cache->origin, p2, sz);
|
|
|
|
|
cache->origin[sz] = '\0';
|
|
|
|
|
|
|
|
|
|
cache->next = cache_lvs;
|
|
|
|
|
cache_lvs = cache;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
cache_lv_fail:
|
|
|
|
|
if (cache)
|
|
|
|
|
{
|
|
|
|
|
grub_free (cache->origin);
|
|
|
|
|
grub_free (cache->cache_pool);
|
|
|
|
|
if (cache->lv)
|
|
|
|
|
{
|
|
|
|
|
grub_free (cache->lv->fullname);
|
|
|
|
|
grub_free (cache->lv->idname);
|
|
|
|
|
grub_free (cache->lv->name);
|
|
|
|
|
}
|
|
|
|
|
grub_free (cache->lv);
|
|
|
|
|
grub_free (cache);
|
|
|
|
|
}
|
|
|
|
|
grub_lvm_free_cache_lvs (cache_lvs);
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
2012-01-29 13:28:01 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef GRUB_UTIL
|
|
|
|
|
char *p2;
|
|
|
|
|
p2 = grub_strchr (p, '"');
|
|
|
|
|
if (p2)
|
|
|
|
|
*p2 = 0;
|
2015-05-13 06:47:17 +00:00
|
|
|
|
grub_util_info ("unknown LVM type %s", p);
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (p2)
|
|
|
|
|
*p2 ='"';
|
|
|
|
|
#endif
|
|
|
|
|
/* Found a non-supported type, give up and move on. */
|
|
|
|
|
skip_lv = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-04-03 14:28:14 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
seg++;
|
2011-04-03 14:28:14 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
continue;
|
|
|
|
|
lvs_segment_fail2:
|
|
|
|
|
grub_free (seg->nodes);
|
|
|
|
|
lvs_segment_fail:
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
2011-04-03 14:28:14 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (p != NULL)
|
|
|
|
|
p = grub_strchr (p, '}');
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
goto lvs_fail;
|
|
|
|
|
p += 3;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (skip_lv)
|
|
|
|
|
{
|
|
|
|
|
grub_free (lv->name);
|
|
|
|
|
grub_free (lv);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-03-29 17:47:34 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
lv->vg = vg;
|
|
|
|
|
lv->next = vg->lvs;
|
|
|
|
|
vg->lvs = lv;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
continue;
|
|
|
|
|
lvs_fail:
|
|
|
|
|
grub_free (lv->name);
|
|
|
|
|
grub_free (lv);
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
/* Match lvs. */
|
|
|
|
|
{
|
|
|
|
|
struct grub_diskfilter_lv *lv1;
|
|
|
|
|
struct grub_diskfilter_lv *lv2;
|
|
|
|
|
for (lv1 = vg->lvs; lv1; lv1 = lv1->next)
|
|
|
|
|
for (i = 0; i < lv1->segment_count; i++)
|
|
|
|
|
for (j = 0; j < lv1->segments[i].node_count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (vg->pvs)
|
|
|
|
|
for (pv = vg->pvs; pv; pv = pv->next)
|
|
|
|
|
{
|
|
|
|
|
if (! grub_strcmp (pv->name,
|
|
|
|
|
lv1->segments[i].nodes[j].name))
|
|
|
|
|
{
|
|
|
|
|
lv1->segments[i].nodes[j].pv = pv;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (lv1->segments[i].nodes[j].pv == NULL)
|
|
|
|
|
for (lv2 = vg->lvs; lv2; lv2 = lv2->next)
|
|
|
|
|
if (grub_strcmp (lv2->name,
|
|
|
|
|
lv1->segments[i].nodes[j].name) == 0)
|
|
|
|
|
lv1->segments[i].nodes[j].lv = lv2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
struct cache_lv *cache;
|
|
|
|
|
|
|
|
|
|
for (cache = cache_lvs; cache; cache = cache->next)
|
|
|
|
|
{
|
|
|
|
|
struct grub_diskfilter_lv *lv;
|
|
|
|
|
|
|
|
|
|
for (lv = vg->lvs; lv; lv = lv->next)
|
|
|
|
|
if (grub_strcmp (lv->name, cache->origin) == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (lv)
|
|
|
|
|
{
|
2020-06-15 16:26:01 +00:00
|
|
|
|
cache->lv->segments = grub_calloc (lv->segment_count, sizeof (*lv->segments));
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
if (!cache->lv->segments)
|
|
|
|
|
{
|
|
|
|
|
grub_lvm_free_cache_lvs (cache_lvs);
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
|
|
|
|
grub_memcpy (cache->lv->segments, lv->segments, lv->segment_count * sizeof (*lv->segments));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < lv->segment_count; ++i)
|
|
|
|
|
{
|
|
|
|
|
struct grub_diskfilter_node *nodes = lv->segments[i].nodes;
|
|
|
|
|
grub_size_t node_count = lv->segments[i].node_count;
|
|
|
|
|
|
2020-06-15 16:26:01 +00:00
|
|
|
|
cache->lv->segments[i].nodes = grub_calloc (node_count, sizeof (*nodes));
|
lvm: Add LVM cache logical volume handling
The LVM cache logical volume is the logical volume consisting of the original
and the cache pool logical volume. The original is usually on a larger and
slower storage device while the cache pool is on a smaller and faster one. The
performance of the original volume can be improved by storing the frequently
used data on the cache pool to utilize the greater performance of faster
device.
The default cache mode "writethrough" ensures that any data written will be
stored both in the cache and on the origin LV, therefore grub can be straight
to read the original lv as no data loss is guarenteed.
The second cache mode is "writeback", which delays writing from the cache pool
back to the origin LV to have increased performance. The drawback is potential
data loss if losing the associated cache device.
During the boot time grub reads the LVM offline i.e. LVM volumes are not
activated and mounted, hence it should be fine to read directly from original
lv since all cached data should have been flushed back in the process of taking
it offline.
It is also not much helpful to the situation by adding fsync calls to the
install code. The fsync did not force to write back dirty cache to the original
device and rather it would update associated cache metadata to complete the
write transaction with the cache device. IOW the writes to cached blocks still
go only to the cache device.
To write back dirty cache, as LVM cache did not support dirty cache flush per
block range, there'no way to do it for file. On the other hand the "cleaner"
policy is implemented and can be used to write back "all" dirty blocks in a
cache, which effectively drain all dirty cache gradually to attain and last in
the "clean" state, which can be useful for shrinking or decommissioning a
cache. The result and effect is not what we are looking for here.
In conclusion, as it seems no way to enforce file writes to the original
device, grub may suffer from power failure as it cannot assemble the cache
device and read the dirty data from it. However since the case is only
applicable to writeback mode which is sensitive to data lost in nature, I'd
still like to propose my (relatively simple) patch and treat reading dirty
cache as improvement.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-19 05:56:13 +00:00
|
|
|
|
if (!cache->lv->segments[i].nodes)
|
|
|
|
|
{
|
|
|
|
|
for (j = 0; j < i; ++j)
|
|
|
|
|
grub_free (cache->lv->segments[j].nodes);
|
|
|
|
|
grub_free (cache->lv->segments);
|
|
|
|
|
cache->lv->segments = NULL;
|
|
|
|
|
grub_lvm_free_cache_lvs (cache_lvs);
|
|
|
|
|
goto fail4;
|
|
|
|
|
}
|
|
|
|
|
grub_memcpy (cache->lv->segments[i].nodes, nodes, node_count * sizeof (*nodes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cache->lv->segments)
|
|
|
|
|
{
|
|
|
|
|
cache->lv->segment_count = lv->segment_count;
|
|
|
|
|
cache->lv->vg = vg;
|
|
|
|
|
cache->lv->next = vg->lvs;
|
|
|
|
|
vg->lvs = cache->lv;
|
|
|
|
|
cache->lv = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grub_lvm_free_cache_lvs (cache_lvs);
|
2012-01-29 13:28:01 +00:00
|
|
|
|
if (grub_diskfilter_vg_register (vg))
|
|
|
|
|
goto fail4;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
2012-01-29 13:28:01 +00:00
|
|
|
|
else
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
{
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_free (vgname);
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
2011-04-21 22:09:07 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
id->uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
|
|
|
|
|
if (!id->uuid)
|
|
|
|
|
goto fail4;
|
|
|
|
|
grub_memcpy (id->uuid, pv_id, GRUB_LVM_ID_STRLEN);
|
|
|
|
|
id->uuidlen = GRUB_LVM_ID_STRLEN;
|
|
|
|
|
grub_free (metadatabuf);
|
|
|
|
|
*start_sector = -1;
|
|
|
|
|
return vg;
|
|
|
|
|
|
|
|
|
|
/* Failure path. */
|
|
|
|
|
fail4:
|
|
|
|
|
grub_free (vg);
|
|
|
|
|
fail3:
|
|
|
|
|
grub_free (vgname);
|
|
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
|
grub_free (metadatabuf);
|
|
|
|
|
fail:
|
|
|
|
|
return NULL;
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
static struct grub_diskfilter grub_lvm_dev = {
|
|
|
|
|
.name = "lvm",
|
|
|
|
|
.detect = grub_lvm_detect,
|
|
|
|
|
.next = 0
|
|
|
|
|
};
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
GRUB_MOD_INIT (lvm)
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
{
|
2012-04-18 21:11:33 +00:00
|
|
|
|
grub_diskfilter_register_back (&grub_lvm_dev);
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-29 13:28:01 +00:00
|
|
|
|
GRUB_MOD_FINI (lvm)
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
{
|
2012-01-29 13:28:01 +00:00
|
|
|
|
grub_diskfilter_unregister (&grub_lvm_dev);
|
2006-10-14 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c,
include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h,
include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h,
include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c,
video/readers/tga.c and video/i386/pc/vbeutil.c.
2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx>
Added support for RAID and LVM.
* disk/lvm.c: New file.
* disk/raid.c: Likewise.
* include/grub/lvm.h: Likewise.
* include/grub/raid.h: Likewise.
* include/grub/util/lvm.h: Likewise.
* include/grub/util/raid.h: Likewise.
* util/lvm.c: Likewise.
* util/raid.c: Likewise.
* include/grub/disk.h (grub_disk_dev_id): Add
GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID.
(grub_disk_get_size): New prototype.
* kern/disk.c (grub_disk_open): Check whether grub_partition_probe()
returns a partition.
(grub_disk_get_size): New function.
* kern/i386/pc/init.c (make_install_device): Copy the prefix
verbatim if grub_install_dos_part is -2.
* util/i386/pc/getroot.c (grub_guess_root_device): Support RAID
and LVM devices.
* util/i386/pc/grub-setup.c (setup): New argument
MUST_EMBED. Force embedding of GRUB when the argument is
true. Close FILE before returning.
(main): Add support for RAID and LVM.
* conf/common.rmk: Add RAID and LVM modules.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and
util/lvm.c.
(grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c.
* kern/misc.c (grub_strstr): New function.
* include/grub/misc.h (grub_strstr): New prototype.
2006-10-14 15:24:53 +00:00
|
|
|
|
}
|