All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Mike Snitzer <snitzer@redhat.com>,
	device-mapper development <dm-devel@redhat.com>,
	Joe Thornber <ejt@redhat.com>
Subject: Re: Another cache target
Date: Mon, 17 Dec 2012 17:49:51 -0800	[thread overview]
Message-ID: <20121218014951.GA4878@blackbox.djwong.org> (raw)
In-Reply-To: <20121215082309.GA5330@reti.lambda.co.uk>

On Sat, Dec 15, 2012 at 08:23:09AM +0000, Joe Thornber wrote:
> On Fri, Dec 14, 2012 at 01:51:19PM -0800, Darrick J. Wong wrote:
> > Yeah, I think I've seen some odd behavior too - on one of my runs, blkid
> > reported that the cache device had the same superblock as the aggregate device.
> > My guess is that block 0 on the exported device got mapped to block 0 of the
> > cache.  I'll see if I can make it happen again, but that brings me to another
> > set of questions.
> 
> This is normal.

Okay, but this is a little scary too:

# blkid
/dev/sda1: UUID="3cec6984-7db1-4b51-988c-19a574d444b3" TYPE="ext4" 
/dev/mapper/cache: UUID="3cec6984-7db1-4b51-988c-19a574d444b3" TYPE="ext4" 
/dev/vda: UUID="0bf9cc39-9ca1-4b4a-b543-774efe5b51cb" TYPE="ext4"

sda1 is the ssd, vda is the origin.  I haven't used the cleaner yet; this is
merely the result of beating on the cache long enough that the superblock gets
flushed out to the origin.

It's not a problem /while/ the cache is mounted because opening sda1 or vda
with O_EXCL (such as when you try to mount) return -EBUSY.  When the cache
isn't mounted, however, there's more of a problem -- any sane filesystem will
notice that sda1 is smaller than the filesystem and refuse to mount, but
there's not a lot preventing erroneous mounts of vda, which will possibly end
in disaster.

I guess I'm simply afraid of accidentally mounting the origin device when it's
dirty, whether it's through overeager boot scripts, or plain old stupidity on
my part. :)

> > First, is there a plan to have userspace tools to set up the cache, provide
> > protective superblocks, etc.?
> 
> Yes, lvm2 will support it soon (hopefully).  Tools like cache_check,
> cache_dump, cache_restore that manipulate the metadata device are
> nearly ready.
> 
> >  As far as I can tell, the slow disk and the fast
> > disk don't have headers to declare the existence of the cache, so blkid and
> > friends can end up seeing things they shouldn't.  How were you planning to keep
> > users from mounting the slow device before the cache comes up?
> 
> We don't label the origin device or ssd in anyway.

<nod> I was rather hoping there'd be a label to avoid all that above blkid
drama. :/

> > Second, if the cache is in WB mode, is there a way to force it to flush the
> > cache contents to disk?  Or does it do that at dmsetup create time?
> 
>   Reload the cache target with the cleaner policy.  Once it's finished
>   writing everything back it'll trigger a dm event that you can catch
>   with 'dmsetup wait'.  Then check the status to double check there
>   are no dirty blocks.  At this point you can ditch the cache and use
>   the origin directly.  See test below.
> 
> 
>   def wait_for_all_clean(cache)
>     cache.event_tracker.wait(cache) do |cache|
>       status = CacheStatus.new(cache)
>       status.nr_dirty == 0
>     end
>   end
> 
>   def test_cleaner_policy
>     with_standard_cache(:format => true) do |cache|
>       git_prepare(cache, :ext4)
> 
>       cache.pause do
>         table = cache.active_table
>         table.targets[0].args[6] = 'cleaner'
>         cache.load(table)
>       end
> 
>       wait_for_all_clean(cache)
>     end
> 
>     # We should be able to use the origin directly now
>     with_standard_linear do |origin|
>       fs = FS::file_system(:ext4, origin)
>       fs.with_mount('./kernel_builds', :discard => true) do
>         # triggers fsck
>       end
>     end
>   end

Ahh, nifty.  But how does it work from the command line?

# dmsetup table
cache: 0 67108864 cache 8:2 8:1 254:0 512 1 writeback default 0
# echo '0 67108864 cache /dev/sda2 /dev/sda1 /dev/vda 512 0 cleaner 0' | dmsetup reload cache
# dmsetup table
cache: 0 67108864 cache 8:2 8:1 254:0 512 1 writeback default 0

Is there some trickery to dmsetup that I'm missing here?

--D

  reply	other threads:[~2012-12-18  1:49 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
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 [this message]
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=20121218014951.GA4878@blackbox.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=ejt@redhat.com \
    --cc=snitzer@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.