Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbcDRUrR (ORCPT ); Mon, 18 Apr 2016 16:47:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:58953 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751015AbcDRUrQ (ORCPT ); Mon, 18 Apr 2016 16:47:16 -0400 Date: Mon, 18 Apr 2016 22:47:08 +0200 From: Jan Kara To: Toshi Kani Cc: akpm@linux-foundation.org, dan.j.williams@intel.com, viro@zeniv.linux.org.uk, willy@linux.intel.com, ross.zwisler@linux.intel.com, kirill.shutemov@linux.intel.com, david@fromorbit.com, jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] dax: add dax_get_unmapped_area for pmd mappings Message-ID: <20160418204708.GB17889@quack2.suse.cz> References: <1460652511-19636-1-git-send-email-toshi.kani@hpe.com> <1460652511-19636-2-git-send-email-toshi.kani@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460652511-19636-2-git-send-email-toshi.kani@hpe.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1744 Lines: 56 On Thu 14-04-16 10:48:30, Toshi Kani wrote: > + > +/** > + * dax_get_unmapped_area - handle get_unmapped_area for a DAX file > + * @filp: The file being mmap'd, if not NULL > + * @addr: The mmap address. If NULL, the kernel assigns the address > + * @len: The mmap size in bytes > + * @pgoff: The page offset in the file where the mapping starts from. > + * @flags: The mmap flags > + * > + * This function can be called by a filesystem for get_unmapped_area(). > + * When a target file is a DAX file, it aligns the mmap address at the > + * beginning of the file by the pmd size. > + */ > +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr, > + unsigned long len, unsigned long pgoff, unsigned long flags) > +{ > + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd; I think we need to use 'loff_t' for the offsets for things to work on 32-bits. > + if (!IS_ENABLED(CONFIG_FS_DAX_PMD) || > + !filp || addr || !IS_DAX(filp->f_mapping->host)) > + goto out; > + > + off = pgoff << PAGE_SHIFT; And here we need to type to loff_t before the shift... > + off_end = off + len; > + off_pmd = round_up(off, PMD_SIZE); /* pmd-aligned offset */ > + > + if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE)) None of these parenthesis is actually needed (and IMHO they make the code less readable, not more). > + goto out; > + > + len_pmd = len + PMD_SIZE; > + if ((off + len_pmd) < off) > + goto out; > + > + addr_pmd = current->mm->get_unmapped_area(filp, addr, len_pmd, > + pgoff, flags); > + if (!IS_ERR_VALUE(addr_pmd)) { > + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1); > + return addr_pmd; Otherwise the patch looks good to me. Honza -- Jan Kara SUSE Labs, CR