From: Dave Wysochanski <dwysocha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 6/6] RFC: Change lvm2app version number from 1 to 2.
Date: Sun, 04 Apr 2010 23:03:16 -0400 [thread overview]
Message-ID: <1270436597.2495.25.camel@f10-node1> (raw)
In-Reply-To: <4BB5D77A.2090409@redhat.com>
On Fri, 2010-04-02 at 13:39 +0200, Milan Broz wrote:
> On 04/01/2010 11:57 PM, Dave Wysochanski wrote:
> > This version number change reflects the memory handling change
> > for string-based pv/vg/lv string based attributes.
>
> Maybe it is better idea to use VG mempool, maybe not for
> VG attributes.
>
> But change it now, it means that application using
> calls which previously deallocates these attributes with dm_free
> will now crash, because the memory returned is now owned
> by library.
>
Right it's not a "nice" change right now but as far as I know we have
one library user and I've been in touch with him.
> I really do not like changing API this way in every release...
>
Do you think it is better to leave things as they are?
It has not been changed until now. Plus, there is already an
inconsistency in the way memory is handled with the APIs that return
lists owned by lvm2app and the attribute APIs return memory owned by the
application.
With things as they are now, in addition to the inconsistency, an
application could easily create memory leaks if for example it just
wants to display attributes with something like this:
printf("vg_name = %s", lvm_vg_get_name(vg));
instead, the proper code is:
char *vgname;
vgname = lvm_vg_get_name(vg);
printf ("vg_name = %s", vgname);
dm_free(vgname);
And this must be done for _every_ attribute.
> I see three API possibilities
>
> - define buffer parameter, so all memory allocations are
> in user application
>
> - return strings/parameters *CONST* and define that lvm2app
> owns memory
>
> - use dm_malloc, and require dm_free in user aplications.
>
Right, those are the possibilities. I had discussed this with the David
Zeuthen a few weeks ago and he seemed to be fine with the change as this
is how one of his other APIs work. I can forward you the discussion
and/or confirm with him again.
There are pros and cons of each approach.
> But please do not change this later!
>
> It is extremely confusing for library users,
> no warning that API is not stable will not help here...
>
Agreed. But do you feel we should leave the current inconsistency?
Given that we are still early in the library development, and there are
few users, I felt it was not out of the question to propose a change.
next prev parent reply other threads:[~2010-04-05 3:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 21:57 [PATCH 0/6] Add pv->vg link, rework lvm2app string properties Dave Wysochanski
2010-04-01 21:57 ` [PATCH 1/6] Add pv to vg->pvs after check for maximum value of vg->extent_count Dave Wysochanski
2010-04-01 21:57 ` [PATCH 2/6] Refactor _read_pv() code adding pv to vg->pvs and updating vg counts Dave Wysochanski
2010-04-01 21:57 ` [PATCH 3/6] Add add_pvl_to_vgs() - helper function to add a pv to a vg list Dave Wysochanski
2010-04-01 21:57 ` [PATCH 4/6] Add pv->vg to solidify link between a pv and a vg Dave Wysochanski
2010-04-01 21:57 ` [PATCH 5/6] Use vg->vgmem to allocate vg/lv/pv string properties instead of dm_malloc/free Dave Wysochanski
2010-04-01 21:57 ` [PATCH 6/6] RFC: Change lvm2app version number from 1 to 2 Dave Wysochanski
2010-04-02 11:39 ` Milan Broz
2010-04-05 3:03 ` Dave Wysochanski [this message]
2010-04-02 1:23 ` [PATCH 4/6] Add pv->vg to solidify link between a pv and a vg Alasdair G Kergon
2010-04-05 15:13 ` Dave Wysochanski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1270436597.2495.25.camel@f10-node1 \
--to=dwysocha@redhat.com \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.