All of lore.kernel.org
 help / color / mirror / Atom feed
From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/device/dev-cache.c
Date: 21 Dec 2011 13:17:54 -0000	[thread overview]
Message-ID: <20111221131754.9797.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac at sourceware.org	2011-12-21 13:17:54

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

Log message:
	Add common initialization code for struct device
	
	Avoid duplicate code and add _dev_init() where all common
	member values are initialized.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2210&r2=1.2211
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68

--- LVM2/WHATS_NEW	2011/12/21 13:14:54	1.2210
+++ LVM2/WHATS_NEW	2011/12/21 13:17:54	1.2211
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Add function to inialize common structure device members.
   Always zalloc device structure during initialization.
   Fix missing thread list manipulation protection in dmeventd.
   Do not derefence lv pointer in _percent_run() function before NULL check.
--- LVM2/lib/device/dev-cache.c	2011/12/21 13:14:54	1.67
+++ LVM2/lib/device/dev-cache.c	2011/12/21 13:17:54	1.68
@@ -54,6 +54,18 @@
 
 static int _insert(const char *path, int rec, int check_with_udev_db);
 
+/* Setup non-zero members of passed zeroed 'struct device' */
+static void _dev_init(struct device *dev, int max_error_count)
+{
+	dev->block_size = -1;
+	dev->fd = -1;
+	dev->read_ahead = -1;
+	dev->max_error_count = max_error_count;
+
+	dm_list_init(&dev->aliases);
+	dm_list_init(&dev->open_list);
+}
+
 struct device *dev_create_file(const char *filename, struct device *dev,
 			       struct str_list *alias, int use_malloc)
 {
@@ -76,7 +88,6 @@
 				dm_free(alias);
 				return NULL;
 			}
-			dev->flags = DEV_ALLOCED;
 		} else {
 			if (!(dev = _zalloc(sizeof(*dev)))) {
 				log_error("struct device allocation failed");
@@ -97,19 +108,9 @@
 		return NULL;
 	}
 
-	dev->flags |= DEV_REGULAR;
-	dm_list_init(&dev->aliases);
+	_dev_init(dev, NO_DEV_ERROR_COUNT_LIMIT);
+	dev->flags = DEV_REGULAR | ((use_malloc) ? DEV_ALLOCED : 0);
 	dm_list_add(&dev->aliases, &alias->list);
-	dev->end = UINT64_C(0);
-	dev->dev = 0;
-	dev->fd = -1;
-	dev->open_count = 0;
-	dev->error_count = 0;
-	dev->max_error_count = NO_DEV_ERROR_COUNT_LIMIT;
-	dev->block_size = -1;
-	dev->read_ahead = -1;
-	memset(dev->pvid, 0, sizeof(dev->pvid));
-	dm_list_init(&dev->open_list);
 
 	return dev;
 }
@@ -122,17 +123,9 @@
 		log_error("struct device allocation failed");
 		return NULL;
 	}
-	dev->flags = 0;
-	dm_list_init(&dev->aliases);
+
+	_dev_init(dev, dev_disable_after_error_count());
 	dev->dev = d;
-	dev->fd = -1;
-	dev->open_count = 0;
-	dev->max_error_count = dev_disable_after_error_count();
-	dev->block_size = -1;
-	dev->read_ahead = -1;
-	dev->end = UINT64_C(0);
-	memset(dev->pvid, 0, sizeof(dev->pvid));
-	dm_list_init(&dev->open_list);
 
 	return dev;
 }



             reply	other threads:[~2011-12-21 13:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 13:17 zkabelac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-04-11  9:12 LVM2 ./WHATS_NEW lib/device/dev-cache.c prajnoha
2011-12-21 13:21 zkabelac
2011-12-21 13:14 zkabelac
2011-01-17 15:16 zkabelac
2010-05-24 22:53 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=20111221131754.9797.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@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.