Bug 131981

Summary: O_DIRECT doesn't work on LVM devices
Product: Red Hat Enterprise Linux 3 Reporter: Robert <robert.popescu-pretor>
Component: kernelAssignee: Heinz Mauelshagen <heinzm>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: greg.marsden, kanderso, petrides, riel
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-18 13:27:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
rawread.tar none

Description Robert 2004-09-07 17:33:41 UTC
Description of problem:

O_DIRECT doesn't work on LVM devices

Version-Release number of selected component (if applicable):

kernel-2.4.21-4.EL, O_DIRECT to a LVM device on a SCSI disk worked fine.
kernel-2.4.21-9.EL, kernel-2.4.21-15.EL,  kernel-2.4.21-18.EL seem to
disable varyio to LVM devices.
I.e. see mm/filemap.c
/* Only files on a varyio-capable block device are allowed to do
 * sector-aligned direct IO, and then only if the direct_sector_IO
 * method is present.  Otherwise we need to constrain the IO to fs
 * blocksize. */
This seems to be no longer true since kernel-2.4.21-9.EL for a LVM
device.

How reproducible:
anytime


Steps to Reproduce:

Using attached rawread to simulate O_DIRECT pread to /mnt/u1/<anyfile>
1.
/sbin/insmod /lib/modules/2.4.21-15.ELsmp/kernel/drivers/md/lvm-mod.o
/sbin/vgscan -v
/sbin/pvcreate /dev/sdj2
/sbin/vgcreate vgbde /dev/sdj2
/sbin/lvcreate -I512 -L3G -nlvgbde  -v vgbde
mkfs -t ext3 /dev/vgbde/lvgbde
mount -f ext3 /dev/vgbde/lvgbde /mnt/u1
.
2. rawread -f -z -t 4 -o 512 -s 8192 -r 1 => Errno = EINVAL
   rawread -f -z -t 4 -o 1024 -s 8192 -r 1 => Errno = EINVAL
   rawread -f -z -t 4 -o 2048 -s 8192 -r 1 => Errno = EINVAL
   rawread -f -z -t 4 -o 4096 -s 8192 -r 1 => OK, i.e. if offset is 
     FS blocksize multiple
  
Actual results:

9169  open("/mnt/u1/control01.ctl", O_RDONLY|O_DIRECT|O_LARGEFILE) = 15
9169  close(15)                         = 0
9169  open("/mnt3/bde/BDETST/control01.ctl",
O_RDWR|O_SYNC|O_DIRECT|O_LARGEFILE) = 15
9169  fcntl64(15, F_SETFD, FD_CLOEXEC)  = 0
9169  fcntl64(15, F_GETFL)              = 0xd002
(flags=O_RDWR|O_SYNC|O_DIRECT|O_LARGEFILE)
9169  fcntl64(15, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0,
len=0}) = 0
9169  gettimeofday({1093901803, 43850}, NULL) = 0
9169  pread(15, 0xbbb5e00, 8192, 512)   = -1 EINVAL (Invalid argument)

Expected results:

O_DIRECT pread/pwrite should work with 512 bytes aligned offset on LVM

Additional info:

Comment 1 Robert 2004-09-07 17:39:57 UTC
Created attachment 103549 [details]
rawread.tar

Comment 5 Robert 2004-10-13 15:54:35 UTC
Note RH's Issue Tracker id for this is: 41346

Comment 10 Ernie Petrides 2005-01-15 00:27:09 UTC
A fix for this problem has just been committed to the RHEL3 U5
patch pool this evening (in kernel version 2.4.21-27.8.EL).


Comment 11 Tim Powers 2005-05-18 13:27:55 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2005-294.html