mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Move .cache file into a new /etc/lvm/cache directory by default.
Add devices/cache_dir & devices/cache_file_prefix, deprecating devices/cache. Create directory in fcntl_lock_file() if required.
This commit is contained in:
parent
f359c9b80f
commit
87cec8eb5e
@ -1,5 +1,8 @@
|
|||||||
Version 2.02.23 -
|
Version 2.02.23 -
|
||||||
====================================
|
====================================
|
||||||
|
Move .cache file into a new /etc/lvm/cache directory by default.
|
||||||
|
Add devices/cache_dir & devices/cache_file_prefix, deprecating devices/cache.
|
||||||
|
Create directory in fcntl_lock_file() if required.
|
||||||
Exclude readline support from lvm.static.
|
Exclude readline support from lvm.static.
|
||||||
Fix a leak in a reporting error path (2.02.19).
|
Fix a leak in a reporting error path (2.02.19).
|
||||||
|
|
||||||
|
@ -56,10 +56,14 @@ devices {
|
|||||||
# filter = [ "a|^/dev/hda8$|", "r/.*/" ]
|
# filter = [ "a|^/dev/hda8$|", "r/.*/" ]
|
||||||
|
|
||||||
# The results of the filtering are cached on disk to avoid
|
# The results of the filtering are cached on disk to avoid
|
||||||
# rescanning dud devices (which can take a very long time). By
|
# rescanning dud devices (which can take a very long time).
|
||||||
# default this cache file is hidden in the /etc/lvm directory.
|
# By default this cache is stored in the /etc/lvm/cache directory
|
||||||
# It is safe to delete this file: the tools regenerate it.
|
# in a file called '.cache'.
|
||||||
cache = "/etc/lvm/.cache"
|
# It is safe to delete the contents: the tools regenerate it.
|
||||||
|
# (The old setting 'cache' is still respected if neither of
|
||||||
|
# these new ones is present.)
|
||||||
|
cache_dir = "/etc/lvm/cache"
|
||||||
|
cache_file_prefix = ""
|
||||||
|
|
||||||
# You can turn off writing this cache file by setting this to 0.
|
# You can turn off writing this cache file by setting this to 0.
|
||||||
write_cache_state = 1
|
write_cache_state = 1
|
||||||
|
@ -575,7 +575,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
|
|
||||||
static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
|
static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
|
||||||
{
|
{
|
||||||
const char *dev_cache;
|
const char *dev_cache = NULL, *cache_dir, *cache_file_prefix;
|
||||||
struct dev_filter *f3, *f4;
|
struct dev_filter *f3, *f4;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char cache_file[PATH_MAX];
|
char cache_file[PATH_MAX];
|
||||||
@ -585,19 +585,35 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
|
|||||||
if (!(f3 = _init_filter_components(cmd)))
|
if (!(f3 = _init_filter_components(cmd)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (dm_snprintf(cache_file, sizeof(cache_file),
|
|
||||||
"%s/.cache", cmd->sys_dir) < 0) {
|
|
||||||
log_error("Persistent cache filename too long ('%s/.cache').",
|
|
||||||
cmd->sys_dir);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_ignore_suspended_devices(find_config_tree_int(cmd,
|
init_ignore_suspended_devices(find_config_tree_int(cmd,
|
||||||
"devices/ignore_suspended_devices", DEFAULT_IGNORE_SUSPENDED_DEVICES));
|
"devices/ignore_suspended_devices", DEFAULT_IGNORE_SUSPENDED_DEVICES));
|
||||||
|
|
||||||
dev_cache = find_config_tree_str(cmd, "devices/cache",
|
/*
|
||||||
cache_file);
|
* If 'cache_dir' or 'cache_file_prefix' is set, ignore 'cache'.
|
||||||
if (!(f4 = persistent_filter_create(f3, dev_cache))) {
|
*/
|
||||||
|
cache_dir = find_config_tree_str(cmd, "devices/cache_dir", NULL);
|
||||||
|
cache_file_prefix = find_config_tree_str(cmd, "devices/cache_file_prefix", NULL);
|
||||||
|
|
||||||
|
if (cache_dir || cache_file_prefix) {
|
||||||
|
if (dm_snprintf(cache_file, sizeof(cache_file),
|
||||||
|
"%s%s%s/%s.cache",
|
||||||
|
cache_dir ? "" : cmd->sys_dir,
|
||||||
|
cache_dir ? "" : "/",
|
||||||
|
cache_dir ? : DEFAULT_CACHE_SUBDIR,
|
||||||
|
cache_file_prefix ? : DEFAULT_CACHE_FILE_PREFIX) < 0) {
|
||||||
|
log_error("Persistent cache filename too long.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else if (!(dev_cache = find_config_tree_str(cmd, "devices/cache", NULL)) &&
|
||||||
|
(dm_snprintf(cache_file, sizeof(cache_file),
|
||||||
|
"%s/%s/%s.cache",
|
||||||
|
cmd->sys_dir, DEFAULT_CACHE_SUBDIR,
|
||||||
|
DEFAULT_CACHE_FILE_PREFIX) < 0)) {
|
||||||
|
log_error("Persistent cache filename too long.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(f4 = persistent_filter_create(f3, dev_cache ? : cache_file))) {
|
||||||
log_error("Failed to create persistent device filter");
|
log_error("Failed to create persistent device filter");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#define DEFAULT_ARCHIVE_SUBDIR "archive"
|
#define DEFAULT_ARCHIVE_SUBDIR "archive"
|
||||||
#define DEFAULT_BACKUP_SUBDIR "backup"
|
#define DEFAULT_BACKUP_SUBDIR "backup"
|
||||||
|
#define DEFAULT_CACHE_SUBDIR "cache"
|
||||||
|
#define DEFAULT_CACHE_FILE_PREFIX ""
|
||||||
|
|
||||||
#define DEFAULT_ARCHIVE_DAYS 30
|
#define DEFAULT_ARCHIVE_DAYS 30
|
||||||
#define DEFAULT_ARCHIVE_NUMBER 10
|
#define DEFAULT_ARCHIVE_NUMBER 10
|
||||||
|
@ -256,6 +256,8 @@ void sync_dir(const char *file)
|
|||||||
int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only)
|
int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only)
|
||||||
{
|
{
|
||||||
int lockfd;
|
int lockfd;
|
||||||
|
char *dir;
|
||||||
|
char *c;
|
||||||
struct flock lock = {
|
struct flock lock = {
|
||||||
.l_type = lock_type,
|
.l_type = lock_type,
|
||||||
.l_whence = 0,
|
.l_whence = 0,
|
||||||
@ -263,6 +265,17 @@ int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only)
|
|||||||
.l_len = 0
|
.l_len = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!(dir = dm_strdup(file))) {
|
||||||
|
log_error("fcntl_lock_file failed in strdup.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c = strrchr(dir, '/')))
|
||||||
|
*c = '\0';
|
||||||
|
|
||||||
|
if (!create_dir(dir))
|
||||||
|
return -1;
|
||||||
|
|
||||||
log_very_verbose("Locking %s (%s, %hd)", file,
|
log_very_verbose("Locking %s (%s, %hd)", file,
|
||||||
(lock_type == F_WRLCK) ? "F_WRLCK" : "F_RDLCK",
|
(lock_type == F_WRLCK) ? "F_WRLCK" : "F_RDLCK",
|
||||||
lock_type);
|
lock_type);
|
||||||
|
@ -95,8 +95,8 @@ pattern it is rejected; otherwise it is accepted.
|
|||||||
As an example, to ignore /dev/cdrom you could use:
|
As an example, to ignore /dev/cdrom you could use:
|
||||||
\fBdevices { filter=["r|cdrom|"] }\fP
|
\fBdevices { filter=["r|cdrom|"] }\fP
|
||||||
.IP
|
.IP
|
||||||
\fBcache\fP \(em Persistent filter cache file.
|
\fBcache_dir\fP \(em Persistent filter cache file directory.
|
||||||
Defaults to "/etc/lvm/.cache".
|
Defaults to "/etc/lvm/cache".
|
||||||
.IP
|
.IP
|
||||||
\fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the
|
\fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the
|
||||||
persistent filter cache file when \fBlvm\fP exits.
|
persistent filter cache file when \fBlvm\fP exits.
|
||||||
@ -364,9 +364,9 @@ understand how things work: to make changes you should always use
|
|||||||
the tools as normal, or else vgcfgbackup, edit backup, vgcfgrestore.
|
the tools as normal, or else vgcfgbackup, edit backup, vgcfgrestore.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.I /etc/lvm/lvm.conf
|
.I /etc/lvm/lvm.conf
|
||||||
.I /etc/lvm/.cache
|
|
||||||
.I /etc/lvm/archive
|
.I /etc/lvm/archive
|
||||||
.I /etc/lvm/backup
|
.I /etc/lvm/backup
|
||||||
|
.I /etc/lvm/cache/.cache
|
||||||
.I /var/lock/lvm
|
.I /var/lock/lvm
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR lvm (8),
|
.BR lvm (8),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user