LVM2 ./WHATS_NEW lib/commands/toolcontext.c li ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2006-11-04 03:34:10
Modified files:
. : WHATS_NEW lib/commands : toolcontext.c lib/config : config.c config.h lib/filters : filter-persistent.c filter-persistent.h
lib/format_text: import.c
lib/misc : lvm-file.c lvm-file.h
Log message:
Protect .cache manipulations with fcntl locking. Change .cache timestamp comparisons to use ctime.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.489&r2=1.490
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@ Version 2.02.14 - =================================== + Protect .cache manipulations with fcntl locking. + Change .cache timestamp comparisons to use ctime. Fix mirror log LV writing to set all bits in whole LV. Fix clustered VG detection and default runlevels in clvmd_init_rhel4. Fix high-level free space check for partial allocations.
lib/commands/toolcontext.c +5 -5
@@ -330,7 +330,7 @@return 0 ; } -if (!(cfl->cft =create_config_tree (config_file))) { +if (!(cfl->cft =create_config_tree (config_file,0 ))) {log_error ("config_tree allocation failed" );return 0 ; }
@@ -370,7 +370,7 @@ {/* No config file if LVM_SYSTEM_DIR is empty */ if (!*cmd->sys_dir) { -if (!(cmd->cft =create_config_tree (NULL ))) { +if (!(cmd->cft =create_config_tree (NULL ,0 ))) {log_error ("Failed to create config tree" );return 0 ; }
@@ -408,7 +408,7 @@/* Replace temporary duplicate copy of lvm.conf */ if (cmd->cft->root) { -if (!(cmd->cft =create_config_tree (NULL ))) { +if (!(cmd->cft =create_config_tree (NULL ,0 ))) {log_error ("Failed to create config tree" );return 0 ; }
@@ -609,8 +609,8 @@ cmd->dump_filter =0 ;if (!stat (dev_cache, &st) && - (st.st_mtime >config_file_timestamp (cmd->cft)) && - !persistent_filter_load (f4)) + (st.st_ctime !=config_file_timestamp (cmd->cft)) && + !persistent_filter_load (f4,NULL ))log_verbose ("Failed to load existing device cache from %s" , dev_cache);
lib/config/config.c +24 -15
@@ -58,6 +58,8 @@time_t timestamp;char *filename;int exists; +int keep_open; +struct device *dev; };static void _get_token (struct parser *p,int tok_prev);
@@ -95,7 +97,7 @@/* * public interface */ -struct config_tree *create_config_tree (const char *filename) +struct config_tree *create_config_tree (const char *filename,int keep_open) {struct cs *c;struct dm_pool *mem =dm_pool_create ("config" ,10 *1024 );
@@ -115,6 +117,8 @@ c->cft.root = (struct config_node *)NULL ; c->timestamp =0 ; c->exists =0 ; + c->keep_open = keep_open; + c->dev =0 ;if (filename) c->filename =dm_pool_strdup (c->mem, filename);return &c->cft;
@@ -122,7 +126,12 @@void destroy_config_tree (struct config_tree *cft) { -dm_pool_destroy (((struct cs *) cft)->mem); +struct cs *c = (struct cs *) cft; + +if (c->dev) +dev_close (c->dev); + +dm_pool_destroy (c->mem); }static int _parse_config_file (struct parser *p,struct config_tree *cft)
@@ -143,7 +152,7 @@struct config_tree *cft;struct parser *p; -if (!(cft =create_config_tree (NULL ))) +if (!(cft =create_config_tree (NULL ,0 ))) return_NULL; c = (struct cs *) cft;
@@ -250,7 +259,6 @@ {struct cs *c = (struct cs *) cft;struct stat info; -struct device *dev;int r =1 ;if (stat (c->filename, &info)) {
@@ -272,22 +280,23 @@return 1 ; } -if (!(dev =dev_create_file (c->filename,NULL ,NULL ,1 ))) { - stack; -return 0 ; - } +if (!c->dev) { +if (!(c->dev =dev_create_file (c->filename,NULL ,NULL ,1 ))) + return_0; -if (!dev_open_flags (dev,O_RDONLY ,0 ,0 )) { - stack; -return 0 ; +if (!dev_open_flags (c->dev,O_RDONLY ,0 ,0 )) + return_0; } - r =read_config_fd (cft, dev,0 , (size_t ) info.st_size,0 ,0 , + r =read_config_fd (cft, c->dev,0 , (size_t ) info.st_size,0 ,0 , (checksum_fn_t )NULL ,0 ); -dev_close (dev); +if (!c->keep_open) { +dev_close (c->dev); + c->dev =0 ; + } - c->timestamp = info.st_mtime; + c->timestamp = info.st_ctime;return r; }
@@ -331,7 +340,7 @@ }/* Unchanged? */ -if (c->timestamp == info.st_mtime) +if (c->timestamp == info.st_ctime)return 0 ; reload:
lib/config/config.h +1 -1
@@ -53,7 +53,7 @@struct config_tree *cft; }; -struct config_tree *create_config_tree (const char *filename); +struct config_tree *create_config_tree (const char *filename,int keep_open);struct config_tree *create_config_tree_from_string (struct cmd_context *cmd,const char *config_settings);void destroy_config_tree (struct config_tree *cft);
lib/filters/filter-persistent.c +79 -21
157 lines not on this page · raw message
lib/filters/filter-persistent.h +1 -1
@@ -22,7 +22,7 @@ const char *file);int persistent_filter_wipe (struct dev_filter *f); -int persistent_filter_load (struct dev_filter *f); +int persistent_filter_load (struct dev_filter *f,struct config_tree **cft_out);int persistent_filter_dump (struct dev_filter *f);#endif
lib/format_text/import.c +2 -2
@@ -43,7 +43,7 @@ _text_import_initialised =1 ; } -if (!(cft =create_config_tree (NULL ))) +if (!(cft =create_config_tree (NULL ,0 ))) return_NULL; if ((!dev && !read_config_file(cft)) ||
@@ -94,7 +94,7 @@ *desc =NULL ; *when =0 ; -if (!(cft =create_config_tree (file))) +if (!(cft =create_config_tree (file,0 ))) return_NULL; if ((!dev && !read_config_file(cft)) ||
lib/misc/lvm-file.c +58 -0
61 lines not on this page · raw message
lib/misc/lvm-file.h +4 -0
@@ -48,4 +48,8 @@/* Sync directory changes */ void sync_dir (const char *file); +/* fcntl locking wrappers */ +int fcntl_lock_file (const char *file,short lock_type,int warn_if_read_only); +void fcntl_unlock_file (int lockfd); +#endif