Commit Graph

61 Commits

Author SHA1 Message Date
Jim Harris
d25f2db94a reduce: account for compressed buffers
When we decompress, pass the size of the compressed
data - not the size of the buffer itself.

We also need to remove an assert that's no longer
true since we can now handle compressed chunks.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ifb7896db12ccbefdd49815b5037af11ddd82e625

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449513
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-04-02 21:40:21 +00:00
Jim Harris
fa0d54d431 reduce: write uncompressed data when compress returns error
Most typically, the error will be -ENOSPC, meaning the
destination buffer wasn't big enough to hold the compressed
data.  But even for other types of errors, just write the
uncompressed data rather than treating it as an I/O
failure.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id6526cab95488a1a587b183237f9980c83287761

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449511
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-04-02 21:40:21 +00:00
Jim Harris
df082c931e reduce: fix chunk_is_compressed calculation
Stupid bug - a chunk is compressed when the number
of io_units for the compressed data does *not* equal
the number of io_units per chunk.

Paul found this during some of his initial DPDK
framework integration testing.  I have some better
unit tests coming up to test this further, but want
to get this obvious fix in for now.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iaf9c78a1c1d6045070e7625c6a54ab3d227c8ea7

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449498
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-29 02:34:21 +00:00
Jim Harris
2edc652913 reduce: save num_io_units and chunk_is_compressed to req object
When a chunk cannot be compressed enough to save one I/O
unit, we will just write the uncompressed data to disk.  In
this case, we want the helper routine to use the decomp_buf
instead of the comp_buf.

To facilitate that, save some information in the request
object on the number of io_units to be read from or written
to disk, and whether the data is compressed or not.  We
could easily deduce if the data is compressed based on the
number of io_units but saving it in the structure will
save a few instructions and simplify the code a bit.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I1537130577943e19fe4dfcee58eac453eca3c29b

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449259
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-03-28 03:45:29 +00:00
Jim Harris
309f7791b9 reduce: plumb basic compress/decompress callbacks
The unit tests don't really try to compress anything
yet, but this at least gets the pipeline in place.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic413850b30e4d9631f3ece2bab40d9026225e5b2

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449097
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-03-28 03:45:29 +00:00
Jim Harris
72da9b7562 reduce: use consistent callback names
There are a sequence of operations needed for both
read and write I/O.  For example, on a write I/O,
we may need to do a read, modify the chunk, then
write the data back to disk.

For read I/O, the name of the callback is
_read_read_done - the first "read" indicates the
I/O type, the second "read" indicates the disk read
part of the sequence.

The write I/O steps aren't using this same naming
convention, so change that here.  This will be
important in upcoming patches where we'll be adding
compress/decompress steps into the I/O pipeline -
having a consistent naming strategy will make the code
easier to follow.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Icd525874918378118d807acdbe5dd42d5be03126

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449258
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-03-28 03:45:29 +00:00
Jim Harris
f9ac7dcf11 reduce: move code into _read_complete_req helper function
This preps for some future changes.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I380258938e2412062b43c3d460a7322c5afdf819

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449096
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-03-28 03:45:29 +00:00
Jim Harris
09aff2d0fd reduce: add intermediate buffers for compression operations
We will actually use these in future patches.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I730ef90da6d93922dd17a5ac16594e66132a5f11

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449086
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-03-28 03:45:29 +00:00
Jim Harris
20145fd714 reduce: prepend rw to request buf and buf_iov
We will need separate temporary buffers for compress/decompress.
A single temporary buffer won't do because a user's read/write
operations may not cover a full chunk - so we'll need one buffer
to read/write the compressed data, and another buffer for
the uncompressed data.

So for now, just prepend rw to the existing fields - this
will signify these fields are used for the read/write operations
to the backing storage device.  We'll add additional ones in future
patches for the buffers that will hold the uncompressed data.

Note: the vol->buf_mem and ->buf_iov_mem are not prepending "rw"
because they will be used for the compress/decompress temporary
buffers as well.  We'll just double the size of these buffers
when allocating them for the volume.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7df56ab72769f4689f3abac3354446e9cf78d423

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449085
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-27 14:20:26 +00:00
Jim Harris
502ab5b66d reduce: rename vol->reqbufspace to buf_mem
This matches better with the existing buf_iov_mem.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I3b85708672553c281666becc8eaf9f9028da8782

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449084
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-27 14:20:26 +00:00
Jim Harris
5a04099b01 reduce: save compressed data size in chunk map
Upcoming patches will try to compress the data before
writing it to backing I/O units, and we'll need to save
the exact number of compressed bytes.

For now, since we're not actually compressing data yet,
just save the uncompressed data size to this field.  There
will be cases when we cannot realize any compression
savings and will just store the uncompressed data, so
handling this now is one less path we'll need to add later.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I499a89590349e4816fe0fef77cc1bfabde6871bf

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449078
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-27 14:20:26 +00:00
Jim Harris
3bb1f95570 reduce: add struct for chunk maps
Previously we were just passing around uint64_t pointers,
since the chunk map was literally only an array of uint64_t.
But we need to store the compressed data size in the chunk
as well.  Before adding the compressed data size, let's do
the prep work here to just create the chunk map structure
which for now only includes an array of uint64_t.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Icbfa6e509463d4f560444d3db8acd9e87917835f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449076
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-27 14:20:26 +00:00
Jim Harris
4fb2260117 lib/reduce: queue overlapping I/O to same logical chunk
Write operations are not in-place, meaning that once it
is completed, it's chunk and backing io units are freed.
Reads in progress to these backing io units, from other
I/O to the same chunk, could cause data corruption.
Simultaneous writes to the same chunk can cause similar
issues.

There are cases where we can relax this in the future -
for example, overlapped reads to the same chunk poses
no problems.  We'll leave that as a future exercise.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I3a4d9e8e3ab920f823084cd1bae91f179a4386ff
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448333
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-03-25 04:39:26 +00:00
Jim Harris
b1c5a962d4 lib/reduce: create helper functions for starting read/write ops
Upcoming changes will require queuing an I/O if it overlaps
with another I/O to the same logical chunk.  So split out
code (especially from the writev path) into separate functions,
so that we can execute an spdk_reduce_vol_request object
whether it's just been created via readv/writev, or after
another I/O to the same chunk has been completed.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I2a216c92e4999313ecc9f7cf157dccd65c9bb30f

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448332
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
2019-03-22 18:28:43 +00:00
Jim Harris
d7c80bfb44 lib/reduce: save logical_map_index in the request object
This will help optimize some upcoming patches which
guard against overlapped I/O to the same chunk in the logical
map.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia1370fffd3bf3d55dc9ce88a993ed157ecee272a

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448331
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
2019-03-22 18:28:43 +00:00
Jim Harris
1036358ecf lib/reduce: rename variable to old_chunk_map_index
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I39479f44684e2c5e6652d07237ac40949dcf0aca

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448330
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
2019-03-22 18:28:43 +00:00
paul luse
cf467578f8 bdev/reduce: fix issue with vol_load
Discovered in bdev compression test.  Vol load was using the index
of the logical map to set the allocated chunk map bits as well as
retrieve the chunk. Exposed with overwrite situations. Also clarrified
one var name that I missed in previous patch.

Also added UT that fails without the fix, passes with the fix.

Change-Id: I776a5af9364cc3d4e8b7dafec22acf23bd463630
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447969
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-03-18 17:41:32 +00:00
paul luse
228396f898 lib/reduce: change some var names
Changed a few cases where var name chunk was used where a better
name would be logical_map_index to avoid confusion with 'chunk'
used as a data pointer.

Change-Id: Ib82a783725cad4609c31bfa8997debb3e71e75b9
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447962
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-03-18 17:41:32 +00:00
paul luse
5abe0ec852 reduce: fix ordering bug
_allocate_bit_arrays() needs vol->backing_dev set which was being done
after the call.

Change-Id: Ic8c36c98aee94fbd8230273638011b948cd95675
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443048
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-04 19:23:35 +00:00
Jim Harris
1fa0283f31 reduce: mark correct number of backing pages for md
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iebdfe79dd8e4240f2333db6a758193e048f9b5f2

Reviewed-on: https://review.gerrithub.io/c/440574
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-01-17 19:43:28 +00:00
Jim Harris
42aa5a262b reduce: remove close callback
Let the application figure out how to close the
underlying block device after an init fails or
an initialized/loaded volume is closed/destroyed.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id0b9b99c85ed13166ec9a229eaaa0b0eb04289fd

Reviewed-on: https://review.gerrithub.io/c/440573
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-01-16 22:25:13 +00:00
Jim Harris
c0f3805153 reduce: add spdk_reduce_vol_destroy
This will remove the metadata from the associated backing
device and delete the pm_file associated with the reduce
volume.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I30ffd68e5ba69b31ee1be85418c5b8c592d82e70

Reviewed-on: https://review.gerrithub.io/c/437995
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-01-16 22:25:13 +00:00
Jim Harris
63ba545f54 reduce: rebuild bit arrays during load
This requires fixing up the unit test pmem emulation
code - we need to copy the 'persistent' buffer into
the newly 'mmaped' buffer in the pmem_map_file stub.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I4e474f437922e652a57d0b45b6ef92fc713eb587

Reviewed-on: https://review.gerrithub.io/c/437888
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-01-16 22:25:13 +00:00
wuzhouhui
8db5ff2bdd reduce: _allocate_vol_requests: set pointer to NULL after freed
If _allocate_vol_requests() failed, the caller will call
_init_load_cleanup() to free memory that _allocate_vol_requests()
already freed, and cause segment fault. Setting pointer to NULL keeps
_init_load_cleanup() is safe to free it again.

Change-Id: I9ad09eabf6b65350f174bd5a4faf5ee643cbd23f
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/437292
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-18 23:38:51 +00:00
wuzhouhui
3a4185be19 reduce: check strlen(SPDK_REDUCE_SIGNATURE) in buildtime
Change-Id: I4d12f2a693a4a34c840d972a4f60cbd0fc35011b
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/437236
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-18 23:34:17 +00:00
wuzhouhui
7fbc5106e4 reduce: put pmem_unmap() in _init_load_cleanup()
In effect, this commit fixes error path of spdk_reduce_vol_init()
and spdk_reduce_vol_load(): forget to unmap pmem file after mapped.

Change-Id: I797f15e315fff3ff42c17509a73dc46e7f6bdb24
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/437270
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-18 23:33:50 +00:00
Konrad Sztyber
62db4ac2cf util: added spdk_divide_round_up()
Replaced divide_round_up() from blobstore.c, lvol.c and reduce.c with
new spdk_divide_round_up() from util.h.

Change-Id: I013383ac286ca52b5c15c7fab4fb40ad97b92656
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/437649
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-12-18 17:26:49 +00:00
Jim Harris
3d1c1f945c reduce: don't try to clear io units for empty chunk maps
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Reported-by: Shuhei Matsumoto
Change-Id: Idcf427e32962236acfeb7dab793e27c44cdc6151

Reviewed-on: https://review.gerrithub.io/436878
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
0b0af8f30b reduce: calculate vol size from backing dev size
This more closely matches the sequence of events
a user will take in creating a compressed volume.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I2311aed49e2a623feb9c5fbdbd25fb3201aeeeb5

Reviewed-on: https://review.gerrithub.io/436065
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
8c2cf577b3 reduce: remove extra size check
This was the result of a previous merge conflict.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic657e7f9e16b6a073669b078b4323f7abfef95b9

Reviewed-on: https://review.gerrithub.io/436063
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
1c68d71107 reduce: change some member names to make them more descriptive
Based on feedback from Paul Luse in some earlier reviews.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I1930a3de05ada15d3ac4530c081c2f951b96fe97

Reviewed-on: https://review.gerrithub.io/435368
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
383b117309 reduce: implement read and write with data
For write operations, copy data to req->buf and write
to disk.

If chunk already specified in logical map, read the
chunk first into req->buf, and overwrite with data
specified by the write operation.

If chunk not specified in logical map, fill logical
blocks not specified by the write operation with
zeroes.

For read operations, read chunk into req->buf first,
then copy relevant data into the buffers specified
by the read operations.

These operations are all functional, but have room
for future improvement.  For example, this patch
will issue a separate backing read/write operations
for each backing block in the chunk - this could be
optimized to coalesce operations where the backing
blocks are contiguous.

While here, clean up freeing bufspace in one of
the error paths - this needs to be freed using
spdk_dma_free instead.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I6dbf4fc9a8fdf0f5424b1f1f9178c79891c96d0d

Reviewed-on: https://review.gerrithub.io/434116
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-13 14:55:39 +00:00
Jim Harris
84f8b6339f reduce: start implementation of spdk_reduce_vol_writev
Focus of this patch is adding the foundations of manipulating
the chunk_map and backing_block bit arrays and persisting
chunk maps and the logical map to the pm_file.

No data is writting the backing device yet.  That will come
in later patches.  This also does not rebuild the bit arrays
from the pm_file during spdk_reduce_vol_load - that will also come
in a later patch.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ib5336dbe907c253e545704471de8c4e812bbc157

Reviewed-on: https://review.gerrithub.io/434115
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
3213962e91 reduce: replace ziperrno with reduce_errno
ziperrno was left over from earlier versions of this
patch set that used "sbzip" instead of "reduce".

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I4159141b92727bb0a24db5f9aefcccaadc360d9e

Reviewed-on: https://review.gerrithub.io/436399
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-13 14:55:39 +00:00
Jim Harris
1d75aad3ff reduce: don't pass size when loading pmem file
libpmem only allows passing a size when CREATE flag
is set.

This requires some updates in the unit test stubs
for pmem_map_file as well.  While here, do some
additional cleanup and add a g_volatile_pm_buf_len to
track the size of the allocated volatile pm buffer.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ib9fe58fd9946161dd20bb8391be2e9680705ab22

Reviewed-on: https://review.gerrithub.io/435945
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-06 00:22:36 +00:00
Jim Harris
e3a7bf7974 reduce: add _reduce_persist()
This is just a wrapper around the pmem_persist/pmem_sync
calls.  It basically turns this:

if (vol->pm_file.pm_is_pmem) {
	pmem_persist(buf, sizeof(buf));
} else {
	pmem_msync(buf, sizeof(buf));
}

into this:

_reduce_persist(vol, buf, sizeof(buf));

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id4e3f1538901cf7a3d5f5cec10b18907ca94afe0

Reviewed-on: https://review.gerrithub.io/434114
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-03 20:34:11 +00:00
Jim Harris
5ae61d4286 reduce: add logical block size to vol params
This will be the logical block size presented by the
compressed volume to differ from the backing device's
block size.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ie4ef06e131d8e101a0c9ced228c56a02fcbfb7af

Reviewed-on: https://review.gerrithub.io/434113
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-03 20:34:11 +00:00
Jim Harris
7be176e1e6 reduce: add vol->backing_io_units_per_chunk
This can be derived from chunk_size and backing_io_unit_size
in the params, but saving this value explicitly in the vol
structure is helpful so we don't always have to calculate
it.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic389afcf60984ea431a6d1c7523005a368547447

Reviewed-on: https://review.gerrithub.io/434112
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-03 20:34:11 +00:00
Jim Harris
d465a21a30 reduce: allocate scratch buffer space for requests
Each request will need a scratch buffer of size
chunk_size.  This is needed for read/modify/write
operations when only part of a chunk is written.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ided33f1e9ae18dd9a5de45f53f0a994a6f260b17

Reviewed-on: https://review.gerrithub.io/434111
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-03 20:34:11 +00:00
Jim Harris
b0281115b5 reduce: clean up a few items found during code review
1) Add #define with comment for the 2-element iov array
2) Account for user passing trailing slash in pm file path

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id5b620ae9d17dd3534e4cc78ddf1ba176f9c7fcd

Reviewed-on: https://review.gerrithub.io/433903
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-11-20 14:50:27 +00:00
Jim Harris
202bb34fcc reduce: add struct spdk_reduce_vol_request
These structures will be used as contexts for every
I/O request.  Allocate a bunch of these requests
when a volume is initialized or loaded.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ibf4da3081b03dd3950550e4ca1c5a3a50f72fd52

Reviewed-on: https://review.gerrithub.io/433516
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
8489937b2e reduce: add bit_arrays for free chunk maps and backing blocks
This patch only creates and frees the bit arrays.  Later
patches will initialize the bit arrays during load based
on information in the pm file.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id3ba2b27fa7988778df440b3221ce12c80306c66

Reviewed-on: https://review.gerrithub.io/433515
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
ee26b22b4c reduce: simplify init/load cleanup code
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7a724a3c7c78485c292ebcc65c32e84a5a852b86

Reviewed-on: https://review.gerrithub.io/433514
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
922258a6a7 reduce: initialize vol pm pointer members at load
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id3865c873be1ae80c3e27473ef369b1eeeac7a18

Reviewed-on: https://review.gerrithub.io/433513
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
80ba4fa879 reduce: store a params struct in spdk_reduce_vol
These parameters will be needed for a number of reasons
after init/load.

The params struct contains the uuid, so the explicit uuid
member in spdk_reduce_vol is no longer needed.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ide12a7816e4a236be5c73a5733e76919ad9af103

Reviewed-on: https://review.gerrithub.io/433512
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
a03515de80 reduce: define and initialize pm file regions
A pm file consists of:
* volume metadata
* logical map
* chunk maps

Define all three of these in struct spdk_reduce_vol.
Also define -1ULL to denote an empty entry in the logical
map or a chunk map - and initialize the logical map
and chunk maps entirely with this value when initializing
a new compressed volume.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I9aae23c73d2fbbdc72050ab103fe9e686907eb40

Reviewed-on: https://review.gerrithub.io/433490
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
eebdab6137 reduce: add spdk_reduce_vol_load()
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7923d461af8ec8835fc258fc537230eff52f787e

Reviewed-on: https://review.gerrithub.io/433088
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
b8745a8403 reduce: allocate 2 iovs for reduce_init_load_ctx
We will need the extra iov in the upcoming load path,
so we can load the superblock and pmem file path into
separate buffers.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I99cce0172bd772ca93813a002dcce6943e661f35

Reviewed-on: https://review.gerrithub.io/433087
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
d31f2be55f reduce: have library create pmem file
Currently the API requires the caller to open the
pmem file and pass the mapped buffer pointer, length
and pmem flag to libreduce using the spdk_reduce_pm_file
structure.

Let's have the library just do the pmem_map_file() instead.
Users then just pass the path to create the pmem file.  The
library will still use the spdk_reduce_pm_file structure
internally - so move its definition out of the public header
and into reduce.c.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I81fcbfdfbb3211dca016d6aa422cf2e1ab16d84d

Reviewed-on: https://review.gerrithub.io/432593
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-20 14:50:27 +00:00
Jim Harris
38259b9982 reduce: generate uuid if user doesn't pass one
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I29a68cac0c2ace3db65e684c36d1512ce72078ac

Reviewed-on: https://review.gerrithub.io/433086
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-11-15 01:03:26 +00:00