From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linda Knippers Subject: Re: [PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev Date: Fri, 14 Aug 2015 16:53:25 -0400 Message-ID: <55CE5545.7010304@hp.com> References: <1439583332-13754-1-git-send-email-jmoyer@redhat.com> <1439583332-13754-2-git-send-email-jmoyer@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-nvdimm@ml01.01.org, linux-kernel@vger.kernel.org To: Jeff Moyer , matthew.r.wilcox@intel.com Return-path: In-Reply-To: <1439583332-13754-2-git-send-email-jmoyer@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On 8/14/2015 4:15 PM, Jeff Moyer wrote: > commit bbab37ddc20b (block: Add support for DAX reads/writes to > block devices) caused a regression in mkfs.xfs. That utility > sets the block size of the device to the logical block size > using the BLKBSZSET ioctl, and then issues a single sector read > from the last sector of the device. This results in the dax_io > code trying to do a page-sized read from 512 bytes from the end > of the device. The result is -ERANGE being returned to userspace. > > The fix is to align the block to the page size before calling > get_block. > > Thanks to willy for simplifying my original patch. > > Signed-off-by: Jeff Moyer Tested-by: Linda Knippers > --- > fs/dax.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/dax.c b/fs/dax.c > index a7f77e1..ef35a20 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -116,7 +116,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, > unsigned len; > if (pos == max) { > unsigned blkbits = inode->i_blkbits; > - sector_t block = pos >> blkbits; > + long page = pos >> PAGE_SHIFT; > + sector_t block = page << (PAGE_SHIFT - blkbits); > unsigned first = pos - (block << blkbits); > long size; > >