From: thornber@redhat.com
To: Joe Thornber <ejt@redhat.com>, dm-devel@redhat.com
Subject: Re: [PATCH 6/8] [persistent-data] Add a transactional array.
Date: Mon, 28 Jan 2013 14:57:36 +0000 [thread overview]
Message-ID: <20130128145735.GE2442@raspberrypi> (raw)
In-Reply-To: <20130125201106.GJ3122@agk-dp.fab.redhat.com>
Alasdair,
I've just pushed a series of patches to thin-dev, and all-caches that
address these.
I've refactored the grow() function, breaking it up to reduce
indentation. However, I've left in 'else' clauses. I find the
following says 'there are three options' ...
if (resize->new_nr_full_blocks > resize->old_nr_full_blocks)
return grow_needs_more_blocks(resize);
else if (resize->old_nr_entries_in_last_block)
return grow_extend_tail_block(resize, resize->new_nr_entries_in_last_block);
else
return grow_add_tail_block(resize);
... more clearly than ...
if (resize->new_nr_full_blocks > resize->old_nr_full_blocks)
return grow_needs_more_blocks(resize);
else if (resize->old_nr_entries_in_last_block)
return grow_extend_tail_block(resize, resize->new_nr_entries_in_last_block);
return grow_add_tail_block(resize);
Will change if you're still having trouble with it though.
- Joe
On Fri, Jan 25, 2013 at 08:11:06PM +0000, Alasdair G Kergon wrote:
> On Thu, Dec 13, 2012 at 08:19:14PM +0000, Joe Thornber wrote:
> > diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
> > new file mode 100644
> > index 0000000..d762caf
> > --- /dev/null
> > +++ b/drivers/md/persistent-data/dm-array.c
> > @@ -0,0 +1,818 @@
>
> > +static int array_block_check(struct dm_block_validator *v,
> > + struct dm_block *b,
> > + size_t block_size)
>
> Please rename block_size throughout to avoid any possible confusion
> with the inline function of the same name.
>
> > +{
> > + struct array_block *bh_le = dm_block_data(b);
> > + __le32 csum_disk;
> > +
> > + if (dm_block_location(b) != le64_to_cpu(bh_le->blocknr)) {
> > + DMERR_LIMIT("array_block_check failed: blocknr %llu != wanted %llu",
> > + le64_to_cpu(bh_le->blocknr), dm_block_location(b));
>
> We generally use an explicit cast to (unsigned long long) to avoid warnings
> on some archs. (Check the other places with format strings too.)
>
> > +static uint32_t calc_max_entries(size_t value_size, size_t block_size)
> > +{
> > + return (block_size - sizeof(struct array_block)) / value_size;
> > +}
>
> : warning: conversion to ‘uint32_t’ from ‘long unsigned int’ may alter its value
>
> Perhaps some of the implict casting could be tidied a bit, but I haven't spotted
> any places where it causes real problems.
>
> > +static int insert_full_ablocks(struct dm_array_info *info, size_t block_size,
> > + unsigned begin_block, unsigned end_block,
> > + unsigned max_entries, const void *value,
> > + dm_block_t *root)
> > +{
> > + int r;
> > + struct dm_block *block;
> > + struct array_block *ab;
> > +
> > +
>
> Extra blank line.
>
> > + while (begin_block != end_block) {
> > + r = alloc_ablock(info, block_size, &block, &ab);
> > + if (r)
> > + return r;
> > +
> > + fill_ablock(info, ab, value, le32_to_cpu(ab->max_entries));
>
> max_entries function parameter is unused - which should it be?
>
> > +static int grow(struct resize *resize)
> > +{
> > + int r;
> > + struct dm_block *block;
> > + struct array_block *ab;
> > +
> > + if (resize->new_nr_full_blocks > resize->old_nr_full_blocks) {
> > + /*
> > + * Pad the end of the old block?
> > + */
> > + if (resize->old_nr_entries_in_last_block > 0) {
> > + r = shadow_ablock(resize->info, &resize->root,
> > + resize->old_nr_full_blocks, &block, &ab);
> > + if (r)
> > + return r;
> > +
> > + fill_ablock(resize->info, ab, resize->value, resize->max_entries);
> > + unlock_ablock(resize->info, block);
> > + }
> > +
> > + /*
> > + * Add the full blocks.
> > + */
> > + r = insert_full_ablocks(resize->info, resize->block_size,
> > + resize->old_nr_full_blocks,
> > + resize->new_nr_full_blocks,
> > + resize->max_entries, resize->value,
> > + &resize->root);
> > + if (r)
> > + return r;
> > +
> > + /*
> > + * Add new tail block?
> > + */
> > + if (resize->new_nr_entries_in_last_block)
> > + r = insert_partial_ablock(resize->info, resize->block_size,
> > + resize->new_nr_full_blocks,
> > + resize->new_nr_entries_in_last_block,
> > + resize->value, &resize->root);
>
> return directly here and drop the else (maybe inverting the if test) and
> reducing the indentation?
>
> > + } else {
> > + if (!resize->old_nr_entries_in_last_block) {
> > + r = insert_partial_ablock(resize->info, resize->block_size,
>
> Redundant {}
>
> > + resize->new_nr_full_blocks,
> > + resize->new_nr_entries_in_last_block,
> > + resize->value, &resize->root);
> > + } else {
>
> ...
>
> > + r = dm_tm_ref(info->btree_info.tm, b, &ref_count);
> > + if (r) {
> > + DMERR_LIMIT("couldn't get reference count");
> > + return;
> > + }
> > +
> > + if (ref_count == 1) {
> > + /*
> > + * We're about to drop the last reference to this ablock.
> > + * So we need to decrement the ref count of the contents.
> > + */
> > + r = get_ablock(info, b, &block, &ab);
> > + if (r) {
> > + DMERR_LIMIT("couldn't get array block");
> > + return;
> > + }
>
> Can we add more context to these error messages - e.g. the block number?
>
> Alasdair
>
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2013-01-28 14:57 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-13 20:19 Another cache target Joe Thornber
2012-12-13 20:19 ` [PATCH 1/8] [persistent-data] Fix a bug in btree_del, and another bug that was compensating for it Joe Thornber
2012-12-13 20:19 ` [PATCH 2/8] [persistent-data] dm_btree_walk Joe Thornber
2012-12-13 20:19 ` [PATCH 3/8] [persistent-data] tweak an error message Joe Thornber
2012-12-13 20:19 ` [PATCH 4/8] [dm-bio-prison] Change the bio-prison interface so the memory for the cells is passed in Joe Thornber
2013-01-14 10:02 ` Alasdair G Kergon
2013-01-14 14:06 ` thornber
2013-01-14 14:22 ` Alasdair G Kergon
2013-01-21 23:32 ` Alasdair G Kergon
2013-01-22 11:31 ` thornber
2013-01-22 12:10 ` Alasdair G Kergon
2012-12-13 20:19 ` [PATCH 5/8] [dm-thin] Fix a race condition between discard bios and ordinary bios Joe Thornber
2012-12-14 15:52 ` Mike Snitzer
2013-01-22 0:03 ` Alasdair G Kergon
2013-01-24 2:35 ` Alasdair G Kergon
2013-01-24 13:23 ` thornber
2013-02-06 0:11 ` Mikulas Patocka
2013-02-07 11:20 ` thornber
2012-12-13 20:19 ` [PATCH 6/8] [persistent-data] Add a transactional array Joe Thornber
2013-01-22 21:18 ` Alasdair G Kergon
2013-01-23 12:07 ` thornber
2013-01-25 20:11 ` Alasdair G Kergon
2013-01-28 13:06 ` thornber
2013-01-28 20:25 ` Alasdair G Kergon
2013-01-28 14:57 ` thornber [this message]
2013-01-28 20:22 ` Alasdair G Kergon
2012-12-13 20:19 ` [PATCH 7/8] [persistent-data] transactional bitset Joe Thornber
2013-01-22 21:59 ` Alasdair G Kergon
2012-12-13 20:19 ` [PATCH 8/8] [dm-cache] cache target Joe Thornber
2012-12-14 0:17 ` Darrick J. Wong
2012-12-14 10:09 ` thornber
2013-02-12 15:27 ` Alasdair G Kergon
2013-02-12 16:40 ` Alasdair G Kergon
2013-02-12 17:29 ` Alasdair G Kergon
2013-02-14 13:57 ` Joe Thornber
2013-02-14 14:05 ` Joe Thornber
2013-02-14 21:06 ` Alasdair G Kergon
2012-12-13 21:57 ` Another " Mike Snitzer
2012-12-14 1:16 ` Darrick J. Wong
2012-12-14 2:19 ` Mike Snitzer
2012-12-14 2:27 ` Mike Snitzer
2012-12-14 2:42 ` Darrick J. Wong
2012-12-14 4:23 ` Mike Snitzer
2012-12-14 2:34 ` Darrick J. Wong
2012-12-14 10:24 ` thornber
2012-12-14 12:11 ` thornber
2012-12-14 21:51 ` Darrick J. Wong
2012-12-15 8:23 ` Joe Thornber
2012-12-18 1:49 ` Darrick J. Wong
2012-12-18 2:31 ` Alasdair G Kergon
2013-01-08 0:19 ` Darrick J. Wong
2013-01-08 13:55 ` thornber
2012-12-22 18:50 ` Mark Hills
2012-12-17 16:54 ` Heinz Mauelshagen
2012-12-18 15:44 ` basic cache policy module fix [was: Re: Another cache target] Mike Snitzer
2012-12-20 1:14 ` Darrick J. Wong
2012-12-20 12:57 ` Heinz Mauelshagen
2012-12-20 13:24 ` Mike Snitzer
2012-12-20 16:10 ` Darrick J. Wong
2012-12-20 17:02 ` Heinz Mauelshagen
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=20130128145735.GE2442@raspberrypi \
--to=thornber@redhat.com \
--cc=dm-devel@redhat.com \
--cc=ejt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox