public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: agk@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/device/dev-io.c
Date: Wed, 22 Sep 2010 22:31:00 -0000	[thread overview]
Message-ID: <20100922223146.17341.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-09-22 22:31:46

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-io.c 

Log message:
	Replace alloca with dm_malloc in _aligned_io.
	
	(This section of code dates from 2.4 and could be written more efficiently nowadays.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1733&r2=1.1734
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70

--- LVM2/WHATS_NEW	2010/09/22 13:45:21	1.1733
+++ LVM2/WHATS_NEW	2010/09/22 22:31:45	1.1734
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 =====================================
+  Replace alloca with dm_malloc in _aligned_io.
   Fix partial mode operations for lvm1 metadata format.
   Track recursive filter iteration to avoid refreshing while in use. (2.02.56)
   Revert to old glibc vsnprintf behaviour in emit_to_buffer() to catch overflow.
--- LVM2/lib/device/dev-io.c	2010/07/09 15:34:42	1.69
+++ LVM2/lib/device/dev-io.c	2010/09/22 22:31:46	1.70
@@ -164,10 +164,11 @@
 static int _aligned_io(struct device_area *where, void *buffer,
 		       int should_write)
 {
-	void *bounce;
+	void *bounce, *bounce_buf;
 	unsigned int block_size = 0;
 	uintptr_t mask;
 	struct device_area widened;
+	int r = 0;
 
 	if (!(where->dev->flags & DEV_REGULAR) &&
 	    !_get_block_size(where->dev, &block_size))
@@ -185,8 +186,8 @@
 		return _io(where, buffer, should_write);
 
 	/* Allocate a bounce buffer with an extra block */
-	if (!(bounce = alloca((size_t) widened.size + block_size))) {
-		log_error("Bounce buffer alloca failed");
+	if (!(bounce_buf = bounce = dm_malloc((size_t) widened.size + block_size))) {
+		log_error("Bounce buffer malloc failed");
 		return 0;
 	}
 
@@ -199,7 +200,7 @@
 	/* channel the io through the bounce buffer */
 	if (!_io(&widened, bounce, 0)) {
 		if (!should_write)
-			return_0;
+			goto_out;
 		/* FIXME pre-extend the file */
 		memset(bounce, '\n', widened.size);
 	}
@@ -209,13 +210,18 @@
 		       (size_t) where->size);
 
 		/* ... then we write */
-		return _io(&widened, bounce, 1);
+		r = _io(&widened, bounce, 1);
+		goto_out;
 	}
 
 	memcpy(buffer, bounce + (where->start - widened.start),
 	       (size_t) where->size);
 
-	return 1;
+	r = 1;
+
+out:
+	dm_free(bounce_buf);
+	return r;
 }
 
 static int _dev_get_size_file(const struct device *dev, uint64_t *size)


             reply	other threads:[~2010-09-22 22:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 22:31 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-12-21 13:24 zkabelac
2007-09-07 11:24 meyering
2005-11-23 16:07 agk
2004-12-21 20:23 agk
2004-12-09 16:56 agk
2004-09-14 22:23 agk

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=20100922223146.17341.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).