All of lore.kernel.org
 help / color / mirror / Atom feed
* device-mapper/lib libdm-common.c
@ 2007-12-03 17:56 agk
  0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2007-12-03 17:56 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-12-03 17:56:37

Modified files:
	lib            : libdm-common.c 

Log message:
	missing #include

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-common.c.diff?cvsroot=dm&r1=1.51&r2=1.52

--- device-mapper/lib/libdm-common.c	2007/11/30 16:44:42	1.51
+++ device-mapper/lib/libdm-common.c	2007/12/03 17:56:36	1.52
@@ -21,6 +21,7 @@
 
 #include <stdarg.h>
 #include <sys/param.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 
 #include <linux/dm-ioctl.h>

^ permalink raw reply	[flat|nested] 3+ messages in thread
* device-mapper/lib libdm-common.c
@ 2007-11-30 16:44 agk
  0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2007-11-30 16:44 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-11-30 16:44:42

Modified files:
	lib            : libdm-common.c 

Log message:
	fix

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-common.c.diff?cvsroot=dm&r1=1.50&r2=1.51

--- device-mapper/lib/libdm-common.c	2007/11/30 16:42:26	1.50
+++ device-mapper/lib/libdm-common.c	2007/11/30 16:44:42	1.51
@@ -381,7 +381,7 @@
 	int fd;
 
 	if ((fd = _open_dev_node(dev_name)) < 0)
-		; // return_0;
+		return_0;
 
 	*read_ahead = 0;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread
* device-mapper/lib libdm-common.c
@ 2007-11-30 16:42 agk
  0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2007-11-30 16:42 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-11-30 16:42:26

Modified files:
	lib            : libdm-common.c 

Log message:
	readahead support completed - untested

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-common.c.diff?cvsroot=dm&r1=1.49&r2=1.50

--- device-mapper/lib/libdm-common.c	2007/11/30 14:59:57	1.49
+++ device-mapper/lib/libdm-common.c	2007/11/30 16:42:26	1.50
@@ -21,9 +21,14 @@
 
 #include <stdarg.h>
 #include <sys/param.h>
+#include <fcntl.h>
 
 #include <linux/dm-ioctl.h>
 
+#ifdef linux
+#  include <linux/fs.h>
+#endif
+
 #ifdef HAVE_SELINUX
 #  include <selinux/selinux.h>
 #endif
@@ -356,16 +361,61 @@
 	return 1;
 }
 
+#ifdef linux
+static int _open_dev_node(const char *dev_name)
+{
+	int fd = -1;
+	char path[PATH_MAX];
+
+	_build_dev_path(path, sizeof(path), dev_name);
+
+	if ((fd = open(path, O_RDONLY, 0)) < 0)
+		log_sys_error("open", path);
+
+	return fd;
+}
+
 int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead)
 {
+	int r = 1;
+	int fd;
+
+	if ((fd = _open_dev_node(dev_name)) < 0)
+		; // return_0;
+
 	*read_ahead = 0;
 
-	return 1;
+	if (!ioctl(fd, BLKRAGET, read_ahead)) {
+		log_sys_error("BLKRAGET", dev_name);
+		r = 0;
+	}  else
+		log_debug("%s: read ahead is %" PRIu32, dev_name, *read_ahead);
+
+	if (!close(fd))
+		stack;
+
+	return r;
 }
 
 static int _set_read_ahead(const char *dev_name, uint32_t read_ahead)
 {
-	return 1;
+	int r = 1;
+	int fd;
+
+	if ((fd = _open_dev_node(dev_name)) < 0)
+		return_0;
+
+	log_debug("%s: Setting read ahead to %" PRIu32, dev_name, read_ahead);
+
+	if (ioctl(fd, BLKRASET, read_ahead)) {
+		log_sys_error("BLKRASET", dev_name);
+		r = 0;
+	}
+
+	if (!close(fd))
+		stack;
+
+	return r;
 }
 
 static int _set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
@@ -394,6 +444,22 @@
 	return _set_read_ahead(dev_name, read_ahead);
 }
 
+#else
+
+int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead)
+{
+	*read_ahead = 0;
+
+	return 1;
+}
+
+static int _set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
+				    uint32_t read_ahead_flags)
+{
+	return 1;
+}
+#endif
+
 typedef enum {
 	NODE_ADD,
 	NODE_DEL,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-03 17:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-03 17:56 device-mapper/lib libdm-common.c agk
  -- strict thread matches above, loose matches on Subject: below --
2007-11-30 16:44 agk
2007-11-30 16:42 agk

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.