linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@linux.intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk,
	boaz@plexistor.com, david@fromorbit.com,
	linux-arch@vger.kernel.org, arnd@arndb.de,
	linux-nvdimm@lists.01.org, benh@kernel.crashing.org,
	linux-fsdevel@vger.kernel.org, heiko.carstens@de.ibm.com,
	hch@lst.de, mingo@kernel.org, tj@kernel.org, paulus@samba.org,
	hpa@zytor.com, schwidefsky@de.ibm.com,
	ross.zwisler@linux.intel.com, torvalds@linux-foundation.org,
	akpm@linux-foundation.org
Subject: Re: [PATCH v4 4/9] dax: fix mapping lifetime handling, convert to __pfn_t + kmap_atomic_pfn_t()
Date: Sat, 6 Jun 2015 07:58:22 -0400	[thread overview]
Message-ID: <20150606115822.GI2729@linux.intel.com> (raw)
In-Reply-To: <20150605211924.20751.434.stgit@dwillia2-desk3.amr.corp.intel.com>

On Fri, Jun 05, 2015 at 05:19:24PM -0400, Dan Williams wrote:
> @@ -35,13 +35,16 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
>  	might_sleep();
>  	do {
>  		void *addr;
> -		unsigned long pfn;
> +		__pfn_t pfn;
>  		long count;
>  
> -		count = bdev_direct_access(bdev, sector, &addr, &pfn, size);
> +		count = bdev_direct_access(bdev, sector, &pfn, size);
>  		if (count < 0)
>  			return count;
>  		BUG_ON(size < count);
> +		addr = kmap_atomic_pfn_t(pfn);
> +		if (!addr)
> +			return -EIO;
>  		while (count > 0) {
>  			unsigned pgsz = PAGE_SIZE - offset_in_page(addr);
>  			if (pgsz > count)

This part is incomplete.  When bdev_direct_access() could return an
address, it was possible for that address to be unaligned (eg when
'sector' was not a multiple of 8).  DAX has never had full support for
devices that weren't a 4k sector size, but I was trying to not make that
assumption in more places than I had to.  So this function needs a lot
more simplification (or it needs to add '(sector & 7) << 9' to addr ...
assuming that the partition this bdev represents actually starts at a
multiple of 8 ... bleh!).

>  
> -static long dax_get_addr(struct buffer_head *bh, void **addr, unsigned blkbits)
> +static long dax_get_pfn(struct buffer_head *bh, __pfn_t *pfn, unsigned blkbits)
>  {
> -	unsigned long pfn;
>  	sector_t sector = bh->b_blocknr << (blkbits - 9);
> -	return bdev_direct_access(bh->b_bdev, sector, addr, &pfn, bh->b_size);
> +	return bdev_direct_access(bh->b_bdev, sector, pfn, bh->b_size);
>  }

This function should just be deleted.  It offers essentially nothing
over just calling bdev_direct_access().

> @@ -142,9 +146,19 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
>  				addr = NULL;
>  				size = bh->b_size - first;
>  			} else {
> -				retval = dax_get_addr(bh, &addr, blkbits);
> +				if (kmap) {
> +					kunmap_atomic_pfn_t(kmap);
> +					kmap = NULL;
> +				}
> +				retval = dax_get_pfn(bh, &pfn, blkbits);
>  				if (retval < 0)
>  					break;
> +				kmap = kmap_atomic_pfn_t(pfn);
> +				if (!kmap) {
> +					retval = -EIO;
> +					break;
> +				}
> +				addr = kmap;
>  				if (buffer_unwritten(bh) || buffer_new(bh))
>  					dax_new_buf(addr, retval, first, pos,
>  									end);

Interesting approach.  The patch I sent you was more complex ... this
probably ends up working out better since it has fewer places to check
for kmap returning an error.

  reply	other threads:[~2015-06-06 11:58 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05 21:19 [PATCH v4 0/9] introduce __pfn_t, evacuate struct page from sgls Dan Williams
2015-06-05 21:19 ` [PATCH v4 1/9] introduce __pfn_t for scatterlists and pmem Dan Williams
2015-06-05 21:37   ` Linus Torvalds
2015-06-05 22:12     ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 2/9] x86: support kmap_atomic_pfn_t() for persistent memory Dan Williams
2015-06-09  6:50   ` Christoph Hellwig
2015-06-10 12:12   ` Christoph Hellwig
2015-06-10 15:03     ` Matthew Wilcox
2015-06-10 15:11       ` Christoph Hellwig
2015-06-10 15:36         ` Dan Williams
2015-06-10 16:11           ` Christoph Hellwig
2015-06-10 16:17             ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 3/9] dax: drop size parameter to ->direct_access() Dan Williams
2015-06-06 11:37   ` Matthew Wilcox
2015-06-09  6:51   ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 4/9] dax: fix mapping lifetime handling, convert to __pfn_t + kmap_atomic_pfn_t() Dan Williams
2015-06-06 11:58   ` Matthew Wilcox [this message]
2015-08-07 23:54     ` Dan Williams
2015-06-08 16:29   ` Elliott, Robert (Server Storage)
2015-06-08 16:36     ` Dan Williams
2015-06-09  6:55   ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 5/9] dma-mapping: allow archs to optionally specify a ->map_pfn() operation Dan Williams
2015-06-05 21:19 ` [PATCH v4 6/9] scatterlist: use sg_phys() Dan Williams
2015-06-09  6:59   ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 7/9] scatterlist: cleanup sg_chain() and sg_unmark_end() Dan Williams
2015-06-05 21:19 ` [PATCH v4 8/9] scatterlist: convert to __pfn_t Dan Williams
2015-06-05 21:19 ` [PATCH v4 9/9] x86: convert dma_map_ops to support mapping a __pfn_t Dan Williams
2015-06-09  6:58   ` Christoph Hellwig
2015-06-09 13:47     ` Konrad Rzeszutek Wilk
2015-06-05 21:23 ` [PATCH v4 0/9] introduce __pfn_t, evacuate struct page from sgls Dan Williams

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=20150606115822.GI2729@linux.intel.com \
    --to=willy@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=benh@kernel.crashing.org \
    --cc=boaz@plexistor.com \
    --cc=dan.j.williams@intel.com \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).