diff mbox series

[ACT] UBUNTU: SAUCE: aio_dio_bugs: Fix O_DIRECT define

Message ID 20210715212740.3556875-1-ian.may@canonical.com
State New
Headers show
Series [ACT] UBUNTU: SAUCE: aio_dio_bugs: Fix O_DIRECT define | expand

Commit Message

Ian May July 15, 2021, 9:27 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1900791

If O_DIRECT is not defined in <fcntl.h> there is a manual
definition specified for O_DIRECT, but it is the wrong value.

    define O_DIRECT         040000 /* direct disk access hint */

This value maps to O_DIRECTORY, hence the failure errno=20(ENOTDIR)

strace also confirms the incorrect flag

    openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECTORY, 0600)

The fix is to set the correct value for O_DIRECT

Confirmed behavior with strace and that affected tests pass.

    openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECT, 0600)

Signed-off-by: Ian May <ian.may@canonical.com>
---
 aio_dio_bugs/src/aio-dio-extend-stat.c        | 2 +-
 aio_dio_bugs/src/aio-dio-invalidate-failure.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Thadeu Lima de Souza Cascardo July 15, 2021, 9:35 p.m. UTC | #1
On Thu, Jul 15, 2021 at 04:27:40PM -0500, Ian May wrote:
> BugLink: https://bugs.launchpad.net/bugs/1900791
> 
> If O_DIRECT is not defined in <fcntl.h> there is a manual
> definition specified for O_DIRECT, but it is the wrong value.
> 
>     define O_DIRECT         040000 /* direct disk access hint */
> 
> This value maps to O_DIRECTORY, hence the failure errno=20(ENOTDIR)
> 
> strace also confirms the incorrect flag
> 
>     openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECTORY, 0600)
> 
> The fix is to set the correct value for O_DIRECT
> 
> Confirmed behavior with strace and that affected tests pass.
> 
>     openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECT, 0600)
> 
> Signed-off-by: Ian May <ian.may@canonical.com>
> ---
>  aio_dio_bugs/src/aio-dio-extend-stat.c        | 2 +-
>  aio_dio_bugs/src/aio-dio-invalidate-failure.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/aio_dio_bugs/src/aio-dio-extend-stat.c b/aio_dio_bugs/src/aio-dio-extend-stat.c
> index e0dd2dfa..04e6225d 100644
> --- a/aio_dio_bugs/src/aio-dio-extend-stat.c
> +++ b/aio_dio_bugs/src/aio-dio-extend-stat.c
> @@ -11,7 +11,7 @@
>  #include <errno.h>
>  
>  #ifndef O_DIRECT
> -#define O_DIRECT         040000 /* direct disk access hint */
> +#define O_DIRECT         0200000 /* direct disk access hint */
>  #endif
>  
>  
> diff --git a/aio_dio_bugs/src/aio-dio-invalidate-failure.c b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> index c5ffff05..11bd7c2d 100644
> --- a/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> +++ b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> @@ -26,7 +26,7 @@
>   * return -EIO.
>   */
>  #ifndef O_DIRECT
> -#define O_DIRECT         040000 /* direct disk access hint */
> +#define O_DIRECT         0200000 /* direct disk access hint */
>  #endif
>  
>  #define GINORMOUS (32 * 1024 * 1024)
> -- 
> 2.25.1

I see it the other way around here. O_DIRECT is 040000 and O_DIRECTORY is 0200000.

Where did you find this failure? Which kernel on which series?

Cascardo.

> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Ian May July 15, 2021, 10:10 p.m. UTC | #2
Appears to be further flag definition conflicts.  Resending v2 with different fix.

On 2021-07-15 16:27:40 , Ian May wrote:
> BugLink: https://bugs.launchpad.net/bugs/1900791
> 
> If O_DIRECT is not defined in <fcntl.h> there is a manual
> definition specified for O_DIRECT, but it is the wrong value.
> 
>     define O_DIRECT         040000 /* direct disk access hint */
> 
> This value maps to O_DIRECTORY, hence the failure errno=20(ENOTDIR)
> 
> strace also confirms the incorrect flag
> 
>     openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECTORY, 0600)
> 
> The fix is to set the correct value for O_DIRECT
> 
> Confirmed behavior with strace and that affected tests pass.
> 
>     openat(AT_FDCWD, "file", O_RDWR|O_CREAT|O_TRUNC|O_DIRECT, 0600)
> 
> Signed-off-by: Ian May <ian.may@canonical.com>
> ---
>  aio_dio_bugs/src/aio-dio-extend-stat.c        | 2 +-
>  aio_dio_bugs/src/aio-dio-invalidate-failure.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/aio_dio_bugs/src/aio-dio-extend-stat.c b/aio_dio_bugs/src/aio-dio-extend-stat.c
> index e0dd2dfa..04e6225d 100644
> --- a/aio_dio_bugs/src/aio-dio-extend-stat.c
> +++ b/aio_dio_bugs/src/aio-dio-extend-stat.c
> @@ -11,7 +11,7 @@
>  #include <errno.h>
>  
>  #ifndef O_DIRECT
> -#define O_DIRECT         040000 /* direct disk access hint */
> +#define O_DIRECT         0200000 /* direct disk access hint */
>  #endif
>  
>  
> diff --git a/aio_dio_bugs/src/aio-dio-invalidate-failure.c b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> index c5ffff05..11bd7c2d 100644
> --- a/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> +++ b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
> @@ -26,7 +26,7 @@
>   * return -EIO.
>   */
>  #ifndef O_DIRECT
> -#define O_DIRECT         040000 /* direct disk access hint */
> +#define O_DIRECT         0200000 /* direct disk access hint */
>  #endif
>  
>  #define GINORMOUS (32 * 1024 * 1024)
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/aio_dio_bugs/src/aio-dio-extend-stat.c b/aio_dio_bugs/src/aio-dio-extend-stat.c
index e0dd2dfa..04e6225d 100644
--- a/aio_dio_bugs/src/aio-dio-extend-stat.c
+++ b/aio_dio_bugs/src/aio-dio-extend-stat.c
@@ -11,7 +11,7 @@ 
 #include <errno.h>
 
 #ifndef O_DIRECT
-#define O_DIRECT         040000 /* direct disk access hint */
+#define O_DIRECT         0200000 /* direct disk access hint */
 #endif
 
 
diff --git a/aio_dio_bugs/src/aio-dio-invalidate-failure.c b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
index c5ffff05..11bd7c2d 100644
--- a/aio_dio_bugs/src/aio-dio-invalidate-failure.c
+++ b/aio_dio_bugs/src/aio-dio-invalidate-failure.c
@@ -26,7 +26,7 @@ 
  * return -EIO.
  */
 #ifndef O_DIRECT
-#define O_DIRECT         040000 /* direct disk access hint */
+#define O_DIRECT         0200000 /* direct disk access hint */
 #endif
 
 #define GINORMOUS (32 * 1024 * 1024)