From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946282AbbHGSLc (ORCPT ); Fri, 7 Aug 2015 14:11:32 -0400 Received: from mga14.intel.com ([192.55.52.115]:60619 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1945911AbbHGSLa convert rfc822-to-8bit (ORCPT ); Fri, 7 Aug 2015 14:11:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,630,1432623600"; d="scan'208";a="779032648" From: "Wilcox, Matthew R" To: Jeff Moyer CC: "linda.knippers@hp.com" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" Subject: RE: regression introduced by "block: Add support for DAX reads/writes to block devices" Thread-Topic: regression introduced by "block: Add support for DAX reads/writes to block devices" Thread-Index: AQHQ0I8tbz3w0Nd/aUKgc2IIOADimZ4A1PoQ Date: Fri, 7 Aug 2015 18:11:14 +0000 Message-ID: <100D68C7BA14664A8938383216E40DE0409144D9@FMSMSX114.amr.corp.intel.com> References: <100D68C7BA14664A8938383216E40DE04091408C@FMSMSX114.amr.corp.intel.com> In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.200.107] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So ... what you're doing here is if somebody requests the last 512 bytes, you're asking for the last page. That's going to work as long as the partition is a multiple of PAGE_SIZE, but not if the partition happens to be misaligned. It's an improvement, although I'd be tempted to do this as: 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; We need to cope with the case where the end of a partition isn't on a page boundary though. -----Original Message----- From: Jeff Moyer [mailto:jmoyer@redhat.com] Sent: Thursday, August 06, 2015 2:31 PM To: Wilcox, Matthew R Cc: linda.knippers@hp.com; linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org Subject: Re: regression introduced by "block: Add support for DAX reads/writes to block devices" "Wilcox, Matthew R" writes: > I think I see the problem. I'm kind of wrapped up in other things > right now; can you try replacing the line in dax_io(): > > - bh->b_size = PAGE_ALIGN(end - pos); > + bh->b_size = ALIGN(end - pos, 1 << blkbits); This works for me. If it looks okay to others, I'll submit a properly signed-off patch. Cheers, Jeff diff --git a/fs/dax.c b/fs/dax.c index a7f77e1..b6c4f93 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -98,6 +98,10 @@ static bool buffer_size_valid(struct buffer_head *bh) return bh->b_state != 0; } +/* + * This function assumes file system block size (represented by + * inode->i_blkbits) is less than or equal to the system page size. + */ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, loff_t start, loff_t end, get_block_t get_block, struct buffer_head *bh) @@ -117,9 +121,15 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, if (pos == max) { unsigned blkbits = inode->i_blkbits; sector_t block = pos >> blkbits; - unsigned first = pos - (block << blkbits); + long page = pos >> PAGE_SHIFT; + unsigned first; /* byte offset into block */ long size; + /* we can only map entire pages */ + if (pos & (PAGE_SIZE-1)) + block = page << (PAGE_SHIFT - blkbits); + first = pos - (block << blkbits); + if (pos == bh_max) { bh->b_size = PAGE_ALIGN(end - pos); bh->b_state = 0;