LVM2 daemons/lvmetad/lvmetad-core.c lib/cache/ ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2012-03-02 20:46:37
Modified files:
daemons/lvmetad: lvmetad-core.c
lib/cache : lvmetad.c lvmetad.h
lib/format_text: format-text.c
lib/metadata : metadata.c
Log message:
Pass struct device around internally rather than dev_t. Add 3rd daemon return state "unknown" for lookups that are carried out successfully but don't find the item requested.
Avoid issuing error messages when it's expected that a device that's being looked up in lvmetad might not be there.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmetad.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmetad.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.198&r2=1.199
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.496&r2=1.497
daemons/lvmetad/lvmetad-core.c +8 -6
@@ -47,6 +47,7 @@fprintf (stderr,"[D %lu] " ,pthread_self ());vfprintf (stderr, fmt, ap);va_end (ap); +fflush (stderr); }static int debug_cft_line (const char *line,void *baton) {
@@ -412,14 +413,14 @@debug ("pv_lookup: could not find device %" PRIu64"\n" , devt);unlock_pvid_to_pvmeta (s);dm_config_destroy (res.cft); -return daemon_reply_simple ("failed" ,"reason = %s" ,"device not found" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"device not found" ,NULL ); } pv =make_pv_node (s, pvid, res.cft,NULL , res.cft->root);if (!pv) {unlock_pvid_to_pvmeta (s);dm_config_destroy (res.cft); -return daemon_reply_simple ("failed" ,"reason = %s" ,"PV not found" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"PV not found" ,NULL ); } pv->key ="physical_volume" ;
@@ -520,12 +521,12 @@debug ("vg_lookup: updated uuid = %s, name = %s\n" , uuid, name);if (!uuid) -return daemon_reply_simple ("failed" ,"reason = %s" ,"VG not found" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"VG not found" ,NULL ); cft =lock_vg (s, uuid);if (!cft || !cft->root) {unlock_vg (s, uuid); -return daemon_reply_simple ("failed" ,"reason = %s" ,"UUID not found" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"UUID not found" ,NULL ); } metadata = cft->root;
@@ -821,7 +822,7 @@ pvid =dm_hash_lookup_binary (s->device_to_pvid, &device,sizeof (device));if (!pvid) {unlock_pvid_to_pvmeta (s); -return daemon_reply_simple ("failed" ,"reason = %s" ,"device not in cache" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"device not in cache" ,NULL ); }debug ("pv_gone (updated): %s / %" PRIu64"\n" , pvid, device);
@@ -836,7 +837,7 @@dm_config_destroy (pvmeta);return daemon_reply_simple ("OK" ,NULL ); }else -return daemon_reply_simple ("failed" ,"reason = %s" ,"PVID does not exist" ,NULL ); +return daemon_reply_simple ("unknown" ,"reason = %s" ,"PVID does not exist" ,NULL ); }static response pv_found (lvmetad_state *s,request r)
@@ -912,6 +913,7 @@else {unlock_vg (s, vgid);return daemon_reply_simple ("failed" ,"reason = %s" , +// FIXME provide meaningful-to-user error message "internal treason!" ,NULL ); }unlock_vg (s, vgid);
lib/cache/lvmetad.c +91 -38
232 lines not on this page · raw message
lib/cache/lvmetad.h +9 -4
@@ -79,8 +79,13 @@*/ int lvmetad_pv_list_to_lvmcache (struct cmd_context *cmd); -int lvmetad_pv_lookup (struct cmd_context *cmd,struct id pvid); -int lvmetad_pv_lookup_by_devt (struct cmd_context *cmd,dev_t dev); +/* +* Lookup an individual PV. +* If found is not NULL, it is set according to whether or not the PV is found, +* otherwise if the PV is not found an error is returned. +*/ +int lvmetad_pv_lookup (struct cmd_context *cmd,struct id pvid,int *found); +int lvmetad_pv_lookup_by_dev (struct cmd_context *cmd,struct device *dev,int *found);/* * Request a list of all VGs available to lvmetad and use it to fill in
@@ -111,8 +116,8 @@# define lvmetad_pv_found (pvid, device, fmt, label_sector, vg) (1)# define lvmetad_pv_gone (dev) (1)# define lvmetad_pv_list_to_lvmcache (cmd) (1) -# define lvmetad_pv_lookup (cmd, pvid) (0) -# define lvmetad_pv_lookup_by_devt (cmd, dev) (0) +# define lvmetad_pv_lookup (cmd, pvid, found) (0) +# define lvmetad_pv_lookup_by_dev (cmd, dev, found) (0)# define lvmetad_vg_list_to_lvmcache (cmd) (1)# define lvmetad_vg_lookup (cmd, vgname, vgid) (NULL)# define pvscan_lvmetad (cmd, argc, argv) (0)
lib/format_text/format-text.c +1 -1
@@ -1445,7 +1445,7 @@if (lvmetad_active ()) { info =lvmcache_info_from_pvid (dev->pvid,0 ); -if (!info && !lvmetad_pv_lookup_by_devt (fmt->cmd, dev->dev)) +if (!info && !lvmetad_pv_lookup_by_dev (fmt->cmd, dev,NULL ))return 0 ; info =lvmcache_info_from_pvid (dev->pvid,0 ); }else {
lib/metadata/metadata.c +11 -3
@@ -3614,15 +3614,23 @@struct lvmcache_info *info;struct device *dev;const struct format_type *fmt; +int found;if (!(dev =dev_cache_get (pv_name, cmd->filter))) return_NULL;if (lvmetad_active ()) { info =lvmcache_info_from_pvid (dev->pvid,0 ); -// FIXME AGK no error unless 'warnings' set! -if (!info && !lvmetad_pv_lookup_by_devt (cmd, dev->dev)) -return NULL ; +if (!info) { +if (!lvmetad_pv_lookup_by_dev (cmd, dev, &found)) + return_NULL; +if (!found) { +if (warnings) +log_error ("No physical volume found in lvmetad cache for %s" , + pv_name); +return NULL ; + } + } info =lvmcache_info_from_pvid (dev->pvid,0 ); label =lvmcache_get_label (info); }else {