Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1463020

[RFC PATCH 12/16] DM: release unneeded buffer as soon as possible.

From Ram Pai <linuxram@us.ibm.com>
Newsgroups linux.kernel
Subject [RFC PATCH 12/16] DM: release unneeded buffer as soon as possible.
Date 2016-08-15 19:40 +0200
Message-ID <s6u1I-59-27@gated-at.bofh.it> (permalink)
References <s6u1H-59-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Done to conserve as much free space as possible.  Waiting to release till the
bio is done will unneccesarily hog up memory.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 drivers/md/dm-inplace-compress.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-inplace-compress.c b/drivers/md/dm-inplace-compress.c
index bc1cf70..b1c3e5f 100644
--- a/drivers/md/dm-inplace-compress.c
+++ b/drivers/md/dm-inplace-compress.c
@@ -977,7 +977,7 @@ static struct dm_icomp_io_range *dm_icomp_create_io_read_range(
 	io->comp_kmap = (segments == 1);
 	/* note down the requested length for decompress buffer.
 	 * but dont allocate it yet.
-	 /
+	 */
 	io->decomp_req_len = decomp_len;
 	return io;
 }
@@ -1375,8 +1375,13 @@ static int dm_icomp_handle_write_modify(struct dm_icomp_io_range *io,
 	}
 
 	dm_icomp_get_req(req);
-	if (ret == 1)
+
+	if (ret == 1) {
 		io->io_req.mem.ptr.addr = io->decomp_data + (offset << 9);
+		dm_icomp_release_comp_buffer(io);
+	} else
+		dm_icomp_release_decomp_buffer(io);
+
 	io->io_region.count = comp_len >> 9;
 	io->io_region.sector = start + req->info->data_start;
 
@@ -1443,8 +1448,11 @@ static void dm_icomp_handle_write_comp(struct dm_icomp_req *req)
 	io->io_region.sector = req->bio->bi_iter.bi_sector +
 			 req->info->data_start;
 
-	if (ret == 1)
+	if (ret == 1) {
 		io->io_req.mem.ptr.addr = io->decomp_data;
+		dm_icomp_release_comp_buffer(io);
+	} else
+		dm_icomp_release_decomp_buffer(io);
 
 	io->io_region.count = comp_len >> 9;
 	io->io_req.bi_rw = req->bio->bi_rw;
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 00/16] dm-inplace-compression block device Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 15/16] DM: Add sysfs parameters to track total memory saved and allocated. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 06/16] DM: separate out compression and decompression routines. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 12/16] DM: release unneeded buffer as soon as possible. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 14/16] DM: Wasted bio copy. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 11/16] DM: Try to avoid temporary buffer allocation to hold compressed data. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 13/16] DM: macros to set and get the state of the request. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 03/16] DM: Error if enough space is not available. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 16/16] DM: add documentation for dm-inplace-compress. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 09/16] DM: Delay allocation of decompression buffer during read. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:40 +0200
  [RFC PATCH 04/16] DM: Ensure that the read request is within the device range. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:50 +0200
  [RFC PATCH 07/16] DM: Optimize memory allocated to hold compressed buffer. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:50 +0200
  [RFC PATCH 10/16] DM: Try to use the bio buffer for decompression instead of allocating one. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:50 +0200
  [RFC PATCH 05/16] DM: allocation/free helper routines. Ram Pai <linuxram@us.ibm.com> - 2016-08-15 19:50 +0200

csiph-web