From: agk@sourceware.org
To: dm-cvs@sourceware.org, dm-devel@redhat.com
Subject: device-mapper/lib libdm-common.c
Date: 30 Nov 2007 16:42:27 -0000 [thread overview]
Message-ID: <20071130164227.9098.qmail@sourceware.org> (raw)
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,
next reply other threads:[~2007-11-30 16:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-30 16:42 agk [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-11-30 16:44 device-mapper/lib libdm-common.c agk
2007-12-03 17:56 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=20071130164227.9098.qmail@sourceware.org \
--to=agk@sourceware.org \
--cc=dm-cvs@sourceware.org \
--cc=dm-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.