git://git.camperquake.de
/
zfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Sanatize zpios-sanity.sh environment
[zfs.git]
/
lib
/
libzpool
/
kernel.c
diff --git
a/lib/libzpool/kernel.c
b/lib/libzpool/kernel.c
index
0559347
..
002276a
100644
(file)
--- a/
lib/libzpool/kernel.c
+++ b/
lib/libzpool/kernel.c
@@
-35,6
+35,7
@@
#include <sys/processor.h>
#include <sys/zfs_context.h>
#include <sys/utsname.h>
#include <sys/processor.h>
#include <sys/zfs_context.h>
#include <sys/utsname.h>
+#include <sys/time.h>
#include <sys/systeminfo.h>
/*
#include <sys/systeminfo.h>
/*
@@
-533,7
+534,11
@@
vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
* for its size. So -- gag -- we open the block device to get
* its size, and remember it for subsequent VOP_GETATTR().
*/
* for its size. So -- gag -- we open the block device to get
* its size, and remember it for subsequent VOP_GETATTR().
*/
+#if defined(__sun__) || defined(__sun)
if (strncmp(path, "/dev/", 5) == 0) {
if (strncmp(path, "/dev/", 5) == 0) {
+#else
+ if (0) {
+#endif
char *dsk;
fd = open64(path, O_RDONLY);
if (fd == -1) {
char *dsk;
fd = open64(path, O_RDONLY);
if (fd == -1) {
@@
-562,6
+567,14
@@
vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
}
}
}
}
+ if (!(flags & FCREAT) && S_ISBLK(st.st_mode)) {
+#ifdef __linux__
+ flags |= O_DIRECT;
+#endif
+ /* We shouldn't be writing to block devices in userspace */
+ VERIFY(!(flags & FWRITE));
+ }
+
if (flags & FCREAT)
old_umask = umask(0);
if (flags & FCREAT)
old_umask = umask(0);
@@
-578,7
+591,7
@@
vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
if (fd == -1)
return (errno);
if (fd == -1)
return (errno);
- if (fstat64(fd, &st) == -1) {
+ if (fstat64
_blk
(fd, &st) == -1) {
err = errno;
close(fd);
return (err);
err = errno;
close(fd);
return (err);
@@
-637,6
+650,16
@@
vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
}
}
}
}
+#ifdef __linux__
+ if (rc == -1 && errno == EINVAL) {
+ /*
+ * Under Linux, this most likely means an alignment issue
+ * (memory or disk) due to O_DIRECT, so we abort() in order to
+ * catch the offender.
+ */
+ abort();
+ }
+#endif
if (rc == -1)
return (errno);
if (rc == -1)
return (errno);
@@
-665,10
+688,12
@@
int
fop_getattr(vnode_t *vp, vattr_t *vap)
{
struct stat64 st;
fop_getattr(vnode_t *vp, vattr_t *vap)
{
struct stat64 st;
+ int err;
- if (fstat64(vp->v_fd, &st) == -1) {
+ if (fstat64_blk(vp->v_fd, &st) == -1) {
+ err = errno;
close(vp->v_fd);
close(vp->v_fd);
- return (err
no
);
+ return (err);
}
vap->va_size = st.st_size;
}
vap->va_size = st.st_size;
@@
-1107,25
+1132,27
@@
ksiddomain_rele(ksiddomain_t *ksid)
umem_free(ksid, sizeof (ksiddomain_t));
}
umem_free(ksid, sizeof (ksiddomain_t));
}
-/*
- * Do not change the length of the returned string; it must be freed
- * with strfree().
- */
char *
char *
-kmem_
asprintf(const char *fmt, ...
)
+kmem_
vasprintf(const char *fmt, va_list adx
)
{
{
- int size;
- va_list adx;
- char *buf;
+ char *buf = NULL;
+ va_list adx_copy;
- va_
start(adx, fmt
);
-
size = vsnprintf(NULL, 0, fmt, adx) + 1
;
- va_end(adx);
+ va_
copy(adx_copy, adx
);
+
VERIFY(vasprintf(&buf, fmt, adx_copy) != -1)
;
+ va_end(adx
_copy
);
- buf = kmem_alloc(size, KM_SLEEP);
+ return (buf);
+}
+
+char *
+kmem_asprintf(const char *fmt, ...)
+{
+ char *buf = NULL;
+ va_list adx;
va_start(adx, fmt);
va_start(adx, fmt);
-
size = vsnprintf(buf, size, fmt, adx
);
+
VERIFY(vasprintf(&buf, fmt, adx) != -1
);
va_end(adx);
return (buf);
va_end(adx);
return (buf);