linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Jan Kara <jack@suse.cz>
Cc: xfs <linux-xfs@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-mm@kvack.org, hch@infradead.org, cyberax@amazon.com,
	osandov@osandov.com, Eryu Guan <guaneryu@gmail.com>
Subject: Re: [PATCH v3 1/2] iomap: add a swapfile activation function
Date: Wed, 9 May 2018 10:11:24 -0700	[thread overview]
Message-ID: <20180509171124.GD9510@magnolia> (raw)
In-Reply-To: <20180509152002.kuqjfpyzlxdc7izg@quack2.suse.cz>

On Wed, May 09, 2018 at 05:20:02PM +0200, Jan Kara wrote:
> On Thu 03-05-18 10:46:59, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Add a new iomap_swapfile_activate function so that filesystems can
> > activate swap files without having to use the obsolete and slow bmap
> > function.  This enables XFS to support fallocate'd swap files and
> > swap files on realtime devices.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > v3: catch null iomap addr, fix too-short extent detection
> > v2: document the swap file layout requirements, combine adjacent
> >     real/unwritten extents, align reported swap extents to physical page
> >     size boundaries, fix compiler errors when swap disabled
> > ---
> >  fs/iomap.c            |  162 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  fs/xfs/xfs_aops.c     |   12 ++++
> >  include/linux/iomap.h |   11 +++
> >  3 files changed, 185 insertions(+)
> > 
> > diff --git a/fs/iomap.c b/fs/iomap.c
> > index afd163586aa0..ac7115492366 100644
> > --- a/fs/iomap.c
> > +++ b/fs/iomap.c
> > @@ -27,6 +27,7 @@
> >  #include <linux/task_io_accounting_ops.h>
> >  #include <linux/dax.h>
> >  #include <linux/sched/signal.h>
> > +#include <linux/swap.h>
> >  
> >  #include "internal.h"
> >  
> > @@ -1089,3 +1090,164 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
> >  	return ret;
> >  }
> >  EXPORT_SYMBOL_GPL(iomap_dio_rw);
> > +
> > +/* Swapfile activation */
> > +
> > +#ifdef CONFIG_SWAP
> > +struct iomap_swapfile_info {
> > +	struct iomap iomap;		/* accumulated iomap */
> > +	struct swap_info_struct *sis;
> > +	uint64_t lowest_ppage;		/* lowest physical addr seen (pages) */
> > +	uint64_t highest_ppage;		/* highest physical addr seen (pages) */
> > +	unsigned long nr_pages;		/* number of pages collected */
> > +	int nr_extents;			/* extent count */
> > +};
> > +
> > +/*
> > + * Collect physical extents for this swap file.  Physical extents reported to
> > + * the swap code must be trimmed to align to a page boundary.  The logical
> > + * offset within the file is irrelevant since the swapfile code maps logical
> > + * page numbers of the swap device to the physical page-aligned extents.
> > + */
> > +static int iomap_swapfile_add_extent(struct iomap_swapfile_info *isi)
> > +{
> > +	struct iomap *iomap = &isi->iomap;
> > +	unsigned long nr_pages;
> > +	uint64_t first_ppage;
> > +	uint64_t first_ppage_reported;
> > +	uint64_t last_ppage;
> > +	int error;
> > +
> > +	/*
> > +	 * Round the start up and the end down so that the physical
> > +	 * extent aligns to a page boundary.
> > +	 */
> > +	first_ppage = ALIGN(iomap->addr, PAGE_SIZE) >> PAGE_SHIFT;
> > +	last_ppage = (ALIGN_DOWN(iomap->addr + iomap->length, PAGE_SIZE) >>
> > +			PAGE_SHIFT) - 1;
> 
> But this can still end up underflowing last_ppage to (unsigned long)-1 and
> the following test won't trigger?

Yeah, I'll fix it and resubmit.  Thx for catching this.

--D

> > +
> > +	/* Skip too-short physical extents. */
> > +	if (first_ppage > last_ppage)
> > +		return 0;
> 
> 								Honza
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR

      reply	other threads:[~2018-05-09 17:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 17:46 [PATCH v3 1/2] iomap: add a swapfile activation function Darrick J. Wong
2018-05-03 17:49 ` [PATCH v3 2/2] generic: test swapfile creation, activation, and deactivation Darrick J. Wong
2018-05-03 20:58 ` [PATCH v3 1/2] iomap: add a swapfile activation function Omar Sandoval
2018-05-03 21:24   ` Darrick J. Wong
2018-05-03 21:26     ` Omar Sandoval
2018-05-09 15:20 ` Jan Kara
2018-05-09 17:11   ` Darrick J. Wong [this message]

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=20180509171124.GD9510@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=cyberax@amazon.com \
    --cc=guaneryu@gmail.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=osandov@osandov.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).