From: Jan Kara <jack@suse.cz>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: xfs <linux-xfs@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-mm@kvack.org, hch@infradead.org, cyberax@amazon.com,
jack@suse.cz, osandov@osandov.com, Eryu Guan <guaneryu@gmail.com>
Subject: Re: [PATCH 1/2] iomap: add a swapfile activation function
Date: Thu, 3 May 2018 15:16:30 +0200 [thread overview]
Message-ID: <20180503131630.tpfv5eu744vxx4gj@quack2.suse.cz> (raw)
In-Reply-To: <20180502203228.GA4141@magnolia>
On Wed 02-05-18 13:32:28, Darrick J. Wong wrote:
> +/*
> + * 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 length 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;
> + nr_pages = last_ppage - first_ppage + 1;
So if I pass in iomap->addr = 1k, iomap->length = 1k, I get first_ppage =
1, last_ppage = -1, and thus nr_pages = (unsigned long)-1 and the test
below does not hit although it should. I think you need there
if (first_ppage > last_ppage)
Otherwise the patch looks good to me.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2018-05-03 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 20:32 [PATCH 1/2] iomap: add a swapfile activation function Darrick J. Wong
2018-05-02 20:33 ` [PATCH 2/2] generic: test swapfile creation, activation, and deactivation Darrick J. Wong
2018-05-03 13:16 ` Jan Kara [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=20180503131630.tpfv5eu744vxx4gj@quack2.suse.cz \
--to=jack@suse.cz \
--cc=cyberax@amazon.com \
--cc=darrick.wong@oracle.com \
--cc=guaneryu@gmail.com \
--cc=hch@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.