linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
Subject: [PATCH 0/6] nilfs2: implement tracking of live blocks
Date: Sun, 16 Mar 2014 11:47:33 +0100	[thread overview]
Message-ID: <cover.1394966728.git.andreas.rohner@gmx.net> (raw)

Hi,

This patch set implements the tracking of live blocks in segments. This 
information is crucial in implementing better GC policies, because 
now the policies can make informed decisions about which segments have 
the biggest number of reclaimable blocks.

The difficulty in tracking live blocks is the fact, that any block can 
belong to any number of snapshots and snapshots can be deleted and 
created at any time. A block belongs to a snapshot, if the checkpoint 
number lies between de_start and de_end of the block. So if a new 
snapshot is created, all the reclaimable blocks belonging to it are no 
longer reclaimable and therefore the live block counter of the 
corresponding segment must be incremented. Conversely if a snapshot is 
removed, all the reclaimable blocks belonging to it should really be 
counted as reclaimable again and the counter must be decremented. But if 
one block belongs to two or more snapshots the counter must only be 
incremented once for the first and decremented once for the last 
snapshot.

To achieve this I used the de_rsv field of nilfs_dat_entry to store one 
of the snapshot numbers. Every time a snapshot is created/removed the 
whole DAT-File is scanned and de_rsv is updated if the snapshot number 
is between de_start and de_end. But one block can belong to an 
arbitrary number of snapshots. Here I use the fact, that the 
snapshot list is organized as a sorted linked list. So by knowing the 
previous and the next snapshot number it is possible to 
reliably determine, if a block is reclaimable or belongs to another 
snapshot. 

It is of course unacceptable to update the whole DAT-File to create one 
snapshot. So only reclaimable blocks are updated. But this leads to 
certain situations, where the counters won't be accurate. The userspace 
GC should be capable of compensating and correcting the inaccurate 
values.

Another problem is the protection period in the userspace GC. The kernel 
doesn't know anything about the userspace protection period, and it is 
therefore not reflected in the number of live blocks in a segment. For 
example if the GC policy chooses a segment that seems to have a lot of 
reclaimable blocks, it could turn out, that all of those blocks are 
still protected by the protection period.

To overcome this problem I added an additional field to su_lastdec to 
the segment usage information. Whenever the number of live blocks in a 
segment is adjusted su_lastdec is set to the current timestamp. If the 
number of live blocks was adjusted within the protection period, then 
the userspace GC policy can recognize it and choose a different segment.

Compatibility Issues:
1. su_nblocks is reused to represent the number of live blocks
   old nilfs-utils would break the file system.
2. the vd_pad field of nilfs_vdesc was not initialized to 0
   so old nilfs-utils could send arbitrary flags to the kernel

Benchmark Results:

The benchmark replays NFS-Traces to simulate a real file system load. 
The file system is filled up to 20% capacity and then the NFS-Traces are 
replayed. In parallel every 5 minutes random checkpoints are turned into 
snapshots. After 15 minutes the snapshot is turned back into a 
checkpoint.

Greedy-Policy-Runtime:       6221.712s
Cost-Benefit-Policy-Runtime: 6874.840s
Timestamp-Policy-Runtime:    13179.626s

Best regards,
Andreas Rohner

---
Andreas Rohner (6):
  nilfs2: add helper function to go through all entries of meta data
    file
  nilfs2: add new timestamp to seg usage and function to change
    su_nblocks
  nilfs2: scan dat entries at snapshot creation/deletion time
  nilfs2: add ioctl() to clean snapshot flags from dat entries
  nilfs2: add counting of live blocks for blocks that are overwritten
  nilfs2: add counting of live blocks for deleted files

 fs/nilfs2/alloc.c         | 121 +++++++++++++++++++++++++
 fs/nilfs2/alloc.h         |   6 ++
 fs/nilfs2/bmap.c          |   8 +-
 fs/nilfs2/bmap.h          |   2 +-
 fs/nilfs2/btree.c         |   3 +-
 fs/nilfs2/cpfile.c        |   7 ++
 fs/nilfs2/dat.c           | 225 +++++++++++++++++++++++++++++++++++++++++++++-
 fs/nilfs2/dat.h           |  32 ++++++-
 fs/nilfs2/direct.c        |   3 +-
 fs/nilfs2/inode.c         |   2 +
 fs/nilfs2/ioctl.c         | 109 +++++++++++++++++++++-
 fs/nilfs2/mdt.c           |   5 +-
 fs/nilfs2/page.h          |   6 +-
 fs/nilfs2/segbuf.c        |  25 ++++++
 fs/nilfs2/segbuf.h        |   4 +
 fs/nilfs2/segment.c       |  69 ++++++++++++--
 fs/nilfs2/sufile.c        |  86 +++++++++++++++++-
 fs/nilfs2/sufile.h        |  18 ++++
 include/linux/nilfs2_fs.h |  65 +++++++++++++-
 19 files changed, 772 insertions(+), 24 deletions(-)

-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2014-03-16 10:47 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-16 10:47 Andreas Rohner [this message]
     [not found] ` <cover.1394966728.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 10:47   ` [PATCH 1/6] nilfs2: add helper function to go through all entries of meta data file Andreas Rohner
     [not found]     ` <2adbf1034ab4b129223553746577f6ec0e699869.1394966729.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-17  6:51       ` Vyacheslav Dubeyko
2014-03-17  9:24         ` Andreas Rohner
2014-03-16 10:47   ` [PATCH 2/6] nilfs2: add new timestamp to seg usage and function to change su_nblocks Andreas Rohner
     [not found]     ` <12561ce5e2cf8ae07fdda05e16c357f37d17c62f.1394966729.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 13:00       ` Vyacheslav Dubeyko
     [not found]         ` <2FD47FE0-3468-4EF4-AAAE-4A636C640C44-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
2014-03-16 12:24           ` Andreas Rohner
     [not found]             ` <53259801.5080409-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 13:34               ` Vyacheslav Dubeyko
     [not found]                 ` <0ED0D5DA-9AE9-44B8-8936-1680DE2B64C5-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
2014-03-16 16:02                   ` Andreas Rohner
2014-03-16 14:06               ` Vyacheslav Dubeyko
     [not found]                 ` <ED41900C-6380-44C1-AC7E-EB8DF74EBFBD-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
2014-03-16 13:31                   ` Ryusuke Konishi
     [not found]                     ` <20140316.223111.52181167.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-03-16 16:19                       ` Andreas Rohner
2014-03-16 10:47   ` [PATCH 3/6] nilfs2: scan dat entries at snapshot creation/deletion time Andreas Rohner
     [not found]     ` <29dee92595249b713fff1e4903d5d76556926eec.1394966729.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-17  7:04       ` Vyacheslav Dubeyko
2014-03-17  9:35         ` Andreas Rohner
     [not found]           ` <5326C1E5.10108-hi6Y0CQ0nG0@public.gmane.org>
2014-03-17  9:54             ` Vyacheslav Dubeyko
2014-03-16 10:47   ` [PATCH 4/6] nilfs2: add ioctl() to clean snapshot flags from dat entries Andreas Rohner
     [not found]     ` <be7d3bd13015117222aac43194c0fdb9c5d0046f.1394966729.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-17 13:19       ` Vyacheslav Dubeyko
2014-03-17 13:49         ` Andreas Rohner
     [not found]           ` <5326FD51.7000209-hi6Y0CQ0nG0@public.gmane.org>
2014-03-18  7:10             ` Vyacheslav Dubeyko
2014-03-18  8:38               ` Andreas Rohner
2014-03-16 10:47   ` [PATCH 5/6] nilfs2: add counting of live blocks for blocks that are overwritten Andreas Rohner
     [not found]     ` <25dd8a8bb6943ffa3e0663848363135585a48109.1394966729.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-18 11:50       ` Vyacheslav Dubeyko
2014-03-18 14:02         ` Andreas Rohner
2014-03-16 10:47   ` [PATCH 6/6] nilfs2: add counting of live blocks for deleted files Andreas Rohner
2014-03-16 10:49   ` [PATCH 1/4] nilfs-utils: remove reliance on sui_nblocks to read segment Andreas Rohner
     [not found]     ` <36b7f57861b69c7fdb9d9e54a21df6f5c7f21061.1394966935.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 10:49       ` [PATCH 2/4] nilfs-utils: add cost-benefit and greedy policies Andreas Rohner
     [not found]         ` <cc43be2e6bba5367fd2982dc0df5255b884bdace.1394966935.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 12:55           ` Ryusuke Konishi
     [not found]             ` <20140316.215545.291456562.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-03-16 15:50               ` Andreas Rohner
2014-03-16 10:49       ` [PATCH 3/4] nilfs-utils: add support for nilfs_clean_snapshot_flags() Andreas Rohner
2014-03-16 10:49       ` [PATCH 4/4] nilfs-utils: add extra flags to nilfs_vdesc and update sui_nblocks Andreas Rohner
2014-03-16 11:01   ` [PATCH 0/6] nilfs2: implement tracking of live blocks Andreas Rohner
     [not found]     ` <532584A2.8000004-hi6Y0CQ0nG0@public.gmane.org>
2014-03-16 12:34       ` Vyacheslav Dubeyko
     [not found]         ` <3EC9549C-84A7-49B5-9BE1-34A7337BFFDC-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
2014-03-16 11:36           ` Andreas Rohner

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=cover.1394966728.git.andreas.rohner@gmx.net \
    --to=andreas.rohner-hi6y0cq0ng0@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).