From: Jan Kara <jack@suse.cz>
To: Toshi Kani <toshi.kani@hpe.com>
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@lists.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
Date: Mon, 18 Apr 2016 22:47:08 +0200 [thread overview]
Message-ID: <20160418204708.GB17889@quack2.suse.cz> (raw)
In-Reply-To: <1460652511-19636-2-git-send-email-toshi.kani@hpe.com>
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 <jack@suse.com>
SUSE Labs, CR
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-04-18 20:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 16:48 [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani
2016-04-14 16:48 ` [PATCH v3 1/2] dax: add dax_get_unmapped_area for " Toshi Kani
2016-04-18 20:47 ` Jan Kara [this message]
2016-04-19 2:36 ` Toshi Kani
2016-04-14 16:48 ` [PATCH v3 2/2] ext2/4, xfs, blk: call dax_get_unmapped_area() for DAX " Toshi Kani
2016-04-16 5:05 ` [PATCH v3 0/2] Align mmap address " Andrew Morton
2016-04-18 20:26 ` Jan Kara
2016-04-19 18:23 ` Matthew Wilcox
2016-04-21 3:10 ` Toshi Kani
2016-04-21 7:06 ` Matthew Wilcox
2016-04-21 20:21 ` Mike Kravetz
2016-04-21 23:43 ` Toshi Kani
2016-04-22 0:22 ` Matthew Wilcox
2016-04-22 0:59 ` Toshi Kani
2016-04-21 23:35 ` Toshi Kani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160418204708.GB17889@quack2.suse.cz \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=ross.zwisler@linux.intel.com \
--cc=toshi.kani@hpe.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).