(1/2) new library interface for vg_read
PATCH 1/1 (1/2) new library interface for vg_read
Hi,
this is history-collapsed version of the previous vg_read patches. This portion just adds new APIs (it also contains the fixes proposed in the ongoing review process). Applying this patch should obtain you a compilable and workable version of LVM. The tools are patched to use vg_read_internal, which is just rename of previous vg_read. The followup patch will change those vg_read_internal's to use the new API instead.
Yours,
Petr.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvm2-vg_read-lib.diff
Type: text/x-diff
Size: 22578 bytes
Desc: lvm2-vg_read-lib.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081209/30e8d514/attachment.bin>
-------------- next part --------------
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 (1/2) new library interface for vg_read
Quoted 15 lines · Petr Rockai
/* FIXME: remove redundant
vg_name*/
int vg_remove_single(structcmd_context*cmd, const char*vg_name,(quoted diff) +2
-2- struct volume_group *vg, int consistent, + struct volume_group *vg, force_t force __attribute((unused))) { struct physical_volume *pv;@@ -340,7 +340,7 @@ int vg_remove_single(struct cmd_context unsigned lv_count; int ret = 1; - if (!vg || !consistent || vg_missing_pv_count(vg)) { + if (vg_read_error(vg) || vg_missing_pv_count(vg)) { log_error("Volume group \"%s\" not found, isinconsistent "
Quoted 3 lines
"or has PVs missing.", vg_name); log_error("Consider vgreduce --removemissing ifmetadata "
Did you mean to put this in the second patch?
PATCH 1/1 (1/2) new library interface for vg_read
Quoted 12 lines · Dave Wysochanski
Quoted 11 lines · Petr Rockai
/* FIXME: remove redundant
vg_name*/
int vg_remove_single(structcmd_context*cmd, const char*vg_name,(quoted diff) +1
-1- struct volume_group *vg, int consistent, + struct volume_group *vg, force_t force __attribute((unused))) { struct physical_volume *pv;@@ -340,7 +340,7 @@ int vg_remove_single(struct cmd_context unsigned lv_count; int ret = 1;
Quoted 9 lines
Quoted 7 lines
(quoted diff) +1
-1- if (!vg || !consistent || vg_missing_pv_count(vg)) { + if (vg_read_error(vg) || vg_missing_pv_count(vg)) { log_error("Volume group \"%s\" not found, isinconsistent "
"or has PVs missing.", vg_name); log_error("Consider vgreduce --removemissing ifmetadata "
Did you mean to put this in the second patch?
Actually, hard to tell. It, after all, is part of the library, for a reason or other. It belongs equally well to the first as to the second patch. What do you propose?
Yours,
Petr.
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 (1/2) new library interface for vg_read
Quoted 22 lines · Petr Rockai
Quoted 12 lines · Dave Wysochanski
Quoted 11 lines · Petr Rockai
/* FIXME: remove redundant
vg_name*/
int vg_remove_single(structcmd_context*cmd, const char*vg_name,(quoted diff) +1
-1- struct volume_group *vg, int consistent, + struct volume_group *vg, force_t force __attribute((unused))) { struct physical_volume *pv;@@ -340,7 +340,7 @@ int vg_remove_single(struct cmd_context unsigned lv_count; int ret = 1;Quoted 9 lines
Quoted 7 lines
(quoted diff) +1
-1- if (!vg || !consistent || vg_missing_pv_count(vg)) { + if (vg_read_error(vg) || vg_missing_pv_count(vg)) { log_error("Volume group \"%s\" not found, isinconsistent "
"or has PVs missing.", vg_name); log_error("Consider vgreduce --removemissing ifmetadata "
Did you mean to put this in the second patch?
Quoted 4 lines
Actually, hard to tell. It, after all, is part of the library, for a reason or other. It belongs equally well to the first as to the second patch. What do you propose?
Well, doesn't this cause a bug in this path though for the !consistent case? First patch drops the consistent variable in this vgremove path, but things like _process_one_vg() do not use the new APIs (which sets the proper error codes) until the second patch. You mention in your patch intro this first patch should apply and make a completely workable LVM so I'm assuming you mean no bugs.
I'm still digesting the main changes in vg_lock_and_read().
PATCH 1/1 (1/2) new library interface for vg_read
Hi,
Quoted 6 lines · Dave Wysochanski
Well, doesn't this cause a bug in this path though for the !consistent case? First patch drops the consistent variable in this vgremove path, but things like
_process_one_vg()do not use the new APIs (which sets the proper error codes) until the second patch. You mention in your patch intro this first patch should apply and make a completely workable LVM so I'm assuming you mean no bugs.
Oh, hm, you are apparently right. Interestingly enough, the presumably buggy code does pass the testsuite, so something's wrong with the testsuite, I suppose. It might be good to have a test triggering that problem. I will re-split the patch and resubmit later today.
To jstava@:
Could you please apply the attached patch? Now lvm with this patch should break down on certain error conditions. I won't be able to exactly tell you how to reproduce the problem, or whether it's even possible from the commandline at this time, but if there is a testcase, it'll likely include inconsistent metadata. If it turns out to be too hard, feel free to leave it alone. You might be able to find extra info in this thread on lvm-devel at .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new-all.diff
Type: text/x-diff
Size: 22464 bytes
Desc: new-all.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081215/baf57aec/attachment.bin>
-------------- next part --------------
Yours,
Petr.
PS: This version of the patch actually compiles, but has the abovementioned bug. The previous failed to compile due to forgotten int vs uint32_t in vg_check_status definition.
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 (1/2) new library interface for vg_read
Quoted 9 lines · Petr Rockai
Hi,
Quoted 6 lines · Dave Wysochanski
Well, doesn't this cause a bug in this path though for the !consistent case? First patch drops the consistent variable in this vgremove path, but things like
_process_one_vg()do not use the new APIs (which sets the proper error codes) until the second patch. You mention in your patch intro this first patch should apply and make a completely workable LVM so I'm assuming you mean no bugs.
Quoted 5 lines
Oh, hm, you are apparently right. Interestingly enough, the presumably buggy code does pass the testsuite, so something's wrong with the testsuite, I suppose. It might be good to have a test triggering that problem. I will re-split the patch and resubmit later today.
The other thing I had wondered about was your changing vg_lock_and_read() significantly (in particular the return value / handle) but not changing any of the callers until the second patch. I have not thought this through but are you confident the existing callers will be ok without the second patch?
PATCH 1/1 (1/2) new library interface for vg_read
In reply to Dave WysochanskiI'm attaching a hopefully more-correct version of the two patches, with the split moved. Sorry for slipping the "later today" to "tomorrow"...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvm2-vg_read-lib.diff
Type: text/x-diff
Size: 20820 bytes
Desc: lvm2-vg_read-lib.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081216/db6018bc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvm2-vg_read-tools.diff
Type: text/x-diff
Size: 42920 bytes
Desc: lvm2-vg_read-tools.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081216/db6018bc/attachment-0001.bin>
-------------- next part --------------
Yours,
Petr.
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 (1/2) new library interface for vg_read
In reply to Petr RockaiQuoted 9 lines · Petr Rockai
diff -rN -p -u
old-lvmlib/lib/device/dev-io.cnew-lvmlib/lib/device/dev-io.c
---old-lvmlib/lib/device/dev-io.c2008-12-09 17:44:06.638398136
+0100
+++new-lvmlib/lib/device/dev-io.c2008-12-09 17:44:06.930396980
+0100(quoted diff) +0
-0@@ -622,6 +622,11 @@ int dev_write(struct device *dev, uint64 where.start = offset;
Review int dev_write(struct device *dev, uint64 · line 632
Quoted 10 lines
(quoted diff) +5
-0where.size = len; + if (!vg_write_lock_held()) { + log_error("Attempted to write unlocked VG's device."); + return_0; + } + dev->flags |= DEV_ACCESSED_W; return _aligned_io(&where, buffer, 1);
Should this be its own patch? It seems unrelated to the vg_read() library changes.
PATCH 1/1 (1/2) new library interface for vg_read
Quoted 8 lines · Dave Wysochanski
Review int dev_write(struct device *dev, uint64 · line 625
Quoted 7 lines · Petr Rockai
+++
new-lvmlib/lib/device/dev-io.c2008-12-09 17:44:06.930396980
+0100(quoted diff) +3
-0@@ -622,6 +622,11 @@ int dev_write(struct device *dev, uint64 + if (!vg_write_lock_held()) { + log_error("Attempted to write unlocked VG's device."); + return_0;
If the code was correct that never would happen?
i.e. Label it as 'Internal error:'
Alasdair
Signature · 1 line
agk at redhat.com
PATCH 1/1 (1/2) new library interface for vg_read
In reply to Petr RockaiQuoted 6 lines · Petr Rockai
(quoted diff) +1
-1-int vg_check_status(const struct volume_group *vg, uint32_t status) +static int _vg_check_status(const struct volume_group *vg, uint32_tstatus)
{
+uint32_tret = 0;
Can you clean up some of the return value prototypes so they use uint32_t consistently for return values? This includes vg_check_status(), vg_read_error(), vg_exists(), and the flag definitions.
PATCH 1/1 (1/2) new library interface for vg_read
Hi,
Quoted 4 lines · Dave Wysochanski
Can you clean up some of the return value prototypes so they use
uint32_tconsistently for return values? This includesvg_check_status(),vg_read_error(),vg_exists(), and the flag definitions.
I have changed those, plus removed the warning you mentioned in other mail, I'll probably re-add separately later. I'm attaching new-changes and new-all, first just giving the diff against the previous version of the patch. I'm not sure I agree that they should all be uint32_t though, but I suppose it's a minor point.
The diff-diff:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new-changes.diff
Type: text/x-diff
Size: 2828 bytes
Desc: new-changes.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081212/a20c350c/attachment.bin>
-------------- next part --------------
And the full-diff:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new-all.diff
Type: text/x-diff
Size: 16639 bytes
Desc: new-all.diff
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20081212/a20c350c/attachment-0001.bin>
-------------- next part --------------
Yours,
Petr.
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 (1/2) new library interface for vg_read
Quoted 7 lines · Petr Rockai
Hi,
Quoted 4 lines · Dave Wysochanski
Can you clean up some of the return value prototypes so they use
uint32_tconsistently for return values? This includesvg_check_status(),vg_read_error(),vg_exists(), and the flag definitions.
Quoted 6 lines
I have changed those, plus removed the warning you mentioned in other mail, I'll probably re-add separately later. I'm attaching new-changes and new-all, first just giving the diff against the previous version of the patch. I'm not sure I agree that they should all be
uint32_tthough, but I suppose it's a minor point.
I'm not sure either - what's the argument for 'int' returns for API calls? More like standard C library calls?
The flag definitions you have are not consistent with others in metadata-exported.h but honestly I am not sure what is clearer. Do you agree we should be consistent here or is there a reason not to?
Agreed that mostly these are minor points. Consistency I think is the main goal.