From: Mike Snitzer <snitzer@redhat.com>
To: lvm-devel@redhat.com
Subject: Re: [PATCH 1/6] Add --dataalignmentoffset to pvcreate to pad aligned data area
Date: Thu, 16 Jul 2009 16:53:58 -0400 [thread overview]
Message-ID: <20090716205357.GB9005@redhat.com> (raw)
In-Reply-To: <20090716151153.GD32757@agk-dp.fab.redhat.com>
On Thu, Jul 16 2009 at 11:11am -0400,
Alasdair G Kergon <agk@redhat.com> wrote:
> On Mon, Jul 13, 2009 at 04:11:17PM -0400, Mike Snitzer wrote:
> > When setting up the first mda, format-text.c:_mda_setup now sets the
> > pe_start to immediately follow the first mda (which ends at a pe_align
> > boundry). data_alignment_offset will be added to pe_start if
> > --dataalignmentoffset was used.
>
> The reason this cannot be reviewed easily is this:
>
> > Index: LVM2/lib/format_text/format-text.c
> > ===================================================================
> > --- LVM2.orig/lib/format_text/format-text.c
> > +++ LVM2/lib/format_text/format-text.c
> > @@ -1175,6 +1175,7 @@ static int _text_scan(const struct forma
> > Always have an mda between end-of-label and pe_align() boundary */
> > static int _mda_setup(const struct format_type *fmt,
> > uint64_t pe_start, uint64_t pe_end,
> > + unsigned long data_alignment_offset,
> > int pvmetadatacopies,
> > uint64_t pvmetadatasize, struct dm_list *mdas,
> > struct physical_volume *pv,
> > @@ -1251,6 +1252,16 @@ static int _mda_setup(const struct forma
> > return 0;
> > }
> >
> > + if (!pe_start && !pe_end) {
> > + /*
> > + * Set PV's pe_start to immediately follow the
> > + * first mda (which ends at a pe_align boundary)
> > + */
> > + pv->pe_start = (start1 + mda_size1) >> SECTOR_SHIFT;
> > + if (data_alignment_offset)
> > + pv->pe_start += data_alignment_offset;
> > + }
> > +
> > if (pvmetadatacopies == 1)
> > return 1;
> > } else
>
> While the code already has elsewhere (_text_pv_write):
>
> /*
> * If pe_start is still unset, set it to first aligned
> * sector after any metadata areas that begin before pe_start.
> */
> if (!pv->pe_start)
> pv->pe_start = pv->pe_align;
>
>
> Further explanation is required to understand how both can be correct.
Yes, that code in _text_pv_write really has no place being in there
(that I can see); especially given that _text_pv_setup() also sets
pv->pe_start accordingly with:
if (pe_start)
pv->pe_start = pe_start;
...
if (pv->pe_start < pv->pe_align)
pv->pe_start = pv->pe_align;
If anything: that _text_pv_write being where it is makes that code quite
a bit more labored/awkward.. see the dm_list_iterate_items() loop that
follows the pv->pe_start initialization you shared above:
...
pv->pe_start = (mdac->area.start + mdac->area.size)
>> SECTOR_SHIFT;
adjustment = pv->pe_start % pv->pe_align;
if (adjustment)
pv->pe_start += pv->pe_align -
adjustment;
}
All those nuanced conditional checks (that preceed the _text_pv_write
code I just shared) really amount to "we need to place the pe_start
immediately after the first data area". The setup path (_mda_setup) is
the more logical place to establish the start of the PV's data area.
But given the care that someone clearly put into all those
(undocumented) checks in _text_pv_write I thought I could still be
missing _why_ the pe_start needed to be established so late (in the
_text_pv_write path). I'll take one more pass through it when I get
back (tracing all entry into _text_pv_write). It could be safe to just
remove that code in _text_pv_write.
Mike
next prev parent reply other threads:[~2009-07-16 20:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-13 20:11 [PATCH 0/6 v5] LVM2 topology support Mike Snitzer
2009-07-13 20:11 ` [PATCH 1/6] Add --dataalignmentoffset to pvcreate to pad aligned data area Mike Snitzer
2009-07-16 15:11 ` Alasdair G Kergon
2009-07-16 20:53 ` Mike Snitzer [this message]
2009-07-16 22:11 ` Alasdair G Kergon
2009-07-13 20:11 ` [PATCH 2/6] Add devices/data_alignment_offset_detection to lvm.conf Mike Snitzer
2009-07-16 18:47 ` Milan Broz
2009-07-16 21:00 ` Mike Snitzer
2009-07-16 21:15 ` Mike Snitzer
2009-07-17 7:43 ` Milan Broz
2009-07-13 20:11 ` [PATCH 3/6] Add devices/data_alignment_detection " Mike Snitzer
2009-07-13 20:11 ` [PATCH 4/6] Improve ability to lookup primary device associated with partition Mike Snitzer
2009-07-13 20:11 ` [PATCH 5/6] Retrieve MD sysfs attributes for MD partitions Mike Snitzer
2009-07-13 20:11 ` [PATCH 6/6] Add MD, partition and topology tests to the LVM2 test-suite Mike Snitzer
-- strict thread matches above, loose matches on Subject: below --
2009-07-23 2:53 [PATCH 0/6 v6] LVM2 topology support Mike Snitzer
2009-07-23 2:53 ` [PATCH 1/6] Add --dataalignmentoffset to pvcreate to pad aligned data area Mike Snitzer
2009-07-25 22:09 ` Mike Snitzer
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=20090716205357.GB9005@redhat.com \
--to=snitzer@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.