1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

device: Retry open without O_NOATIME if it fails.

This commit is contained in:
Alasdair G Kergon 2016-05-12 01:05:52 +01:00
parent f3d508630d
commit b5314c2a6a
3 changed files with 14 additions and 1 deletions

View File

@ -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
===============================

View File

@ -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;

View File

@ -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.