summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2016-05-12 01:05:52 +0100
committerAlasdair G Kergon <agk@redhat.com>2016-05-12 01:05:52 +0100
commitb5314c2a6ae5fe4f802e82a4f31cf2fad398ded9 (patch)
tree5604d24f88e43902cd9229ca81aff1a87346257e
parentf3d508630d7acdd638afae700973f1d68e43cbcc (diff)
downloadlvm2-b5314c2a6ae5fe4f802e82a4f31cf2fad398ded9.tar.gz
device: Retry open without O_NOATIME if it fails.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/device/dev-io.c13
-rw-r--r--lib/device/device.h1
3 files changed, 14 insertions, 1 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 89fa681e7..e11a40abc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.154 -
===============================
+ Retry open without O_NOATIME if it fails (not file owner/CAP_FOWNER).
Version 2.02.153 - 7th May 2016
===============================
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 9bf6d2e14..a9a237417 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -494,11 +494,22 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
#ifdef O_NOATIME
/* Don't update atime on device inodes */
- if (!(dev->flags & DEV_REGULAR))
+ if (!(dev->flags & DEV_REGULAR) && !(dev->flags & DEV_NOT_O_NOATIME))
flags |= O_NOATIME;
#endif
if ((dev->fd = open(name, flags, 0777)) < 0) {
+#ifdef O_NOATIME
+ if ((errno == EPERM) && (flags & O_NOATIME)) {
+ flags &= ~O_NOATIME;
+ dev->flags |= DEV_NOT_O_NOATIME;
+ if ((dev->fd = open(name, flags, 0777)) >= 0) {
+ log_debug_devs("%s: Not using O_NOATIME", name);
+ goto opened;
+ }
+ }
+#endif
+
#ifdef O_DIRECT_SUPPORT
if (direct && !(dev->flags & DEV_O_DIRECT_TESTED)) {
flags &= ~O_DIRECT;
diff --git a/lib/device/device.h b/lib/device/device.h
index aaa009fc8..fa03f1061 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -30,6 +30,7 @@
#define DEV_OPEN_FAILURE 0x00000080 /* Has last open failed? */
#define DEV_USED_FOR_LV 0x00000100 /* Is device used for an LV */
#define DEV_ASSUMED_FOR_LV 0x00000200 /* Is device assumed for an LV */
+#define DEV_NOT_O_NOATIME 0x00000400 /* Don't use O_NOATIME */
/*
* Support for external device info.