Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932200AbbHFWZb (ORCPT ); Thu, 6 Aug 2015 18:25:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47081 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526AbbHFWZ3 (ORCPT ); Thu, 6 Aug 2015 18:25:29 -0400 From: Jeff Moyer 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" References: <100D68C7BA14664A8938383216E40DE04091408C@FMSMSX114.amr.corp.intel.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Thu, 06 Aug 2015 17:30:56 -0400 In-Reply-To: <100D68C7BA14664A8938383216E40DE04091408C@FMSMSX114.amr.corp.intel.com> (Matthew R. Wilcox's message of "Thu, 6 Aug 2015 14:21:24 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1706 Lines: 52 "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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/